fix(blockchain): fix metamask using the old web3

This commit is contained in:
Jonathan Rainville 2019-01-07 12:10:22 -05:00
parent 919d271996
commit 749c32cf07

View File

@ -3,8 +3,14 @@
const __embarkWeb3 = {};
__embarkWeb3.init = function(_config) {
this.web3 = global.web3 || new Web3();
global.web3 = global.web3 || this.web3;
// Check if the global web3 object uses the old web3 (0.x)
if (global.web3 && typeof global.web3.version !== 'string') {
// If so, use a new instance using 1.0, but use its provider
this.web3 = new Web3(global.web3.currentProvider);
} else {
this.web3 = global.web3 || new Web3();
}
global.web3 = this.web3;
};
__embarkWeb3.getInstance = function () {