Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add v1 ArbOwnerPublic setters #135

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 setMaxTxGasLimit<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);
}
Loading