From 84f20efff0427f367dea4b4d7f5610fd4d48d76c Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 27 Aug 2019 12:19:01 +0200 Subject: [PATCH] Add ENV var for custom DAO address This makes it much easier to test hubot-kredits with local development chains. --- index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index cf410c4..dc8527f 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const Kredits = require('kredits-contracts'); const walletPath = process.env.KREDITS_WALLET_PATH || './wallet.json'; const walletJson = fs.readFileSync(walletPath); const providerUrl = process.env.KREDITS_PROVIDER_URL; +const daoAddress = process.env.KREDITS_DAO_ADDRESS; const ipfsConfig = { host: process.env.IPFS_API_HOST || 'localhost', @@ -48,14 +49,18 @@ module.exports = async function(robot) { // Kredits contracts setup // + const opts = { ipfsConfig }; + + if (daoAddress) { + opts.addresses = { Kernel: daoAddress }; + } else { + opts.apm = 'open.aragonpm.eth'; + } + let kredits; + try { - kredits = await new Kredits(signer.provider, signer, { - // TODO support local devchain custom address - apm: 'open.aragonpm.eth', - // addresses: { Kernel: '0x93aa4531329e4bf3efcd1ec0b74adb6f66d9d10e' } - ipfsConfig - }).init(); + kredits = await new Kredits(signer.provider, signer, opts).init(); } catch(error) { robot.logger.warning('[hubot-kredits] Could not set up kredits:', error); process.exit(1);