Skip to content

Commit

Permalink
Feat: Add v1 upgradeExecutor getters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Sep 25, 2024
1 parent 2f33e44 commit 7bb31d2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/actions/hasRole.ts
Original file line number Diff line number Diff line change
@@ -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<Curried extends boolean = false> = ActionParameters<
{
role: UpgradeExecutorRole;
address: Address;
},
'upgradeExecutor',
Curried
>;

export type HasRoleReturnType = ReadContractReturnType<typeof upgradeExecutorABI, 'hasRole'>;

export async function hasRole<TChain extends Chain>(
client: PublicClient<Transport, TChain>,
{ upgradeExecutor, params }: HasRoleParameters,
): Promise<HasRoleReturnType> {
return client.readContract({
abi: upgradeExecutorABI,
functionName: 'hasRole',
address: upgradeExecutor,
args: [params.role, params.address],
});
}

0 comments on commit 7bb31d2

Please sign in to comment.