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