From 22021ccca93444bfb28438f99d7f88855c6b4fa2 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 9 Jun 2018 19:29:32 -0400 Subject: [PATCH 1/9] extend with current contract methods --- js/embark.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/embark.js b/js/embark.js index 755060fe8..534943ef6 100644 --- a/js/embark.js +++ b/js/embark.js @@ -30,6 +30,29 @@ EmbarkJS.Contract = function(options) { ContractClass.options.data = this.code; ContractClass.abi = ContractClass.options.abi; ContractClass.address = this.address; + + let originalMethods = Object.keys(ContractClass); + + ContractClass._jsonInterface.forEach((abi) => { + if (originalMethods.indexOf(abi.name) >= 0) { + console.log(abi.name + " is a reserved word and cannot be used as a contract method, property or event"); + return; + } + if (abi.constant) { + ContractClass[abi.name] = function() { + let ref = ContractClass.methods[abi.name]; + let send = ref.apply(ref, ..arguments).send; + return send.apply(call, []); + }; + } else { + ContractClass[abi.name] = function() { + let ref = ContractClass.methods[abi.name]; + let call = ref.apply(ref, ..arguments).call; + return call.apply(call, []); + }; + } + }); + return ContractClass; } else { ContractClass = this.web3.eth.contract(this.abi); From 3185a1374c4937129c295e3b9d14d38522dd193c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 10 Jun 2018 10:07:02 -0400 Subject: [PATCH 2/9] fix passing options; add events --- js/embark.js | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/js/embark.js b/js/embark.js index 534943ef6..7aa335596 100644 --- a/js/embark.js +++ b/js/embark.js @@ -32,24 +32,54 @@ EmbarkJS.Contract = function(options) { ContractClass.address = this.address; let originalMethods = Object.keys(ContractClass); + let methods = []; ContractClass._jsonInterface.forEach((abi) => { if (originalMethods.indexOf(abi.name) >= 0) { console.log(abi.name + " is a reserved word and cannot be used as a contract method, property or event"); return; } - if (abi.constant) { + methods.push(abi.name); + + if (!abi.inputs) { + return; + } + + let numExpectedInputs = abi.inputs.length; + + if (abi.type === 'function' && abi.constant) { ContractClass[abi.name] = function() { + let options = {}, cb = null, args = Array.from(arguments || []).slice(0, numExpectedInputs); + if (typeof (arguments[numExpectedInputs]) === 'function') { + cb = arguments[numExpectedInputs]; + } else if (typeof (arguments[numExpectedInputs]) === 'object') { + options = arguments[numExpectedInputs]; + cb = arguments[numExpectedInputs + 1]; + } + let ref = ContractClass.methods[abi.name]; - let send = ref.apply(ref, ..arguments).send; - return send.apply(call, []); - }; - } else { - ContractClass[abi.name] = function() { - let ref = ContractClass.methods[abi.name]; - let call = ref.apply(ref, ..arguments).call; + let call = ref.apply(ref, ...arguments).call; return call.apply(call, []); }; + } else if (abi.type === 'function') { + ContractClass[abi.name] = function() { + let options = {}, cb = null, args = Array.from(arguments || []).slice(0, numExpectedInputs); + if (typeof (arguments[numExpectedInputs]) === 'function') { + cb = arguments[numExpectedInputs]; + } else if (typeof (arguments[numExpectedInputs]) === 'object') { + options = arguments[numExpectedInputs]; + cb = arguments[numExpectedInputs + 1]; + } + + let ref = ContractClass.methods[abi.name]; + let send = ref.apply(ref, args).send; + return send.apply(send, [options, cb]); + }; + } else if (abi.type === 'event') { + ContractClass[abi.name] = function(options, cb) { + let ref = ContractClass.events[abi.name]; + return ref.apply(ref, [options, cb]); + } } }); From e119007f76bad756ee2e4a6da5f4e288ff04a7ac Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 10 Jun 2018 10:22:09 -0400 Subject: [PATCH 3/9] clean up, improve setting the web3 object --- js/embark.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/embark.js b/js/embark.js index 7aa335596..19fe6d88b 100644 --- a/js/embark.js +++ b/js/embark.js @@ -19,27 +19,28 @@ EmbarkJS.Contract = function(options) { this.address = options.address; this.code = '0x' + options.code; //this.web3 = options.web3 || web3; - this.web3 = options.web3 || window.web3; + this.web3 = options.web3; + if (!this.web3 && typeof ('web3') !== 'undefined') { + this.web3 = web3; + } else { + this.web3 = window.web3; + } if (EmbarkJS.isNewWeb3()) { - // TODO: - // add default **from** address - // add gasPrice ContractClass = new this.web3.eth.Contract(this.abi, this.address); ContractClass.setProvider(this.web3.currentProvider); ContractClass.options.data = this.code; + ContractClass.options.from = this.from; ContractClass.abi = ContractClass.options.abi; ContractClass.address = this.address; let originalMethods = Object.keys(ContractClass); - let methods = []; ContractClass._jsonInterface.forEach((abi) => { if (originalMethods.indexOf(abi.name) >= 0) { console.log(abi.name + " is a reserved word and cannot be used as a contract method, property or event"); return; } - methods.push(abi.name); if (!abi.inputs) { return; From c4ca4e52b88ce2ebec5c7ae20b47f5498635970c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 10 Jun 2018 12:11:34 -0400 Subject: [PATCH 4/9] support embarkjs in the tests --- js/embark.js | 20 +++++++++++++------ lib/tests/test.js | 13 ++++++++---- .../test_app/test/another_storage_spec.js | 5 +++++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/js/embark.js b/js/embark.js index 19fe6d88b..4412a5d5b 100644 --- a/js/embark.js +++ b/js/embark.js @@ -1,9 +1,14 @@ var EmbarkJS = { - onReady: __embarkContext.execWhenReady + onReady: function(cb) { + if (typeof (__embarkContext) === 'undefined') { + return cb(); + } + return __embarkContext.execWhenReady(cb); + } }; -EmbarkJS.isNewWeb3 = function() { - var _web3 = new Web3(); +EmbarkJS.isNewWeb3 = function(web3Obj) { + var _web3 = web3Obj || (new Web3()); if (typeof(_web3.version) === "string") { return true; } @@ -17,22 +22,24 @@ EmbarkJS.Contract = function(options) { this.abi = options.abi; 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 { + } else if (!this.web3) { this.web3 = window.web3; } - if (EmbarkJS.isNewWeb3()) { + if (EmbarkJS.isNewWeb3(this.web3)) { ContractClass = new this.web3.eth.Contract(this.abi, this.address); ContractClass.setProvider(this.web3.currentProvider); ContractClass.options.data = this.code; ContractClass.options.from = this.from; ContractClass.abi = ContractClass.options.abi; ContractClass.address = this.address; + ContractClass.gas = this.gas; let originalMethods = Object.keys(ContractClass); @@ -386,4 +393,5 @@ EmbarkJS.Utils = { } }; -export default EmbarkJS; +//export default EmbarkJS; +module.exports = EmbarkJS; diff --git a/lib/tests/test.js b/lib/tests/test.js index a6789da93..4ebcfddd0 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -8,6 +8,8 @@ const cloneDeep = require('clone-deep'); const AccountParser = require('../contracts/accountParser'); const Provider = require('../contracts/provider'); +const EmbarkJS = require('../../js/embark'); + function getSimulator() { try { return require('ganache-cli'); @@ -241,8 +243,10 @@ class Test { } else { data = self.contracts[contractName].options.data; } - Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.deployedAddress, - {from: self.web3.eth.defaultAccount, gas: 6000000})); + //Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.deployedAddress, + // {from: self.web3.eth.defaultAccount, gas: 6000000})); + Object.assign(self.contracts[contractName], new EmbarkJS.Contract({abi: contract.abiDefinition, address: contract.deployedAddress, from: self.web3.eth.defaultAccount, gas: 6000000, web3: self.web3})); + self.contracts[contractName].address = contract.deployedAddress; if (self.contracts[contractName].options) { self.contracts[contractName].options.from = self.contracts[contractName].options.from || self.web3.eth.defaultAccount; @@ -288,8 +292,9 @@ class Test { contract = this.engine.contractsManager.contracts[contractNames[0]]; } } - this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address, - {from: this.web3.eth.defaultAccount, gas: 6000000}); + //this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address, + // {from: this.web3.eth.defaultAccount, gas: 6000000}); + this.contracts[contractName] = new EmbarkJS.Contract({abi: contract.abiDefinition, address: contract.address, from: this.web3.eth.defaultAccount, gas: 6000000, web3: this.web3}); this.contracts[contractName].address = contract.address; this.contracts[contractName].options.data = contract.code; this.web3.eth.getAccounts().then((accounts) => { diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index 8ebc9e3f3..5bdc738cb 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -40,6 +40,11 @@ contract("AnotherStorage", function() { assert.equal(result.toString(), SimpleStorage.options.address); }); + it("set SimpleStorage address with alternative syntax", async function() { + let result = await AnotherStorage.simpleStorageAddress(); + assert.equal(result.toString(), SimpleStorage.options.address); + }); + it('should set the balance correctly', async function () { const balance = await web3.eth.getBalance(accounts[0]); assert.ok(balance < 5000000000000000000); From 8783f04a9cae540a72b281ea34ba28bd3bc733a9 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 10 Jun 2018 12:55:59 -0400 Subject: [PATCH 5/9] add node version of embarkjs to avoid export issues with webpack.. (for now...) --- js/embark.js | 3 +- js/embark_node.js | 396 ++++++++++++++++++++++++++++++++++++++++++++++ lib/tests/test.js | 2 +- 3 files changed, 398 insertions(+), 3 deletions(-) create mode 100644 js/embark_node.js diff --git a/js/embark.js b/js/embark.js index 4412a5d5b..b3e7114d4 100644 --- a/js/embark.js +++ b/js/embark.js @@ -393,5 +393,4 @@ EmbarkJS.Utils = { } }; -//export default EmbarkJS; -module.exports = EmbarkJS; +export default EmbarkJS; diff --git a/js/embark_node.js b/js/embark_node.js new file mode 100644 index 000000000..bfcda6da3 --- /dev/null +++ b/js/embark_node.js @@ -0,0 +1,396 @@ +var EmbarkJS = { + onReady: function(cb) { + if (typeof (__embarkContext) === 'undefined') { + return cb(); + } + return __embarkContext.execWhenReady(cb); + } +}; + +EmbarkJS.isNewWeb3 = function(web3Obj) { + var _web3 = web3Obj || (new Web3()); + if (typeof(_web3.version) === "string") { + return true; + } + return parseInt(_web3.version.api.split('.')[0], 10) >= 1; +}; + +EmbarkJS.Contract = function(options) { + var self = this; + var i, abiElement; + var ContractClass; + + this.abi = options.abi; + 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 (EmbarkJS.isNewWeb3(this.web3)) { + ContractClass = new this.web3.eth.Contract(this.abi, this.address); + ContractClass.setProvider(this.web3.currentProvider); + ContractClass.options.data = this.code; + ContractClass.options.from = this.from; + ContractClass.abi = ContractClass.options.abi; + ContractClass.address = this.address; + ContractClass.gas = this.gas; + + let originalMethods = Object.keys(ContractClass); + + ContractClass._jsonInterface.forEach((abi) => { + if (originalMethods.indexOf(abi.name) >= 0) { + console.log(abi.name + " is a reserved word and cannot be used as a contract method, property or event"); + return; + } + + if (!abi.inputs) { + return; + } + + let numExpectedInputs = abi.inputs.length; + + if (abi.type === 'function' && abi.constant) { + ContractClass[abi.name] = function() { + let options = {}, cb = null, args = Array.from(arguments || []).slice(0, numExpectedInputs); + if (typeof (arguments[numExpectedInputs]) === 'function') { + cb = arguments[numExpectedInputs]; + } else if (typeof (arguments[numExpectedInputs]) === 'object') { + options = arguments[numExpectedInputs]; + cb = arguments[numExpectedInputs + 1]; + } + + let ref = ContractClass.methods[abi.name]; + let call = ref.apply(ref, ...arguments).call; + return call.apply(call, []); + }; + } else if (abi.type === 'function') { + ContractClass[abi.name] = function() { + let options = {}, cb = null, args = Array.from(arguments || []).slice(0, numExpectedInputs); + if (typeof (arguments[numExpectedInputs]) === 'function') { + cb = arguments[numExpectedInputs]; + } else if (typeof (arguments[numExpectedInputs]) === 'object') { + options = arguments[numExpectedInputs]; + cb = arguments[numExpectedInputs + 1]; + } + + let ref = ContractClass.methods[abi.name]; + let send = ref.apply(ref, args).send; + return send.apply(send, [options, cb]); + }; + } else if (abi.type === 'event') { + ContractClass[abi.name] = function(options, cb) { + let ref = ContractClass.events[abi.name]; + return ref.apply(ref, [options, cb]); + } + } + }); + + return ContractClass; + } else { + ContractClass = this.web3.eth.contract(this.abi); + + this.eventList = []; + + if (this.abi) { + for (i = 0; i < this.abi.length; i++) { + abiElement = this.abi[i]; + if (abiElement.type === 'event') { + this.eventList.push(abiElement.name); + } + } + } + + var messageEvents = function() { + this.cb = function() {}; + }; + + messageEvents.prototype.then = function(cb) { + this.cb = cb; + }; + + messageEvents.prototype.error = function(err) { + return err; + }; + + this._originalContractObject = ContractClass.at(this.address); + this._methods = Object.getOwnPropertyNames(this._originalContractObject).filter(function(p) { + // TODO: check for forbidden properties + if (self.eventList.indexOf(p) >= 0) { + + self[p] = function() { + var promise = new messageEvents(); + var args = Array.prototype.slice.call(arguments); + args.push(function(err, result) { + if (err) { + promise.error(err); + } else { + promise.cb(result); + } + }); + + self._originalContractObject[p].apply(self._originalContractObject[p], args); + return promise; + }; + return true; + } else if (typeof self._originalContractObject[p] === 'function') { + self[p] = function(_args) { + var args = Array.prototype.slice.call(arguments); + var fn = self._originalContractObject[p]; + var props = self.abi.find((x) => x.name == p); + + var promise = new Promise(function(resolve, reject) { + args.push(function(err, transaction) { + promise.tx = transaction; + if (err) { + return reject(err); + } + + var getConfirmation = function() { + self.web3.eth.getTransactionReceipt(transaction, function(err, receipt) { + if (err) { + return reject(err); + } + + if (receipt !== null) { + return resolve(receipt); + } + + setTimeout(getConfirmation, 1000); + }); + }; + + if (typeof(transaction) !== "string" || props.constant) { + resolve(transaction); + } else { + getConfirmation(); + } + }); + + fn.apply(fn, args); + }); + + return promise; + }; + return true; + } + return false; + }); + } +}; + +EmbarkJS.Contract.prototype.deploy = function(args, _options) { + var self = this; + var contractParams; + var options = _options || {}; + + contractParams = args || []; + + contractParams.push({ + from: this.web3.eth.accounts[0], + data: this.code, + gas: options.gas || 800000 + }); + + var contractObject = this.web3.eth.contract(this.abi); + + var promise = new Promise(function(resolve, reject) { + contractParams.push(function(err, transaction) { + if (err) { + reject(err); + } else if (transaction.address !== undefined) { + resolve(new EmbarkJS.Contract({ + abi: self.abi, + code: self.code, + address: transaction.address + })); + } + }); + + // returns promise + // deploys contract + // wraps it around EmbarkJS.Contract + contractObject["new"].apply(contractObject, contractParams); + }); + + + return promise; +}; + +EmbarkJS.Contract.prototype.new = EmbarkJS.Contract.prototype.deploy; + +EmbarkJS.Contract.prototype.at = function(address) { + return new EmbarkJS.Contract({ abi: this.abi, code: this.code, address: address }); +}; + +EmbarkJS.Contract.prototype.send = function(value, unit, _options) { + var options, wei; + if (typeof unit === 'object') { + options = unit; + wei = value; + } else { + options = _options || {}; + wei = this.web3.toWei(value, unit); + } + + options.to = this.address; + options.value = wei; + + this.web3.eth.sendTransaction(options); +}; + +EmbarkJS.Storage = {}; + +EmbarkJS.Storage.Providers = {}; + +EmbarkJS.Storage.saveText = function(text) { + if (!this.currentStorage) { + throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + } + return this.currentStorage.saveText(text); +}; + +EmbarkJS.Storage.get = function(hash) { + if (!this.currentStorage) { + throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + } + return this.currentStorage.get(hash); +}; + +EmbarkJS.Storage.uploadFile = function(inputSelector) { + if (!this.currentStorage) { + throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + } + return this.currentStorage.uploadFile(inputSelector); +}; + +EmbarkJS.Storage.getUrl = function(hash) { + if (!this.currentStorage) { + throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + } + return this.currentStorage.getUrl(hash); +}; + +EmbarkJS.Storage.registerProvider = function(providerName, obj) { + EmbarkJS.Storage.Providers[providerName] = obj; +}; + +EmbarkJS.Storage.setProvider = function(provider, options) { + let providerObj = this.Providers[provider]; + + if (!providerObj) { + throw new Error('Unknown storage provider'); + } + + this.currentStorage = providerObj; + + return providerObj.setProvider(options); +}; + +EmbarkJS.Storage.isAvailable = function(){ + if (!this.currentStorage) { + throw new Error('Storage provider not set; e.g EmbarkJS.Storage.setProvider("ipfs")'); + } + return this.currentStorage.isAvailable(); +}; + +EmbarkJS.Messages = {}; + +EmbarkJS.Messages.Providers = {}; + +EmbarkJS.Messages.registerProvider = function(providerName, obj) { + EmbarkJS.Messages.Providers[providerName] = obj; +}; + +EmbarkJS.Messages.setProvider = function(provider, options) { + let providerObj = this.Providers[provider]; + + if (!providerObj) { + throw new Error('Unknown messages provider'); + } + + this.currentMessages = providerObj; + + return providerObj.setProvider(options); +}; + +EmbarkJS.Messages.isAvailable = function(){ + return this.currentMessages.isAvailable(); +}; + +EmbarkJS.Messages.sendMessage = function(options) { + if (!this.currentMessages) { + throw new Error('Messages provider not set; e.g EmbarkJS.Messages.setProvider("whisper")'); + } + return this.currentMessages.sendMessage(options); +}; + +EmbarkJS.Messages.listenTo = function(options, callback) { + if (!this.currentMessages) { + throw new Error('Messages provider not set; e.g EmbarkJS.Messages.setProvider("whisper")'); + } + return this.currentMessages.listenTo(options, callback); +}; + +EmbarkJS.Names = {}; + +EmbarkJS.Names.Providers = {}; + +EmbarkJS.Names.registerProvider = function(providerName, obj) { + EmbarkJS.Names.Providers[providerName] = obj; +} + +EmbarkJS.Names.setProvider = function(provider, options) { + let providerObj = this.Providers[provider]; + + if (!providerObj) { + throw new Error('Unknown name system provider'); + } + + this.currentNameSystems = providerObj; + + return providerObj.setProvider(options); +}; + +// resolve resolves a name into an identifier of some kind +EmbarkJS.Names.resolve = function(name) { + if (!this.currentNameSystems) { + throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")'); + } + return this.currentNameSystems.resolve(name); +} + +// the reverse of resolve, resolves using an identifier to get to a name +EmbarkJS.Names.lookup = function(identifier) { + if (!this.currentNameSystems) { + throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")'); + } + return this.currentNameSystems.lookup(identifier); +} + +// To Implement + +/* +// register a name +EmbarkJS.Names.register = function(name, options) { + +} +*/ + +EmbarkJS.Utils = { + fromAscii: function(str) { + var _web3 = new Web3(); + return _web3.utils ? _web3.utils.fromAscii(str) : _web3.fromAscii(str); + }, + toAscii: function(str) { + var _web3 = new Web3(); + return _web3.utils.toAscii(str); + } +}; + +module.exports = EmbarkJS; diff --git a/lib/tests/test.js b/lib/tests/test.js index 4ebcfddd0..ad91ae77b 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -8,7 +8,7 @@ const cloneDeep = require('clone-deep'); const AccountParser = require('../contracts/accountParser'); const Provider = require('../contracts/provider'); -const EmbarkJS = require('../../js/embark'); +const EmbarkJS = require('../../js/embark_node'); function getSimulator() { try { From 6b26f2a9d7ea924cc9c526fddab5f57321de46cb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 11 Jun 2018 13:37:06 -0400 Subject: [PATCH 6/9] set default gas --- lib/tests/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index ad91ae77b..a6c836575 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -243,14 +243,13 @@ class Test { } else { data = self.contracts[contractName].options.data; } - //Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.deployedAddress, - // {from: self.web3.eth.defaultAccount, gas: 6000000})); Object.assign(self.contracts[contractName], new EmbarkJS.Contract({abi: contract.abiDefinition, address: contract.deployedAddress, from: self.web3.eth.defaultAccount, gas: 6000000, web3: self.web3})); self.contracts[contractName].address = contract.deployedAddress; if (self.contracts[contractName].options) { self.contracts[contractName].options.from = self.contracts[contractName].options.from || self.web3.eth.defaultAccount; self.contracts[contractName].options.data = data; + self.contracts[contractName].options.gas = 6000000; } eachCb(); }, (err) => { @@ -297,6 +296,7 @@ class Test { this.contracts[contractName] = new EmbarkJS.Contract({abi: contract.abiDefinition, address: contract.address, from: this.web3.eth.defaultAccount, gas: 6000000, web3: this.web3}); this.contracts[contractName].address = contract.address; this.contracts[contractName].options.data = contract.code; + this.contracts[contractName].options.gas = 6000000; this.web3.eth.getAccounts().then((accounts) => { this.contracts[contractName].options.from = contract.from || accounts[0]; }); From 57ef5731426f16966563ba06833df2eb4ecfdf0e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 11 Jun 2018 13:41:26 -0400 Subject: [PATCH 7/9] remove trailing whitespace --- js/embark.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/embark.js b/js/embark.js index b3e7114d4..06817208f 100644 --- a/js/embark.js +++ b/js/embark.js @@ -376,9 +376,9 @@ EmbarkJS.Names.lookup = function(identifier) { // To Implement /* -// register a name +// register a name EmbarkJS.Names.register = function(name, options) { - + } */ From 5f8f7f35acc3d82f71a101914ddbc3fce263cae4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 11 Jun 2018 16:27:39 -0400 Subject: [PATCH 8/9] fix checking web3 --- js/embark.js | 2 +- js/embark_node.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/embark.js b/js/embark.js index 06817208f..86d31a041 100644 --- a/js/embark.js +++ b/js/embark.js @@ -26,7 +26,7 @@ EmbarkJS.Contract = function(options) { this.code = '0x' + options.code; //this.web3 = options.web3 || web3; this.web3 = options.web3; - if (!this.web3 && typeof ('web3') !== 'undefined') { + if (!this.web3 && typeof (web3) !== 'undefined') { this.web3 = web3; } else if (!this.web3) { this.web3 = window.web3; diff --git a/js/embark_node.js b/js/embark_node.js index bfcda6da3..9e9ea8b70 100644 --- a/js/embark_node.js +++ b/js/embark_node.js @@ -26,7 +26,7 @@ EmbarkJS.Contract = function(options) { this.code = '0x' + options.code; //this.web3 = options.web3 || web3; this.web3 = options.web3; - if (!this.web3 && typeof ('web3') !== 'undefined') { + if (!this.web3 && typeof (web3) !== 'undefined') { this.web3 = web3; } else if (!this.web3) { this.web3 = window.web3; From 20acb5425f3ffb9391a34df3c7c9081dcfeff118 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 11 Jun 2018 16:34:41 -0400 Subject: [PATCH 9/9] remove comment --- lib/tests/test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index a6c836575..d594ab3e9 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -291,8 +291,6 @@ class Test { contract = this.engine.contractsManager.contracts[contractNames[0]]; } } - //this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address, - // {from: this.web3.eth.defaultAccount, gas: 6000000}); this.contracts[contractName] = new EmbarkJS.Contract({abi: contract.abiDefinition, address: contract.address, from: this.web3.eth.defaultAccount, gas: 6000000, web3: this.web3}); this.contracts[contractName].address = contract.address; this.contracts[contractName].options.data = contract.code;