Skip to content

Commit

Permalink
Feat: Add v1 ArbOwnerPublic setters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Jul 10, 2024
1 parent 5f27cc3 commit f223da4
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/actions/addChainOwner.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: AddChainOwnerParameters,
): Promise<AddChainOwnerReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}
43 changes: 43 additions & 0 deletions src/actions/removeChainOwner.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: RemoveChainOwnerParameters,
): Promise<RemoveChainOwnerReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}
42 changes: 42 additions & 0 deletions src/actions/setMaxTxGasLimit.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetMaxTxGasLimitParameters,
): Promise<SetMaxTxGasLimitReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}
42 changes: 42 additions & 0 deletions src/actions/setParentPricePerUnit.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetParentPricePerUnitParameters,
): Promise<SetParentPricePerUnitReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}
42 changes: 42 additions & 0 deletions src/actions/setParentPricingRewardRate.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetParentPricingRewardRateParameters,
): Promise<SetParentPricingRewardRateReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}
43 changes: 43 additions & 0 deletions src/actions/setParentPricingRewardRecipient.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetParentPricingRewardRecipientParameters,
): Promise<SetParentPricingRewardRecipientReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}
42 changes: 42 additions & 0 deletions src/actions/setSpeedLimit.ts
Original file line number Diff line number Diff line change
@@ -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<TChain extends Chain | undefined>(
client: PublicClient<Transport, TChain>,
args: SetSpeedLimitParameters,
): Promise<SetSpeedLimitReturnType> {
const data = arbOwnerFunctionData(args);

return client.prepareTransactionRequest({
to: arbOwner.address,
value: BigInt(0),
chain: client.chain,
data,
account: args.account,
} satisfies PrepareTransactionRequestParameters);
}

0 comments on commit f223da4

Please sign in to comment.