From f04abba377f952bb90f5cd61c59d313e9aa30380 Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 27 Jun 2024 20:12:43 +0000 Subject: [PATCH] Feat: Add v1 RollupAdminLogic getters Closes FS-620 --- src/actions/getConfirmPeriodBlocks.ts | 25 ++++++++++++++++++++++ src/actions/getExtraChallengeTimeBlocks.ts | 22 +++++++++++++++++++ src/actions/getMinimumAssertionPeriod.ts | 25 ++++++++++++++++++++++ src/actions/getWasmModuleRoot.ts | 25 ++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 src/actions/getConfirmPeriodBlocks.ts create mode 100644 src/actions/getExtraChallengeTimeBlocks.ts create mode 100644 src/actions/getMinimumAssertionPeriod.ts create mode 100644 src/actions/getWasmModuleRoot.ts diff --git a/src/actions/getConfirmPeriodBlocks.ts b/src/actions/getConfirmPeriodBlocks.ts new file mode 100644 index 00000000..327aa571 --- /dev/null +++ b/src/actions/getConfirmPeriodBlocks.ts @@ -0,0 +1,25 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { rollupAdminLogic } from '../contracts'; +import { ActionParameters } from '../types/Actions'; + +export type GetConfirmPeriodBlocksParameters = ActionParameters< + {}, + 'rollupAdminLogic', + Curried +>; + +export type GetConfirmPeriodBlocksReturnType = ReadContractReturnType< + typeof rollupAdminLogic.abi, + 'confirmPeriodBlocks' +>; + +export async function getConfirmPeriodBlocks( + client: PublicClient, + args: GetConfirmPeriodBlocksParameters, +): Promise { + return client.readContract({ + abi: rollupAdminLogic.abi, + functionName: 'confirmPeriodBlocks', + address: args.rollupAdminLogic, + }); +} diff --git a/src/actions/getExtraChallengeTimeBlocks.ts b/src/actions/getExtraChallengeTimeBlocks.ts new file mode 100644 index 00000000..ede8f8b2 --- /dev/null +++ b/src/actions/getExtraChallengeTimeBlocks.ts @@ -0,0 +1,22 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { rollupAdminLogic } from '../contracts'; +import { ActionParameters } from '../types/Actions'; + +export type GetExtraChallengeTimeBlocksParameters = + ActionParameters<{}, 'rollupAdminLogic', Curried>; + +export type GetExtraChallengeTimeBlocksReturnType = ReadContractReturnType< + typeof rollupAdminLogic.abi, + 'extraChallengeTimeBlocks' +>; + +export async function getExtraChallengeTimeBlocks( + client: PublicClient, + args: GetExtraChallengeTimeBlocksParameters, +): Promise { + return client.readContract({ + abi: rollupAdminLogic.abi, + functionName: 'extraChallengeTimeBlocks', + address: args.rollupAdminLogic, + }); +} diff --git a/src/actions/getMinimumAssertionPeriod.ts b/src/actions/getMinimumAssertionPeriod.ts new file mode 100644 index 00000000..c250b2ce --- /dev/null +++ b/src/actions/getMinimumAssertionPeriod.ts @@ -0,0 +1,25 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { rollupAdminLogic } from '../contracts'; +import { ActionParameters } from '../types/Actions'; + +export type GetMinimumAssertionPeriodParameters = ActionParameters< + {}, + 'rollupAdminLogic', + Curried +>; + +export type GetMinimumAssertionPeriodReturnType = ReadContractReturnType< + typeof rollupAdminLogic.abi, + 'minimumAssertionPeriod' +>; + +export async function getMinimumAssertionPeriod( + client: PublicClient, + args: GetMinimumAssertionPeriodParameters, +): Promise { + return client.readContract({ + abi: rollupAdminLogic.abi, + functionName: 'minimumAssertionPeriod', + address: args.rollupAdminLogic, + }); +} diff --git a/src/actions/getWasmModuleRoot.ts b/src/actions/getWasmModuleRoot.ts new file mode 100644 index 00000000..ba6b23cd --- /dev/null +++ b/src/actions/getWasmModuleRoot.ts @@ -0,0 +1,25 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { rollupAdminLogic } from '../contracts'; +import { ActionParameters } from '../types/Actions'; + +export type GetWasmModuleRootParameters = ActionParameters< + {}, + 'rollupAdminLogic', + Curried +>; + +export type GetWasmModuleRootReturnType = ReadContractReturnType< + typeof rollupAdminLogic.abi, + 'wasmModuleRoot' +>; + +export async function getWasmModuleRoot( + client: PublicClient, + args: GetWasmModuleRootParameters, +): Promise { + return client.readContract({ + abi: rollupAdminLogic.abi, + functionName: 'wasmModuleRoot', + address: args.rollupAdminLogic, + }); +}