Refactor kredits init in helper scripts

This now also supports readonly providers like infura
This commit is contained in:
2019-03-29 12:05:51 +01:00
parent 94832d4d07
commit 4bd1aed197
10 changed files with 99 additions and 90 deletions

View File

@@ -1,18 +1,10 @@
const REPL = require('repl');
const promptly = require('promptly');
const ethers = require('ethers');
const Kredits = require('../lib/kredits');
const getNetworkId = require('./helpers/networkid.js')
const initKredits = require('./helpers/init_kredits.js');
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(
web3.currentProvider, { chainId: parseInt(networkId) }
);
new Kredits(provider, provider.getSigner()).init().then(async function(kredits) {
initKredits(web3).then(async function(kredits) {
let contractName = await promptly.prompt('Contract Name: ');
const contractWrapper = kredits[contractName];