-
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.
- Loading branch information
1 parent
6fe99d3
commit a61fb2a
Showing
16 changed files
with
190 additions
and
453 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
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
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
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
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,70 @@ | ||
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { rollupABI } from '../contracts/Rollup'; | ||
import { | ||
WithAccount, | ||
ActionParameters, | ||
WithUpgradeExecutor, | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { getRollupAddress } from '../getRollupAddress'; | ||
import { validateParentChainPublicClient } from '../types/ParentChain'; | ||
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters'; | ||
|
||
export type BuildSetValidatorWhitelistDisabledParameters<Curried extends boolean = false> = | ||
Prettify<WithUpgradeExecutor<WithAccount<ActionParameters<{}, 'rollupAdminLogic', Curried>>>>; | ||
|
||
export type BuildSetValidatorWhitelistDisabledReturnType = | ||
PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function buildSetValidatorWhitelistDisabled<TChain extends Chain>( | ||
client: PublicClient<Transport, TChain>, | ||
{ | ||
account, | ||
upgradeExecutor, | ||
params, | ||
...args | ||
}: BuildSetValidatorWhitelistDisabledParameters & { params: { enable: boolean } }, | ||
): Promise<BuildSetValidatorWhitelistDisabledReturnType> { | ||
const validatedPublicClient = validateParentChainPublicClient(client); | ||
const rollupAdminLogicAddress = | ||
'sequencerInbox' in args ? await getRollupAddress(client, args) : args.rollupAdminLogic; | ||
|
||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain as Chain | undefined, | ||
account, | ||
...prepareUpgradeExecutorCallParameters({ | ||
to: rollupAdminLogicAddress, | ||
upgradeExecutor, | ||
args: [params.enable], | ||
abi: rollupABI, | ||
functionName: 'setValidatorWhitelistDisabled', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} | ||
|
||
export async function buildEnableValidatorWhitelist<TChain extends Chain>( | ||
client: PublicClient<Transport, TChain>, | ||
args: BuildSetValidatorWhitelistDisabledParameters, | ||
): Promise<BuildSetValidatorWhitelistDisabledReturnType> { | ||
return buildSetValidatorWhitelistDisabled(client, { | ||
...args, | ||
params: { | ||
enable: true, | ||
}, | ||
}); | ||
} | ||
|
||
export async function buildDisableValidatorWhitelist<TChain extends Chain>( | ||
client: PublicClient<Transport, TChain>, | ||
args: BuildSetValidatorWhitelistDisabledParameters, | ||
): Promise<BuildSetValidatorWhitelistDisabledReturnType> { | ||
return buildSetValidatorWhitelistDisabled(client, { | ||
...args, | ||
params: { | ||
enable: false, | ||
}, | ||
}); | ||
} |
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,51 @@ | ||
import { Chain, Hex, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { rollupABI } from '../contracts/Rollup'; | ||
import { | ||
WithAccount, | ||
ActionParameters, | ||
WithUpgradeExecutor, | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { getRollupAddress } from '../getRollupAddress'; | ||
import { validateParentChainPublicClient } from '../types/ParentChain'; | ||
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters'; | ||
|
||
export type BuildSetWasmModuleRootParameters<Curried extends boolean = false> = Prettify< | ||
WithUpgradeExecutor< | ||
WithAccount< | ||
ActionParameters< | ||
{ | ||
newWasmModuleRoot: Hex; | ||
}, | ||
'rollupAdminLogic', | ||
Curried | ||
> | ||
> | ||
> | ||
>; | ||
|
||
export type BuildSetWasmModuleRootReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function buildSetWasmModuleRoot<TChain extends Chain>( | ||
client: PublicClient<Transport, TChain>, | ||
{ account, upgradeExecutor, params, ...args }: BuildSetWasmModuleRootParameters, | ||
): Promise<BuildSetWasmModuleRootReturnType> { | ||
const validatedPublicClient = validateParentChainPublicClient(client); | ||
const rollupAdminLogicAddress = | ||
'sequencerInbox' in args ? await getRollupAddress(client, args) : args.rollupAdminLogic; | ||
|
||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain as Chain | undefined, | ||
account, | ||
...prepareUpgradeExecutorCallParameters({ | ||
to: rollupAdminLogicAddress, | ||
upgradeExecutor, | ||
args: [params.newWasmModuleRoot], | ||
abi: rollupABI, | ||
functionName: 'setWasmModuleRoot', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.