From 6e77069c741b37ee278c71c256fe79b23702cdd3 Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 28 Jun 2024 15:30:19 +0000 Subject: [PATCH] Feat: Add v1 upgradeExecutor getters --- src/actions/hasRole.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/actions/hasRole.ts diff --git a/src/actions/hasRole.ts b/src/actions/hasRole.ts new file mode 100644 index 00000000..45f754c6 --- /dev/null +++ b/src/actions/hasRole.ts @@ -0,0 +1,29 @@ +import { Address, Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { upgradeExecutor } from '../contracts'; +import { ActionParameters } from '../types/Actions'; +import { UpgradeExecutorRole } from '../upgradeExecutorEncodeFunctionData'; + +type Args = { + role: UpgradeExecutorRole; + address: Address; +}; +type UpgradeExecutorABI = typeof upgradeExecutor.abi; +export type hasRoleParameters = ActionParameters< + Args, + 'upgradeExecutor', + Curried +>; + +export type hasRoleReturnType = ReadContractReturnType; + +export async function hasRole( + client: PublicClient, + args: hasRoleParameters, +): Promise { + return client.readContract({ + abi: upgradeExecutor.abi, + functionName: 'hasRole', + address: args.upgradeExecutor, + args: [args.role, args.address], + }); +}