-
Notifications
You must be signed in to change notification settings - Fork 43
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
2f33e44
commit 7bb31d2
Showing
1 changed file
with
27 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,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], | ||
}); | ||
} |