From d090e28ab722b13fea2a85990cf8c0d420a23ff2 Mon Sep 17 00:00:00 2001 From: Will Cory Date: Thu, 5 Oct 2023 21:12:33 -0700 Subject: [PATCH] :bug: fix: Add padding to deposit eth --- src/actions/wallet/L1/writeDepositETH.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/actions/wallet/L1/writeDepositETH.ts b/src/actions/wallet/L1/writeDepositETH.ts index 7742c3a6..0a07deeb 100644 --- a/src/actions/wallet/L1/writeDepositETH.ts +++ b/src/actions/wallet/L1/writeDepositETH.ts @@ -1,4 +1,5 @@ import type { Account, Chain, Transport, WalletClient, WriteContractReturnType } from 'viem' +import { estimateContractGas } from 'viem/actions' import { ABI, CONTRACT, type DepositETHParameters, FUNCTION } from '../../../types/depositETH.js' import type { L1WriteActionBaseType } from '../../../types/l1Actions.js' import { writeOpStackL1, type WriteOpStackL1Parameters } from './writeOpStackL1.js' @@ -33,24 +34,22 @@ export async function writeDepositETH< args: { to, minGasLimit, extraData = '0x' }, l1StandardBridgeAddress, ...rest - }: WriteDepositETHParameters< - TChain, - TAccount, - TChainOverride - >, + }: WriteDepositETHParameters, ): Promise { + const gas = await estimateContractGas(client, { + args: { to, minGasLimit, extraData }, + l1StandardBridgeAddress, + abi: ABI, + functionName: FUNCTION, + ...rest, + } as any) return writeOpStackL1(client, { address: l1StandardBridgeAddress, abi: ABI, contract: CONTRACT, functionName: FUNCTION, + gas: gas + (gas / BigInt(2)), args: [to, minGasLimit, extraData], ...rest, - } as unknown as WriteOpStackL1Parameters< - TChain, - TAccount, - TChainOverride, - typeof ABI, - typeof FUNCTION - >) + } as unknown as WriteOpStackL1Parameters) }