From c1691f9230510ad8e809c5056f95b8114b13742d Mon Sep 17 00:00:00 2001 From: Will Cory Date: Thu, 5 Oct 2023 21:12:14 -0700 Subject: [PATCH 1/2] :bug: fix: Export simulateDepositEth correctly --- src/actions/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/index.ts b/src/actions/index.ts index 3b10c12e..35f87b3e 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -26,7 +26,7 @@ export { type SimulateDepositERC20ReturnType, } from './public/L1/simulateDepositERC20.js' export { - type simulateDepositETH, + simulateDepositETH, type SimulateDepositETHParameters, type SimulateDepositETHReturnType, } from './public/L1/simulateDepositETH.js' From 7c5610c545f59bf00194a5e9f93c0f7f9f493571 Mon Sep 17 00:00:00 2001 From: Will Cory Date: Thu, 5 Oct 2023 21:12:33 -0700 Subject: [PATCH 2/2] :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..a8a82659 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, { + account: client.account, + args: [to, minGasLimit, extraData], + abi: ABI, + functionName: FUNCTION, + address: l1StandardBridgeAddress, + } 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) }