UNPKG

@flarenetwork/flare-stake-tool

Version:
300 lines 10.9 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.prompts = void 0; const chalk_1 = __importDefault(require("chalk")); const inquirer_1 = __importDefault(require("inquirer")); const screen_1 = require("../constants/screen"); /** * Provides various prompts used in the CLI for user interaction. */ exports.prompts = { connectWallet: async () => { const questions = [ { type: "list", name: "wallet", message: chalk_1.default.magenta("How do you want to connect your wallet?"), choices: [...Object.values(screen_1.walletConstants)], filter: (val) => { const key = Object.keys(screen_1.walletConstants).find((key) => screen_1.walletConstants[key] === val); return key; }, }, ]; return inquirer_1.default.prompt(questions); }, derivationType: async () => { const questions = [ { type: "list", name: "derivation", message: chalk_1.default.magenta("Choose derivation path..."), choices: [...Object.values(screen_1.derivationModeConstants)], filter: (val) => { const key = Object.keys(screen_1.derivationModeConstants).find((key) => screen_1.derivationModeConstants[key] === val); return key; }, }, ]; return inquirer_1.default.prompt(questions); }, pvtKeyPath: async () => { const questions = [ { type: "input", name: "pvtKeyPath", message: chalk_1.default.magenta("Enter Path to Private Key file") + " " + chalk_1.default.yellow("(E.g. /home/wallet/pvtKeyFile)") + chalk_1.default.magenta(":"), }, ]; return inquirer_1.default.prompt(questions); }, publicKey: async () => { const questions = [ { type: "input", name: "publicKey", message: chalk_1.default.magenta("Enter your secp256k1 curve public key") + " " + chalk_1.default.yellow("(E.g. 0x02efe41c5d213089cb7a9e808505e9084bb9eb2bf3aa8050ea92a5ae9e20e5a692)") + chalk_1.default.magenta(":"), }, ]; return inquirer_1.default.prompt(questions); }, amount: async (amountPurpose = "", defaultAmount) => { const questions = [ { type: "input", default: defaultAmount, name: "amount", message: chalk_1.default.magenta(`Enter amount ${amountPurpose}`) + " " + chalk_1.default.magenta(`(in FLR):`), }, ]; return inquirer_1.default.prompt(questions); }, // exportCP and importPC fees fees: async (defaultFees) => { const questions = [ { type: "input", default: defaultFees, name: "fees", message: chalk_1.default.magenta("Enter fees (in FLR):"), }, ]; return inquirer_1.default.prompt(questions); }, // base fee for exportCP and importPC txs with private key baseFee: async (defaultBaseFee) => { const questions = [ { type: "input", default: defaultBaseFee, name: "baseFee", message: chalk_1.default.magenta("Enter base fee (in nanoFLR):"), }, ]; return inquirer_1.default.prompt(questions); }, nodeId: async () => { const questions = [ { type: "input", name: "id", message: chalk_1.default.magenta("Enter NodeId") + " " + chalk_1.default.yellow("(E.g. NodeID-FQKTLuZHEsjCxPeFTFgsojsucmdyNDsz1)") + chalk_1.default.magenta(":"), }, ]; return inquirer_1.default.prompt(questions); }, unixTime: async (timeType) => { const questions = [ { type: "input", name: "time", message: chalk_1.default.magenta(`Enter ${timeType} time`) + " " + chalk_1.default.yellow("(E.g. 1693185095)") + chalk_1.default.magenta(":"), }, ]; return inquirer_1.default.prompt(questions); }, ctxFile: async () => { const questions = [ { type: "list", name: "isContinue", message: chalk_1.default.magenta("Do you wish to continue with this?"), choices: ["Yes", "No"], filter: (val) => { return val === "Yes" ? true : false; }, }, ]; return inquirer_1.default.prompt(questions); }, selectNetwork: async () => { const questions = [ { type: "list", name: "network", message: chalk_1.default.magenta("Which network do you want to connect to?"), choices: [...Object.values(screen_1.networkConstants)], filter: (val) => { const key = Object.keys(screen_1.networkConstants).find((key) => screen_1.networkConstants[key] === val); return key; }, }, ]; return inquirer_1.default.prompt(questions); }, selectTask: async () => { const questions = [ { type: "list", name: "task", message: chalk_1.default.magenta("What do you want to do?"), choices: [...Object.values(screen_1.taskConstants)], filter: (val) => { const key = Object.keys(screen_1.taskConstants).find((key) => screen_1.taskConstants[key] === val); return key; }, }, ]; return inquirer_1.default.prompt(questions); }, selectAddress: async (choiceList) => { const questions = [ { type: "list", name: "address", message: chalk_1.default.magenta("Which address do you want to use?"), choices: [...choiceList], filter: (val) => { const address = val.split(" ")[1]; return address; }, }, ]; return inquirer_1.default.prompt(questions); }, delegationFee: async () => { const questions = [ { type: "input", name: "fee", message: chalk_1.default.magenta("Enter delegation fee") + " " + chalk_1.default.yellow("(E.g. 10)") + chalk_1.default.magenta(":"), }, ]; return inquirer_1.default.prompt(questions); }, transactionId: async () => { const questions = [ { type: "input", name: "id", message: chalk_1.default.magenta("Enter Transaction Id") + " " + chalk_1.default.yellow("(E.g. abc-txn)") + chalk_1.default.magenta(":"), }, ]; return inquirer_1.default.prompt(questions); }, importTrxType: async () => { const questions = [ { type: "list", name: "type", message: chalk_1.default.magenta("Please select the destination chain to which you want to import your funds?"), choices: ["P", "C"], }, ]; return inquirer_1.default.prompt(questions); }, popBLSPublicKey: async () => { const questions = [ { type: "input", name: "popBLSPublicKey", message: chalk_1.default.magenta("Please enter the popBLSPublicKey:"), }, ]; return inquirer_1.default.prompt(questions); }, popBLSSignature: async () => { const questions = [ { type: "input", name: "popBLSSignature", message: chalk_1.default.magenta("Please enter the popBLSSignature:"), }, ]; return inquirer_1.default.prompt(questions); }, transferAddress: async () => { const questions = [ { type: "input", name: "transferAddress", message: chalk_1.default.magenta("Enter destination P-chain address:"), }, ]; return inquirer_1.default.prompt(questions); }, // wrap rewards when claiming staking rewards wrapRewards: async () => { const questions = [ { type: "list", name: "wrapRewards", message: chalk_1.default.magenta("Should claimed rewards be wrapped?"), choices: ["Yes", "No"], filter: (val) => { return val === "Yes" ? true : false; }, }, ]; return inquirer_1.default.prompt(questions); }, // recipient address to receive claimed staking rewards recipientAddress: async (defaultAddress) => { const questions = [ { type: "input", default: defaultAddress, name: "recipientAddress", message: chalk_1.default.magenta("Please enter the recipient address (default address is reward owner):"), }, ]; return inquirer_1.default.prompt(questions); }, claimAmount: async () => { const questions = [ { type: "input", name: "claimAmount", message: chalk_1.default.magenta("Please enter the amount to claim:"), }, ]; return inquirer_1.default.prompt(questions); }, claimAllUnclaimed: async (totalUnclaimed, symbol) => { const questions = [ { type: "list", name: "claimAllUnclaimed", message: chalk_1.default.magenta(`Do you want to claim all unclaimed rewards?`, totalUnclaimed ? "(total unclaimed: " + totalUnclaimed + " " + symbol + ")" : ""), choices: ["Yes", "No"], filter: (val) => { return val === "Yes" ? true : false; }, }, ]; return inquirer_1.default.prompt(questions); }, }; //# sourceMappingURL=prompts.js.map