From 93ba02aa255b81a808812ac9e64dc3aa57c75bec Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 9 Jul 2015 22:51:51 -0400 Subject: [PATCH 01/15] update meteor demo --- boilerplate/embark.yml | 4 +- demo_meteor/.meteor/.finished-upgraders | 8 ++++ demo_meteor/.meteor/.gitignore | 1 + demo_meteor/.meteor/.id | 7 ++++ demo_meteor/.meteor/packages | 10 +++++ demo_meteor/.meteor/platforms | 2 + demo_meteor/.meteor/release | 1 + demo_meteor/.meteor/versions | 49 ++++++++++++++++++++++++ demo_meteor/client/embark.js | 1 + demo_meteor/client/myapp.css | 1 + demo_meteor/client/myapp.html | 29 ++++++++++++++ demo_meteor/client/myapp.js | 35 +++++++++++++++++ demo_meteor/config/blockchain.yml | 23 +++++++++++ demo_meteor/config/contracts.yml | 8 ++++ demo_meteor/config/password | 1 + demo_meteor/contracts/simple_storage.sol | 14 +++++++ demo_meteor/embark.yml | 5 +++ 17 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 demo_meteor/.meteor/.finished-upgraders create mode 100644 demo_meteor/.meteor/.gitignore create mode 100644 demo_meteor/.meteor/.id create mode 100644 demo_meteor/.meteor/packages create mode 100644 demo_meteor/.meteor/platforms create mode 100644 demo_meteor/.meteor/release create mode 100644 demo_meteor/.meteor/versions create mode 100644 demo_meteor/client/embark.js create mode 100644 demo_meteor/client/myapp.css create mode 100644 demo_meteor/client/myapp.html create mode 100644 demo_meteor/client/myapp.js create mode 100644 demo_meteor/config/blockchain.yml create mode 100644 demo_meteor/config/contracts.yml create mode 100644 demo_meteor/config/password create mode 100644 demo_meteor/contracts/simple_storage.sol create mode 100644 demo_meteor/embark.yml diff --git a/boilerplate/embark.yml b/boilerplate/embark.yml index 603021324..5d19d9174 100644 --- a/boilerplate/embark.yml +++ b/boilerplate/embark.yml @@ -1,5 +1,5 @@ type: "grunt" #other options: meteor, manual -#contracts: ["app/contracts/**"] -#output: "generated/tmp/abi.js" +#contracts: ["app/contracts/**/*.sol"] +#output: "src/embark.js" #blockchainConfig: "config/blockchain.yml" #contractsConfig: "config/contracts.yml" diff --git a/demo_meteor/.meteor/.finished-upgraders b/demo_meteor/.meteor/.finished-upgraders new file mode 100644 index 000000000..8a761038c --- /dev/null +++ b/demo_meteor/.meteor/.finished-upgraders @@ -0,0 +1,8 @@ +# This file contains information which helps Meteor properly upgrade your +# app when you run 'meteor update'. You should check it into version control +# with your project. + +notices-for-0.9.0 +notices-for-0.9.1 +0.9.4-platform-file +notices-for-facebook-graph-api-2 diff --git a/demo_meteor/.meteor/.gitignore b/demo_meteor/.meteor/.gitignore new file mode 100644 index 000000000..408303742 --- /dev/null +++ b/demo_meteor/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/demo_meteor/.meteor/.id b/demo_meteor/.meteor/.id new file mode 100644 index 000000000..bc5e1676f --- /dev/null +++ b/demo_meteor/.meteor/.id @@ -0,0 +1,7 @@ +# This file contains a token that is unique to your project. +# Check it into your repository along with the rest of this directory. +# It can be used for purposes such as: +# - ensuring you don't accidentally deploy one app on top of another +# - providing package authors with aggregated statistics + +v2fbp61wvu7nd11xgkdz diff --git a/demo_meteor/.meteor/packages b/demo_meteor/.meteor/packages new file mode 100644 index 000000000..1e64d2fa3 --- /dev/null +++ b/demo_meteor/.meteor/packages @@ -0,0 +1,10 @@ +# Meteor packages used by this project, one per line. +# Check this file (and the other files in this directory) into your repository. +# +# 'meteor add' and 'meteor remove' will edit this file for you, +# but you can also edit it by hand. + +meteor-platform +autopublish +insecure +ethereum:web3 diff --git a/demo_meteor/.meteor/platforms b/demo_meteor/.meteor/platforms new file mode 100644 index 000000000..efeba1b50 --- /dev/null +++ b/demo_meteor/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/demo_meteor/.meteor/release b/demo_meteor/.meteor/release new file mode 100644 index 000000000..dab6b552c --- /dev/null +++ b/demo_meteor/.meteor/release @@ -0,0 +1 @@ +METEOR@1.1.0.2 diff --git a/demo_meteor/.meteor/versions b/demo_meteor/.meteor/versions new file mode 100644 index 000000000..fbae83436 --- /dev/null +++ b/demo_meteor/.meteor/versions @@ -0,0 +1,49 @@ +autopublish@1.0.3 +autoupdate@1.2.1 +base64@1.0.3 +binary-heap@1.0.3 +blaze@2.1.2 +blaze-tools@1.0.3 +boilerplate-generator@1.0.3 +callback-hook@1.0.3 +check@1.0.5 +ddp@1.1.0 +deps@1.0.7 +ejson@1.0.6 +ethereum:web3@0.8.1 +fastclick@1.0.3 +geojson-utils@1.0.3 +html-tools@1.0.4 +htmljs@1.0.4 +http@1.1.0 +id-map@1.0.3 +insecure@1.0.3 +jquery@1.11.3_2 +json@1.0.3 +launch-screen@1.0.2 +livedata@1.0.13 +logging@1.0.7 +meteor@1.1.6 +meteor-platform@1.2.2 +minifiers@1.1.5 +minimongo@1.0.8 +mobile-status-bar@1.0.3 +mongo@1.1.0 +observe-sequence@1.0.6 +ordered-dict@1.0.3 +random@1.0.3 +reactive-dict@1.1.0 +reactive-var@1.0.5 +reload@1.1.3 +retry@1.0.3 +routepolicy@1.0.5 +session@1.1.0 +spacebars@1.0.6 +spacebars-compiler@1.0.6 +templating@1.1.1 +tracker@1.0.7 +ui@1.0.6 +underscore@1.0.3 +url@1.0.4 +webapp@1.2.0 +webapp-hashing@1.0.3 diff --git a/demo_meteor/client/embark.js b/demo_meteor/client/embark.js new file mode 100644 index 000000000..7de3dbf66 --- /dev/null +++ b/demo_meteor/client/embark.js @@ -0,0 +1 @@ +web3.setProvider(new web3.providers.HttpProvider('http://localhost:8101'));web3.eth.defaultAccount = web3.eth.accounts[0];SimpleStorageAbi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"type":"constructor"}];SimpleStorageContract = web3.eth.contract(SimpleStorageAbi);SimpleStorage = SimpleStorageContract.at('0x823802b31f5856bcf5a8a99f791934f9593afbf8'); \ No newline at end of file diff --git a/demo_meteor/client/myapp.css b/demo_meteor/client/myapp.css new file mode 100644 index 000000000..b6b4052b4 --- /dev/null +++ b/demo_meteor/client/myapp.css @@ -0,0 +1 @@ +/* CSS declarations go here */ diff --git a/demo_meteor/client/myapp.html b/demo_meteor/client/myapp.html new file mode 100644 index 000000000..8dc9b050c --- /dev/null +++ b/demo_meteor/client/myapp.html @@ -0,0 +1,29 @@ + + Embark - SimpleStorage Demo + + +

Embark - SimpleStorage Demo

+ + {{> set_value}} + + {{> current_value}} + +
+
+ + + + + + + diff --git a/demo_meteor/client/myapp.js b/demo_meteor/client/myapp.js new file mode 100644 index 000000000..ee408d8a0 --- /dev/null +++ b/demo_meteor/client/myapp.js @@ -0,0 +1,35 @@ +if (Meteor.isClient) { + Session.setDefault('value', 0); + + var addToLog = function(txt) { + $(".logs").append("
" + txt); + } + + Template.current_value.helpers({ + value: function () { + return Session.get('value'); + } + }); + + Template.current_value.events({ + 'click button': function () { + var value = SimpleStorage.get().toNumber(); + Session.set('value', value); + addToLog("SimpleStorage.get()"); + } + }); + + Template.set_value.events({ + 'click button': function () { + var value = parseInt($("input.text").val(), 10); + SimpleStorage.set(value); + addToLog("SimpleStorage.set("+value+")"); + } + }); +} + +if (Meteor.isServer) { + Meteor.startup(function () { + // code to run on server at startup + }); +} diff --git a/demo_meteor/config/blockchain.yml b/demo_meteor/config/blockchain.yml new file mode 100644 index 000000000..e1a4936be --- /dev/null +++ b/demo_meteor/config/blockchain.yml @@ -0,0 +1,23 @@ +development: + rpc_host: localhost + rpc_port: 8101 + rpc_whitelist: "*" + minerthreads: 1 + datadir: /tmp/embark + mine_when_needed: true + gas_limit: 500000 + gas_price: 10000000000000 + console: false + account: + init: true + password: config/password +staging: + rpc_host: localhost + rpc_port: 8101 + rpc_whitelist: "*" + datadir: default + network_id: 0 + console: true + account: + init: false + address: diff --git a/demo_meteor/config/contracts.yml b/demo_meteor/config/contracts.yml new file mode 100644 index 000000000..2b6d25d66 --- /dev/null +++ b/demo_meteor/config/contracts.yml @@ -0,0 +1,8 @@ +development: + SimpleStorage: + args: + - 100 +staging: + SimpleStorage: + args: + - 100 diff --git a/demo_meteor/config/password b/demo_meteor/config/password new file mode 100644 index 000000000..c747d679e --- /dev/null +++ b/demo_meteor/config/password @@ -0,0 +1 @@ +dev_password diff --git a/demo_meteor/contracts/simple_storage.sol b/demo_meteor/contracts/simple_storage.sol new file mode 100644 index 000000000..0b12e43db --- /dev/null +++ b/demo_meteor/contracts/simple_storage.sol @@ -0,0 +1,14 @@ +contract SimpleStorage { + uint public storedData; + + function SimpleStorage(uint initialValue) { + storedData = initialValue; + } + + function set(uint x) { + storedData = x; + } + function get() constant returns (uint retVal) { + return storedData; + } +} diff --git a/demo_meteor/embark.yml b/demo_meteor/embark.yml new file mode 100644 index 000000000..d39816df3 --- /dev/null +++ b/demo_meteor/embark.yml @@ -0,0 +1,5 @@ +type: "meteor" +contracts: ["contracts/**/*.sol"] +output: "client/embark.js" +blockchainConfig: "config/blockchain.yml" +contractsConfig: "config/contracts.yml" From d55f31f64b8ee6169aedbecfb163ea442d6b1c09 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 9 Jul 2015 22:54:04 -0400 Subject: [PATCH 02/15] add meteor-build-client --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index fdca391d1..f5343263d 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "hashmerge": "^1.0.2", "jasmine": "^2.3.1", "matchdep": "^0.3.0", + "meteor-build-client": "^0.1.6", "methodmissing": "^0.0.3", "python": "^0.0.4", "read-yaml": "^1.0.0", From 1fef23a14ce5c71a1cc55d3c3dac2776db3db0f4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 9 Jul 2015 23:05:34 -0400 Subject: [PATCH 03/15] take into account other type of cmds --- bin/embark | 55 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/bin/embark b/bin/embark index 38a0e6db3..f6da6e18e 100644 --- a/bin/embark +++ b/bin/embark @@ -51,31 +51,66 @@ program.command('deploy [env]').description('deploy contracts').action(function( program.command('build [env]').description('build dapp').action(function(env_) { var env = env_ || 'development'; - run("grunt clean"); - run("grunt deploy_contracts:" + env); - run('grunt build:' + env); + var embarkConfig = readYaml.sync("./embark.yml"); + + if (embarkConfig.type === "grunt") { + run("grunt clean"); + run("grunt deploy_contracts:" + env); + run('grunt build:' + env); + } }); program.command('ipfs [env]').description('build dapp and make it available in ipfs').action(function(env_) { var env = env_ || 'development'; - run("grunt clean") - run("grunt deploy_contracts:" + env) - run('grunt build:' + env) - run('grunt ipfs:' + env) + var embarkConfig = readYaml.sync("./embark.yml"); + + if (embarkConfig.type === "grunt") { + run("grunt clean") + run("grunt deploy_contracts:" + env) + run('grunt build:' + env) + run('grunt ipfs:' + env) + } + else { + console.log("command not available in meteor or manual mode yet"); + } }); program.command('run [env]').description('run dapp').action(function(env_) { var env = env_ || 'development'; - run('grunt deploy:' + env); + var embarkConfig = readYaml.sync("./embark.yml"); + + if (embarkConfig.type === "grunt") { + run('grunt deploy:' + env); + } + else { + console.log("command not available in meteor or manual mode yet"); + } }); program.command('spec').description('run specs').action(function() { - run('jasmine'); + var embarkConfig = readYaml.sync("./embark.yml"); + + if (embarkConfig.type === "grunt") { + run('jasmine'); + } + else { + console.log("command not available in meteor or manual mode yet"); + } }); program.command('blockchain [env]').description('run blockchain').action(function(env_) { var env = env_ || 'development'; - run('grunt blockchain:' + env); + var embarkConfig = readYaml.sync("./embark.yml"); + + if (embarkConfig.type === "grunt") { + run('grunt blockchain:' + env); + } + else { + Embark.init() + Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) + Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) + Embark.startBlockchain(env); + } }); program.command('demo').description('create a working dapp with a SimpleStorage contract').action(function() { From 85f3a7ae1598800b84a3c265ce964acfcf3d3a12 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 10 Jul 2015 07:30:26 -0400 Subject: [PATCH 04/15] updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b94cb7802..8cfec56e5 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ See the [Wiki](https://github.com/iurimatias/embark-framework/wiki) for more det Installation ====== -Requirements: geth (0.9.32, warning: 0.9.34 not supported at the moment), solc (0.9.23), node (0.12.2) and npm +Requirements: geth (0.9.38), solc (0.9.23), node (0.12.2) and npm For specs: pyethereum, ethertdd.py From f070b6b56112d6b27cf35f9e527a0a9d3474e15e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 10 Jul 2015 20:40:38 -0400 Subject: [PATCH 05/15] add license --- LICENSE | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..85a8a8a3f --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) [year] [fullname] + +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 d45ca38d2b983fa6460bde12d64d72d4b27407f4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 10 Jul 2015 20:41:45 -0400 Subject: [PATCH 06/15] add license --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 85a8a8a3f..3fc192b80 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) [year] [fullname] +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 From ea16259f342554c1038ef2b5c95bea5c00529c38 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 12 Jul 2015 21:33:36 -0400 Subject: [PATCH 07/15] support embark blockchain without node modules --- bin/embark | 6 +++++- lib/blockchain.js | 15 ++++++++++----- lib/index.js | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bin/embark b/bin/embark index f6da6e18e..f8737d163 100644 --- a/bin/embark +++ b/bin/embark @@ -109,7 +109,11 @@ program.command('blockchain [env]').description('run blockchain').action(functio Embark.init() Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) - Embark.startBlockchain(env); + + //TODO: better with --exec, but need to fix console bug first + wrench.copyDirSyncRecursive(__dirname + "/../js", "/tmp", {forceDelete: true}); + + Embark.startBlockchain(env, true); } }); diff --git a/lib/blockchain.js b/lib/blockchain.js index d10805f7e..fc7cc9ceb 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -44,7 +44,7 @@ Blockchain.prototype.init_command = function() { return this.generate_basic_command() + "account new "; } -Blockchain.prototype.run_command = function(address) { +Blockchain.prototype.run_command = function(address, use_tmp) { var cmd = this.generate_basic_command(); var config = this.config; @@ -57,7 +57,12 @@ Blockchain.prototype.run_command = function(address) { } if (config.mine_when_needed) { - cmd += "js node_modules/embark-framework/js/mine.js"; + if (use_tmp) { + cmd += "js /tmp/mine.js"; + } + else { + cmd += "js node_modules/embark-framework/js/mine.js"; + } } return cmd; @@ -84,10 +89,10 @@ Blockchain.prototype.get_address = function() { return address; } -Blockchain.prototype.startChain = function() { +Blockchain.prototype.startChain = function(use_tmp) { var address = this.get_address(); - console.log("running: " + this.run_command(address)); - exec(this.run_command(address)); + console.log("running: " + this.run_command(address, use_tmp)); + exec(this.run_command(address, use_tmp)); } module.exports = Blockchain diff --git a/lib/index.js b/lib/index.js index b168f00d0..8281b4ef6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -30,9 +30,9 @@ Embark = { return new Tests(this.contractsConfig, contractFiles); }, - startBlockchain: function(env) { + startBlockchain: function(env, use_tmp) { var chain = new Blockchain(this.blockchainConfig.config(env)); - chain.startChain(); + chain.startChain(use_tmp); }, deployContracts: function(env, contractFiles, destFile) { From 88866f135742173013e8ecf8a02841b155667480 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 12 Jul 2015 22:11:59 -0400 Subject: [PATCH 08/15] add meteor build and ipfs support --- bin/embark | 12 +++++++++++- lib/ipfs.js | 4 +--- tasks/ipfs.coffee | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/embark b/bin/embark index f8737d163..35ffc2d88 100644 --- a/bin/embark +++ b/bin/embark @@ -58,6 +58,10 @@ program.command('build [env]').description('build dapp').action(function(env_) { run("grunt deploy_contracts:" + env); run('grunt build:' + env); } + else if (embarkConfig.type === "meteor") { + //deploy + run("meteor-build-client ./build -p ''"); + } }); program.command('ipfs [env]').description('build dapp and make it available in ipfs').action(function(env_) { @@ -70,8 +74,14 @@ program.command('ipfs [env]').description('build dapp and make it available in i run('grunt build:' + env) run('grunt ipfs:' + env) } + else if (embarkConfig.type === "meteor") { + //deploy + //build + Embark = require('embark-framework') + Embark.release.ipfs("build/") + } else { - console.log("command not available in meteor or manual mode yet"); + console.log("command not available in manual mode yet"); } }); diff --git a/lib/ipfs.js b/lib/ipfs.js index 35c91c0f8..5fb505f78 100644 --- a/lib/ipfs.js +++ b/lib/ipfs.js @@ -1,10 +1,8 @@ require('shelljs/global'); -ipfs = function() { +ipfs = function(build_dir) { ipfs_path = "~/go/bin"; - build_dir = "dist/dapp/"; - cmd = ipfs_path + "/ipfs add -r " + build_dir; console.log("=== adding " + cmd + " to ipfs"); diff --git a/tasks/ipfs.coffee b/tasks/ipfs.coffee index 85b399169..f2b4dc2d7 100644 --- a/tasks/ipfs.coffee +++ b/tasks/ipfs.coffee @@ -3,5 +3,5 @@ module.exports = (grunt) -> grunt.registerTask "ipfs", "distribute into ipfs", (env_) => env = env_ || "development" Embark = require('embark-framework') - Embark.release.ipfs() + Embark.release.ipfs("dist/dapp/") From d70c98665bd0839dc23cc3854945188f4aae4c3b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 12 Jul 2015 22:18:59 -0400 Subject: [PATCH 09/15] add meteor demo cmd --- bin/embark | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/embark b/bin/embark index 35ffc2d88..0f08a19bb 100644 --- a/bin/embark +++ b/bin/embark @@ -142,6 +142,14 @@ program.command('demo').description('create a working dapp with a SimpleStorage console.log('\n\ninit complete'); }); +program.command('meteor_demo').description('create a working meteor dapp with a SimpleStorage contract').action(function() { + var boilerPath = path.join(__dirname + '/../demo_meteor'); + + var targetDir = "./embark_demo"; + wrench.copyDirSyncRecursive(boilerPath, targetDir); + console.log('\n\ninit complete'); +}); + program.parse(process.argv) if (!process.argv.slice(2).length) { From b5f7d32d6532141dd82ad49c6b2088ea5d098b77 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 14 Jul 2015 19:11:16 -0400 Subject: [PATCH 10/15] add clarification to embark run cmd --- bin/embark | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/embark b/bin/embark index 0f08a19bb..366aa22b2 100644 --- a/bin/embark +++ b/bin/embark @@ -94,6 +94,7 @@ program.command('run [env]').description('run dapp').action(function(env_) { } else { console.log("command not available in meteor or manual mode yet"); + console.log("try instead embark run"); } }); From 9579ea3b914d705769b5cd8d4fe91bb35f6bb34c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 14 Jul 2015 19:43:21 -0400 Subject: [PATCH 11/15] remove grunt; use grunt plugin --- bin/embark | 2 +- boilerplate/Gruntfile.coffee | 130 ++++++++++++++++++++++++----------- boilerplate/package.json | 3 +- package.json | 2 +- tasks/_gruntfile.coffee | 102 --------------------------- tasks/blockchain.coffee | 9 --- tasks/deploy.coffee | 17 ----- tasks/ipfs.coffee | 7 -- tasks/server.coffee | 21 ------ tasks/tasks.coffee | 5 -- 10 files changed, 93 insertions(+), 205 deletions(-) delete mode 100644 tasks/_gruntfile.coffee delete mode 100644 tasks/blockchain.coffee delete mode 100644 tasks/deploy.coffee delete mode 100644 tasks/ipfs.coffee delete mode 100644 tasks/server.coffee delete mode 100644 tasks/tasks.coffee diff --git a/bin/embark b/bin/embark index 366aa22b2..a370d9b7c 100644 --- a/bin/embark +++ b/bin/embark @@ -15,7 +15,7 @@ var run = function(cmd) { } program - .version('0.5.0') + .version('0.6.0') program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/boilerplate/Gruntfile.coffee b/boilerplate/Gruntfile.coffee index 43bfd86c8..d6f568193 100644 --- a/boilerplate/Gruntfile.coffee +++ b/boilerplate/Gruntfile.coffee @@ -1,54 +1,102 @@ module.exports = (grunt) -> - grunt.loadNpmTasks "embark-framework" + grunt.loadNpmTasks "grunt-embark" grunt.initConfig( - @initEmbarkConfig( - files: - js: - src: [ - "app/js/**/*.js" - ] + files: + web3: + "node_modules/embark-framework/js/web3.js" - css: - src: [ - "app/css/**/*.css" - ] + js: + src: [ + "app/js/**/*.js" + ] - html: - src: [ - "app/html/**/*.html" - ] + css: + src: [ + "app/css/**/*.css" + ] - contracts: - src: [ - "app/contracts/**/*.sol" - ] + html: + src: [ + "app/html/**/*.html" + ] - concat: - app: - src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"] - dest: "generated/dapp/js/app.min.js" - css: - src: "<%= files.css.src %>" - dest: "generated/dapp/css/app.min.css" + coffee: + dest: "generated/dapp/compiled-coffee" + compiled: [ + "generated/dapp/compiled-coffee/app.coffee" + "generated/dapp/compiled-coffee/**/*.js" + ] - copy: - html: - files: - "generated/dapp/index.html" : "<%= files.html.src %>" - "dist/dapp/index.html" : "<%= files.html.src %>" - css: - files: - "dist/dapp/css/app.min.css" : "<%= files.css.src %>" - contracts: - files: - "dist/contracts/": '<%= files.contracts.src %>' + contracts: + src: [ + "app/contracts/**/*.sol" + ] - deploy: - contracts: '<%= files.contracts.src %>' - dest: 'generated/tmp/abi.js' - ) + coffee: + compile: + expand: true + cwd: 'coffee' + src: '**/*.coffee' + dest: '<%= files.coffee.dest %>' + ext: '.js' + + concat: + app: + src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"] + dest: "generated/dapp/js/app.min.js" + css: + src: "<%= files.css.src %>" + dest: "generated/dapp/css/app.min.css" + + watch: + options: + livereload: true + + html: + files: ["<%= files.html.src %>"] + tasks: ["copy"] + + js: + files: ["<%= files.js.src %>"] + tasks: ["concat"] + + css: + files: ["<%= concat.css.src %>"] + tasks: ["concat"] + + coffee: + files: ["coffee/**/*.coffee"] + tasks: ["coffee", "concat"] + + contracts: + files: ["<%= files.contracts.src %>"] + tasks: ["deploy", "concat", "copy"] + + copy: + html: + files: + "generated/dapp/index.html" : "<%= files.html.src %>" + "dist/dapp/index.html" : "<%= files.html.src %>" + css: + files: + "dist/dapp/css/app.min.css" : "<%= files.css.src %>" + contracts: + files: + "dist/contracts/": '<%= files.contracts.src %>' + + uglify: + dist: + src: "<%= concat.app.dest %>" # input from the concat process + dest: "dist/dapp/js/app.min.js" + + clean: + workspaces: ["dist", "generated"] + + deploy: + contracts: '<%= files.contracts.src %>' + dest: 'generated/tmp/abi.js' ) # loading external tasks (aka: plugins) diff --git a/boilerplate/package.json b/boilerplate/package.json index c3af2fe45..79f289bd2 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,7 +10,8 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "iurimatias/embark-framework#develop", + "embark-framework": "/Users/iurimatias/Projects/embark-framework", + "grunt-embark": "/Users/iurimatias/Projects/grunt-embark", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", "grunt-contrib-concat": "^0.5.1", diff --git a/package.json b/package.json index f5343263d..46af2d2d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "0.5.0", + "version": "0.6.0", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/tasks/_gruntfile.coffee b/tasks/_gruntfile.coffee deleted file mode 100644 index f8c8f94b3..000000000 --- a/tasks/_gruntfile.coffee +++ /dev/null @@ -1,102 +0,0 @@ -module.exports = (grunt) -> - - @embarkConfig = - files: - web3: - "node_modules/embark-framework/js/web3.js" - - js: - src: [ - "app/js/**/*.js" - ] - - css: - src: [ - "app/css/**/*.css" - ] - - html: - src: [ - "app/html/**/*.html" - ] - - coffee: - dest: "generated/dapp/compiled-coffee" - compiled: [ - "generated/dapp/compiled-coffee/app.coffee" - "generated/dapp/compiled-coffee/**/*.js" - ] - - contracts: - src: [ - "app/contracts/**/*.sol" - ] - - coffee: - compile: - expand: true - cwd: 'coffee' - src: '**/*.coffee' - dest: '<%= files.coffee.dest %>' - ext: '.js' - - concat: - app: - src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"] - dest: "generated/dapp/js/app.min.js" - css: - src: "<%= files.css.src %>" - dest: "generated/dapp/css/app.min.css" - - watch: - options: - livereload: true - - html: - files: ["<%= files.html.src %>"] - tasks: ["copy"] - - js: - files: ["<%= files.js.src %>"] - tasks: ["concat"] - - css: - files: ["<%= concat.css.src %>"] - tasks: ["concat"] - - coffee: - files: ["coffee/**/*.coffee"] - tasks: ["coffee", "concat"] - - contracts: - files: ["<%= files.contracts.src %>"] - tasks: ["deploy", "concat", "copy"] - - copy: - html: - files: - "generated/dapp/index.html" : "<%= files.html.src %>" - "dist/dapp/index.html" : "<%= files.html.src %>" - css: - files: - "dist/dapp/css/app.min.css" : "<%= files.css.src %>" - contracts: - files: - "dist/contracts/": '<%= files.contracts.src %>' - - uglify: - dist: - src: "<%= concat.app.dest %>" # input from the concat process - dest: "dist/dapp/js/app.min.js" - - clean: - workspaces: ["dist", "generated"] - - deploy: - contracts: '<%= files.contracts.src %>' - dest: 'generated/tmp/abi.js' - - @initEmbarkConfig = (userConfig) => - hashmerge = require('hashmerge') - hashmerge(@embarkConfig, userConfig) - diff --git a/tasks/blockchain.coffee b/tasks/blockchain.coffee deleted file mode 100644 index 4cc574cca..000000000 --- a/tasks/blockchain.coffee +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = (grunt) -> - - grunt.registerTask "blockchain", "deploy ethereum node", (env_) => - env = env_ || "development" - Embark = require('embark-framework') - Embark.init() - Embark.blockchainConfig.loadConfigFile('config/blockchain.yml') - Embark.startBlockchain(env) - diff --git a/tasks/deploy.coffee b/tasks/deploy.coffee deleted file mode 100644 index 8b92e293f..000000000 --- a/tasks/deploy.coffee +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = (grunt) -> - web3 = require('web3') - readYaml = require('read-yaml'); - - grunt.registerTask "deploy_contracts", "deploy code", (env_) => - env = env_ || "development" - contractFiles = grunt.file.expand(grunt.config.get("deploy.contracts")); - destFile = grunt.config.get("deploy.dest"); - - Embark = require('embark-framework') - Embark.init() - Embark.blockchainConfig.loadConfigFile('config/blockchain.yml') - Embark.contractsConfig.loadConfigFile('config/contracts.yml') - #abi = Embark.deployContracts(env, contractFiles, destFile) - abi = Embark.deployContracts(env, contractFiles, destFile) - grunt.file.write(destFile, abi); - diff --git a/tasks/ipfs.coffee b/tasks/ipfs.coffee deleted file mode 100644 index f2b4dc2d7..000000000 --- a/tasks/ipfs.coffee +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = (grunt) -> - - grunt.registerTask "ipfs", "distribute into ipfs", (env_) => - env = env_ || "development" - Embark = require('embark-framework') - Embark.release.ipfs("dist/dapp/") - diff --git a/tasks/server.coffee b/tasks/server.coffee deleted file mode 100644 index dfe607c8e..000000000 --- a/tasks/server.coffee +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = (grunt) -> - express = require("express") - compression = require("compression") - readYaml = require('read-yaml') - - grunt.registerTask "server", "static file development server", => - serverConfig = readYaml.sync("config/server.yml") - - webPort = serverConfig.port || 8000 - webHost = serverConfig.host || 'localhost' - webRoot = "generated/dapp" - - app = express() - app.use(compression()) - app.use(express.static("" + (process.cwd()) + "/" + webRoot)) - app.listen(webPort, webHost) - - grunt.log.writeln("Running web server on port http://#{webHost}:#{webPort}") - - return app - diff --git a/tasks/tasks.coffee b/tasks/tasks.coffee deleted file mode 100644 index 209bafa2a..000000000 --- a/tasks/tasks.coffee +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = (grunt) -> - - grunt.registerTask "deploy", ["coffee", "deploy_contracts", "concat", "copy", "server", "watch"] - grunt.registerTask "build", ["clean", "deploy_contracts", "coffee", "concat", "uglify", "copy"] - From 12e30f5c359b34f7469a57531b365ad082659977 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 14 Jul 2015 19:52:59 -0400 Subject: [PATCH 12/15] remove old grunt packages --- package.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/package.json b/package.json index 46af2d2d0..7eb1f05c1 100644 --- a/package.json +++ b/package.json @@ -17,17 +17,8 @@ "compression": "^1.4.3", "express": "^4.12.3", "grunt": "^0.4.5", - "grunt-cli": "^0.1.13", - "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-coffee": "^0.13.0", - "grunt-contrib-concat": "^0.5.1", - "grunt-contrib-copy": "^0.8.0", - "grunt-contrib-uglify": "^0.9.1", - "grunt-contrib-watch": "^0.6.1", - "grunt-open": "^0.2.3", "hashmerge": "^1.0.2", "jasmine": "^2.3.1", - "matchdep": "^0.3.0", "meteor-build-client": "^0.1.6", "methodmissing": "^0.0.3", "python": "^0.0.4", From 92d37fd60a0977b32ca8453c4b05016f5cb76ba0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 14 Jul 2015 20:12:26 -0400 Subject: [PATCH 13/15] update embark and grunt plugin versions --- boilerplate/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boilerplate/package.json b/boilerplate/package.json index 79f289bd2..f478b14f1 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,8 +10,8 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "/Users/iurimatias/Projects/embark-framework", - "grunt-embark": "/Users/iurimatias/Projects/grunt-embark", + "embark-framework": "^0.6.0", + "grunt-embark": "0.1.0", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", "grunt-contrib-concat": "^0.5.1", From 9a5c3906cd6aae89b5a0b5ecb8ff8a9ba918e4ea Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 14 Jul 2015 20:58:08 -0400 Subject: [PATCH 14/15] update meteor commands --- bin/embark | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/bin/embark b/bin/embark index a370d9b7c..67f9c6ac1 100644 --- a/bin/embark +++ b/bin/embark @@ -14,6 +14,16 @@ var run = function(cmd) { } } +var deploy = fnction(embarkConfig) { + contractFiles = grunt.file.expand(embarkConfig.contracts); + destFile = embarkConfig.output + Embark.init() + Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) + Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) + abi = Embark.deployContracts(env, contractFiles, destFile) + grunt.file.write(destFile, abi); +} + program .version('0.6.0') @@ -39,13 +49,7 @@ program.command('deploy [env]').description('deploy contracts').action(function( run("grunt deploy_contracts:" + env); } else { - contractFiles = grunt.file.expand(embarkConfig.contracts); - destFile = embarkConfig.output - Embark.init() - Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) - Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) - abi = Embark.deployContracts(env, contractFiles, destFile) - grunt.file.write(destFile, abi); + deploy(); } }); @@ -59,7 +63,7 @@ program.command('build [env]').description('build dapp').action(function(env_) { run('grunt build:' + env); } else if (embarkConfig.type === "meteor") { - //deploy + deploy(); run("meteor-build-client ./build -p ''"); } }); @@ -75,9 +79,8 @@ program.command('ipfs [env]').description('build dapp and make it available in i run('grunt ipfs:' + env) } else if (embarkConfig.type === "meteor") { - //deploy - //build - Embark = require('embark-framework') + deploy(); + run("meteor-build-client ./build -p ''"); Embark.release.ipfs("build/") } else { @@ -106,6 +109,7 @@ program.command('spec').description('run specs').action(function() { } else { console.log("command not available in meteor or manual mode yet"); + console.log("note: you can use embark tests with any framework"); } }); From c1113dda00010a547c5da6506cabc8fc6d9edda8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 15 Jul 2015 08:06:40 -0400 Subject: [PATCH 15/15] update readme --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 8cfec56e5..452eca6db 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,39 @@ If you are using multiple contracts, you can pass a reference to another contrac ... ``` +You can now deploy many instances of the same contract. e.g + + +```Yaml +# config/contracts.yml + development: + Currency: + args: + - 100 + Usd: + instanceOf: Currency + args: + - "initial string" + MyCoin: + instanceOf: Currency + args: + - $SimpleStorage + ... +``` + +Contracts addresses can be defined, If an address is defined the contract wouldn't be deployed but its defined address will be used instead. + + +```Yaml + development: + UserStorage: + address: 0x123456 + UserManagement: + args: + - $UserStorage + ... +``` + Tests ======