UNPKG

@ledgerhq/coin-near

Version:
24 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const bignumber_js_1 = require("bignumber.js"); const preload_1 = require("./preload"); const api_1 = require("./api"); const logic_1 = require("./logic"); const getEstimatedFees = async (transaction) => { const rawGasPrice = await (0, api_1.getGasPrice)(); const gasPrice = new bignumber_js_1.BigNumber(rawGasPrice); if (["stake", "unstake", "withdraw"].includes(transaction.mode)) { return (0, logic_1.getStakingFees)(transaction, gasPrice); } const { createAccountCostSend, createAccountCostExecution, transferCostSend, transferCostExecution, addKeyCostSend, addKeyCostExecution, receiptCreationSend, receiptCreationExecution, } = (0, preload_1.getCurrentNearPreloadData)(); let sendFee = transferCostSend.plus(receiptCreationSend); let executionFee = transferCostExecution.plus(receiptCreationExecution); if ((0, logic_1.isImplicitAccount)(transaction.recipient)) { sendFee = sendFee.plus(createAccountCostSend).plus(addKeyCostSend); executionFee = executionFee.plus(createAccountCostExecution).plus(addKeyCostExecution); } const fees = sendFee.multipliedBy(gasPrice).plus(executionFee.multipliedBy(gasPrice)); return fees; }; exports.default = getEstimatedFees; //# sourceMappingURL=getFeesForTransaction.js.map