@kubiklabs/wasmkit
Version:
Wasmkit is a development environment to compile, deploy, test, run cosmwasm contracts on different networks.
54 lines (53 loc) • 2.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const config_env_1 = require("../internal/core/config/config-env");
const errors_1 = require("../internal/core/errors");
const errors_list_1 = require("../internal/core/errors-list");
const client_1 = require("../lib/client");
const types_1 = require("../types");
const task_names_1 = require("./task-names");
function default_1() {
(0, config_env_1.task)(task_names_1.TASK_NODE_INFO, "Prints node info and status")
.setAction(nodeInfo);
}
exports.default = default_1;
async function nodeInfo(_taskArgs, env) {
const client = await (0, client_1.getClient)(env.network);
console.log("Network:", chalk_1.default.green(env.network.name));
console.log("RPC URL:", chalk_1.default.green(env.network.config.endpoint));
const chain = (0, client_1.getChainFromAccount)(env.network);
switch (chain) {
case types_1.ChainType.Secret: {
const tendermintClient = client.query.tendermint;
const blockInfo = await tendermintClient.getLatestBlock({});
console.log("Block height:", chalk_1.default.green(blockInfo));
// console.log("ChainId:", await tendermintClient.getChainId()); // TODO: replace this
const nodeInfo = await tendermintClient.getNodeInfo({})
// eslint-disable-next-line
.catch((err) => { throw new Error(`Could not fetch node info: ${err}`); });
console.log("Node Info:", chalk_1.default.green(nodeInfo));
break;
}
case types_1.ChainType.Juno:
case types_1.ChainType.Osmosis:
case types_1.ChainType.Archway:
case types_1.ChainType.Neutron:
case types_1.ChainType.Atom:
case types_1.ChainType.Umee:
case types_1.ChainType.Nibiru:
case types_1.ChainType.Terra: {
console.log("ChainId:", chalk_1.default.green(await client.getChainId()));
console.log("Block height:", chalk_1.default.green(await client.getHeight()));
break;
}
// case ChainType.Injective: {
// }
default: {
throw new errors_1.WasmkitError(errors_list_1.ERRORS.NETWORK.UNKNOWN_NETWORK, { account: env.network.config.accounts[0].address });
}
}
}