UNPKG

@ledgerhq/coin-near

Version:
36 lines 1.04 kB
import BigNumber from "bignumber.js"; import { encodeOperationId } from "@ledgerhq/coin-framework/operation"; export const buildOptimisticOperation = (account, transaction, fee) => { let type; let value = new BigNumber(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: 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; }; //# sourceMappingURL=buildOptimisticOperation.js.map