From a8c02d82c885910cbfb9739fccd17636094f15c4 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 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..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], + }); +}