-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add v1 upgradeExecutor getters
- Loading branch information
1 parent
3450f03
commit 52f9f58
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
}); | ||
} |