Skip to content

Commit 8c5caaa

Browse files
committed
Rename setMaxTxGasLimit
1 parent e839468 commit 8c5caaa

File tree

8 files changed

+216
-201
lines changed

8 files changed

+216
-201
lines changed

src/actions/addChainOwner.ts

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
import {
2-
Address,
3-
Chain,
4-
PrepareTransactionRequestParameters,
5-
PrepareTransactionRequestReturnType,
6-
PublicClient,
7-
Transport,
8-
encodeFunctionData,
9-
} from 'viem';
1+
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
102
import { arbOwner } from '../contracts';
11-
import { WithAccount } from '../types/Actions';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
128
import { Prettify } from '../types/utils';
9+
import { withUpgradeExecutor } from '../withUpgradeExecutor';
10+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
1311

1412
export type AddChainOwnerParameters = Prettify<
15-
WithAccount<{
16-
newOwner: Address;
17-
}>
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
newOwner: Address;
16+
}>
17+
>
1818
>;
1919

20-
export type AddChainOwnerReturnType = PrepareTransactionRequestReturnType;
21-
22-
function arbOwnerFunctionData({ newOwner }: AddChainOwnerParameters) {
23-
return encodeFunctionData({
24-
abi: arbOwner.abi,
25-
functionName: 'addChainOwner',
26-
args: [newOwner],
27-
});
28-
}
20+
export type AddChainOwnerReturnType = PrepareTransactionRequestReturnTypeWithChainId;
2921

3022
export async function addChainOwner<TChain extends Chain | undefined>(
3123
client: PublicClient<Transport, TChain>,
32-
args: AddChainOwnerParameters,
24+
params: AddChainOwnerParameters,
3325
): Promise<AddChainOwnerReturnType> {
34-
const data = arbOwnerFunctionData(args);
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
const { account, upgradeExecutor, newOwner } = params;
3528

36-
return client.prepareTransactionRequest({
37-
to: arbOwner.address,
38-
value: BigInt(0),
29+
const request = await client.prepareTransactionRequest({
3930
chain: client.chain,
40-
data,
41-
account: args.account,
31+
account,
32+
...withUpgradeExecutor({
33+
to: arbOwner.address,
34+
upgradeExecutor,
35+
args: [newOwner],
36+
abi: arbOwner.abi,
37+
functionName: 'addChainOwner',
38+
}),
4239
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
4342
}

src/actions/removeChainOwner.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
import {
2-
Address,
3-
Chain,
4-
PrepareTransactionRequestParameters,
5-
PrepareTransactionRequestReturnType,
6-
PublicClient,
7-
Transport,
8-
encodeFunctionData,
9-
} from 'viem';
1+
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
102
import { arbOwner } from '../contracts';
11-
import { WithAccount } from '../types/Actions';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
128
import { Prettify } from '../types/utils';
9+
import { withUpgradeExecutor } from '../withUpgradeExecutor';
10+
import { validateParentChainPublicClient } from '../types/ParentChain';
11+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
1312

1413
export type RemoveChainOwnerParameters = Prettify<
15-
WithAccount<{
16-
owner: Address;
17-
}>
14+
WithUpgradeExecutor<
15+
WithAccount<{
16+
owner: Address;
17+
}>
18+
>
1819
>;
1920

20-
export type RemoveChainOwnerReturnType = PrepareTransactionRequestReturnType;
21-
22-
function arbOwnerFunctionData({ owner }: RemoveChainOwnerParameters) {
23-
return encodeFunctionData({
24-
abi: arbOwner.abi,
25-
functionName: 'removeChainOwner',
26-
args: [owner],
27-
});
28-
}
21+
export type RemoveChainOwnerReturnType = PrepareTransactionRequestReturnTypeWithChainId;
2922

3023
export async function removeChainOwner<TChain extends Chain | undefined>(
3124
client: PublicClient<Transport, TChain>,
32-
args: RemoveChainOwnerParameters,
25+
params: RemoveChainOwnerParameters,
3326
): Promise<RemoveChainOwnerReturnType> {
34-
const data = arbOwnerFunctionData(args);
27+
const validatedPublicClient = validateChildChainPublicClient(client);
28+
const { account, upgradeExecutor, owner } = params;
3529

36-
return client.prepareTransactionRequest({
37-
to: arbOwner.address,
38-
value: BigInt(0),
30+
const request = await client.prepareTransactionRequest({
3931
chain: client.chain,
40-
data,
41-
account: args.account,
32+
account,
33+
...withUpgradeExecutor({
34+
to: arbOwner.address,
35+
upgradeExecutor,
36+
args: [owner],
37+
abi: arbOwner.abi,
38+
functionName: 'removeChainOwner',
39+
}),
4240
} satisfies PrepareTransactionRequestParameters);
41+
42+
return { ...request, chainId: validatedPublicClient.chain.id };
4343
}

src/actions/setMaxTxGasLimit.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import {
2-
Chain,
3-
PrepareTransactionRequestParameters,
4-
PrepareTransactionRequestReturnType,
5-
PublicClient,
6-
Transport,
7-
encodeFunctionData,
8-
} from 'viem';
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
92
import { arbOwner } from '../contracts';
10-
import { WithAccount } from '../types/Actions';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
118
import { Prettify } from '../types/utils';
9+
import { withUpgradeExecutor } from '../withUpgradeExecutor';
10+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
1211

1312
export type SetMaxTxGasLimitParameters = Prettify<
14-
WithAccount<{
15-
limit: bigint;
16-
}>
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
limit: bigint;
16+
}>
17+
>
1718
>;
1819

19-
export type SetMaxTxGasLimitReturnType = PrepareTransactionRequestReturnType;
20+
export type SetMaxTxGasLimitReturnType = PrepareTransactionRequestReturnTypeWithChainId;
2021

21-
function arbOwnerFunctionData({ limit }: SetMaxTxGasLimitParameters) {
22-
return encodeFunctionData({
23-
abi: arbOwner.abi,
24-
functionName: 'setMaxTxGasLimit',
25-
args: [limit],
26-
});
27-
}
28-
29-
export async function setL1PricingRewardRecipient<TChain extends Chain | undefined>(
22+
export async function setMaxTxGasLimit<TChain extends Chain | undefined>(
3023
client: PublicClient<Transport, TChain>,
31-
args: SetMaxTxGasLimitParameters,
24+
params: SetMaxTxGasLimitParameters,
3225
): Promise<SetMaxTxGasLimitReturnType> {
33-
const data = arbOwnerFunctionData(args);
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
const { account, upgradeExecutor, limit } = params;
3428

35-
return client.prepareTransactionRequest({
36-
to: arbOwner.address,
37-
value: BigInt(0),
29+
const request = await client.prepareTransactionRequest({
3830
chain: client.chain,
39-
data,
40-
account: args.account,
31+
account,
32+
...withUpgradeExecutor({
33+
to: arbOwner.address,
34+
upgradeExecutor,
35+
args: [limit],
36+
abi: arbOwner.abi,
37+
functionName: 'setMaxTxGasLimit',
38+
}),
4139
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
4242
}
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import {
2-
Chain,
3-
PrepareTransactionRequestParameters,
4-
PrepareTransactionRequestReturnType,
5-
PublicClient,
6-
Transport,
7-
encodeFunctionData,
8-
} from 'viem';
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
92
import { arbOwner } from '../contracts';
10-
import { WithAccount } from '../types/Actions';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
118
import { Prettify } from '../types/utils';
9+
import { withUpgradeExecutor } from '../withUpgradeExecutor';
10+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
1211

1312
export type SetParentPricePerUnitParameters = Prettify<
14-
WithAccount<{
15-
pricePerUnit: bigint;
16-
}>
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
pricePerUnit: bigint;
16+
}>
17+
>
1718
>;
1819

19-
export type SetParentPricePerUnitReturnType = PrepareTransactionRequestReturnType;
20-
21-
function arbOwnerFunctionData({ pricePerUnit }: SetParentPricePerUnitParameters) {
22-
return encodeFunctionData({
23-
abi: arbOwner.abi,
24-
functionName: 'setL1PricePerUnit',
25-
args: [pricePerUnit],
26-
});
27-
}
20+
export type SetParentPricePerUnitReturnType = PrepareTransactionRequestReturnTypeWithChainId;
2821

2922
export async function setParentPricePerUnit<TChain extends Chain | undefined>(
3023
client: PublicClient<Transport, TChain>,
31-
args: SetParentPricePerUnitParameters,
24+
params: SetParentPricePerUnitParameters,
3225
): Promise<SetParentPricePerUnitReturnType> {
33-
const data = arbOwnerFunctionData(args);
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
const { account, upgradeExecutor, pricePerUnit } = params;
3428

35-
return client.prepareTransactionRequest({
36-
to: arbOwner.address,
37-
value: BigInt(0),
38-
chain: client.chain,
39-
data,
40-
account: args.account,
29+
const request = await client.prepareTransactionRequest({
30+
chain: validatedPublicClient.chain,
31+
account,
32+
...withUpgradeExecutor({
33+
to: arbOwner.address,
34+
upgradeExecutor,
35+
args: [pricePerUnit],
36+
abi: arbOwner.abi,
37+
functionName: 'setL1PricePerUnit',
38+
}),
4139
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
4242
}
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import {
2-
Chain,
3-
PrepareTransactionRequestParameters,
4-
PrepareTransactionRequestReturnType,
5-
PublicClient,
6-
Transport,
7-
encodeFunctionData,
8-
} from 'viem';
1+
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem';
92
import { arbOwner } from '../contracts';
10-
import { WithAccount } from '../types/Actions';
3+
import {
4+
PrepareTransactionRequestReturnTypeWithChainId,
5+
WithAccount,
6+
WithUpgradeExecutor,
7+
} from '../types/Actions';
118
import { Prettify } from '../types/utils';
9+
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient';
10+
import { withUpgradeExecutor } from '../withUpgradeExecutor';
1211

1312
export type SetParentPricingRewardRateParameters = Prettify<
14-
WithAccount<{
15-
weiPerUnit: bigint;
16-
}>
13+
WithUpgradeExecutor<
14+
WithAccount<{
15+
weiPerUnit: bigint;
16+
}>
17+
>
1718
>;
1819

19-
export type SetParentPricingRewardRateReturnType = PrepareTransactionRequestReturnType;
20-
21-
function arbOwnerFunctionData({ weiPerUnit }: SetParentPricingRewardRateParameters) {
22-
return encodeFunctionData({
23-
abi: arbOwner.abi,
24-
functionName: 'setL1PricingRewardRate',
25-
args: [weiPerUnit],
26-
});
27-
}
20+
export type SetParentPricingRewardRateReturnType = PrepareTransactionRequestReturnTypeWithChainId;
2821

2922
export async function setParentPricingRewardRate<TChain extends Chain | undefined>(
3023
client: PublicClient<Transport, TChain>,
31-
args: SetParentPricingRewardRateParameters,
24+
params: SetParentPricingRewardRateParameters,
3225
): Promise<SetParentPricingRewardRateReturnType> {
33-
const data = arbOwnerFunctionData(args);
26+
const validatedPublicClient = validateChildChainPublicClient(client);
27+
const { account, upgradeExecutor, weiPerUnit } = params;
3428

35-
return client.prepareTransactionRequest({
36-
to: arbOwner.address,
37-
value: BigInt(0),
29+
const request = await client.prepareTransactionRequest({
3830
chain: client.chain,
39-
data,
40-
account: args.account,
31+
account,
32+
...withUpgradeExecutor({
33+
to: arbOwner.address,
34+
upgradeExecutor,
35+
args: [weiPerUnit],
36+
abi: arbOwner.abi,
37+
functionName: 'setL1PricingRewardRate',
38+
}),
4139
} satisfies PrepareTransactionRequestParameters);
40+
41+
return { ...request, chainId: validatedPublicClient.chain.id };
4242
}

0 commit comments

Comments
 (0)