Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Use inspectResponse to display nearcore responses
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Sep 20, 2019
1 parent 8caace3 commit ca47fa9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exports.viewAccount = async function(options) {
let account = await near.account(options.accountId);
let state = await account.state();
console.log(`Account ${options.accountId}`);
console.log(state);
console.log(inspectResponse(state));
}

exports.deleteAccount = async function(options) {
Expand All @@ -95,7 +95,7 @@ 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);
console.log(inspectResponse(status));
}

exports.deploy = async function(options) {
Expand All @@ -114,30 +114,30 @@ exports.scheduleFunctionCall = async function(options) {
const account = await near.account(options.accountId);
const functionCallResponse = await account.functionCall(options.contractName, options.methodName, JSON.parse(options.args || '{}'), options.amount);
const result = nearjs.providers.getTransactionLastResult(functionCallResponse);
console.log('Result:', result);
console.log(inspectResponse(result));
};

exports.sendMoney = async function(options) {
console.log(`Sending ${options.amount} NEAR to ${options.receiver} from ${options.sender}`);
const near = await connect(options);
const account = await near.account(options.sender);
await account.sendMoney(options.receiver, options.amount);
console.log(inspectResponse(await account.sendMoney(options.receiver, options.amount)));
};

exports.callViewFunction = async function(options) {
console.log(`View call: ${options.contractName}.${options.methodName}(${options.args || ''})`);
const near = await connect(options);
// TODO: Figure out how to run readonly calls without account
const account = await near.account(options.accountId || options.masterAccount || 'register.near');
console.log('Result:', await account.viewFunction(options.contractName, options.methodName, JSON.parse(options.args || '{}')));
console.log(inspectResponse(await account.viewFunction(options.contractName, options.methodName, JSON.parse(options.args || '{}'))));
};

exports.stake = async function(options) {
console.log(`Staking ${options.amount} on ${options.accountId} with public key = ${options.publicKey}.`);
const near = await connect(options);
const account = await near.account(options.accountId);
const result = await account.stake(options.publicKey, BigInt(options.amount));
console.log('Result: ', JSON.stringify(result));
console.log(inspectResponse(result));
}

exports.login = async function(options) {
Expand Down

0 comments on commit ca47fa9

Please sign in to comment.