From bf2c94b81b4a4d7cb29737bc814bccb0d3b73ea0 Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Tue, 9 Jul 2019 15:59:58 -0700 Subject: [PATCH] Add tx-status command to lookup transaction status by hash --- bin/near | 13 +++++++++++++ index.js | 8 ++++++++ package.json | 1 + 3 files changed, 22 insertions(+) diff --git a/bin/near b/bin/near index 660f7d64..b92b3d79 100755 --- a/bin/near +++ b/bin/near @@ -95,6 +95,18 @@ const viewAccount = { handler: (argv) => exitOnError(main.viewAccount(argv)) }; +const txStatus = { + command: 'tx-status ', + desc: 'lookup transaction status by hash', + builder: (yargs) => yargs + .option('hash', { + desc: 'base58-encoded hash', + type: 'string', + required: true + }), + handler: (argv) => exitOnError(main.txStatus(argv)) +}; + const clean = { command: 'clean', desc: 'clean the build environment', @@ -176,6 +188,7 @@ yargs // eslint-disable-line }) .command(createAccount) .command(viewAccount) + .command(txStatus) .command(build) .command(deploy) .command(scheduleFunctionCall) diff --git a/index.js b/index.js index ec5319c0..5febd267 100755 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const { KeyPair, keyStores } = require('nearlib'); const UnencryptedFileSystemKeyStore = keyStores.UnencryptedFileSystemKeyStore; const fs = require('fs'); const yargs = require('yargs'); +const bs58 = require('bs58'); const ncp = require('ncp').ncp; const rimraf = require('rimraf'); @@ -61,6 +62,13 @@ exports.viewAccount = async function(options) { console.log(state); } +exports.txStatus = async function(options) { + let near = await connect(options); + let status = await near.connection.provider.txStatus(bs58.decode(options.hash)); + console.log(`Transaction ${options.hash}`); + console.log(status); +} + exports.deploy = async function(options) { console.log( `Starting deployment. Account id: ${options.accountId}, node: ${options.nodeUrl}, helper: ${options.helperUrl}, file: ${options.wasmFile}`); diff --git a/package.json b/package.json index 3d14fad5..3dd16042 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "devDependencies": {}, "dependencies": { "assemblyscript": "github:nearprotocol/assemblyscript#assemblyscript-update", + "bs58": "^4.0.1", "jest-environment-node": "^24.5.0", "ncp": "^2.0.0", "nearlib": "github:nearprotocol/nearlib#nightshade",