Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add v1 ArbOwnerPublic getters #134

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/actions/getAllChainOwners.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
): Promise<GetAllChainOwnersReturnType> {
return client.readContract({
abi: arbOwnerPublic.abi,
functionName: 'getAllChainOwners',
address: arbOwnerPublic.address,
});
}
20 changes: 20 additions & 0 deletions src/actions/getInfraFeeAccount.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
): Promise<GetInfraFeeAccountReturnType> {
return client.readContract({
abi: arbOwnerPublic.abi,
functionName: 'getInfraFeeAccount',
address: arbOwnerPublic.address,
});
}
20 changes: 20 additions & 0 deletions src/actions/getNetworkFeeAccount.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
): Promise<GetNetworkFeeAccountReturnType> {
return client.readContract({
abi: arbOwnerPublic.abi,
functionName: 'getNetworkFeeAccount',
address: arbOwnerPublic.address,
});
}
28 changes: 28 additions & 0 deletions src/actions/getScheduledUpgrade.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
): Promise<GetScheduledUpgradeReturnType> {
const [arbosVersion, scheduledForTimestamp] = await client.readContract({
abi: arbOwnerPublic.abi,
functionName: 'getScheduledUpgrade',
address: arbOwnerPublic.address,
});
return {
arbosVersion,
scheduledForTimestamp,
};
}
21 changes: 21 additions & 0 deletions src/actions/isChainOwner.ts
Original file line number Diff line number Diff line change
@@ -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<ArbOwnerPublicABI, 'isChainOwner'>;

export async function isChainOwner<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: IsChainOwnerParameters,
): Promise<IsChainOwnerReturnType> {
return client.readContract({
abi: arbOwnerPublic.abi,
functionName: 'isChainOwner',
address: arbOwnerPublic.address,
args: [args.address],
});
}
Loading