Skip to content

Commit

Permalink
Feat: Add v1 ArbOwnerPublic getters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Sep 27, 2024
1 parent 64edde2 commit 53e6638
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/actions/getAllChainOwners.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain>(
client: PublicClient<Transport, TChain>,
): Promise<GetAllChainOwnersReturnType> {
return client.readContract({
abi: arbOwnerPublicABI,
functionName: 'getAllChainOwners',
address: arbOwnerPublicAddress,
});
}
19 changes: 19 additions & 0 deletions src/actions/getInfraFeeAccount.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain>(
client: PublicClient<Transport, TChain>,
): Promise<GetInfraFeeAccountReturnType> {
return client.readContract({
abi: arbOwnerPublicABI,
functionName: 'getInfraFeeAccount',
address: arbOwnerPublicAddress,
});
}
19 changes: 19 additions & 0 deletions src/actions/getNetworkFeeAccount.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain>(
client: PublicClient<Transport, TChain>,
): Promise<GetNetworkFeeAccountReturnType> {
return client.readContract({
abi: arbOwnerPublicABI,
functionName: 'getNetworkFeeAccount',
address: arbOwnerPublicAddress,
});
}
27 changes: 27 additions & 0 deletions src/actions/getScheduledUpgrade.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain>(
client: PublicClient<Transport, TChain>,
): Promise<GetScheduledUpgradeReturnType> {
const [arbosVersion, scheduledForTimestamp] = await client.readContract({
abi: arbOwnerPublicABI,
functionName: 'getScheduledUpgrade',
address: arbOwnerPublicAddress,
});
return {
arbosVersion,
scheduledForTimestamp,
};
}
23 changes: 23 additions & 0 deletions src/actions/isChainOwner.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain>(
client: PublicClient<Transport, TChain>,
args: IsChainOwnerParameters,
): Promise<IsChainOwnerReturnType> {
return client.readContract({
abi: arbOwnerPublicABI,
functionName: 'isChainOwner',
address: arbOwnerPublicAddress,
args: [args.address],
});
}

0 comments on commit 53e6638

Please sign in to comment.