|
| 1 | +import { Address, Chain, PrepareTransactionRequestParameters, PublicClient, Transport } from 'viem'; |
| 2 | +import { arbOwnerABI, arbOwnerAddress } from '../contracts/ArbOwner'; |
| 3 | +import { |
| 4 | + PrepareTransactionRequestReturnTypeWithChainId, |
| 5 | + WithAccount, |
| 6 | + WithUpgradeExecutor, |
| 7 | +} from '../types/Actions'; |
| 8 | +import { Prettify } from '../types/utils'; |
| 9 | +import { validateChildChainPublicClient } from '../types/validateChildChainPublicClient'; |
| 10 | +import { prepareUpgradeExecutorCallParameters } from '../prepareUpgradeExecutorCallParameters'; |
| 11 | + |
| 12 | +export type BuildSetParentPricingRewardRecipientParameters = Prettify< |
| 13 | + WithUpgradeExecutor< |
| 14 | + WithAccount<{ |
| 15 | + params: { recipient: Address }; |
| 16 | + }> |
| 17 | + > |
| 18 | +>; |
| 19 | + |
| 20 | +export type BuildSetParentPricingRewardRecipientReturnType = |
| 21 | + PrepareTransactionRequestReturnTypeWithChainId; |
| 22 | + |
| 23 | +export async function buildSetParentPricingRewardRecipient<TChain extends Chain | undefined>( |
| 24 | + client: PublicClient<Transport, TChain>, |
| 25 | + { account, upgradeExecutor, params }: BuildSetParentPricingRewardRecipientParameters, |
| 26 | +): Promise<BuildSetParentPricingRewardRecipientReturnType> { |
| 27 | + const validatedPublicClient = validateChildChainPublicClient(client); |
| 28 | + |
| 29 | + const request = await client.prepareTransactionRequest({ |
| 30 | + chain: client.chain, |
| 31 | + account, |
| 32 | + ...prepareUpgradeExecutorCallParameters({ |
| 33 | + to: arbOwnerAddress, |
| 34 | + upgradeExecutor, |
| 35 | + args: [params.recipient], |
| 36 | + abi: arbOwnerABI, |
| 37 | + functionName: 'setL1PricingRewardRecipient', |
| 38 | + }), |
| 39 | + } satisfies PrepareTransactionRequestParameters); |
| 40 | + |
| 41 | + return { ...request, chainId: validatedPublicClient.chain.id }; |
| 42 | +} |
0 commit comments