-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support customFees in swap web app mode (#4174)
* feat: support customFees in swap web app mode * fix: add other custom params * feat: update wallet-api dependencies * fix: fix async call getCustomFeesPerFamily * fix: fix typecheck * refactor: move getCustomFeesPerFamily to common * fix: fix lint * fix: remove feesStrategy as mandatory to open swap web app * fix: add convertToNonAtomicUnit utils * chore: update wallet-api server call after upgrade * fix: fix lint
- Loading branch information
Showing
6 changed files
with
78 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"ledger-live-desktop": patch | ||
"@ledgerhq/live-common": patch | ||
--- | ||
|
||
Support customFees in swap web app mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./utils"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { getGasLimit as getEthGasLimit } from "../../../families/ethereum/transaction"; | ||
import { getGasLimit as getEvmGasLimit } from "@ledgerhq/coin-evm/logic"; | ||
|
||
export const getCustomFeesPerFamily = transaction => { | ||
const { family, maxFeePerGas, maxPriorityFeePerGas, userGasLimit, customGasLimit, feePerByte } = | ||
transaction; | ||
|
||
switch (family) { | ||
case "ethereum": { | ||
return { | ||
maxFeePerGas, | ||
maxPriorityFeePerGas, | ||
userGasLimit, | ||
gasLimit: getEthGasLimit(transaction), | ||
}; | ||
} | ||
case "evm": { | ||
return { | ||
maxFeePerGas, | ||
maxPriorityFeePerGas, | ||
gasLimit: getEvmGasLimit(transaction), | ||
customGasLimit, | ||
}; | ||
} | ||
case "bitcoin": { | ||
return { | ||
feePerByte, | ||
}; | ||
} | ||
default: | ||
return {}; | ||
} | ||
}; | ||
|
||
export const convertToNonAtomicUnit = (amount, account) => { | ||
const fromMagnitude = | ||
account.type === "TokenAccount" | ||
? account.token.units[0].magnitude || 0 | ||
: account.currency?.units[0].magnitude || 0; | ||
return amount.shiftedBy(-fromMagnitude); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5d20c32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
live-common-tools – ./
ledger-live.vercel.app
live-common-tools-ledgerhq.vercel.app
ledger-live-tools.vercel.app
live-common-tools-git-develop-ledgerhq.vercel.app
live.ledger.tools