@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
35 lines • 1.14 kB
JavaScript
export const getCustomFeesPerFamily = transaction => {
const { family, maxFeePerGas, maxPriorityFeePerGas, feePerByte, fees, utxoStrategy, gasPrice } = transaction;
switch (family) {
case "evm": {
return {
maxFeePerGas,
maxPriorityFeePerGas,
gasPrice,
};
}
case "bitcoin": {
return {
feePerByte,
utxoStrategy,
};
}
default:
return {
fees,
};
}
};
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);
};
export const convertToAtomicUnit = ({ amount, account, }) => {
const fromMagnitude = account.type === "TokenAccount"
? account.token.units[0].magnitude || 0
: account.currency?.units[0].magnitude || 0;
return amount?.shiftedBy(fromMagnitude);
};
//# sourceMappingURL=utils.js.map