code style
This commit is contained in:
parent
1488862b42
commit
ebb26f78c2
@ -5,8 +5,8 @@ module.exports = function(callback) {
|
|||||||
let method = process.argv[5];
|
let method = process.argv[5];
|
||||||
let args = process.argv.slice(6);
|
let args = process.argv.slice(6);
|
||||||
|
|
||||||
if(!contractName) {
|
if (!contractName) {
|
||||||
console.log("Usage:")
|
console.log("Usage:");
|
||||||
console.log(" truffle exec scripts/cli.js <Contract name> <method to call> [<optional> <arguments>]");
|
console.log(" truffle exec scripts/cli.js <Contract name> <method to call> [<optional> <arguments>]");
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
@ -16,14 +16,14 @@ module.exports = function(callback) {
|
|||||||
console.log(`Using ${contractName} at ${contractAddress}`);
|
console.log(`Using ${contractName} at ${contractAddress}`);
|
||||||
let contract = await artifacts.require(`./${contractName}`).at(contractAddress);
|
let contract = await artifacts.require(`./${contractName}`).at(contractAddress);
|
||||||
|
|
||||||
if(!contract[method]) {
|
if (!contract[method]) {
|
||||||
callback(new Error(`Method ${method} is not defined on ${contractName}`));
|
callback(new Error(`Method ${method} is not defined on ${contractName}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(`Calling ${method} with ${JSON.stringify(args)}`);
|
console.log(`Calling ${method} with ${JSON.stringify(args)}`);
|
||||||
|
|
||||||
contract[method](...args).then((result) => {
|
contract[method](...args).then((result) => {
|
||||||
console.log('Result:');
|
console.log("\nResult:");
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user