2019-09-09 01:35:05 +00:00
|
|
|
const ganache = require("ganache-core");
|
2019-08-29 19:59:53 +00:00
|
|
|
const Web3Eth = require('web3-eth');
|
2019-09-27 20:04:01 +00:00
|
|
|
const Subspace = require('../dist/node.js');
|
2019-08-29 19:59:53 +00:00
|
|
|
|
2019-09-09 01:35:05 +00:00
|
|
|
console.log("The following error is emitted by ganache - https://github.com/trufflesuite/ganache-core/issues/267")
|
|
|
|
let eth = new Web3Eth(ganache.provider());
|
2019-08-29 19:59:53 +00:00
|
|
|
|
|
|
|
async function run() {
|
|
|
|
let accounts = await eth.getAccounts();
|
|
|
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
await eth.sendTransaction({from: accounts[0], to: accounts[1], value: "100000000"});
|
|
|
|
await eth.sendTransaction({from: accounts[2], to: accounts[0], value: "999999999"});
|
|
|
|
await eth.sendTransaction({from: accounts[2], to: accounts[0], value: "232433434"});
|
2019-09-09 01:35:05 +00:00
|
|
|
}, 2000);
|
2019-08-29 19:59:53 +00:00
|
|
|
|
2019-09-27 20:04:01 +00:00
|
|
|
const subspace = new Subspace(eth.currentProvider);
|
2019-08-29 19:59:53 +00:00
|
|
|
|
2019-09-27 20:04:01 +00:00
|
|
|
await subspace.init();
|
2019-08-29 19:59:53 +00:00
|
|
|
|
2019-09-27 20:04:01 +00:00
|
|
|
subspace.trackBalance(accounts[0]).subscribe((balance) => {
|
2019-08-29 19:59:53 +00:00
|
|
|
console.log("accounts[0] balance is ", balance);
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
run()
|