From f223da40cc1db6489df721a7d33231bc9ce2d4f0 Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 28 Jun 2024 13:50:05 +0000 Subject: [PATCH] Feat: Add v1 ArbOwnerPublic setters --- src/actions/addChainOwner.ts | 43 +++++++++++++++++++ src/actions/removeChainOwner.ts | 43 +++++++++++++++++++ src/actions/setMaxTxGasLimit.ts | 42 ++++++++++++++++++ src/actions/setParentPricePerUnit.ts | 42 ++++++++++++++++++ src/actions/setParentPricingRewardRate.ts | 42 ++++++++++++++++++ .../setParentPricingRewardRecipient.ts | 43 +++++++++++++++++++ src/actions/setSpeedLimit.ts | 42 ++++++++++++++++++ 7 files changed, 297 insertions(+) create mode 100644 src/actions/addChainOwner.ts create mode 100644 src/actions/removeChainOwner.ts create mode 100644 src/actions/setMaxTxGasLimit.ts create mode 100644 src/actions/setParentPricePerUnit.ts create mode 100644 src/actions/setParentPricingRewardRate.ts create mode 100644 src/actions/setParentPricingRewardRecipient.ts create mode 100644 src/actions/setSpeedLimit.ts diff --git a/src/actions/addChainOwner.ts b/src/actions/addChainOwner.ts new file mode 100644 index 00000000..27c2e581 --- /dev/null +++ b/src/actions/addChainOwner.ts @@ -0,0 +1,43 @@ +import { + Address, + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type AddChainOwnerParameters = Prettify< + WithAccount<{ + newOwner: Address; + }> +>; + +export type AddChainOwnerReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ newOwner }: AddChainOwnerParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'addChainOwner', + args: [newOwner], + }); +} + +export async function addChainOwner( + client: PublicClient, + args: AddChainOwnerParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +} diff --git a/src/actions/removeChainOwner.ts b/src/actions/removeChainOwner.ts new file mode 100644 index 00000000..04e6d9d5 --- /dev/null +++ b/src/actions/removeChainOwner.ts @@ -0,0 +1,43 @@ +import { + Address, + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type RemoveChainOwnerParameters = Prettify< + WithAccount<{ + owner: Address; + }> +>; + +export type RemoveChainOwnerReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ owner }: RemoveChainOwnerParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'removeChainOwner', + args: [owner], + }); +} + +export async function removeChainOwner( + client: PublicClient, + args: RemoveChainOwnerParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +} diff --git a/src/actions/setMaxTxGasLimit.ts b/src/actions/setMaxTxGasLimit.ts new file mode 100644 index 00000000..c414f8df --- /dev/null +++ b/src/actions/setMaxTxGasLimit.ts @@ -0,0 +1,42 @@ +import { + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type SetMaxTxGasLimitParameters = Prettify< + WithAccount<{ + limit: bigint; + }> +>; + +export type SetMaxTxGasLimitReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ limit }: SetMaxTxGasLimitParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'setMaxTxGasLimit', + args: [limit], + }); +} + +export async function setL1PricingRewardRecipient( + client: PublicClient, + args: SetMaxTxGasLimitParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +} diff --git a/src/actions/setParentPricePerUnit.ts b/src/actions/setParentPricePerUnit.ts new file mode 100644 index 00000000..ef726318 --- /dev/null +++ b/src/actions/setParentPricePerUnit.ts @@ -0,0 +1,42 @@ +import { + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type SetParentPricePerUnitParameters = Prettify< + WithAccount<{ + pricePerUnit: bigint; + }> +>; + +export type SetParentPricePerUnitReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ pricePerUnit }: SetParentPricePerUnitParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'setL1PricePerUnit', + args: [pricePerUnit], + }); +} + +export async function setParentPricePerUnit( + client: PublicClient, + args: SetParentPricePerUnitParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +} diff --git a/src/actions/setParentPricingRewardRate.ts b/src/actions/setParentPricingRewardRate.ts new file mode 100644 index 00000000..c101b087 --- /dev/null +++ b/src/actions/setParentPricingRewardRate.ts @@ -0,0 +1,42 @@ +import { + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type SetParentPricingRewardRateParameters = Prettify< + WithAccount<{ + weiPerUnit: bigint; + }> +>; + +export type SetParentPricingRewardRateReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ weiPerUnit }: SetParentPricingRewardRateParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'setL1PricingRewardRate', + args: [weiPerUnit], + }); +} + +export async function setParentPricingRewardRate( + client: PublicClient, + args: SetParentPricingRewardRateParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +} diff --git a/src/actions/setParentPricingRewardRecipient.ts b/src/actions/setParentPricingRewardRecipient.ts new file mode 100644 index 00000000..99568ba2 --- /dev/null +++ b/src/actions/setParentPricingRewardRecipient.ts @@ -0,0 +1,43 @@ +import { + Address, + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type SetParentPricingRewardRecipientParameters = Prettify< + WithAccount<{ + recipient: Address; + }> +>; + +export type SetParentPricingRewardRecipientReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ recipient }: SetParentPricingRewardRecipientParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'setL1PricingRewardRecipient', + args: [recipient], + }); +} + +export async function setParentPricingRewardRecipient( + client: PublicClient, + args: SetParentPricingRewardRecipientParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +} diff --git a/src/actions/setSpeedLimit.ts b/src/actions/setSpeedLimit.ts new file mode 100644 index 00000000..9495fa86 --- /dev/null +++ b/src/actions/setSpeedLimit.ts @@ -0,0 +1,42 @@ +import { + Chain, + PrepareTransactionRequestParameters, + PrepareTransactionRequestReturnType, + PublicClient, + Transport, + encodeFunctionData, +} from 'viem'; +import { arbOwner } from '../contracts'; +import { WithAccount } from '../types/Actions'; +import { Prettify } from '../types/utils'; + +export type SetSpeedLimitParameters = Prettify< + WithAccount<{ + limit: bigint; + }> +>; + +export type SetSpeedLimitReturnType = PrepareTransactionRequestReturnType; + +function arbOwnerFunctionData({ limit }: SetSpeedLimitParameters) { + return encodeFunctionData({ + abi: arbOwner.abi, + functionName: 'setSpeedLimit', + args: [limit], + }); +} + +export async function setSpeedLimit( + client: PublicClient, + args: SetSpeedLimitParameters, +): Promise { + const data = arbOwnerFunctionData(args); + + return client.prepareTransactionRequest({ + to: arbOwner.address, + value: BigInt(0), + chain: client.chain, + data, + account: args.account, + } satisfies PrepareTransactionRequestParameters); +}