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

Commit

Permalink
Add command to send tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Jun 5, 2019
1 parent 4a7cd49 commit 1ca504f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/near
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ const callViewFunction = {
handler: (argv) => exitOnError(main.callViewFunction(argv))
};

const sendTokens = {
command: 'send <receiver> <amount>',
desc: 'send tokens to given receiver',
builder: (yargs) => yargs,
handler: (argv) => exitOnError(main.sendTokens(argv))
};

const { spawn } = require('child_process');
const build = {
command: 'build',
Expand Down Expand Up @@ -129,6 +136,7 @@ yargs // eslint-disable-line
.command(deploy)
.command(scheduleFunctionCall)
.command(callViewFunction)
.command(sendTokens)
.command(clean)
.command(newProject)
.config(config)
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ exports.scheduleFunctionCall = async function(options) {
options.contractName, options.methodName, JSON.parse(options.args || '{}'))));
};

exports.sendTokens = async function(options) {
console.log(`Sending ${options.amount} NEAR to ${options.receiver}`);
const near = await connect(options);
await near.waitForTransactionResult(
await near.sendTokens(options.amount, options.accountId, options.receiver));
};

exports.callViewFunction = async function(options) {
console.log(`View call: ${options.contractName}.${options.methodName}(${options.args || ''})`);
const near = await connect(options);
Expand Down

0 comments on commit 1ca504f

Please sign in to comment.