UNPKG

@ledgerhq/coin-near

Version:
43 lines 1.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildOptimisticOperation = void 0; const bignumber_js_1 = __importDefault(require("bignumber.js")); const operation_1 = require("@ledgerhq/coin-framework/operation"); const buildOptimisticOperation = (account, transaction, fee) => { let type; let value = new bignumber_js_1.default(transaction.amount); switch (transaction.mode) { case "stake": type = "STAKE"; break; case "unstake": type = "UNSTAKE"; break; case "withdraw": type = "WITHDRAW_UNSTAKED"; break; default: value = value.plus(fee); type = "OUT"; } const operation = { id: (0, operation_1.encodeOperationId)(account.id, "", type), hash: "", type, value, fee, blockHash: null, blockHeight: null, senders: [account.freshAddress], recipients: [transaction.recipient].filter(Boolean), accountId: account.id, date: new Date(), extra: {}, }; return operation; }; exports.buildOptimisticOperation = buildOptimisticOperation; //# sourceMappingURL=buildOptimisticOperation.js.map