UNPKG

@ledgerhq/coin-celo

Version:
56 lines 1.96 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = makeCliTools; const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); const network_1 = require("../network"); const invariant_1 = __importDefault(require("invariant")); const flatMap_1 = __importDefault(require("lodash/flatMap")); const options = [ { name: "mode", type: String, desc: "mode of transaction: send, lock, unlock, withdraw, vote, revoke, activate, register", }, { name: "transactionIndex", type: String, desc: "transaction index of a pending withdraw in case of withdraw mode", }, ]; function inferAccounts(account) { (0, invariant_1.default)(account.currency.family === "celo", "celo family"); const accounts = [account]; return accounts; } function inferTransactions(transactions, opts) { const mode = opts.mode || "send"; (0, invariant_1.default)(["send", "lock", "unlock", "withdraw", "vote", "revoke", "activate", "register"].includes(mode), `Unexpected mode: ${mode}`); return (0, flatMap_1.default)(transactions, ({ transaction }) => { (0, invariant_1.default)(transaction.family === "celo", "celo family"); return { ...transaction, family: "celo", mode, index: opts.transactionIndex || null, }; }); } const celoValidatorGroups = { args: [], job: () => (0, rxjs_1.from)((0, network_1.getValidatorGroups)()).pipe((0, operators_1.map)(validatorGroup => JSON.stringify(validatorGroup))), }; function makeCliTools() { return { options, inferAccounts, inferTransactions, commands: { celoValidatorGroups, }, }; } //# sourceMappingURL=cli-transaction.js.map