Skip to content

Commit

Permalink
Add tx-status command to lookup transaction status by hash
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Jul 12, 2019
1 parent 4115011 commit bf2c94b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/near
Expand Up @@ -95,6 +95,18 @@ const viewAccount = {
handler: (argv) => exitOnError(main.viewAccount(argv))
};

const txStatus = {
command: 'tx-status <hash>',
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',
Expand Down Expand Up @@ -176,6 +188,7 @@ yargs // eslint-disable-line
})
.command(createAccount)
.command(viewAccount)
.command(txStatus)
.command(build)
.command(deploy)
.command(scheduleFunctionCall)
Expand Down
8 changes: 8 additions & 0 deletions index.js
Expand Up @@ -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');

Expand Down Expand Up @@ -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}`);
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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",
Expand Down

0 comments on commit bf2c94b

Please sign in to comment.