diff --git a/src/browser.js b/src/browser.js new file mode 100644 index 0000000..fb18030 --- /dev/null +++ b/src/browser.js @@ -0,0 +1,14 @@ +import _EmbarkJS from './embark'; + +var EmbarkJS = Object.assign({}, _EmbarkJS); + +EmbarkJS.checkWeb3 = function () { + _EmbarkJS.checkWeb3.call(this); + if (!this.web3 && typeof (web3) !== 'undefined') { + this.web3 = web3; + } else if (!this.web3) { + this.web3 = window.web3; + } +}; + +export default EmbarkJS; diff --git a/src/embark.js b/src/embark.js index 2db701e..53757ce 100644 --- a/src/embark.js +++ b/src/embark.js @@ -15,6 +15,8 @@ EmbarkJS.isNewWeb3 = function (web3Obj) { return parseInt(_web3.version.api.split('.')[0], 10) >= 1; }; +EmbarkJS.checkWeb3 = function () {}; + EmbarkJS.Contract = function (options) { var self = this; var i, abiElement; @@ -24,13 +26,16 @@ EmbarkJS.Contract = function (options) { this.address = options.address; this.gas = options.gas; this.code = '0x' + options.code; + //this.web3 = options.web3 || web3; this.web3 = options.web3; - if (!this.web3 && typeof (web3) !== 'undefined') { - this.web3 = web3; - } else if (!this.web3) { - this.web3 = window.web3; - } + + //if (!this.web3 && typeof (web3) !== 'undefined') { + // this.web3 = web3; + //} else if (!this.web3) { + // this.web3 = window.web3; + //} + EmbarkJS.checkWeb3.call(this); if (EmbarkJS.isNewWeb3(this.web3)) { ContractClass = new this.web3.eth.Contract(this.abi, this.address);