From 505da4dd322e28c0c6cbfc445d2fa86936ce64e8 Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 28 Jun 2024 12:54:27 +0000 Subject: [PATCH] Feat: Add v1 ArbOwnerPublic getters --- src/actions/getAllChainOwners.ts | 20 ++++++++++++++++++++ src/actions/getInfraFeeAccount.ts | 20 ++++++++++++++++++++ src/actions/getNetworkFeeAccount.ts | 20 ++++++++++++++++++++ src/actions/getScheduledUpgrade.ts | 28 ++++++++++++++++++++++++++++ src/actions/isChainOwner.ts | 21 +++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 src/actions/getAllChainOwners.ts create mode 100644 src/actions/getInfraFeeAccount.ts create mode 100644 src/actions/getNetworkFeeAccount.ts create mode 100644 src/actions/getScheduledUpgrade.ts create mode 100644 src/actions/isChainOwner.ts diff --git a/src/actions/getAllChainOwners.ts b/src/actions/getAllChainOwners.ts new file mode 100644 index 00000000..41c69dd0 --- /dev/null +++ b/src/actions/getAllChainOwners.ts @@ -0,0 +1,20 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublic } from '../contracts'; + +type ArbOwnerPublicABI = typeof arbOwnerPublic.abi; +export type GetAllChainOwnersParameters = void; + +export type GetAllChainOwnersReturnType = ReadContractReturnType< + ArbOwnerPublicABI, + 'getAllChainOwners' +>; + +export async function getAllChainOwners( + client: PublicClient, +): Promise { + return client.readContract({ + abi: arbOwnerPublic.abi, + functionName: 'getAllChainOwners', + address: arbOwnerPublic.address, + }); +} diff --git a/src/actions/getInfraFeeAccount.ts b/src/actions/getInfraFeeAccount.ts new file mode 100644 index 00000000..bdd7bd13 --- /dev/null +++ b/src/actions/getInfraFeeAccount.ts @@ -0,0 +1,20 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublic } from '../contracts'; + +type ArbOwnerPublicABI = typeof arbOwnerPublic.abi; +export type GetInfraFeeAccountParameters = void; + +export type GetInfraFeeAccountReturnType = ReadContractReturnType< + ArbOwnerPublicABI, + 'getInfraFeeAccount' +>; + +export async function getInfraFeeAccount( + client: PublicClient, +): Promise { + return client.readContract({ + abi: arbOwnerPublic.abi, + functionName: 'getInfraFeeAccount', + address: arbOwnerPublic.address, + }); +} diff --git a/src/actions/getNetworkFeeAccount.ts b/src/actions/getNetworkFeeAccount.ts new file mode 100644 index 00000000..334e93ff --- /dev/null +++ b/src/actions/getNetworkFeeAccount.ts @@ -0,0 +1,20 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublic } from '../contracts'; + +type ArbOwnerPublicABI = typeof arbOwnerPublic.abi; +export type GetNetworkFeeAccountParameters = void; + +export type GetNetworkFeeAccountReturnType = ReadContractReturnType< + ArbOwnerPublicABI, + 'getNetworkFeeAccount' +>; + +export async function getNetworkFeeAccount( + client: PublicClient, +): Promise { + return client.readContract({ + abi: arbOwnerPublic.abi, + functionName: 'getNetworkFeeAccount', + address: arbOwnerPublic.address, + }); +} diff --git a/src/actions/getScheduledUpgrade.ts b/src/actions/getScheduledUpgrade.ts new file mode 100644 index 00000000..6d634fc4 --- /dev/null +++ b/src/actions/getScheduledUpgrade.ts @@ -0,0 +1,28 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublic } from '../contracts'; + +type ArbOwnerPublicABI = typeof arbOwnerPublic.abi; +export type GetScheduledUpgradeParameters = void; + +type GetScheduledUpgradeRawReturnType = ReadContractReturnType< + ArbOwnerPublicABI, + 'getScheduledUpgrade' +>; +export type GetScheduledUpgradeReturnType = { + arbosVersion: GetScheduledUpgradeRawReturnType[0]; + scheduledForTimestamp: GetScheduledUpgradeRawReturnType[1]; +}; + +export async function getScheduledUpgrade( + client: PublicClient, +): Promise { + const [arbosVersion, scheduledForTimestamp] = await client.readContract({ + abi: arbOwnerPublic.abi, + functionName: 'getScheduledUpgrade', + address: arbOwnerPublic.address, + }); + return { + arbosVersion, + scheduledForTimestamp, + }; +} diff --git a/src/actions/isChainOwner.ts b/src/actions/isChainOwner.ts new file mode 100644 index 00000000..aebaeadc --- /dev/null +++ b/src/actions/isChainOwner.ts @@ -0,0 +1,21 @@ +import { Address, Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublic } from '../contracts'; + +type ArbOwnerPublicABI = typeof arbOwnerPublic.abi; +export type IsChainOwnerParameters = { + address: Address; +}; + +export type IsChainOwnerReturnType = ReadContractReturnType; + +export async function isChainOwner( + client: PublicClient, + args: IsChainOwnerParameters, +): Promise { + return client.readContract({ + abi: arbOwnerPublic.abi, + functionName: 'isChainOwner', + address: arbOwnerPublic.address, + args: [args.address], + }); +}