Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Feat: Add v1 upgradeExecutor getters
  • Loading branch information
chrstph-dvx committed Jul 10, 2024
commit 68f5894eb68a80df4d0552a224520d4c56a1512f
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],
});
}