Make the CLI a real reply

After calling the contract function a reply is started.
This allows to interact and inspect the result object or call more
functions on the contract.
This commit is contained in:
bumi 2018-04-09 01:52:51 +02:00
parent ef3b3dd6bb
commit b3d19e556c

View File

@ -1,3 +1,5 @@
const REPL = require('repl');
module.exports = function(callback) { module.exports = function(callback) {
const Registry = artifacts.require('./Registry.sol'); const Registry = artifacts.require('./Registry.sol');
Registry.deployed().then(async (registry) => { Registry.deployed().then(async (registry) => {
@ -26,7 +28,17 @@ module.exports = function(callback) {
console.log("\nResult:"); console.log("\nResult:");
console.log(result); console.log(result);
console.log("\nStartig a REPL. (type .exit to exit)");
console.log(`defined variables: result, ${contractName}, web3`);
let r = REPL.start();
r.context.result = result;
r.context[contractName] = contract;
r.context.web3 = web3;
r.on('exit', () => {
console.log('Bye');
callback(); callback();
})
}).catch((error) => { }).catch((error) => {
console.log("Call failed. Probably the contract raised an error?\n"); console.log("Call failed. Probably the contract raised an error?\n");
console.log("..."); console.log("...");