From 806a2e3f012e2c53878bb1b95e456d37b16cf84d 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 | 19 +++++++++++++++++++ src/actions/getInfraFeeAccount.ts | 19 +++++++++++++++++++ src/actions/getNetworkFeeAccount.ts | 19 +++++++++++++++++++ src/actions/getScheduledUpgrade.ts | 27 +++++++++++++++++++++++++++ src/actions/isChainOwner.ts | 23 +++++++++++++++++++++++ 5 files changed, 107 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..6c07a098 --- /dev/null +++ b/src/actions/getAllChainOwners.ts @@ -0,0 +1,19 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublicABI, arbOwnerPublicAddress } from '../contracts/ArbOwnerPublic'; + +export type GetAllChainOwnersParameters = void; + +export type GetAllChainOwnersReturnType = ReadContractReturnType< + typeof arbOwnerPublicABI, + 'getAllChainOwners' +>; + +export async function getAllChainOwners( + client: PublicClient, +): Promise { + return client.readContract({ + abi: arbOwnerPublicABI, + functionName: 'getAllChainOwners', + address: arbOwnerPublicAddress, + }); +} diff --git a/src/actions/getInfraFeeAccount.ts b/src/actions/getInfraFeeAccount.ts new file mode 100644 index 00000000..53a09f0f --- /dev/null +++ b/src/actions/getInfraFeeAccount.ts @@ -0,0 +1,19 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublicABI, arbOwnerPublicAddress } from '../contracts/ArbOwnerPublic'; + +export type GetInfraFeeAccountParameters = void; + +export type GetInfraFeeAccountReturnType = ReadContractReturnType< + typeof arbOwnerPublicABI, + 'getInfraFeeAccount' +>; + +export async function getInfraFeeAccount( + client: PublicClient, +): Promise { + return client.readContract({ + abi: arbOwnerPublicABI, + functionName: 'getInfraFeeAccount', + address: arbOwnerPublicAddress, + }); +} diff --git a/src/actions/getNetworkFeeAccount.ts b/src/actions/getNetworkFeeAccount.ts new file mode 100644 index 00000000..d1d2d6ef --- /dev/null +++ b/src/actions/getNetworkFeeAccount.ts @@ -0,0 +1,19 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublicABI, arbOwnerPublicAddress } from '../contracts/ArbOwnerPublic'; + +export type GetNetworkFeeAccountParameters = void; + +export type GetNetworkFeeAccountReturnType = ReadContractReturnType< + typeof arbOwnerPublicABI, + 'getNetworkFeeAccount' +>; + +export async function getNetworkFeeAccount( + client: PublicClient, +): Promise { + return client.readContract({ + abi: arbOwnerPublicABI, + functionName: 'getNetworkFeeAccount', + address: arbOwnerPublicAddress, + }); +} diff --git a/src/actions/getScheduledUpgrade.ts b/src/actions/getScheduledUpgrade.ts new file mode 100644 index 00000000..97cb591c --- /dev/null +++ b/src/actions/getScheduledUpgrade.ts @@ -0,0 +1,27 @@ +import { Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublicABI, arbOwnerPublicAddress } from '../contracts/ArbOwnerPublic'; + +export type GetScheduledUpgradeParameters = void; + +type GetScheduledUpgradeRawReturnType = ReadContractReturnType< + typeof 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: arbOwnerPublicABI, + functionName: 'getScheduledUpgrade', + address: arbOwnerPublicAddress, + }); + return { + arbosVersion, + scheduledForTimestamp, + }; +} diff --git a/src/actions/isChainOwner.ts b/src/actions/isChainOwner.ts new file mode 100644 index 00000000..5ed2918e --- /dev/null +++ b/src/actions/isChainOwner.ts @@ -0,0 +1,23 @@ +import { Address, Chain, PublicClient, ReadContractReturnType, Transport } from 'viem'; +import { arbOwnerPublicABI, arbOwnerPublicAddress } from '../contracts/ArbOwnerPublic'; + +export type IsChainOwnerParameters = { + address: Address; +}; + +export type IsChainOwnerReturnType = ReadContractReturnType< + typeof arbOwnerPublicABI, + 'isChainOwner' +>; + +export async function isChainOwner( + client: PublicClient, + args: IsChainOwnerParameters, +): Promise { + return client.readContract({ + abi: arbOwnerPublicABI, + functionName: 'isChainOwner', + address: arbOwnerPublicAddress, + args: [args.address], + }); +}