-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e839468
commit 8c5caaa
Showing
8 changed files
with
216 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
import { | ||
Address, | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { arbOwner } from '../contracts'; | ||
import { WithAccount } from '../types/Actions'; | ||
import { | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
WithAccount, | ||
WithUpgradeExecutor, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { withUpgradeExecutor } from '../withUpgradeExecutor'; | ||
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient'; | ||
|
||
export type AddChainOwnerParameters = Prettify< | ||
WithAccount<{ | ||
newOwner: Address; | ||
}> | ||
WithUpgradeExecutor< | ||
WithAccount<{ | ||
newOwner: Address; | ||
}> | ||
> | ||
>; | ||
|
||
export type AddChainOwnerReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function arbOwnerFunctionData({ newOwner }: AddChainOwnerParameters) { | ||
return encodeFunctionData({ | ||
abi: arbOwner.abi, | ||
functionName: 'addChainOwner', | ||
args: [newOwner], | ||
}); | ||
} | ||
export type AddChainOwnerReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function addChainOwner<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: AddChainOwnerParameters, | ||
params: AddChainOwnerParameters, | ||
): Promise<AddChainOwnerReturnType> { | ||
const data = arbOwnerFunctionData(args); | ||
const validatedPublicClient = validateChildChainPublicClient(client); | ||
const { account, upgradeExecutor, newOwner } = params; | ||
|
||
return client.prepareTransactionRequest({ | ||
to: arbOwner.address, | ||
value: BigInt(0), | ||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
account, | ||
...withUpgradeExecutor({ | ||
to: arbOwner.address, | ||
upgradeExecutor, | ||
args: [newOwner], | ||
abi: arbOwner.abi, | ||
functionName: 'addChainOwner', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import { | ||
Address, | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { arbOwner } from '../contracts'; | ||
import { WithAccount } from '../types/Actions'; | ||
import { | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
WithAccount, | ||
WithUpgradeExecutor, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { withUpgradeExecutor } from '../withUpgradeExecutor'; | ||
import { validateParentChainPublicClient } from '../types/ParentChain'; | ||
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient'; | ||
|
||
export type RemoveChainOwnerParameters = Prettify< | ||
WithAccount<{ | ||
owner: Address; | ||
}> | ||
WithUpgradeExecutor< | ||
WithAccount<{ | ||
owner: Address; | ||
}> | ||
> | ||
>; | ||
|
||
export type RemoveChainOwnerReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function arbOwnerFunctionData({ owner }: RemoveChainOwnerParameters) { | ||
return encodeFunctionData({ | ||
abi: arbOwner.abi, | ||
functionName: 'removeChainOwner', | ||
args: [owner], | ||
}); | ||
} | ||
export type RemoveChainOwnerReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function removeChainOwner<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: RemoveChainOwnerParameters, | ||
params: RemoveChainOwnerParameters, | ||
): Promise<RemoveChainOwnerReturnType> { | ||
const data = arbOwnerFunctionData(args); | ||
const validatedPublicClient = validateChildChainPublicClient(client); | ||
const { account, upgradeExecutor, owner } = params; | ||
|
||
return client.prepareTransactionRequest({ | ||
to: arbOwner.address, | ||
value: BigInt(0), | ||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
account, | ||
...withUpgradeExecutor({ | ||
to: arbOwner.address, | ||
upgradeExecutor, | ||
args: [owner], | ||
abi: arbOwner.abi, | ||
functionName: 'removeChainOwner', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import { | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { arbOwner } from '../contracts'; | ||
import { WithAccount } from '../types/Actions'; | ||
import { | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
WithAccount, | ||
WithUpgradeExecutor, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { withUpgradeExecutor } from '../withUpgradeExecutor'; | ||
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient'; | ||
|
||
export type SetMaxTxGasLimitParameters = Prettify< | ||
WithAccount<{ | ||
limit: bigint; | ||
}> | ||
WithUpgradeExecutor< | ||
WithAccount<{ | ||
limit: bigint; | ||
}> | ||
> | ||
>; | ||
|
||
export type SetMaxTxGasLimitReturnType = PrepareTransactionRequestReturnType; | ||
export type SetMaxTxGasLimitReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
function arbOwnerFunctionData({ limit }: SetMaxTxGasLimitParameters) { | ||
return encodeFunctionData({ | ||
abi: arbOwner.abi, | ||
functionName: 'setMaxTxGasLimit', | ||
args: [limit], | ||
}); | ||
} | ||
|
||
export async function setL1PricingRewardRecipient<TChain extends Chain | undefined>( | ||
export async function setMaxTxGasLimit<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetMaxTxGasLimitParameters, | ||
params: SetMaxTxGasLimitParameters, | ||
): Promise<SetMaxTxGasLimitReturnType> { | ||
const data = arbOwnerFunctionData(args); | ||
const validatedPublicClient = validateChildChainPublicClient(client); | ||
const { account, upgradeExecutor, limit } = params; | ||
|
||
return client.prepareTransactionRequest({ | ||
to: arbOwner.address, | ||
value: BigInt(0), | ||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
account, | ||
...withUpgradeExecutor({ | ||
to: arbOwner.address, | ||
upgradeExecutor, | ||
args: [limit], | ||
abi: arbOwner.abi, | ||
functionName: 'setMaxTxGasLimit', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import { | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { arbOwner } from '../contracts'; | ||
import { WithAccount } from '../types/Actions'; | ||
import { | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
WithAccount, | ||
WithUpgradeExecutor, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { withUpgradeExecutor } from '../withUpgradeExecutor'; | ||
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient'; | ||
|
||
export type SetParentPricePerUnitParameters = Prettify< | ||
WithAccount<{ | ||
pricePerUnit: bigint; | ||
}> | ||
WithUpgradeExecutor< | ||
WithAccount<{ | ||
pricePerUnit: bigint; | ||
}> | ||
> | ||
>; | ||
|
||
export type SetParentPricePerUnitReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function arbOwnerFunctionData({ pricePerUnit }: SetParentPricePerUnitParameters) { | ||
return encodeFunctionData({ | ||
abi: arbOwner.abi, | ||
functionName: 'setL1PricePerUnit', | ||
args: [pricePerUnit], | ||
}); | ||
} | ||
export type SetParentPricePerUnitReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function setParentPricePerUnit<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetParentPricePerUnitParameters, | ||
params: SetParentPricePerUnitParameters, | ||
): Promise<SetParentPricePerUnitReturnType> { | ||
const data = arbOwnerFunctionData(args); | ||
const validatedPublicClient = validateChildChainPublicClient(client); | ||
const { account, upgradeExecutor, pricePerUnit } = params; | ||
|
||
return client.prepareTransactionRequest({ | ||
to: arbOwner.address, | ||
value: BigInt(0), | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
const request = await client.prepareTransactionRequest({ | ||
chain: validatedPublicClient.chain, | ||
account, | ||
...withUpgradeExecutor({ | ||
to: arbOwner.address, | ||
upgradeExecutor, | ||
args: [pricePerUnit], | ||
abi: arbOwner.abi, | ||
functionName: 'setL1PricePerUnit', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import { | ||
Chain, | ||
PrepareTransactionRequestParameters, | ||
PrepareTransactionRequestReturnType, | ||
PublicClient, | ||
Transport, | ||
encodeFunctionData, | ||
} from 'viem'; | ||
import { Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; | ||
import { arbOwner } from '../contracts'; | ||
import { WithAccount } from '../types/Actions'; | ||
import { | ||
PrepareTransactionRequestReturnTypeWithChainId, | ||
WithAccount, | ||
WithUpgradeExecutor, | ||
} from '../types/Actions'; | ||
import { Prettify } from '../types/utils'; | ||
import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient'; | ||
import { withUpgradeExecutor } from '../withUpgradeExecutor'; | ||
|
||
export type SetParentPricingRewardRateParameters = Prettify< | ||
WithAccount<{ | ||
weiPerUnit: bigint; | ||
}> | ||
WithUpgradeExecutor< | ||
WithAccount<{ | ||
weiPerUnit: bigint; | ||
}> | ||
> | ||
>; | ||
|
||
export type SetParentPricingRewardRateReturnType = PrepareTransactionRequestReturnType; | ||
|
||
function arbOwnerFunctionData({ weiPerUnit }: SetParentPricingRewardRateParameters) { | ||
return encodeFunctionData({ | ||
abi: arbOwner.abi, | ||
functionName: 'setL1PricingRewardRate', | ||
args: [weiPerUnit], | ||
}); | ||
} | ||
export type SetParentPricingRewardRateReturnType = PrepareTransactionRequestReturnTypeWithChainId; | ||
|
||
export async function setParentPricingRewardRate<TChain extends Chain | undefined>( | ||
client: PublicClient<Transport, TChain>, | ||
args: SetParentPricingRewardRateParameters, | ||
params: SetParentPricingRewardRateParameters, | ||
): Promise<SetParentPricingRewardRateReturnType> { | ||
const data = arbOwnerFunctionData(args); | ||
const validatedPublicClient = validateChildChainPublicClient(client); | ||
const { account, upgradeExecutor, weiPerUnit } = params; | ||
|
||
return client.prepareTransactionRequest({ | ||
to: arbOwner.address, | ||
value: BigInt(0), | ||
const request = await client.prepareTransactionRequest({ | ||
chain: client.chain, | ||
data, | ||
account: args.account, | ||
account, | ||
...withUpgradeExecutor({ | ||
to: arbOwner.address, | ||
upgradeExecutor, | ||
args: [weiPerUnit], | ||
abi: arbOwner.abi, | ||
functionName: 'setL1PricingRewardRate', | ||
}), | ||
} satisfies PrepareTransactionRequestParameters); | ||
|
||
return { ...request, chainId: validatedPublicClient.chain.id }; | ||
} |
Oops, something went wrong.