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], + }); +}