UNPKG

@titan-suite/cli

Version:

The complete smart contract development tool

43 lines (42 loc) 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const Web3 = require('aion-web3'); const repl = require('repl'); const utils_1 = require("../utils"); class Console extends command_1.Command { testWeb3(_provider) { let _w3 = new Web3(new Web3.providers.HttpProvider(_provider)); _w3.eth.getBlock('latest'); } run() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { flags } = this.parse(Console); let provider = utils_1.getProvider(flags.network); const currentNetwork = utils_1.getCurrentNetwork(); try { this.testWeb3(provider); const server = repl.start('console@' + currentNetwork + '$ '); const context = server.context; context.Web3 = new Web3(); context.web3 = new Web3(new Web3.providers.HttpProvider(provider)); context.eth = context.web3.eth; context.personal = context.web3.personal; } catch (err) { this.log(/Error:\s+(.+)/gi.exec(err)[1]); } }); } } Console.description = 'Interact with an AION node'; Console.examples = ['$ titan console', '$ titan console -t development']; Console.flags = { help: command_1.flags.help({ char: 'h' }), network: command_1.flags.string({ char: 't', description: 'specify the network to connect to' }) }; exports.default = Console;