Add repl.js helper script
This is similar to the cli.js helper but only provides an initialized `kredits` instance. The cli.js is for executing contract functions
This commit is contained in:
parent
847f5a251c
commit
b1345b53f3
@ -81,11 +81,15 @@ At some point these should be moved into a real nice CLI.
|
|||||||
To run these scripts use `truffle exec`. For example: `truffle exec scripts/add-proposal.js`
|
To run these scripts use `truffle exec`. For example: `truffle exec scripts/add-proposal.js`
|
||||||
|
|
||||||
### cli.js
|
### cli.js
|
||||||
|
|
||||||
Call any function on any contract:
|
Call any function on any contract:
|
||||||
|
|
||||||
$ truffle exec scripts/cli.js
|
$ truffle exec scripts/cli.js
|
||||||
|
|
||||||
|
### repl.js
|
||||||
|
Similar to cli.js but only provides a REPL with an initialized `kredits` instance.
|
||||||
|
|
||||||
|
$ truffle exec scripts/repl.js
|
||||||
|
|
||||||
### add-contributor.js
|
### add-contributor.js
|
||||||
Adds a new core contributor, creates a proposal for the new contributor and votes for that one.
|
Adds a new core contributor, creates a proposal for the new contributor and votes for that one.
|
||||||
|
|
||||||
|
25
scripts/repl.js
Normal file
25
scripts/repl.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
const REPL = require('repl');
|
||||||
|
const promptly = require('promptly');
|
||||||
|
|
||||||
|
const ethers = require('ethers');
|
||||||
|
const Kredits = require('../lib/kredits');
|
||||||
|
|
||||||
|
module.exports = function(callback) {
|
||||||
|
const Registry = artifacts.require('./Registry.sol');
|
||||||
|
Registry.deployed().then(async (registry) => {
|
||||||
|
const networkId = parseInt(web3.version.network);
|
||||||
|
const provider = new ethers.providers.Web3Provider(
|
||||||
|
web3.currentProvider, { chainId: networkId }
|
||||||
|
);
|
||||||
|
const kredits = await Kredits.setup(provider, provider.getSigner());
|
||||||
|
console.log(`defined variables: kredits, web3`);
|
||||||
|
let r = REPL.start();
|
||||||
|
r.context.kredits = kredits;
|
||||||
|
r.context.web3 = web3;
|
||||||
|
|
||||||
|
r.on('exit', () => {
|
||||||
|
console.log('Bye');
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user