mirror of https://github.com/embarklabs/embark.git
add wallet and clean up
This commit is contained in:
parent
39ede07cdb
commit
37ca90ad9b
|
@ -11,6 +11,8 @@ class Provider {
|
|||
this.accountsConfig = options.accountsConfig;
|
||||
this.logger = options.logger;
|
||||
this.engine = new ProviderEngine();
|
||||
this.asyncMethods = {};
|
||||
this.syncMethods = {};
|
||||
|
||||
this.engine.addProvider(new RpcSubprovider({
|
||||
rpcUrl: options.web3Endpoint
|
||||
|
@ -36,6 +38,9 @@ class Provider {
|
|||
});
|
||||
|
||||
if (this.accounts.length) {
|
||||
this.accounts.forEach(account => {
|
||||
this.web3.eth.accounts.wallet.add(account);
|
||||
});
|
||||
this.asyncMethods = {
|
||||
eth_accounts: self.eth_accounts.bind(this)
|
||||
};
|
||||
|
@ -45,16 +50,10 @@ class Provider {
|
|||
}
|
||||
}
|
||||
|
||||
this.engine.on('block', function (block) {
|
||||
console.log('================================');
|
||||
console.log('BLOCK CHANGED:', '#' + block.number.toString('hex'), '0x' + block.hash.toString('hex'));
|
||||
console.log('================================');
|
||||
});
|
||||
|
||||
// network connectivity error
|
||||
this.engine.on('error', function (err) {
|
||||
this.engine.on('error', (err) => {
|
||||
// report connectivity errors
|
||||
console.error(err.stack);
|
||||
this.logger.error(err.stack);
|
||||
});
|
||||
this.engine.start();
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ class Provider {
|
|||
|
||||
const addressIndex = accountConfig.addressIndex || 0;
|
||||
const numAddresses = accountConfig.numAddresses || 1;
|
||||
const wallet_hdpath = "m/44'/60'/0'/0/"; // TODO check if this can change
|
||||
const wallet_hdpath = accountConfig.hdpath || "m/44'/60'/0'/0/";
|
||||
|
||||
const accounts = [];
|
||||
for (let i = addressIndex; i < addressIndex + numAddresses; i++) {
|
||||
|
@ -96,7 +95,6 @@ class Provider {
|
|||
}
|
||||
|
||||
sendAsync(payload, callback) {
|
||||
// this.engine.sendAsync.apply(this.engine, arguments);
|
||||
let method = this.asyncMethods[payload.method];
|
||||
if (method) {
|
||||
return method.call(method, payload, (err, result) => {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue