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 Jul 1, 2024
1 parent 88b52c4 commit e0ee516
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/actions/hasRole.ts
Original file line number Diff line number Diff line change
@@ -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<Curried extends boolean = false> = ActionParameters<
Args,
'upgradeExecutor',
Curried
>;

export type hasRoleReturnType = ReadContractReturnType<UpgradeExecutorABI, 'hasRole'>;

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

0 comments on commit e0ee516

Please sign in to comment.