Skip to content

Commit

Permalink
Fix/swap UI gas limit (#8520)
Browse files Browse the repository at this point in the history
* fix: ui gas limit fixed for swap

* chore: returning default gasLimit

* fix: hasDrawer
  • Loading branch information
CremaFR authored Nov 28, 2024
1 parent 0aa6ec9 commit e341fa2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-tables-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

ui gas limit fixed for swap
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,16 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => {
openDrawer: boolean;
customFeeConfig: object;
SWAP_VERSION: string;
gasLimit?: string;
};
}): Promise<{
feesStrategy: string;
estimatedFees: BigNumber | undefined;
errors: object;
warnings: object;
customFeeConfig: object;
gasLimit?: string;
hasDrawer: boolean;
}> => {
const realFromAccountId = getAccountIdFromWalletAccountId(params.fromAccountId);
if (!realFromAccountId) {
Expand Down Expand Up @@ -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);
Expand All @@ -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({
Expand All @@ -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",
Expand All @@ -241,6 +239,8 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => {
errors: statusInit.errors,
warnings: statusInit.warnings,
customFeeConfig,
hasDrawer,
gasLimit: transaction.gasLimit,
});
}
resolve({
Expand All @@ -253,6 +253,8 @@ const SwapWebView = ({ manifest, liveAppUnavailable }: SwapWebProps) => {
errors: status.errors,
warnings: status.warnings,
customFeeConfig,
hasDrawer,
gasLimit: transaction.gasLimit,
});
};

Expand Down

0 comments on commit e341fa2

Please sign in to comment.