UNPKG

@ledgerhq/coin-celo

Version:
45 lines 2.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSendMaxMutation = exports.createSend50PercentMutation = exports.minimalAmount = void 0; const invariant_1 = __importDefault(require("invariant")); const index_1 = require("@ledgerhq/cryptoassets/index"); const parseCurrencyUnit_1 = require("@ledgerhq/coin-framework/currencies/parseCurrencyUnit"); const specs_1 = require("@ledgerhq/coin-framework/bot/specs"); const maxAccount = 10; const currency = (0, index_1.getCryptoCurrencyById)("celo"); exports.minimalAmount = (0, parseCurrencyUnit_1.parseCurrencyUnit)(currency.units[0], "0.01"); const createSend50PercentMutation = () => ({ name: "Celo: Move 50% to another account", feature: "send", maxRun: 1, transaction: ({ account, siblings, bridge, maxSpendable }) => { (0, invariant_1.default)(maxSpendable.gt(exports.minimalAmount), "Celo: Move 50% | balance is too low"); const sibling = (0, specs_1.pickSiblings)(siblings, maxAccount); const recipient = sibling.freshAddress; const amount = maxSpendable.div(2).integerValue(); return { transaction: bridge.createTransaction(account), updates: [{ recipient }, { amount }], }; }, }); exports.createSend50PercentMutation = createSend50PercentMutation; const createSendMaxMutation = () => ({ name: "Celo: Send max to another account", feature: "sendMax", maxRun: 1, transaction: ({ account, siblings, bridge, maxSpendable }) => { (0, invariant_1.default)(maxSpendable.gt(exports.minimalAmount), "Celo: Send Max | Balance is too low"); const sibling = (0, specs_1.pickSiblings)(siblings, maxAccount); const recipient = sibling.freshAddress; return { transaction: bridge.createTransaction(account), updates: [{ recipient }, { useAllAmount: true }], }; }, }); exports.createSendMaxMutation = createSendMaxMutation; //# sourceMappingURL=createSendMutation.js.map