From e341fa2888bfbbdd6588c8d62ee450b565acfacb Mon Sep 17 00:00:00 2001 From: Thomas Brillard Date: Thu, 28 Nov 2024 13:35:52 +0100 Subject: [PATCH] Fix/swap UI gas limit (#8520) * fix: ui gas limit fixed for swap * chore: returning default gasLimit * fix: hasDrawer --- .changeset/mean-tables-behave.md | 5 ++++ .../exchange/Swap2/Form/SwapWebViewDemo3.tsx | 26 ++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 .changeset/mean-tables-behave.md diff --git a/.changeset/mean-tables-behave.md b/.changeset/mean-tables-behave.md new file mode 100644 index 000000000000..c28bc137e673 --- /dev/null +++ b/.changeset/mean-tables-behave.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +ui gas limit fixed for swap diff --git a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx index ad77bae0b74c..8c42c8e7cf94 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/SwapWebViewDemo3.tsx @@ -148,6 +148,7 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { openDrawer: boolean; customFeeConfig: object; SWAP_VERSION: string; + gasLimit?: string; }; }): Promise<{ feesStrategy: string; @@ -155,6 +156,8 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { errors: object; warnings: object; customFeeConfig: object; + gasLimit?: string; + hasDrawer: boolean; }> => { const realFromAccountId = getAccountIdFromWalletAccountId(params.fromAccountId); if (!realFromAccountId) { @@ -185,6 +188,7 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { account: fromAccount, }), feesStrategy: params.feeStrategy || "medium", + customGasLimit: params.gasLimit ? new BigNumber(params.gasLimit) : null, ...transformToBigNumbers(params.customFeeConfig), }); let status = await bridge.getTransactionStatus(mainAccount, preparedTransaction); @@ -198,11 +202,9 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { return newTransaction; }; + // filters out the custom fee config for chains without drawer + const hasDrawer = ["evm", "bitcoin"].includes(transaction.family); if (!params.openDrawer) { - // filters out the custom fee config for chains without drawer - const config = ["evm", "bitcoin"].includes(transaction.family) - ? { hasDrawer: true, ...customFeeConfig } - : {}; return { feesStrategy: finalTx.feesStrategy, estimatedFees: convertToNonAtomicUnit({ @@ -211,17 +213,13 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { }), errors: status.errors, warnings: status.warnings, - customFeeConfig: config, + customFeeConfig, + hasDrawer, + gasLimit: transaction.gasLimit, }; } - return new Promise<{ - feesStrategy: string; - estimatedFees: BigNumber | undefined; - errors: object; - warnings: object; - customFeeConfig: object; - }>(resolve => { + return new Promise(resolve => { const performClose = (save: boolean) => { track("button_clicked2", { button: save ? "continueNetworkFees" : "closeNetworkFees", @@ -241,6 +239,8 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { errors: statusInit.errors, warnings: statusInit.warnings, customFeeConfig, + hasDrawer, + gasLimit: transaction.gasLimit, }); } resolve({ @@ -253,6 +253,8 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => { errors: status.errors, warnings: status.warnings, customFeeConfig, + hasDrawer, + gasLimit: transaction.gasLimit, }); };