-
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 setters
- Loading branch information
1 parent
2f33e44
commit 33f26b7
Showing
3 changed files
with
74 additions
and
1 deletion.
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,36 @@ | ||
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { upgradeExecutorABI } from '../contracts/UpgradeExecutor'; | ||
import { PrepareTransactionRequestReturnTypeWithChainId, WithAccount } from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { UPGRADE_EXECUTOR_ROLE_EXECUTOR } from '../upgradeExecutorEncodeFunctionData'; | ||
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters'; | ||
|
||
export type BuildAddExecutorParameters = Prettify< | ||
WithAccount<{ | ||
params: { | ||
address: Address; | ||
}; | ||
upgradeExecutor: Address; | ||
}> | ||
>; | ||
|
||
export type BuildAddExecutorReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function buildAddExecutor<TChain extends Chain>( | ||
client: PublicClient<Transport, TChain>, | ||
{ account, upgradeExecutor: upgradeExecutorAddress, params }: BuildAddExecutorParameters, | ||
): Promise<BuildAddExecutorReturnType> { | ||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain as Chain | undefined, | ||
account, | ||
...prepareUpgradeExecutorCallParameters({ | ||
to: upgradeExecutorAddress, | ||
upgradeExecutor: upgradeExecutorAddress, | ||
args: [UPGRADE_EXECUTOR_ROLE_EXECUTOR, params.address], | ||
abi: upgradeExecutorABI, | ||
functionName: 'grantRole', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: client.chain.id }; | ||
} |
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,36 @@ | ||
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { upgradeExecutorABI } from '../contracts/UpgradeExecutor'; | ||
import { PrepareTransactionRequestReturnTypeWithChainId, WithAccount } from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { UPGRADE_EXECUTOR_ROLE_EXECUTOR } from '../upgradeExecutorEncodeFunctionData'; | ||
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters'; | ||
|
||
export type RemoveExecutorParameters = Prettify< | ||
WithAccount<{ | ||
params: { | ||
address: Address; | ||
}; | ||
upgradeExecutor: Address; | ||
}> | ||
>; | ||
|
||
export type RemoveExecutorReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function buildRemoveExecutor<TChain extends Chain>( | ||
client: PublicClient<Transport, TChain>, | ||
{ account, upgradeExecutor: upgradeExecutorAddress, params }: RemoveExecutorParameters, | ||
): Promise<RemoveExecutorReturnType> { | ||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain as Chain | undefined, | ||
account, | ||
...prepareUpgradeExecutorCallParameters({ | ||
to: upgradeExecutorAddress, | ||
upgradeExecutor: upgradeExecutorAddress, | ||
args: [UPGRADE_EXECUTOR_ROLE_EXECUTOR, params.address], | ||
abi: upgradeExecutorABI, | ||
functionName: 'revokeRole', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: client.chain.id }; | ||
} |
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