Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44a2b49e2b | |||
| 1df79cbec5 | |||
| ae453882a3 |
14
index.js
14
index.js
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user