From 5c80571bf80a60cee7e37504942573e268f14830 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 | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/actions/wallet/L1/writeDepositETH.ts b/src/actions/wallet/L1/writeDepositETH.ts index 7742c3a6..88a2953b 100644 --- a/src/actions/wallet/L1/writeDepositETH.ts +++ b/src/actions/wallet/L1/writeDepositETH.ts @@ -1,6 +1,7 @@ import type { Account, Chain, Transport, WalletClient, WriteContractReturnType } from 'viem' import { ABI, CONTRACT, type DepositETHParameters, FUNCTION } from '../../../types/depositETH.js' import type { L1WriteActionBaseType } from '../../../types/l1Actions.js' +import { simulateDepositETH } from '../../index.js' import { writeOpStackL1, type WriteOpStackL1Parameters } from './writeOpStackL1.js' export type WriteDepositETHParameters< @@ -33,24 +34,24 @@ export async function writeDepositETH< args: { to, minGasLimit, extraData = '0x' }, l1StandardBridgeAddress, ...rest - }: WriteDepositETHParameters< - TChain, - TAccount, - TChainOverride - >, + }: WriteDepositETHParameters, ): Promise { + const { request } = await simulateDepositETH(client as any, { + args: { to, minGasLimit, extraData }, + l1StandardBridgeAddress, + ...rest, + } as any) + // TODO when cleaning up pull this out into it's own error + if (!request.gas) { + throw new Error('unable to calculate gas') + } return writeOpStackL1(client, { address: l1StandardBridgeAddress, abi: ABI, contract: CONTRACT, functionName: FUNCTION, + gas: request.gas + (request.gas / BigInt(2)), args: [to, minGasLimit, extraData], ...rest, - } as unknown as WriteOpStackL1Parameters< - TChain, - TAccount, - TChainOverride, - typeof ABI, - typeof FUNCTION - >) + } as unknown as WriteOpStackL1Parameters) }