@ledgerhq/coin-mina
Version:
23 lines • 1.1 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.prepareTransaction = void 0;
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
const estimateMaxSpendable_1 = __importDefault(require("./estimateMaxSpendable"));
const getEstimatedFees_1 = __importDefault(require("./getEstimatedFees"));
const api_1 = require("../api");
const prepareTransaction = async (a, t) => {
const { fee, accountCreationFee } = await (0, getEstimatedFees_1.default)(t, a.freshAddress);
const amount = t.useAllAmount
? await (0, estimateMaxSpendable_1.default)({
account: a,
transaction: t,
})
: t.amount;
const nonce = await (0, api_1.getNonce)(t, a.freshAddress);
return (0, jsHelpers_1.updateTransaction)(t, { fees: { fee, accountCreationFee }, amount, nonce });
};
exports.prepareTransaction = prepareTransaction;
//# sourceMappingURL=prepareTransaction.js.map