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

update near call to use object args #782

Merged
merged 4 commits into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions commands/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
default: '0',
alias: 'amount'
})
.option('base64', {
.option('base64', {
desc: 'Treat arguments as base64-encoded BLOB.',
type: 'boolean',
default: false
Expand All @@ -32,7 +32,7 @@ module.exports = {
.option('accountId', {
required: true,
desc: 'Unique identifier for the account that will be used to sign this call',
type: 'string',
type: 'string'
}),
handler: exitOnError(scheduleFunctionCall)
};
Expand All @@ -44,12 +44,13 @@ async function scheduleFunctionCall(options) {
const near = await connect(options);
const account = await near.account(options.accountId);
const parsedArgs = options.base64 ? Buffer.from(options.args, 'base64') : JSON.parse(options.args || '{}');
const functionCallResponse = await account.functionCall(
options.contractName,
options.methodName,
parsedArgs,
options.gas,
utils.format.parseNearAmount(options.deposit));
const functionCallResponse = await account.functionCall({
contractId: options.contractName,
methodName: options.methodName,
args: parsedArgs,
gas: options.gas,
attachedDeposit: utils.format.parseNearAmount(options.deposit),
});
const result = providers.getTransactionLastResult(functionCallResponse);
inspectResponse.prettyPrintResponse(functionCallResponse, options);
console.log(inspectResponse.formatResponse(result));
Expand Down