forked from OffchainLabs/arbitrum-orbit-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharbOwnerReadContract.ts
30 lines (25 loc) · 1.18 KB
/
arbOwnerReadContract.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Chain, GetFunctionArgs, PublicClient, ReadContractReturnType, Transport } from 'viem';
import { arbOwnerPublicABI, arbOwnerPublicAddress } from './contracts/ArbOwnerPublic';
import { GetFunctionName } from './types/utils';
export type ArbOwnerPublicAbi = typeof arbOwnerPublicABI;
export type ArbOwnerPublicFunctionName = GetFunctionName<ArbOwnerPublicAbi>;
export type ArbOwnerReadContractParameters<TFunctionName extends ArbOwnerPublicFunctionName> = {
functionName: TFunctionName;
} & GetFunctionArgs<ArbOwnerPublicAbi, TFunctionName>;
export type ArbOwnerReadContractReturnType<TFunctionName extends ArbOwnerPublicFunctionName> =
ReadContractReturnType<ArbOwnerPublicAbi, TFunctionName>;
export function arbOwnerReadContract<
TChain extends Chain | undefined,
TFunctionName extends ArbOwnerPublicFunctionName,
>(
client: PublicClient<Transport, TChain>,
params: ArbOwnerReadContractParameters<TFunctionName>,
): Promise<ArbOwnerReadContractReturnType<TFunctionName>> {
// @ts-ignore (todo: fix viem type issue)
return client.readContract({
address: arbOwnerPublicAddress,
abi: arbOwnerPublicABI,
functionName: params.functionName,
args: params.args,
});
}