UNPKG

@ledgerhq/live-common

Version:
42 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fees = void 0; const bignumber_js_1 = require("bignumber.js"); exports.fees = { hasPresets: false, hasCustom: true, custom: { inputs: [ { key: "fees", type: "number", unitLabel: "stroop", }, ], getInitialValues: transaction => { const tx = transaction; const customFees = tx.customFees?.parameters?.fees; if (bignumber_js_1.BigNumber.isBigNumber(customFees) && customFees.gt(0)) { return { fees: customFees.toFixed() }; } if (bignumber_js_1.BigNumber.isBigNumber(tx.fees) && tx.fees.gt(0)) { return { fees: tx.fees.toFixed() }; } const networkFees = tx.networkInfo?.fees; return { fees: bignumber_js_1.BigNumber.isBigNumber(networkFees) ? networkFees.toFixed() : "" }; }, buildTransactionPatch: values => { const feesVal = new bignumber_js_1.BigNumber(values.fees); const normalizedFees = feesVal.isNaN() || feesVal.isNegative() ? new bignumber_js_1.BigNumber(0) : feesVal.integerValue(); return { fees: normalizedFees, customFees: { parameters: { fees: normalizedFees, }, }, }; }, }, }; //# sourceMappingURL=fees.js.map