Skip to content

Commit 7f78841

Browse files
committed
Feat: Add v1 upgradeExecutor getters
1 parent d6ea175 commit 7f78841

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/actions/hasRole.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Address, Chain, PublicClient, ReadContractReturnType, Transport } from 'viem';
2+
import { upgradeExecutor } from '../contracts';
3+
import { ActionParameters } from '../types/Actions';
4+
import { UpgradeExecutorRole } from '../upgradeExecutorEncodeFunctionData';
5+
6+
type Args = {
7+
role: UpgradeExecutorRole;
8+
address: Address;
9+
};
10+
type UpgradeExecutorABI = typeof upgradeExecutor.abi;
11+
export type hasRoleParameters<Curried extends boolean = false> = ActionParameters<
12+
Args,
13+
'upgradeExecutor',
14+
Curried
15+
>;
16+
17+
export type hasRoleReturnType = ReadContractReturnType<UpgradeExecutorABI, 'hasRole'>;
18+
19+
export async function hasRole<TChain extends Chain | undefined>(
20+
client: PublicClient<Transport, TChain>,
21+
args: hasRoleParameters,
22+
): Promise<hasRoleReturnType> {
23+
return client.readContract({
24+
abi: upgradeExecutor.abi,
25+
functionName: 'hasRole',
26+
address: args.upgradeExecutor,
27+
args: [args.role, args.address],
28+
});
29+
}

0 commit comments

Comments
 (0)