@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
41 lines • 1.56 kB
JavaScript
;
// TODO: to remove once live-app-sdk is depreciated and removed from LL
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@ledgerhq/coin-evm/utils");
const CAN_EDIT_FEES = true;
const areFeesProvided = (tx) => !!(tx.gasLimit && tx.gasPrice);
const convertToLiveTransaction = (tx) => {
const hasFeesProvided = areFeesProvided(tx);
const params = {
family: "evm",
nonce: tx.nonce === undefined ? utils_1.DEFAULT_NONCE : tx.nonce,
amount: tx.amount,
recipient: tx.recipient,
data: tx.data,
gasLimit: tx.gasLimit,
customGasLimit: tx.gasLimit,
maxFeePerGas: undefined,
maxPriorityFeePerGas: undefined,
};
// We create a type 2 tx by default, and fallback to type 0 if gasPrice is provided
const liveTx = tx.gasPrice
? {
...params,
// custom feesStrategy is only available for type 0 tx since PlatformTransaction
// does not have `maxPriorityFeePerGas` or `maxFeePerGas` properties
feesStrategy: hasFeesProvided ? "custom" : undefined,
gasPrice: tx.gasPrice,
type: 0,
}
: { ...params, type: 2 };
return liveTx;
};
const getPlatformTransactionSignFlowInfos = (tx) => {
return {
canEditFees: CAN_EDIT_FEES,
liveTx: convertToLiveTransaction(tx),
hasFeesProvided: areFeesProvided(tx),
};
};
exports.default = { getPlatformTransactionSignFlowInfos };
//# sourceMappingURL=platformAdapter.js.map