@ledgerhq/coin-algorand
Version:
Ledger Algorand Coin integration
21 lines • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEstimatedFees = void 0;
const bignumber_js_1 = require("bignumber.js");
const buildTransaction_1 = require("./buildTransaction");
const network_1 = require("./network");
// 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 (0, network_1.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