From ce446e530dbcae1ddf3355becc21e695e1f03faf Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 2 Apr 2019 09:58:44 +0200 Subject: [PATCH] Set Kreits apm from arapp.json file in helper scripts different networks might require different apm domains. We set those in the arapp.json file which we can reuise to init the kredits instance in the helper scripts. --- scripts/helpers/init_kredits.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/init_kredits.js b/scripts/helpers/init_kredits.js index 59bf58b..cb2a3f4 100644 --- a/scripts/helpers/init_kredits.js +++ b/scripts/helpers/init_kredits.js @@ -1,14 +1,19 @@ +const argv = require('yargs').argv; const ethers = require('ethers'); -const getNetworkId = require('./networkid.js') +const getNetworkId = require('./networkid.js'); const Kredits = require('../../lib/kredits'); +const arapp = require('../../arapp.json'); +const environment = argv['network'] || argv['environment'] || 'development'; +const apm = arapp.environments[environment].apm; + module.exports = async function(web3) { return new Promise((resolve, reject) => { const provider = new ethers.providers.Web3Provider(web3.currentProvider); let signer = provider.getSigner(); // checking if siner supports signing transactions signer.getAddress().then(_ => { - new Kredits(provider, signer).init().then(kredits => { + new Kredits(provider, signer, { apm }).init().then(kredits => { resolve(kredits); }).catch(e => { reject(e);