mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-17 08:07:51 +00:00
fix webserver errors
This commit is contained in:
parent
817c4a6209
commit
415df3312f
@ -28,6 +28,7 @@ class Provider {
|
|||||||
|
|
||||||
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, self.logger);
|
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, self.logger);
|
||||||
self.addresses = [];
|
self.addresses = [];
|
||||||
|
|
||||||
if (!self.accounts.length) {
|
if (!self.accounts.length) {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
@ -35,32 +36,35 @@ class Provider {
|
|||||||
self.addresses.push(account.address);
|
self.addresses.push(account.address);
|
||||||
self.web3.eth.accounts.wallet.add(account);
|
self.web3.eth.accounts.wallet.add(account);
|
||||||
});
|
});
|
||||||
|
|
||||||
self.web3.eth.defaultAccount = self.addresses[0];
|
self.web3.eth.defaultAccount = self.addresses[0];
|
||||||
const realAccountFunction = self.web3.eth.getAccounts;
|
const realSend = self.provider.send.bind(self.provider);
|
||||||
self.web3.eth.getAccounts = function (cb) {
|
self.provider.send = function (payload, cb) {
|
||||||
cb = cb || function () {};
|
if (payload.method === 'eth_accounts') {
|
||||||
return new Promise((resolve, reject) => {
|
return realSend(payload, function (err, result) {
|
||||||
realAccountFunction((err, accounts) => {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
cb(err);
|
return cb(err);
|
||||||
return reject(err);
|
|
||||||
}
|
}
|
||||||
// console.log('ACOUNTS', accounts);
|
result.result = result.result.concat(self.addresses);
|
||||||
// console.log('My addresses', self.addresses);
|
cb(null, result);
|
||||||
// accounts = self.addresses;
|
|
||||||
accounts = [accounts[0]].concat(self.addresses);
|
|
||||||
// accounts = accounts.concat(self.addresses);
|
|
||||||
// accounts = self.addresses.concat(accounts);
|
|
||||||
cb(null, accounts);
|
|
||||||
resolve(accounts);
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
realSend(payload, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if (this.provider && this.provider.removeAllListeners) {
|
||||||
|
this.provider.removeAllListeners('connect');
|
||||||
|
this.provider.removeAllListeners('error');
|
||||||
|
this.provider.removeAllListeners('end');
|
||||||
|
this.provider.removeAllListeners('data');
|
||||||
|
this.provider.responseCallbacks = {};
|
||||||
|
this.provider = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fundAccounts(callback) {
|
fundAccounts(callback) {
|
||||||
const self = this;
|
const self = this;
|
||||||
if (!self.accounts.length) {
|
if (!self.accounts.length) {
|
||||||
|
@ -77,6 +77,9 @@ class Test {
|
|||||||
|
|
||||||
if (this.simOptions.accounts) {
|
if (this.simOptions.accounts) {
|
||||||
this.simOptions.accounts = this.simOptions.accounts.map((account) => {
|
this.simOptions.accounts = this.simOptions.accounts.map((account) => {
|
||||||
|
if (!account.hexBalance) {
|
||||||
|
account.hexBalance = '0x8AC7230489E80000'; // 10 ether
|
||||||
|
}
|
||||||
return {balance: account.hexBalance, secretKey: account.privateKey};
|
return {balance: account.hexBalance, secretKey: account.privateKey};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ module.exports = {
|
|||||||
default: {
|
default: {
|
||||||
deployment: {
|
deployment: {
|
||||||
host: "localhost",
|
host: "localhost",
|
||||||
port: 8545,
|
port: 8546,
|
||||||
type: "rpc"
|
type: "ws"
|
||||||
},
|
},
|
||||||
dappConnection: [
|
dappConnection: [
|
||||||
"$WEB3",
|
"$WEB3",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user