diff --git a/src/actions/hasRole.ts b/src/actions/hasRole.ts new file mode 100644 index 00000000..ef0a0c1a --- /dev/null +++ b/src/actions/hasRole.ts @@ -0,0 +1,27 @@ +import { Address, Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { upgradeExecutorABI } from '../contracts/UpgradeExecutor'; +import { UpgradeExecutorRole } from '../upgradeExecutorEncodeFunctionData'; +import { ActionParameters } from '../types/Actions'; + +export type HasRoleParameters = ActionParameters< + { + role: UpgradeExecutorRole; + address: Address; + }, + 'upgradeExecutor', + Curried +>; + +export type HasRoleReturnType = ReadContractReturnType; + +export async function hasRole( + client: PublicClient, + { upgradeExecutor, params }: HasRoleParameters, +): Promise { + return client.readContract({ + abi: upgradeExecutorABI, + functionName: 'hasRole', + address: upgradeExecutor, + args: [params.role, params.address], + }); +}