UNPKG

@xyrusworx/web3-cli

Version:

A command line tool which offers low-level EVM interaction for Web3 developers

42 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const common_1 = require("../shared/common"); const helpers_1 = require("@xyrusworx/evm-simulator/implementation/helpers"); // noinspection JSUnusedGlobalSymbols class EncodeCommand { constructor(input, output) { this.input = input; this.output = output; } async run(args) { const { exit, model } = (0, common_1.parseArguments)(this.output, args); if (!!model?.showHelp) { this.usage(); return exit || 0; } if (exit !== undefined) return exit || 0; const firstNonOption = args.findIndex(x => !x.startsWith("-")); if (firstNonOption < 0) { this.usage(); return 1; } const call = args[firstNonOption]; const callArgs = args.slice(firstNonOption + 1); const data = (0, helpers_1.encodeCallData)(call, ...callArgs); process.stdout.write(data, "utf-8"); return 0; } usage() { const console = this.output; console.log("Usage: web3 encode [options] <signature> {parameters}"); console.log("Available options:"); (0, common_1.commonHelp)(console); console.log(""); console.log("The signature needs to be passed in ABI format. For example: transfer(address,uint256)."); console.log("The subsequent arguments are the parameters to the call. Their count must match the signature."); console.log(""); } } exports.default = EncodeCommand; //# sourceMappingURL=encode.js.map