3 Commits

Author SHA1 Message Date
44a2b49e2b 1.2.0 2017-05-06 19:41:38 +02:00
1df79cbec5 Make kredits contract address configurable
Useful with local dev chains.
2017-05-06 19:41:00 +02:00
ae453882a3 Formatting and todo note 2017-05-06 16:06:24 +02:00
2 changed files with 11 additions and 5 deletions

View File

@@ -24,19 +24,25 @@ let wallet = Wallet.fromV3(JSON.parse(walletJson), process.env.KREDITS_WALLET_PA
let providerUrl = process.env.KREDITS_PROVIDER_URL || 'http://localhost:8545';
let hubotWalletAddress = '0x' + wallet.getAddress().toString('hex');
let config = {};
if (process.env.KREDITS_CONTRACT_ADDRESS) {
config = { Kredits: { address: process.env.KREDITS_CONTRACT_ADDRESS }};
}
engine.addProvider(new WalletSubprovider(wallet, {}));
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
// TODO only start engine if providerURL is accessible
engine.start();
let web3 = new Web3(engine);
let contracts = kreditsContracts(web3);
let contracts = kreditsContracts(web3, config);
let Kredits = contracts['Kredits'];
console.log('[HUBOT-KREDITS] wallet address: ' + hubotWalletAddress);
console.log('[HUBOT-KREDITS] Wallet address: ' + hubotWalletAddress);
web3.eth.getBalance(hubotWalletAddress, function (err, balance) {
if (err) { console.log('[HUBOT-KREDITS] error checking balance'); return; }
if (err) { console.log('[HUBOT-KREDITS] Error checking balance'); return; }
if (balance <= 0) {
console.log('[HUBOT-KREDITS] Hubot is broke. Please sond some eth to ' + hubotWalletAddress);
console.log('[HUBOT-KREDITS] Hubot is broke. Please send some ETH to ' + hubotWalletAddress);
}
});

View File

@@ -1,6 +1,6 @@
{
"name": "hubot-kredits",
"version": "1.1.0",
"version": "1.2.0",
"description": "Kosmos Kredits functionality for chat bots",
"main": "index.js",
"scripts": {