From 9ace0f7354a176482aa6da980589309504b555a2 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:25:04 -0500 Subject: [PATCH 01/23] LICENSE --- LICENSE | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3fc192b --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 iuri matias + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + From b6a4fc4191d49453230ac9fc34e882b265b2c7d1 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:23:34 -0500 Subject: [PATCH 02/23] .gitignore --- .gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..306f5c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +dist +node_modules + +.idea +.vscode +.eslintrc.json + +embark.min.js +TODO +NOTES +npm-debug.log From 4036ce49bcdf01e64f8d7e4ec0ee1d87ddbac4ca Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:24:56 -0500 Subject: [PATCH 03/23] .npmrc --- .npmrc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..3dbb5b9 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +package-lock = false +save-exact = true From 9fa3c5df4777567f1a76f6eefeeb20e26956d48a Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 10:11:06 -0500 Subject: [PATCH 04/23] .babelrc --- .babelrc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..649b91a --- /dev/null +++ b/.babelrc @@ -0,0 +1,9 @@ +{ + "compact": false, + "presets": [ + ["@babel/preset-env", {"targets": {"node": "8.11.3"}}] + ], + "plugins": [ + "@babel/plugin-transform-runtime" + ] +} From c81ddd9ddd3988e48de215bcb507698c62605194 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:26:53 -0500 Subject: [PATCH 05/23] package.json --- package.json | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..2b678bb --- /dev/null +++ b/package.json @@ -0,0 +1,46 @@ +{ + "name": "embarkjs", + "version": "0.1.0", + "description": "", + "main": "./dist/index.js", + "browser": "./dist/browser.js", + "files": [ + "dist", + "embark.min.js" + ], + "scripts": { + "build": "npm run clean && npm run build-babel && npm run build-webpack", + "build-babel": "babel --out-dir dist src", + "build-webpack": "npm run webpack", + "clean": "rimraf dist embark.min.js", + "server": "http-server", + "test": "echo \"Error: no test specified\" && exit 1", + "webpack": "webpack" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/embark-framework/EmbarkJS.git" + }, + "author": "Iuri Matias ", + "license": "MIT", + "bugs": { + "url": "https://github.com/embark-framework/EmbarkJS/issues" + }, + "homepage": "https://github.com/embark-framework/EmbarkJS#readme", + "dependencies": { + "@babel/runtime": "7.0.0-beta.52" + }, + "devDependencies": { + "@babel/cli": "7.0.0-beta.52", + "@babel/core": "7.0.0-beta.52", + "@babel/plugin-transform-modules-commonjs": "7.0.0-beta.52", + "@babel/plugin-transform-runtime": "7.0.0-beta.52", + "@babel/preset-env": "7.0.0-beta.52", + "ajv": "6.5.2", + "babel-loader": "8.0.0-beta.4", + "http-server": "0.11.1", + "rimraf": "2.6.2", + "webpack": "4.15.1", + "webpack-cli": "3.0.8" + } +} From 333d8c06dd5efaa53ac048be95b3e37d67a5b5de Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:25:25 -0500 Subject: [PATCH 06/23] helper web page for testing standalone embark.min.js --- index.html | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..e4ad317 --- /dev/null +++ b/index.html @@ -0,0 +1,9 @@ + + + + + EmbarkJS — standalone + + + + From 80a7f6019fe04fd12d1581b9ed592796ae9c89bc Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:26:14 -0500 Subject: [PATCH 07/23] webpack.config.js --- webpack.config.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 webpack.config.js diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..6f46d69 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,38 @@ +const path = require('path'); + +const browser = { + entry: path.resolve(__dirname, 'dist') + '/browser.js', + mode: 'production', + module: { + rules: [ + { + test: /\.js$/, + exclude: /(node_modules|bower_components)/, + use: { + loader: 'babel-loader', + options: { + presets: [ + ['@babel/env'] + ] + } + } + } + ] + }, + // optimization: { + // minimize: false + // }, + output: { + filename: 'embark.min.js', + library: 'EmbarkJS', + libraryTarget: 'umd', + libraryExport: 'default', + path: __dirname, + umdNamedDefine: true, + }, + target: 'web' +}; + +module.exports = [ + browser +]; From ccc043f359c97f44070edafd3f116410007dc442 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 5 Jul 2018 19:26:27 -0500 Subject: [PATCH 08/23] EmbarkJS source code --- src/embark.js | 399 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 399 insertions(+) create mode 100644 src/embark.js diff --git a/src/embark.js b/src/embark.js new file mode 100644 index 0000000..2db701e --- /dev/null +++ b/src/embark.js @@ -0,0 +1,399 @@ +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 || this.web3.eth.defaultAccount; + 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) { + if (!this.currentNameSystems) { + throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")'); + } + return this.currentNameSystems.register(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); + } +}; + +export default EmbarkJS; From 2d41668f2f346a72c66927b58e40154b7a70b58b Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 10:10:12 -0500 Subject: [PATCH 09/23] split out logic to check for web3 into browser entrypoint --- src/browser.js | 14 ++++++++++++++ src/embark.js | 15 ++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/browser.js 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); From 31fb2e30fcc3486d778356c8d8f97a9842dfe9f6 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 10:10:28 -0500 Subject: [PATCH 10/23] node.js entrypoint --- src/index.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/index.js diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..c96c61c --- /dev/null +++ b/src/index.js @@ -0,0 +1 @@ +module.exports = require('./embark').default; From aa575cc39f6a131dd969de20bd38d32891a2a4e9 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:00:32 -0500 Subject: [PATCH 11/23] rm unused devDep --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2b678bb..1c866c7 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "devDependencies": { "@babel/cli": "7.0.0-beta.52", "@babel/core": "7.0.0-beta.52", - "@babel/plugin-transform-modules-commonjs": "7.0.0-beta.52", "@babel/plugin-transform-runtime": "7.0.0-beta.52", "@babel/preset-env": "7.0.0-beta.52", "ajv": "6.5.2", From 66a27d4b30541b37c211a42d38929f2ee0a41193 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:11:36 -0500 Subject: [PATCH 12/23] spec "prepack" script in package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 1c866c7..7d8cbf6 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "build-babel": "babel --out-dir dist src", "build-webpack": "npm run webpack", "clean": "rimraf dist embark.min.js", + "prepack": "npm run build", "server": "http-server", "test": "echo \"Error: no test specified\" && exit 1", "webpack": "webpack" From 1b58efa5c9f3d6ef10b2df31d72b1c3f3c40e5cd Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:53:18 -0500 Subject: [PATCH 13/23] consistent use of "@babel/env" vs. "@babel/preset-env" --- .babelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index 649b91a..034c316 100644 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,7 @@ { "compact": false, "presets": [ - ["@babel/preset-env", {"targets": {"node": "8.11.3"}}] + ["@babel/env", {"targets": {"node": "8.11.3"}}] ], "plugins": [ "@babel/plugin-transform-runtime" From fecb79d2918b110947c7cc1f61737f82c4249f1b Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:53:44 -0500 Subject: [PATCH 14/23] webpack should ignore .babelrc --- webpack.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webpack.config.js b/webpack.config.js index 6f46d69..ea1c1a6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,6 +11,7 @@ const browser = { use: { loader: 'babel-loader', options: { + babelrc: false, presets: [ ['@babel/env'] ] From 9a424d559a50672cb851917e6a3eaecaa2cedc76 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:53:58 -0500 Subject: [PATCH 15/23] webpack should build against src/browser.js vs. dist/browser.js --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index ea1c1a6..a8c7fbc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,7 @@ const path = require('path'); const browser = { - entry: path.resolve(__dirname, 'dist') + '/browser.js', + entry: path.resolve(__dirname, 'src') + '/browser.js', mode: 'production', module: { rules: [ From fe8e44385e869179737edb435a6c0b3c52f6db11 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:54:29 -0500 Subject: [PATCH 16/23] babel should ignore src/browser.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d8cbf6..f512180 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ ], "scripts": { "build": "npm run clean && npm run build-babel && npm run build-webpack", - "build-babel": "babel --out-dir dist src", + "build-babel": "babel --ignore 'src/browser.js' --out-dir dist src", "build-webpack": "npm run webpack", "clean": "rimraf dist embark.min.js", "prepack": "npm run build", From 1240e2faec79c8ab1498cc5ea821526e83cc3f09 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 12:54:40 -0500 Subject: [PATCH 17/23] change browser entrypoint to src/browser.js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f512180..55bd550 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "", "main": "./dist/index.js", - "browser": "./dist/browser.js", + "browser": "./src/browser.js", "files": [ "dist", "embark.min.js" From 4ae3f917ed8bc8428ed43e2f877e2d81a23d3d83 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 13:54:38 -0500 Subject: [PATCH 18/23] keywords in package.json --- package.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package.json b/package.json index 55bd550..9946208 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,15 @@ }, "author": "Iuri Matias ", "license": "MIT", + "keywords": [ + "ethereum", + "dapps", + "ipfs", + "solidity", + "solc", + "blockchain", + "serverless" + ], "bugs": { "url": "https://github.com/embark-framework/EmbarkJS/issues" }, From 1756661ae466acdaf4bb1e3cb2fc8b18b7186c17 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 13:56:16 -0500 Subject: [PATCH 19/23] ignore output of `npm pack` --- .gitignore | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 306f5c4..aabc2ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,13 @@ dist node_modules +package .idea .vscode .eslintrc.json embark.min.js +embarkjs-*.tgz TODO NOTES npm-debug.log diff --git a/package.json b/package.json index 9946208..11f357f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "npm run clean && npm run build-babel && npm run build-webpack", "build-babel": "babel --ignore 'src/browser.js' --out-dir dist src", "build-webpack": "npm run webpack", - "clean": "rimraf dist embark.min.js", + "clean": "rimraf dist embark.min.js embarkjs-*.tgz", "prepack": "npm run build", "server": "http-server", "test": "echo \"Error: no test specified\" && exit 1", From ea0524aefc52fd8ace28279312ccae08e6ffd527 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 14:08:53 -0500 Subject: [PATCH 20/23] rimraf (`npm run clean`) should clean up the output of `npm pack` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 11f357f..7526ec7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "npm run clean && npm run build-babel && npm run build-webpack", "build-babel": "babel --ignore 'src/browser.js' --out-dir dist src", "build-webpack": "npm run webpack", - "clean": "rimraf dist embark.min.js embarkjs-*.tgz", + "clean": "rimraf dist embark.min.js embarkjs-*.tgz package", "prepack": "npm run build", "server": "http-server", "test": "echo \"Error: no test specified\" && exit 1", From d3e1a7626ed84b2e1297c07883cba246d5073ffb Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 14:26:49 -0500 Subject: [PATCH 21/23] must pack src/ since "browser" field points to src/browser.js --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7526ec7..31b7ec2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "browser": "./src/browser.js", "files": [ "dist", - "embark.min.js" + "embark.min.js", + "src" ], "scripts": { "build": "npm run clean && npm run build-babel && npm run build-webpack", From cccfa3e40cf43cc44932e4dfb124de3ede10a6f3 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 16:11:04 -0500 Subject: [PATCH 22/23] add description to package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31b7ec2..66987a5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "embarkjs", "version": "0.1.0", - "description": "", + "description": "JavaScript library for easily interacting with web3 technologies", "main": "./dist/index.js", "browser": "./src/browser.js", "files": [ From be2414da2997355b36903e89b51ad6d1234451d6 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 6 Jul 2018 16:11:17 -0500 Subject: [PATCH 23/23] add description to README, provide link to Embark --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47f071b..e87e39d 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# EmbarkJS \ No newline at end of file +# EmbarkJS + +A JavaScript library for easily interacting with web3 technologies. + +This library is part of the [Embark](https://github.com/embark-framework/embark) framework.