From bf53541192855b03e71853dc00c4b6d5f28163ef Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Fri, 7 Jun 2019 00:31:36 -0700 Subject: [PATCH] Add view_account command --- bin/near | 8 ++++++++ index.js | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/bin/near b/bin/near index 90a1bf76..9c0d7b2e 100755 --- a/bin/near +++ b/bin/near @@ -46,6 +46,13 @@ const callViewFunction = { handler: (argv) => exitOnError(main.callViewFunction(argv)) }; +const viewAccount = { + command: 'view_account ', + desc: 'view given account/contract state', + builder: (yargs) => yargs, + handler: (argv) => exitOnError(main.viewAccount(argv)) +}; + const sendTokens = { command: 'send ', desc: 'send tokens to given receiver', @@ -136,6 +143,7 @@ yargs // eslint-disable-line .command(deploy) .command(scheduleFunctionCall) .command(callViewFunction) + .command(viewAccount) .command(sendTokens) .command(clean) .command(newProject) diff --git a/index.js b/index.js index 2787d390..4b3e07e9 100755 --- a/index.js +++ b/index.js @@ -104,4 +104,11 @@ exports.callViewFunction = async function(options) { console.log(`View call: ${options.contractName}.${options.methodName}(${options.args || ''})`); const near = await connect(options); console.log('Result:', await near.callViewFunction(options.contractName, options.methodName, JSON.parse(options.args || '{}'))); +}; + +exports.viewAccount = async function(options) { + const { accountId } = options; + console.log(`View account: ${accountId}`); + const near = await connect(options); + console.log('Result:', await near.nearClient.viewAccount(accountId)); }; \ No newline at end of file