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

Commit

Permalink
Revert "format cli.js"
Browse files Browse the repository at this point in the history
This reverts commit 081cee0.
  • Loading branch information
vgrichina committed Nov 5, 2019
1 parent 39d6ea6 commit 434532f
Showing 1 changed file with 95 additions and 86 deletions.
181 changes: 95 additions & 86 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,65 @@ const yargs = require('yargs');
const main = require('../');
const exitOnError = require('../utils/exit-on-error');

// For account:
const deploy = {
command: 'deploy',
desc: 'deploy your smart contract',
builder: (yargs) => yargs
.option('wasmFile', {
desc: 'Path to wasm file to deploy',
type: 'string',
default: './out/main.wasm'
})
.alias({
'accountId': ['account_id', 'contractName', 'contract_name'],
}),
handler: exitOnError(main.deploy)
};

const scheduleFunctionCall = {
command: 'call <contractName> <methodName> [args]',
desc: 'schedule smart contract call which can modify state',
builder: (yargs) => yargs
.option('amount', {
desc: 'Number of tokens to attach',
type: 'string',
default: '1000000000'
}),
handler: exitOnError(main.scheduleFunctionCall)
};

const callViewFunction = {
command: 'view <contractName> <methodName> [args]',
desc: 'make smart contract call which can view state',
builder: (yargs) => yargs,
handler: exitOnError(main.callViewFunction)
};

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

const { spawn } = require('child_process');
const build = {
command: 'build',
desc: 'build your smart contract',
handler: () => {
const gulp = spawn('gulp');
gulp.stdout.on('data', function (data) {
console.log(data.toString());
});
gulp.stderr.on('data', function (data) {
console.log(data.toString());
});
gulp.on('exit', function (code) {
process.exit(code);
});
}
};

const createAccount = {
command: 'create_account <accountId>',
desc: 'create a developer account',
Expand Down Expand Up @@ -38,7 +96,7 @@ const login = {
};

const viewAccount = {
command: 'view <accountId>',
command: 'state <accountId>',
desc: 'view account',
builder: (yargs) => yargs
.option('accountId', {
Expand All @@ -50,7 +108,7 @@ const viewAccount = {
};

const deleteAccount = {
command: 'delete <accountId> <beneficiaryId>',
command: 'delete_account <accountId> <beneficiaryId>',
desc: 'delete an account and transfer funds to beneficiary account.',
builder: (yargs) => yargs
.option('accountId', {
Expand Down Expand Up @@ -78,89 +136,6 @@ const keys = {
handler: exitOnError(main.keys)
};

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

const stake = {
command: 'stake [accountId] [stakingKey] [amount]',
desc: 'create staking transaction',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account to stake on',
type: 'string',
required: true,
})
.option('stakingKey', {
descr: 'Public key to stake with (base58 encoded)',
type: 'string',
required: true,
})
.option('amount', {
descr: 'Amount to stake',
type: 'string',
required: true,
}),
handler: exitOnError(main.stake)
};

// For contract:
const deploy = {
command: 'deploy',
desc: 'deploy your smart contract',
builder: (yargs) => yargs
.option('wasmFile', {
desc: 'Path to wasm file to deploy',
type: 'string',
default: './out/main.wasm'
})
.alias({
'accountId': ['account_id', 'contractName', 'contract_name'],
}),
handler: exitOnError(main.deploy)
};

const scheduleFunctionCall = {
command: 'call <contractName> <methodName> [args]',
desc: 'schedule smart contract call which can modify state',
builder: (yargs) => yargs
.option('amount', {
desc: 'Number of tokens to attach',
type: 'string',
default: '1000000000'
}),
handler: exitOnError(main.scheduleFunctionCall)
};

const callViewFunction = {
command: 'view <contractName> <methodName> [args]',
desc: 'make smart contract call which can view state',
builder: (yargs) => yargs,
handler: exitOnError(main.callViewFunction)
};

const { spawn } = require('child_process');
const build = {
command: 'build',
desc: 'build your smart contract',
handler: () => {
const gulp = spawn('gulp');
gulp.stdout.on('data', function (data) {
console.log(data.toString());
});
gulp.stderr.on('data', function (data) {
console.log(data.toString());
});
gulp.on('exit', function (code) {
process.exit(code);
});
}
};

// For transaction:
const txStatus = {
command: 'tx-status <hash>',
desc: 'lookup transaction status by hash',
Expand All @@ -185,6 +160,40 @@ const clean = {
handler: exitOnError(main.clean)
};

const newProject = {
command: 'new_project [projectDir]',
desc: 'create a new blank project',
builder: (yargs) => yargs
.option('projectDir', {
desc: 'project directory',
type: 'string',
default: '.'
}),
handler: exitOnError(main.newProject)
};

const stake = {
command: 'stake [accountId] [publicKey] [amount]',
desc: 'create staking transaction',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account to stake on',
type: 'string',
required: true,
})
.option('publicKey', {
descr: 'Public key to stake with (base58 encoded)',
type: 'string',
required: true,
})
.option('amount', {
descr: 'Amount to stake',
type: 'string',
required: true,
}),
handler: exitOnError(main.stake)
};

let config = require('../get-config')();
yargs // eslint-disable-line
.scriptName('near')
Expand Down

0 comments on commit 434532f

Please sign in to comment.