UNPKG

@ledgerhq/coin-algorand

Version:
24 lines 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getEstimatedFees = void 0; const bignumber_js_1 = require("bignumber.js"); const api_1 = __importDefault(require("./api")); const buildTransaction_1 = require("./buildTransaction"); // This is only true for a single signature. If we ever support different type of signatures // (e.g multi signatures), we will have to add the correct corresponding number of bytes. const SINGLE_SIGNATURE_SIZE = 71; const getEstimatedFees = async (account, transaction) => { const params = await api_1.default.getTransactionParams(); let suggestedFees = 0; if (params.fee) { const payload = await (0, buildTransaction_1.buildTransactionPayload)(account, transaction); const encoded = (0, buildTransaction_1.encodeToSign)(payload); suggestedFees = params.fee * (Buffer.from(encoded, "hex").length + SINGLE_SIGNATURE_SIZE); } return new bignumber_js_1.BigNumber(Math.max(suggestedFees, params.minFee)); }; exports.getEstimatedFees = getEstimatedFees; //# sourceMappingURL=getFeesForTransaction.js.map