Skip to content

Commit 64edde2

Browse files
committed
feat: Add v1 arbOwnerPublic setters
1 parent 7804ca2 commit 64edde2

8 files changed

+306
-0
lines changed

src/actions/buildAddChainOwner.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
10+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
11+
12+
export type BuildAddChainOwnerParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: {
16+
newOwner: Address;
17+
};
18+
}>
19+
>
20+
>;
21+
export type BuildAddChainOwnerReturnType = PrepareTransactionRequestReturnTypeWithChainId;
22+
23+
export async function buildAddChainOwner<TChain extends Chain>(
24+
client: PublicClient<Transport, TChain>,
25+
{ account, upgradeExecutor, params }: BuildAddChainOwnerParameters,
26+
): Promise<BuildAddChainOwnerReturnType> {
27+
const validatedPublicClient = validateChildChainPublicClient(client);
28+
29+
const request = await client.prepareTransactionRequest({
30+
chain: client.chain as Chain | undefined,
31+
account,
32+
...prepareUpgradeExecutorCallParameters({
33+
to: arbOwnerAddress,
34+
upgradeExecutor,
35+
args: [params.newOwner],
36+
abi: arbOwnerABI,
37+
functionName: 'addChainOwner',
38+
}),
39+
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
10+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
11+
12+
export type BuildRemoveChainOwnerParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: { owner: Address };
16+
}>
17+
>
18+
>;
19+
20+
export type BuildRemoveChainOwnerReturnType = PrepareTransactionRequestReturnTypeWithChainId;
21+
22+
export async function buildRemoveChainOwner<TChain extends Chain>(
23+
client: PublicClient<Transport, TChain>,
24+
{ account, upgradeExecutor, params }: BuildRemoveChainOwnerParameters,
25+
): Promise<BuildRemoveChainOwnerReturnType> {
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
28+
const request = await client.prepareTransactionRequest({
29+
chain: client.chain as Chain | undefined,
30+
account,
31+
...prepareUpgradeExecutorCallParameters({
32+
to: arbOwnerAddress,
33+
upgradeExecutor,
34+
args: [params.owner],
35+
abi: arbOwnerABI,
36+
functionName: 'removeChainOwner',
37+
}),
38+
} satisfies PrepareTransactionRequestParameters);
39+
40+
return { ...request, chainId: validatedPublicClient.chain.id };
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
10+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
11+
12+
export type BuildSetMaxTxGasLimitParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: { limit: bigint };
16+
}>
17+
>
18+
>;
19+
20+
export type BuildSetMaxTxGasLimitReturnType = PrepareTransactionRequestReturnTypeWithChainId;
21+
22+
export async function buildSetMaxTxGasLimit<TChain extends Chain>(
23+
client: PublicClient<Transport, TChain>,
24+
{ account, upgradeExecutor, params }: BuildSetMaxTxGasLimitParameters,
25+
): Promise<BuildSetMaxTxGasLimitReturnType> {
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
28+
const request = await client.prepareTransactionRequest({
29+
chain: client.chain as Chain | undefined,
30+
account,
31+
...prepareUpgradeExecutorCallParameters({
32+
to: arbOwnerAddress,
33+
upgradeExecutor,
34+
args: [params.limit],
35+
abi: arbOwnerABI,
36+
functionName: 'setMaxTxGasLimit',
37+
}),
38+
} satisfies PrepareTransactionRequestParameters);
39+
40+
return { ...request, chainId: validatedPublicClient.chain.id };
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
10+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
11+
12+
export type BuildSetParentPricePerUnitParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: { pricePerUnit: bigint };
16+
}>
17+
>
18+
>;
19+
20+
export type BuildSetParentPricePerUnitReturnType = PrepareTransactionRequestReturnTypeWithChainId;
21+
22+
export async function buildSetParentPricePerUnit<TChain extends Chain | undefined>(
23+
client: PublicClient<Transport, TChain>,
24+
{ account, upgradeExecutor, params }: BuildSetParentPricePerUnitParameters,
25+
): Promise<BuildSetParentPricePerUnitReturnType> {
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
28+
const request = await client.prepareTransactionRequest({
29+
chain: validatedPublicClient.chain,
30+
account,
31+
...prepareUpgradeExecutorCallParameters({
32+
to: arbOwnerAddress,
33+
upgradeExecutor,
34+
args: [params.pricePerUnit],
35+
abi: arbOwnerABI,
36+
functionName: 'setL1PricePerUnit',
37+
}),
38+
} satisfies PrepareTransactionRequestParameters);
39+
40+
return { ...request, chainId: validatedPublicClient.chain.id };
41+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
10+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
11+
12+
export type BuildSetParentPricingRewardRateParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: { weiPerUnit: bigint };
16+
}>
17+
>
18+
>;
19+
20+
export type BuildSetParentPricingRewardRateReturnType =
21+
PrepareTransactionRequestReturnTypeWithChainId;
22+
23+
export async function buildSetParentPricingRewardRate<TChain extends Chain | undefined>(
24+
client: PublicClient<Transport, TChain>,
25+
{ account, upgradeExecutor, params }: BuildSetParentPricingRewardRateParameters,
26+
): Promise<BuildSetParentPricingRewardRateReturnType> {
27+
const validatedPublicClient = validateChildChainPublicClient(client);
28+
29+
const request = await client.prepareTransactionRequest({
30+
chain: client.chain,
31+
account,
32+
...prepareUpgradeExecutorCallParameters({
33+
to: arbOwnerAddress,
34+
upgradeExecutor,
35+
args: [params.weiPerUnit],
36+
abi: arbOwnerABI,
37+
functionName: 'setL1PricingRewardRate',
38+
}),
39+
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
10+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
11+
12+
export type BuildSetParentPricingRewardRecipientParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: { recipient: Address };
16+
}>
17+
>
18+
>;
19+
20+
export type BuildSetParentPricingRewardRecipientReturnType =
21+
PrepareTransactionRequestReturnTypeWithChainId;
22+
23+
export async function buildSetParentPricingRewardRecipient<TChain extends Chain | undefined>(
24+
client: PublicClient<Transport, TChain>,
25+
{ account, upgradeExecutor, params }: BuildSetParentPricingRewardRecipientParameters,
26+
): Promise<BuildSetParentPricingRewardRecipientReturnType> {
27+
const validatedPublicClient = validateChildChainPublicClient(client);
28+
29+
const request = await client.prepareTransactionRequest({
30+
chain: client.chain,
31+
account,
32+
...prepareUpgradeExecutorCallParameters({
33+
to: arbOwnerAddress,
34+
upgradeExecutor,
35+
args: [params.recipient],
36+
abi: arbOwnerABI,
37+
functionName: 'setL1PricingRewardRecipient',
38+
}),
39+
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
42+
}

src/actions/buildSetSpeedLimit.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
2+
import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
8+
import { Prettify } from '../types/utils';
9+
import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters';
10+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
11+
12+
export type BuildSetSpeedLimitParameters = Prettify<
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
params: { limit: bigint };
16+
}>
17+
>
18+
>;
19+
20+
export type BuildSetSpeedLimitReturnType = PrepareTransactionRequestReturnTypeWithChainId;
21+
22+
export async function buildSetSpeedLimit<TChain extends Chain | undefined>(
23+
client: PublicClient<Transport, TChain>,
24+
{ account, upgradeExecutor, params }: BuildSetSpeedLimitParameters,
25+
): Promise<BuildSetSpeedLimitReturnType> {
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
28+
const request = await client.prepareTransactionRequest({
29+
chain: client.chain,
30+
account,
31+
...prepareUpgradeExecutorCallParameters({
32+
to: arbOwnerAddress,
33+
upgradeExecutor,
34+
args: [params.limit],
35+
abi: arbOwnerABI,
36+
functionName: 'setSpeedLimit',
37+
}),
38+
} satisfies PrepareTransactionRequestParameters);
39+
40+
return { ...request, chainId: validatedPublicClient.chain.id };
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Chain, PublicClient, Transport } from 'viem';
2+
import { Prettify } from './utils';
3+
4+
export type ChildChainPublicClient<TChain extends Chain | undefined> = Prettify<
5+
PublicClient<Transport, TChain> & { chain: NonNullable<TChain> }
6+
>;
7+
8+
export function validateChildChainPublicClient<TChain extends Chain | undefined>(
9+
publicClient: PublicClient<Transport, TChain>,
10+
): ChildChainPublicClient<TChain> {
11+
if (!publicClient.chain) {
12+
throw new Error('client.chain is undefined');
13+
}
14+
15+
return publicClient as ChildChainPublicClient<TChain>;
16+
}

0 commit comments

Comments
 (0)