From f7f1bb2352c80e7fb592ffce83ae557dde51d096 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 14 Aug 2023 10:53:11 -0400 Subject: [PATCH] fix: handling useEntireBalance case gracefully --- src/lib/evm.ts | 4 ++- src/pages/transfer/confirm.svelte | 7 ++--- src/pages/transfer/index.svelte | 44 ++++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/lib/evm.ts b/src/lib/evm.ts index b9ded41a..00016b00 100644 --- a/src/lib/evm.ts +++ b/src/lib/evm.ts @@ -133,10 +133,12 @@ export async function estimateGas({nativeSession, evmAccount, amount}: TransferP const gasPrice = await provider.getGasPrice() + const reducedAmount = String(Number(amount) - 0.005) + const gas = await provider.estimateGas({ from: evmAccount.address, to: targetEvmAddress, - value: ethers.utils.parseEther(amount), + value: ethers.utils.parseEther(reducedAmount), gasPrice, data: ethers.utils.formatBytes32String(''), }) diff --git a/src/pages/transfer/confirm.svelte b/src/pages/transfer/confirm.svelte index 4be1fa80..bee2c18b 100644 --- a/src/pages/transfer/confirm.svelte +++ b/src/pages/transfer/confirm.svelte @@ -1,5 +1,5 @@