From 6f808cfeb06e252f4673491bade8181b525b4e58 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 14 Sep 2015 19:58:52 -0500 Subject: [PATCH 01/39] ability to create multiple contracts with a single password for testing purposes --- boilerplate/config/blockchain.yml | 4 +--- lib/blockchain.js | 11 +++++++---- lib/config/blockchain.js | 3 +-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 49fb0add..eec7cb53 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -7,20 +7,19 @@ development: datadir: /tmp/embark chains: config/chains/development.json mine_when_needed: true - max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 console: false account: init: true password: config/password + num: 1 staging: rpc_host: localhost rpc_port: 8101 rpc_whitelist: "*" datadir: default network_id: 0 - max_peers: 4 console: true account: init: false @@ -31,7 +30,6 @@ production: rpc_whitelist: "*" datadir: default network_id: 1 - max_peers: 4 console: true account: init: false diff --git a/lib/blockchain.js b/lib/blockchain.js index 9ab37a5c..0915c2a8 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -105,12 +105,15 @@ Blockchain.prototype.get_address = function() { console.log("=== already initialized"); address = result.output.match(/{(\w+)}/)[1]; } else { - console.log("running: " + this.init_command()); - result = exec(this.init_command()); - address = result.output.match(/{(\w+)}/)[1]; + console.log("running: " + this.init_command() + " " + this.account.num + " time(s)"); + result = ''; + for (var i = 0; i < this.account.num; i++){ + result = exec(this.init_command()) + '\n'; + address = result.output.match(/{(\w+)}/)[1]; //TODO: Write a proper reg expression to match multiple lines of output...not my forte + } } } - + if (this.account.num > 1) return exec(this.list_command()); return address; } diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index d0dcdd50..70f2fd50 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -41,7 +41,6 @@ BlockchainConfig.prototype.config = function(env) { genesisBlock: config.genesis_block, datadir: config.datadir, chains: config.chains, - deployTimeout: config.deploy_timeout || 20, networkId: networkId, maxPeers: 4, port: config.port || "30303", @@ -54,4 +53,4 @@ BlockchainConfig.prototype.config = function(env) { return config; }; -module.exports = BlockchainConfig; +module.exports = BlockchainConfig; \ No newline at end of file From bc96708d1389717564a14fefdd452ea9fe319a97 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 14 Sep 2015 20:06:36 -0500 Subject: [PATCH 02/39] correcting some changes I made in error --- boilerplate/config/blockchain.yml | 3 +++ lib/config/blockchain.js | 1 + 2 files changed, 4 insertions(+) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index eec7cb53..911fd1dc 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -7,6 +7,7 @@ development: datadir: /tmp/embark chains: config/chains/development.json mine_when_needed: true + max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 console: false @@ -20,6 +21,7 @@ staging: rpc_whitelist: "*" datadir: default network_id: 0 + max_peers: 4 console: true account: init: false @@ -30,6 +32,7 @@ production: rpc_whitelist: "*" datadir: default network_id: 1 + max_peers: 0 console: true account: init: false diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index 70f2fd50..6fade581 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -41,6 +41,7 @@ BlockchainConfig.prototype.config = function(env) { genesisBlock: config.genesis_block, datadir: config.datadir, chains: config.chains, + deployTimeout: config.deploy_timeout || 20, networkId: networkId, maxPeers: 4, port: config.port || "30303", From ef97e488f3ea9ad52affa296a8f4af16b1116894 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 14 Sep 2015 20:07:36 -0500 Subject: [PATCH 03/39] correcting some changes I made in error --- boilerplate/config/blockchain.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 911fd1dc..7bfee1a5 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -32,7 +32,7 @@ production: rpc_whitelist: "*" datadir: default network_id: 1 - max_peers: 0 + max_peers: 4 console: true account: init: false From 92ca694d35dee200df563386fb353e1b30bc4551 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 15 Sep 2015 09:02:43 -0400 Subject: [PATCH 04/39] fix embarassing typo --- lib/compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compiler.js b/lib/compiler.js index 31b45e72..89d9bf4c 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -50,7 +50,7 @@ Compiler.prototype.compile_solidity = function(contractFile) { var contract = json[className]; compiled_object[className] = {}; - compiled_object[className].code = contract.binary || contact.bin; + compiled_object[className].code = contract.binary || contract.bin; compiled_object[className].info = {}; compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"] || contract["json-abi"]); } From 8539ff241f7785685cfe88737615216c195777f0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 15 Sep 2015 09:03:25 -0400 Subject: [PATCH 05/39] update to 0.9.3 --- bin/embark | 2 +- boilerplate/package.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/embark b/bin/embark index 8a3b7ae7..f633663e 100755 --- a/bin/embark +++ b/bin/embark @@ -29,7 +29,7 @@ var deploy = function(env, embarkConfig) { } program - .version('0.9.2') + .version('0.9.3') program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/boilerplate/package.json b/boilerplate/package.json index 458c8ec2..e82b7d0f 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,7 +10,7 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^0.9.2", + "embark-framework": "^0.9.3", "grunt-embark": "^0.4.3", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", diff --git a/package.json b/package.json index 0f15b435..0987a62a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "0.9.2", + "version": "0.9.3", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 1a4bcd168b762ebfc112dd515badcc7facc1eb24 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Wed, 16 Sep 2015 15:25:50 -0500 Subject: [PATCH 06/39] support solc version 1.0 --- lib/compiler.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/compiler.js b/lib/compiler.js index bcac64e6..4fc60bf4 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -29,7 +29,9 @@ Compiler.prototype.compile_solidity = function(contractFile) { output = result.output; if (result.code === 1) { - throw new Error(result.output); + if (version == '0.1.1' || version == '0.1.0'){ + throw new Error(result.output); + } } json = JSON.parse(output).contracts; From 7620f16c54a065bec27bc3cbe094c3e328f8ca3e Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Thu, 24 Sep 2015 11:03:17 +0100 Subject: [PATCH 07/39] show grunt stacktrace --- boilerplate/Gruntfile.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplate/Gruntfile.coffee b/boilerplate/Gruntfile.coffee index 150ff372..279c1816 100644 --- a/boilerplate/Gruntfile.coffee +++ b/boilerplate/Gruntfile.coffee @@ -1,5 +1,6 @@ module.exports = (grunt) -> + grunt.option 'stack', true grunt.loadNpmTasks "grunt-embark" grunt.loadTasks "tasks" @@ -111,4 +112,3 @@ module.exports = (grunt) -> grunt.registerTask "deploy", ["coffee", "deploy_contracts", "concat", "copy", "server", "watch"] grunt.registerTask "build", ["clean", "deploy_contracts", "coffee", "concat", "uglify", "copy"] - From 3c17582bd5a392fa12c087b3bf253ec272bf14dc Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Fri, 25 Sep 2015 08:44:37 +0100 Subject: [PATCH 08/39] throw error when block cannot be found --- lib/chain_manager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/chain_manager.js b/lib/chain_manager.js index edc48bbd..bc93be3b 100644 --- a/lib/chain_manager.js +++ b/lib/chain_manager.js @@ -28,6 +28,10 @@ ChainManager.prototype.loadConfig = function(config) { ChainManager.prototype.init = function(env, config) { web3.setProvider(new web3.providers.HttpProvider("http://" + config.rpcHost + ":" + config.rpcPort)); + var block = web3.eth.getBlock(0); + if(!block){ + throw new Error("Cannot get the genesis block, is embark blockchain running ?"); + } var chainId = web3.eth.getBlock(0).hash; if (this.chainManagerConfig[chainId] === undefined) { From 8f96834596bc9e5fcfbdd84aaa6b079332637789 Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Fri, 25 Sep 2015 08:47:51 +0100 Subject: [PATCH 09/39] add geth_extra_opts options, can be used to set --vmdebug to geth --- README.md | 1 + lib/blockchain.js | 4 ++++ lib/config/blockchain.js | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4930ed01..88d3b449 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,7 @@ The environment is a specific blockchain configuration that can be managed at co chains: chains_staging.json network_id: 0 console: true + geth_extra_opts: --vmdebug account: init: false address: 0x123 diff --git a/lib/blockchain.js b/lib/blockchain.js index 9ab37a5c..88f0c5db 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -16,6 +16,10 @@ Blockchain.prototype.generate_basic_command = function() { cmd += "--logfile=\"" + config.datadir + ".log\" "; } + if (config.geth_extra_opts) { + cmd += config.geth_extra_opts + " "; + } + cmd += "--port " + config.port + " "; cmd += "--rpc "; cmd += "--rpcport " + config.rpcPort + " "; diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index d0dcdd50..5af4395a 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -48,7 +48,8 @@ BlockchainConfig.prototype.config = function(env) { console_toggle: config.console || false, mine_when_needed: config.mine_when_needed || false, whisper: config.whisper || false, - account: config.account + account: config.account, + geth_extra_opts: config.geth_extra_opts } return config; From 6b7b88d58af26791b38bb6e07e78fafedbdd54e7 Mon Sep 17 00:00:00 2001 From: Frederic Heem Date: Fri, 25 Sep 2015 08:55:35 +0100 Subject: [PATCH 10/39] don-'t call web3.eth.getBlock twice --- lib/chain_manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chain_manager.js b/lib/chain_manager.js index bc93be3b..abd0aea9 100644 --- a/lib/chain_manager.js +++ b/lib/chain_manager.js @@ -32,7 +32,7 @@ ChainManager.prototype.init = function(env, config) { if(!block){ throw new Error("Cannot get the genesis block, is embark blockchain running ?"); } - var chainId = web3.eth.getBlock(0).hash; + var chainId = block.hash; if (this.chainManagerConfig[chainId] === undefined) { this.chainManagerConfig[chainId] = {contracts: {}}; From f818faf680b49857cf038e2b4980b71f71d9644e Mon Sep 17 00:00:00 2001 From: Aakil Fernandes Date: Fri, 25 Sep 2015 15:21:46 -0400 Subject: [PATCH 11/39] only mine if config.mine is true --- lib/blockchain.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index 9ab37a5c..950cb7b2 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -27,7 +27,9 @@ Blockchain.prototype.generate_basic_command = function() { cmd += "--minerthreads \"" + config.minerthreads + "\" "; } - cmd += "--mine "; + if(config.mine) + cmd += "--mine "; + if (config.genesisBlock !== void 0) { cmd += "--genesis=\"" + config.genesisBlock + "\" "; } From 2526ba47fdb48b1cc62eb96cdb01384a4cdc2ea9 Mon Sep 17 00:00:00 2001 From: Aakil Fernandes Date: Fri, 25 Sep 2015 14:46:28 -0400 Subject: [PATCH 12/39] use account if expliciitly set in config --- lib/blockchain.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/blockchain.js b/lib/blockchain.js index 9ab37a5c..cb013ff8 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -87,6 +87,10 @@ Blockchain.prototype.run_command = function(address, use_tmp) { Blockchain.prototype.get_address = function() { var config = this.config; + + if(config.address) + return this.config.address; + var address = null; if (config.account.init) { From 03c7f2521965fa1b946c9c677d7cc5471ba1873a Mon Sep 17 00:00:00 2001 From: Aakil Fernandes Date: Fri, 25 Sep 2015 15:16:44 -0400 Subject: [PATCH 13/39] config.address -> config.account.address --- lib/blockchain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index cb013ff8..b32ad5c8 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -88,8 +88,8 @@ Blockchain.prototype.run_command = function(address, use_tmp) { Blockchain.prototype.get_address = function() { var config = this.config; - if(config.address) - return this.config.address; + if(config.account.address) + return config.account.address; var address = null; From b3cec8287b53d5db01280346d3e1f0aeea7223cd Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Thu, 1 Oct 2015 08:23:41 -0500 Subject: [PATCH 14/39] added ability to boot nodes via a list --- boilerplate/config/blockchain.yml | 6 ++++++ lib/blockchain.js | 17 ++++++++++------- lib/config/blockchain.js | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 7bfee1a5..af516800 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -23,6 +23,9 @@ staging: network_id: 0 max_peers: 4 console: true + bootnodes: + boot: false + enodes: [] #insert enode urls here. account: init: false address: @@ -34,6 +37,9 @@ production: network_id: 1 max_peers: 4 console: true + bootnodes: + boot: false + enodes: [] account: init: false address: diff --git a/lib/blockchain.js b/lib/blockchain.js index 0915c2a8..3b03788a 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -69,6 +69,12 @@ Blockchain.prototype.run_command = function(address, use_tmp) { cmd += "--unlock " + address + " "; } + if (config.bootNodes.init == true){ + cmd += "--bootnodes "; + for (var i = 0; i < config.bootNodes.enodes.length; i++){ + cmd += config.bootNodes.enodes[i] + " "; + } + } if (config.console_toggle) { cmd += "console"; } @@ -105,15 +111,12 @@ Blockchain.prototype.get_address = function() { console.log("=== already initialized"); address = result.output.match(/{(\w+)}/)[1]; } else { - console.log("running: " + this.init_command() + " " + this.account.num + " time(s)"); - result = ''; - for (var i = 0; i < this.account.num; i++){ - result = exec(this.init_command()) + '\n'; - address = result.output.match(/{(\w+)}/)[1]; //TODO: Write a proper reg expression to match multiple lines of output...not my forte - } + console.log("running: " + this.init_command()); + result = exec(this.init_command()); + address = result.output.match(/{(\w+)}/)[1]; } } - if (this.account.num > 1) return exec(this.list_command()); + return address; } diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index 6fade581..33624bad 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -30,6 +30,7 @@ BlockchainConfig.prototype.config = function(env) { else { networkId = config.network_id; } + config = { rpcHost: config.rpc_host, @@ -41,9 +42,10 @@ BlockchainConfig.prototype.config = function(env) { genesisBlock: config.genesis_block, datadir: config.datadir, chains: config.chains, + bootNodes: config.bootnodes, deployTimeout: config.deploy_timeout || 20, networkId: networkId, - maxPeers: 4, + maxPeers: config.max_peers || 4, port: config.port || "30303", console_toggle: config.console || false, mine_when_needed: config.mine_when_needed || false, @@ -54,4 +56,4 @@ BlockchainConfig.prototype.config = function(env) { return config; }; -module.exports = BlockchainConfig; \ No newline at end of file +module.exports = BlockchainConfig; From 02a52f718fb08b0e923af82fd2f176b0e5db50b3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 1 Oct 2015 22:37:47 -0400 Subject: [PATCH 15/39] change enodes config to boot --- lib/blockchain.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index e869136c..c4687831 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -75,12 +75,13 @@ Blockchain.prototype.run_command = function(address, use_tmp) { cmd += "--unlock " + address + " "; } - if (config.bootNodes.init == true){ + if (config.bootNodes.boot == true){ cmd += "--bootnodes "; for (var i = 0; i < config.bootNodes.enodes.length; i++){ cmd += config.bootNodes.enodes[i] + " "; } } + if (config.console_toggle) { cmd += "console"; } From 32ac41a9cbef357d7b435319da14a1c12525a25c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 1 Oct 2015 23:04:15 -0400 Subject: [PATCH 16/39] compile using js solc --- lib/compiler.js | 34 ++++++++-------------------------- package.json | 1 + 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 2006fd57..7593f0e1 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,6 +1,8 @@ var shelljs = require('shelljs'); var shelljs_global = require('shelljs/global'); var web3 = require('web3'); +var fs = require('fs'); +var solc = require('solc'); Compiler = function(blockchainConfig) { this.blockchainConfig = blockchainConfig; @@ -21,44 +23,24 @@ Compiler.prototype.init = function(env) { }; Compiler.prototype.compile_solidity = function(contractFile) { - var cmd, result, output, version, json, compiled_object; + var source = fs.readFileSync(contractFile).toString(); + var output = solc.compile(source, 1); - cmd = "solc --version"; + var json = output.contracts; - result = exec(cmd, {silent: true}); - output = result.output; - version = output.split('\n')[1].split(' ')[1].slice(0,5); - - if (version == '0.1.1') { - cmd = "solc --input-file " + contractFile + " --combined-json binary,json-abi"; - } - else { - cmd = "solc --input-file " + contractFile + " --combined-json bin,abi"; - } - - result = exec(cmd, {silent: true}); - output = result.output; - - if (result.code === 1) { - if (version == '0.1.1' || version == '0.1.0'){ - throw new Error(result.output); - } - } - - json = JSON.parse(output).contracts; compiled_object = {} for (var className in json) { var contract = json[className]; compiled_object[className] = {}; - compiled_object[className].code = contract.binary || contract.bin; + compiled_object[className].code = contract.bytecode; compiled_object[className].info = {}; - compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"] || contract["json-abi"]); + compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); } return compiled_object; -} +}; Compiler.prototype.compile_serpent = function(contractFile) { var cmd, result, output, json, compiled_object; diff --git a/package.json b/package.json index 0987a62a..3d693ce6 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "python": "^0.0.4", "read-yaml": "^1.0.0", "shelljs": "^0.5.0", + "solc": "^0.1.3-2", "sync-me": "^0.1.1", "toposort": "^0.2.10", "web3": "^0.8.1", From 95823a8e5401bb48ec0eecf3643af5552fae939c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 8 Oct 2015 15:30:47 -0400 Subject: [PATCH 17/39] make deployment async --- demo/spec/contracts/simple_storage_spec.js | 14 ++- lib/blockchain.js | 2 +- lib/compiler.js | 9 -- lib/deploy.js | 123 ++++++++++++++------- lib/index.js | 17 +-- lib/test.js | 73 ------------ 6 files changed, 106 insertions(+), 132 deletions(-) delete mode 100644 lib/test.js diff --git a/demo/spec/contracts/simple_storage_spec.js b/demo/spec/contracts/simple_storage_spec.js index 359d9d15..343612c2 100644 --- a/demo/spec/contracts/simple_storage_spec.js +++ b/demo/spec/contracts/simple_storage_spec.js @@ -1,4 +1,6 @@ var Embark = require('embark-framework'); +var ethersim = require('ethersim'); +var web3 = require('web3'); Embark.init(); Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); Embark.contractsConfig.loadConfigFile('config/contracts.yml'); @@ -6,7 +8,17 @@ Embark.contractsConfig.loadConfigFile('config/contracts.yml'); var files = ["app/contracts/simple_storage.sol"]; Embark.contractsConfig.init(files, 'development'); -var EmbarkSpec = Embark.tests(files); + +var Manager = ethersim.Manager; +var Provider = ethersim.Provider; + +console.log("initializing"); +var manager = new Manager(); + +web3.setProvider(new Provider(manager)); +abi = Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", web3); +console.log(abi); +eval(abi); describe("SimpleStorage", function() { beforeAll(function() { diff --git a/lib/blockchain.js b/lib/blockchain.js index c4687831..9ab5deaf 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -75,7 +75,7 @@ Blockchain.prototype.run_command = function(address, use_tmp) { cmd += "--unlock " + address + " "; } - if (config.bootNodes.boot == true){ + if (config.bootNodes !== undefined && config.bootNodes.boot == true){ cmd += "--bootnodes "; for (var i = 0; i < config.bootNodes.enodes.length; i++){ cmd += config.bootNodes.enodes[i] + " "; diff --git a/lib/compiler.js b/lib/compiler.js index 7593f0e1..253bbc13 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -10,15 +10,6 @@ Compiler = function(blockchainConfig) { Compiler.prototype.init = function(env) { var config = this.blockchainConfig.config(env); - - try { - web3.setProvider(new web3.providers.HttpProvider("http://" + config.rpcHost + ":" + config.rpcPort)); - primaryAddress = web3.eth.coinbase; - web3.eth.defaultAccount = primaryAddress; - } catch (e) { - throw new Error("can't connect to " + config.rpcHost + ":" + config.rpcPort + " check if an ethereum node is running"); - } - console.log("address is : " + primaryAddress); }; diff --git a/lib/deploy.js b/lib/deploy.js index d75f7e31..9cabca33 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -32,35 +32,68 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainMa console.log("primary account address is : " + primaryAddress); }; -Deploy.prototype.deploy_contract = function(contractObject, contractParams) { - var transactionHash = contractObject["new"].apply(contractObject, contractParams).transactionHash; - var receipt = null; - var time = 0; - while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null || receipt.contractAddress === null) { - sleep(1000); - time += 1; - if (time >= this.blockchainConfig.deployTimeout) { - return false; +Deploy.prototype.deploy_contract = function(contractObject, contractParams, cb) { + console.log("called deploy_contract"); + var callback = function(e, contract) { + console.log("got receipt"); + console.log(arguments); + if(!e && contract.address !== undefined) { + console.log("Contract mined! Address: " + contract.address); + cb(contract.address); } - } - return receipt; + else { + console.log("error deploying"); + exit(); + } + }; + + contractParams.push(callback); + + contractObject["new"].apply(contractObject, contractParams); + + //var transactionHash = contractObject["new"].apply(contractObject, contractParams).transactionHash; + //var receipt = null; + //var time = 0; + //while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null || receipt.contractAddress === null) { + // sleep(1000); + // time += 1; + // if (time >= this.blockchainConfig.deployTimeout) { + // return false; + // } + //} + //return receipt; } -Deploy.prototype.deploy_contracts = function(env) { +Deploy.prototype.deploy_contracts = function(env, cb) { this.contractsManager.compileContracts(env); - all_contracts = this.contractsManager.all_contracts; + var all_contracts = this.contractsManager.all_contracts; this.contractDB = this.contractsManager.contractDB; - contractDependencies = this.contractsManager.contractDependencies; - this.deployedContracts = {}; - for (k = 0; k < all_contracts.length; k++) { - className = all_contracts[k]; - contract = this.contractDB[className]; + this.deploy_contract_list(all_contracts.length, env, all_contracts, cb); +} + +Deploy.prototype.deploy_contract_list = function(index, env, all_contracts, cb) { + if(index === 0) { + cb(); + } + else { + var _this = this; + this.deploy_contract_list(index - 1, env, all_contracts, function() { + var className = all_contracts[index - 1]; + _this.deploy_a_contract(env, className, cb); + }); + } +} + +Deploy.prototype.deploy_a_contract = function(env, className, cb) { + var contractDependencies = this.contractsManager.contractDependencies; + var contract = this.contractDB[className]; if (contract.deploy === false) { console.log("skipping " + className); - continue; + cb(); + return; } var realArgs = []; @@ -78,6 +111,7 @@ Deploy.prototype.deploy_contracts = function(env) { //console.log("contract " + className + " at " + contractAddress); console.log("contract " + className + " at " + contract.address); + cb(); } else { var chainContract = this.chainManager.getContract(className, contract.compiled.code, realArgs); @@ -86,6 +120,7 @@ Deploy.prototype.deploy_contracts = function(env) { console.log("contract " + className + " is unchanged and already deployed at " + chainContract.address); this.deployedContracts[className] = chainContract.address; this.execute_cmds(contract.onDeploy); + cb(); } else { @@ -101,31 +136,34 @@ Deploy.prototype.deploy_contracts = function(env) { console.log('trying to obtain ' + className + ' address...'); - while((receipt = this.deploy_contract(contractObject, contractParams)) === false) { - console.log("timeout... failed to deploy contract.. retrying..."); - } + var _this = this; + this.deploy_contract(contractObject, contractParams, function(contractAddress) { + console.log("response!"); - var contractAddress = receipt.contractAddress; + if (web3.eth.getCode(contractAddress) === "0x") { + console.log("========="); + console.log("contract was deployed at " + contractAddress + " but doesn't seem to be working"); + console.log("try adjusting your gas values"); + console.log("========="); + } + else { + console.log("deployed " + className + " at " + contractAddress); + _this.chainManager.addContract(className, contract.compiled.code, realArgs, contractAddress); + _this.chainManager.save(); + } - if (web3.eth.getCode(contractAddress) === "0x") { - console.log("========="); - console.log("contract was deployed at " + contractAddress + " but doesn't seem to be working"); - console.log("try adjusting your gas values"); - console.log("========="); - } - else { - console.log("deployed " + className + " at " + contractAddress); - this.chainManager.addContract(className, contract.compiled.code, realArgs, contractAddress); - this.chainManager.save(); - } + _this.deployedContracts[className] = contractAddress; - this.deployedContracts[className] = contractAddress; + _this.execute_cmds(contract.onDeploy); - this.execute_cmds(contract.onDeploy); + cb(); + }); + + //while((receipt = this.deploy_contract(contractObject, contractParams)) === false) { + // console.log("timeout... failed to deploy contract.. retrying..."); + //} } } - } - }; Deploy.prototype.execute_cmds = function(cmds) { @@ -147,11 +185,14 @@ Deploy.prototype.execute_cmds = function(cmds) { } } -Deploy.prototype.generate_abi_file = function() { +Deploy.prototype.generate_abi_file = function(web3) { var result; - result = "web3.setProvider(new web3.providers.HttpProvider('http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + "'));"; - result += "web3.eth.defaultAccount = web3.eth.accounts[0];"; + result = ""; + if (web3 === undefined) { + result = "web3.setProvider(new web3.providers.HttpProvider('http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + "'));"; + result += "web3.eth.defaultAccount = web3.eth.accounts[0];"; + } for(className in this.deployedContracts) { var deployedContract = this.deployedContracts[className]; diff --git a/lib/index.js b/lib/index.js index fcc82d3b..b41ba260 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,7 +10,7 @@ var syncMe = require('sync-me'); var methodmissing = require('methodmissing'); var jasmine = require('jasmine'); -var Tests = require('./test.js'); +//var Tests = require('./test.js'); var Blockchain = require('./blockchain.js'); var Deploy = require('./deploy.js'); var Release = require('./ipfs.js'); @@ -26,9 +26,9 @@ Embark = { this.chainManager = (new ChainManager()); }, - tests: function(contractFiles) { - return new Tests(this.contractsConfig, contractFiles); - }, + //tests: function() { + // return new Tests(); + //}, startBlockchain: function(env, use_tmp) { var chain = new Blockchain(this.blockchainConfig.config(env)); @@ -45,13 +45,16 @@ Embark = { return chain.getStartChainCommand(use_tmp); }, - deployContracts: function(env, contractFiles, destFile, chainFile) { + deployContracts: function(env, contractFiles, destFile, chainFile, cb) { this.contractsConfig.init(contractFiles, env); this.chainManager.loadConfigFile(chainFile) var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig, this.chainManager); - deploy.deploy_contracts(env); - return deploy.generate_abi_file(destFile); + deploy.deploy_contracts(env, function() { + console.log("contracts deployed; generating abi file"); + var result = deploy.generate_abi_file(); + cb(result); + }); }, geth: function(env, args) { diff --git a/lib/test.js b/lib/test.js deleted file mode 100644 index 6c957256..00000000 --- a/lib/test.js +++ /dev/null @@ -1,73 +0,0 @@ -var python = require('python').shell; -var mm = require('methodmissing'); -var sync = require('sync-me'); - -py_exec = function(cmd) { - return sync(python, cmd)[1].trim(); -}; - -TestContractWrapper = (function() { - function TestContractWrapper(contract, className, args) { - this.contract = contract.compiled; - this.className = className; - this.args = args; - this.initializeContract(); - } - - TestContractWrapper.prototype.initializeContract = function() { - example_abi = JSON.stringify(this.contract.info.abiDefinition); - example_binary = this.contract.code.slice(2); - - py_exec("example_abi = '" + example_abi + "'"); - py_exec("example_abi"); - py_exec("example_binary = '" + example_binary + "'.decode('hex')"); - py_exec("example_binary"); - - if (this.args === undefined) { - py_exec(this.className + "_contract = EvmContract(example_abi, example_binary, '" + this.className + "')"); - } - else { - py_exec(this.className + "_contract = EvmContract(example_abi, example_binary, '" + this.className + "', [" + this.args.join(",") + "])"); - } - - this.contractVariable = this.className + "_contract"; - }; - - TestContractWrapper.prototype.execCmd = function(method, args) { - var arg_list = []; - for (var key in args) { - var value = args[key]; - arg_list.push(value); - } - - data = py_exec(this.className + "_contract." + method + "(" + arg_list.join(",") + ")"); - return data; - }; - - return TestContractWrapper; - -})(); - -TestContract = function(contract, className, args) { - var wrapper = new TestContractWrapper(contract, className, args); - var Obj = mm(wrapper, function (key, args) { - return wrapper.execCmd(key, args); - }); - return Obj; -} - -test = function(contractsConfig, contractFiles) { - contractsConfig.init(contractFiles, 'development'); - - contractsConfig.compileContracts(); - this.contractDB = contractsConfig.contractDB; -} - -test.prototype.request = function(className, args) { - var contract = this.contractDB[className]; - py_exec("from ethertdd import EvmContract"); - return TestContract(contract, className, args); -} - -module.exports = test; - From c550b688d3f6c9510945a314f1050ef18d8c7ea9 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 10:18:18 -0400 Subject: [PATCH 18/39] add flag to include provider in abi; update spec --- demo/spec/contracts/simple_storage_spec.js | 46 ++++++++++++++-------- lib/chain_manager.js | 12 +++--- lib/deploy.js | 25 +++++++----- lib/index.js | 20 +++++++--- 4 files changed, 67 insertions(+), 36 deletions(-) diff --git a/demo/spec/contracts/simple_storage_spec.js b/demo/spec/contracts/simple_storage_spec.js index 343612c2..7d34c913 100644 --- a/demo/spec/contracts/simple_storage_spec.js +++ b/demo/spec/contracts/simple_storage_spec.js @@ -1,7 +1,14 @@ var Embark = require('embark-framework'); var ethersim = require('ethersim'); var web3 = require('web3'); -Embark.init(); + +var Manager = ethersim.Manager; +var Provider = ethersim.Provider; + +var manager = new Manager(); +web3.setProvider(new Provider(manager)); + +Embark.init(web3); Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); Embark.contractsConfig.loadConfigFile('config/contracts.yml'); @@ -9,29 +16,34 @@ var files = ["app/contracts/simple_storage.sol"]; Embark.contractsConfig.init(files, 'development'); -var Manager = ethersim.Manager; -var Provider = ethersim.Provider; - console.log("initializing"); -var manager = new Manager(); - -web3.setProvider(new Provider(manager)); -abi = Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", web3); -console.log(abi); -eval(abi); describe("SimpleStorage", function() { - beforeAll(function() { - SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]); + beforeAll(function(done) { + Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, function(abi) { + console.log("return abi"); + console.log(abi); + eval(abi); + done(); + }); + //SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]); }); - it("should set constructor value", function() { - expect(SimpleStorage.storedData()).toEqual('150'); + it("should set constructor value", function(done) { + SimpleStorage.storedData(function(err, result) { + expect(result.toNumber()).toEqual(100); + done(); + }); }); - it("set storage value", function() { - SimpleStorage.set(100); - expect(SimpleStorage.get()).toEqual('100'); + it("set storage value", function(done) { + SimpleStorage.set(150, function() { + SimpleStorage.get(function(err, result) { + console.log(arguments); + expect(result.toNumber()).toEqual(150); + done(); + }); + }); }); }) diff --git a/lib/chain_manager.js b/lib/chain_manager.js index abd0aea9..ca8cff78 100644 --- a/lib/chain_manager.js +++ b/lib/chain_manager.js @@ -2,11 +2,11 @@ var fs = require('fs'); var web3 = require('web3'); var sha3_256 = require('js-sha3').sha3_256; -ChainManager = function() { +ChainManager = function(_web3) { this.chainManagerConfig = {}; this.currentChain = {}; this.file = ""; - this.web3 = null; + this.web3 = _web3; } ChainManager.prototype.loadConfigFile = function(filename) { @@ -26,9 +26,11 @@ ChainManager.prototype.loadConfig = function(config) { }; ChainManager.prototype.init = function(env, config) { - web3.setProvider(new web3.providers.HttpProvider("http://" + config.rpcHost + ":" + config.rpcPort)); + if (this.web3 === undefined) { + web3.setProvider(new web3.providers.HttpProvider("http://" + config.rpcHost + ":" + config.rpcPort)); + } - var block = web3.eth.getBlock(0); + var block = this.web3.eth.getBlock(0); if(!block){ throw new Error("Cannot get the genesis block, is embark blockchain running ?"); } @@ -39,7 +41,7 @@ ChainManager.prototype.init = function(env, config) { } this.currentChain = this.chainManagerConfig[chainId]; - this.web3 = web3; + //this.web3 = web3; } ChainManager.prototype.addContract = function(contractName, code, args, address) { diff --git a/lib/deploy.js b/lib/deploy.js index 9cabca33..7e2c9354 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -10,7 +10,10 @@ sleep = function sleep(ms) { while (new Date().getTime() < start + ms); } -Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainManager) { +Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainManager, _web3) { + if (_web3 !== undefined) { + web3 = _web3; + } //this.blockchainConfig = (new Config.Blockchain()).loadConfigFile('config/blockchain.yml').config(env); this.blockchainConfig = blockchainConfig; this.chainManager = chainManager; @@ -22,7 +25,9 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainMa this.deployedContracts = {}; try { - web3.setProvider(new web3.providers.HttpProvider("http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort)); + if (_web3 === undefined) { + web3.setProvider(new web3.providers.HttpProvider("http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort)); + } primaryAddress = web3.eth.coinbase; web3.eth.defaultAccount = primaryAddress; } catch (e) { @@ -185,14 +190,16 @@ Deploy.prototype.execute_cmds = function(cmds) { } } -Deploy.prototype.generate_abi_file = function(web3) { - var result; +Deploy.prototype.generate_provider_file = function() { + var result = ""; + result = "web3.setProvider(new web3.providers.HttpProvider('http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + "'));"; + result += "web3.eth.defaultAccount = web3.eth.accounts[0];"; - result = ""; - if (web3 === undefined) { - result = "web3.setProvider(new web3.providers.HttpProvider('http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + "'));"; - result += "web3.eth.defaultAccount = web3.eth.accounts[0];"; - } + return result; +} + +Deploy.prototype.generate_abi_file = function() { + var result = ""; for(className in this.deployedContracts) { var deployedContract = this.deployedContracts[className]; diff --git a/lib/index.js b/lib/index.js index b41ba260..19bb8b7c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -19,11 +19,17 @@ var Compiler = require('./compiler.js'); var ChainManager = require('./chain_manager.js'); Embark = { - init: function() { + init: function(_web3) { this.blockchainConfig = (new Config.Blockchain()); this.compiler = (new Compiler(this.blockchainConfig)); this.contractsConfig = (new Config.Contracts(this.blockchainConfig, this.compiler)); - this.chainManager = (new ChainManager()); + if (_web3 !== undefined) { + this.web3 = _web3; + } + else { + this.web3 = web3; + } + this.chainManager = (new ChainManager(this.web3)); }, //tests: function() { @@ -45,14 +51,18 @@ Embark = { return chain.getStartChainCommand(use_tmp); }, - deployContracts: function(env, contractFiles, destFile, chainFile, cb) { + deployContracts: function(env, contractFiles, destFile, chainFile, withProvider, cb) { this.contractsConfig.init(contractFiles, env); this.chainManager.loadConfigFile(chainFile) - var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig, this.chainManager); + var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig, this.chainManager, this.web3); deploy.deploy_contracts(env, function() { console.log("contracts deployed; generating abi file"); - var result = deploy.generate_abi_file(); + var result = "" + if (withProvider) { + result += deploy.generate_provider_file(); + } + result += deploy.generate_abi_file(); cb(result); }); }, From b4d659a3d157471ced71b65cf9d4e0656ab9703c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 10:57:30 -0400 Subject: [PATCH 19/39] move spec code to lib --- demo/spec/contracts/simple_storage_spec.js | 27 ++------------------ lib/index.js | 8 ++++-- lib/test.js | 29 ++++++++++++++++++++++ package.json | 4 +-- 4 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 lib/test.js diff --git a/demo/spec/contracts/simple_storage_spec.js b/demo/spec/contracts/simple_storage_spec.js index 7d34c913..71d654e4 100644 --- a/demo/spec/contracts/simple_storage_spec.js +++ b/demo/spec/contracts/simple_storage_spec.js @@ -1,31 +1,8 @@ -var Embark = require('embark-framework'); -var ethersim = require('ethersim'); -var web3 = require('web3'); - -var Manager = ethersim.Manager; -var Provider = ethersim.Provider; - -var manager = new Manager(); -web3.setProvider(new Provider(manager)); - -Embark.init(web3); -Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); -Embark.contractsConfig.loadConfigFile('config/contracts.yml'); - -var files = ["app/contracts/simple_storage.sol"]; - -Embark.contractsConfig.init(files, 'development'); - -console.log("initializing"); +var EmbarkSpec = require('embark-framework').test; describe("SimpleStorage", function() { beforeAll(function(done) { - Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, function(abi) { - console.log("return abi"); - console.log(abi); - eval(abi); - done(); - }); + EmbarkSpec(done); //SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]); }); diff --git a/lib/index.js b/lib/index.js index 19bb8b7c..39986509 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,7 +5,6 @@ var shelljs_global = require('shelljs/global'); var web3 = require('web3'); var commander = require('commander'); var wrench = require('wrench'); -var python = require('python'); var syncMe = require('sync-me'); var methodmissing = require('methodmissing'); var jasmine = require('jasmine'); @@ -17,6 +16,7 @@ var Release = require('./ipfs.js'); var Config = require('./config/config.js'); var Compiler = require('./compiler.js'); var ChainManager = require('./chain_manager.js'); +var Test = require('./test.js'); Embark = { init: function(_web3) { @@ -72,7 +72,11 @@ Embark = { chain.execGeth(args); }, - release: Release + release: Release, + + test: function(cb) { + var tests = new Test(cb); + } } module.exports = Embark; diff --git a/lib/test.js b/lib/test.js new file mode 100644 index 00000000..d62cdd58 --- /dev/null +++ b/lib/test.js @@ -0,0 +1,29 @@ +var ethersim = require('ethersim'); +var web3 = require('web3'); + +Test = function(cb) { + var Manager = ethersim.Manager; + var Provider = ethersim.Provider; + + var manager = new Manager(); + web3.setProvider(new Provider(manager)); + + Embark.init(web3); + Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); + Embark.contractsConfig.loadConfigFile('config/contracts.yml'); + + var files = ["app/contracts/simple_storage.sol"]; + + Embark.contractsConfig.init(files, 'development'); + + Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, function(abi) { + console.log("return abi"); + console.log(abi); + eval(abi); + cb(); + }); +} + +//Test.prototype.deploy_contract = function(className, params) + +module.exports = Test; diff --git a/package.json b/package.json index 3d693ce6..9fdaea59 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,14 @@ "meteor-build-client": "^0.1.6", "methodmissing": "^0.0.3", "mkdirp": "^0.5.1", - "python": "^0.0.4", "read-yaml": "^1.0.0", "shelljs": "^0.5.0", "solc": "^0.1.3-2", "sync-me": "^0.1.1", "toposort": "^0.2.10", "web3": "^0.8.1", - "wrench": "^1.5.8" + "wrench": "^1.5.8", + "ethersim": "/Users/iurimatias/Projects/projects/EtherSim" }, "author": "Iuri Matias ", "contributors": [], From fb2fbca8f7c391f56722dd4725f497b80eb29b49 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 11:01:55 -0400 Subject: [PATCH 20/39] remove hashmerge dependency --- lib/index.js | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 39986509..903a14b2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,3 @@ -var hashmerge = require('hashmerge'); var readYaml = require('read-yaml'); var shelljs = require('shelljs'); var shelljs_global = require('shelljs/global'); diff --git a/package.json b/package.json index 9fdaea59..198074ac 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "dependencies": { "commander": "^2.8.1", "grunt": "^0.4.5", - "hashmerge": "^1.0.2", "jasmine": "^2.3.1", "js-sha3": "^0.3.1", "meteor-build-client": "^0.1.6", From 0e867c2a03dbf71de69139643515c2b280afff98 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 11:03:02 -0400 Subject: [PATCH 21/39] remove jasmine dependency --- lib/index.js | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 903a14b2..fdfd6b9f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,7 +6,6 @@ var commander = require('commander'); var wrench = require('wrench'); var syncMe = require('sync-me'); var methodmissing = require('methodmissing'); -var jasmine = require('jasmine'); //var Tests = require('./test.js'); var Blockchain = require('./blockchain.js'); diff --git a/package.json b/package.json index 198074ac..20836c5d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "dependencies": { "commander": "^2.8.1", "grunt": "^0.4.5", - "jasmine": "^2.3.1", "js-sha3": "^0.3.1", "meteor-build-client": "^0.1.6", "methodmissing": "^0.0.3", From 2be2a80c315b1125737aec38926905d5391de4c4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 11:05:43 -0400 Subject: [PATCH 22/39] remove method missing dependency --- lib/index.js | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index fdfd6b9f..842fd3e5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,7 +5,6 @@ var web3 = require('web3'); var commander = require('commander'); var wrench = require('wrench'); var syncMe = require('sync-me'); -var methodmissing = require('methodmissing'); //var Tests = require('./test.js'); var Blockchain = require('./blockchain.js'); diff --git a/package.json b/package.json index 20836c5d..21c3606b 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "grunt": "^0.4.5", "js-sha3": "^0.3.1", "meteor-build-client": "^0.1.6", - "methodmissing": "^0.0.3", "mkdirp": "^0.5.1", "read-yaml": "^1.0.0", "shelljs": "^0.5.0", From a7da9bc3c52a15525588a919d14877f4deb5d0a0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 11:09:26 -0400 Subject: [PATCH 23/39] remove sync-me dependency --- lib/index.js | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 842fd3e5..f3229654 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,7 +4,6 @@ var shelljs_global = require('shelljs/global'); var web3 = require('web3'); var commander = require('commander'); var wrench = require('wrench'); -var syncMe = require('sync-me'); //var Tests = require('./test.js'); var Blockchain = require('./blockchain.js'); diff --git a/package.json b/package.json index 21c3606b..750beabb 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "read-yaml": "^1.0.0", "shelljs": "^0.5.0", "solc": "^0.1.3-2", - "sync-me": "^0.1.1", "toposort": "^0.2.10", "web3": "^0.8.1", "wrench": "^1.5.8", From 38445c9e7fe34ee59012374fa5dad50824ad5326 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 13:20:35 -0400 Subject: [PATCH 24/39] fix deployment --- lib/chain_manager.js | 13 +++---------- lib/deploy.js | 41 ++++++++++------------------------------- lib/index.js | 10 +++------- lib/test.js | 2 +- 4 files changed, 17 insertions(+), 49 deletions(-) diff --git a/lib/chain_manager.js b/lib/chain_manager.js index ca8cff78..1e909a7c 100644 --- a/lib/chain_manager.js +++ b/lib/chain_manager.js @@ -1,12 +1,10 @@ var fs = require('fs'); -var web3 = require('web3'); var sha3_256 = require('js-sha3').sha3_256; -ChainManager = function(_web3) { +ChainManager = function() { this.chainManagerConfig = {}; this.currentChain = {}; this.file = ""; - this.web3 = _web3; } ChainManager.prototype.loadConfigFile = function(filename) { @@ -25,12 +23,8 @@ ChainManager.prototype.loadConfig = function(config) { return this; }; -ChainManager.prototype.init = function(env, config) { - if (this.web3 === undefined) { - web3.setProvider(new web3.providers.HttpProvider("http://" + config.rpcHost + ":" + config.rpcPort)); - } - - var block = this.web3.eth.getBlock(0); +ChainManager.prototype.init = function(env, config, web3) { + var block = web3.eth.getBlock(0); if(!block){ throw new Error("Cannot get the genesis block, is embark blockchain running ?"); } @@ -41,7 +35,6 @@ ChainManager.prototype.init = function(env, config) { } this.currentChain = this.chainManagerConfig[chainId]; - //this.web3 = web3; } ChainManager.prototype.addContract = function(contractName, code, args, address) { diff --git a/lib/deploy.js b/lib/deploy.js index 7e2c9354..dfebb4aa 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -4,28 +4,17 @@ var grunt = require('grunt'); var readYaml = require('read-yaml'); var Config = require('./config/config.js'); -// Ugly, but sleep lib has issues on osx -sleep = function sleep(ms) { - var start = new Date().getTime(); - while (new Date().getTime() < start + ms); -} - -Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainManager, _web3) { +Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainManager, withProvider, withChain, _web3) { if (_web3 !== undefined) { web3 = _web3; } - //this.blockchainConfig = (new Config.Blockchain()).loadConfigFile('config/blockchain.yml').config(env); - this.blockchainConfig = blockchainConfig; - this.chainManager = chainManager; - this.chainManager.init(env, this.blockchainConfig); - - //this.contractsManager = (new Config.Contracts(contractFiles, blockchainConfig)).loadConfigFile('config/contracts.yml'); this.contractsManager = contractsConfig; this.contractsConfig = this.contractsManager.config(env); this.deployedContracts = {}; + this.blockchainConfig = blockchainConfig; try { - if (_web3 === undefined) { + if (withProvider) { web3.setProvider(new web3.providers.HttpProvider("http://" + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort)); } primaryAddress = web3.eth.coinbase; @@ -34,6 +23,10 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainMa throw new Error("==== can't connect to " + this.blockchainConfig.rpcHost + ":" + this.blockchainConfig.rpcPort + " check if an ethereum node is running"); } + this.chainManager = chainManager; + this.chainManager.init(env, this.blockchainConfig, web3); + this.withChain = withChain; + console.log("primary account address is : " + primaryAddress); }; @@ -55,18 +48,6 @@ Deploy.prototype.deploy_contract = function(contractObject, contractParams, cb) contractParams.push(callback); contractObject["new"].apply(contractObject, contractParams); - - //var transactionHash = contractObject["new"].apply(contractObject, contractParams).transactionHash; - //var receipt = null; - //var time = 0; - //while ((receipt = web3.eth.getTransactionReceipt(transactionHash)) === null || receipt.contractAddress === null) { - // sleep(1000); - // time += 1; - // if (time >= this.blockchainConfig.deployTimeout) { - // return false; - // } - //} - //return receipt; } Deploy.prototype.deploy_contracts = function(env, cb) { @@ -114,7 +95,6 @@ Deploy.prototype.deploy_a_contract = function(env, className, cb) { if (contract.address !== undefined) { this.deployedContracts[className] = contract.address; - //console.log("contract " + className + " at " + contractAddress); console.log("contract " + className + " at " + contract.address); cb(); } @@ -154,7 +134,9 @@ Deploy.prototype.deploy_a_contract = function(env, className, cb) { else { console.log("deployed " + className + " at " + contractAddress); _this.chainManager.addContract(className, contract.compiled.code, realArgs, contractAddress); - _this.chainManager.save(); + if (_this.withChain) { + _this.chainManager.save(); + } } _this.deployedContracts[className] = contractAddress; @@ -164,9 +146,6 @@ Deploy.prototype.deploy_a_contract = function(env, className, cb) { cb(); }); - //while((receipt = this.deploy_contract(contractObject, contractParams)) === false) { - // console.log("timeout... failed to deploy contract.. retrying..."); - //} } } }; diff --git a/lib/index.js b/lib/index.js index f3229654..844334ab 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,13 +25,9 @@ Embark = { else { this.web3 = web3; } - this.chainManager = (new ChainManager(this.web3)); + this.chainManager = (new ChainManager()); }, - //tests: function() { - // return new Tests(); - //}, - startBlockchain: function(env, use_tmp) { var chain = new Blockchain(this.blockchainConfig.config(env)); chain.startChain(use_tmp); @@ -47,11 +43,11 @@ Embark = { return chain.getStartChainCommand(use_tmp); }, - deployContracts: function(env, contractFiles, destFile, chainFile, withProvider, cb) { + deployContracts: function(env, contractFiles, destFile, chainFile, withProvider, withChain, cb) { this.contractsConfig.init(contractFiles, env); this.chainManager.loadConfigFile(chainFile) - var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig, this.chainManager, this.web3); + var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig, this.chainManager, withProvider, withChain, this.web3); deploy.deploy_contracts(env, function() { console.log("contracts deployed; generating abi file"); var result = "" diff --git a/lib/test.js b/lib/test.js index d62cdd58..bd9a04a1 100644 --- a/lib/test.js +++ b/lib/test.js @@ -16,7 +16,7 @@ Test = function(cb) { Embark.contractsConfig.init(files, 'development'); - Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, function(abi) { + Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, false, function(abi) { console.log("return abi"); console.log(abi); eval(abi); From 5628089865c4e8a39df2078c002632c19298bddd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 9 Oct 2015 13:31:09 -0400 Subject: [PATCH 25/39] fix deployment in binary --- bin/embark | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/embark b/bin/embark index f633663e..d0f897cc 100755 --- a/bin/embark +++ b/bin/embark @@ -14,7 +14,7 @@ var run = function(cmd) { } } -var deploy = function(env, embarkConfig) { +var deploy = function(env, embarkConfig, cb) { var contractFiles = grunt.file.expand(embarkConfig.contracts); var destFile = embarkConfig.output; @@ -24,8 +24,10 @@ var deploy = function(env, embarkConfig) { var chainFile = Embark.blockchainConfig.blockchainConfig[env].chains || embarkConfig.chains || './chains.json'; - abi = Embark.deployContracts(env, contractFiles, destFile, chainFile); - grunt.file.write(destFile, abi); + abi = Embark.deployContracts(env, contractFiles, destFile, chainFile, true, true, function(abi) { + grunt.file.write(destFile, abi); + cb(); + }); } program @@ -53,7 +55,7 @@ program.command('deploy [env]').description('deploy contracts').action(function( run("grunt deploy_contracts:" + env); } else { - deploy(env, embarkConfig); + deploy(env, embarkConfig, function() {}); } }); From da9c705f7f9715ab9cad7c8b28711924f08541ff Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 09:09:11 -0400 Subject: [PATCH 26/39] add embark simulator cmd --- bin/embark | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/embark b/bin/embark index d0f897cc..476897cd 100755 --- a/bin/embark +++ b/bin/embark @@ -6,6 +6,7 @@ var wrench = require('wrench'); var grunt = require('grunt'); require('shelljs/global'); var readYaml = require('read-yaml'); +var EtherSim = require('ethersim'); var Embark = require('..'); var run = function(cmd) { @@ -172,10 +173,14 @@ program.command('meteor_demo').description('create a working meteor dapp with a console.log('\n\ninit complete'); }); +program.command('simulator').description('run a fast ethereum rpc simulator').action(function() { + EtherSim.startServer(); +}); + program.parse(process.argv) if (!process.argv.slice(2).length) { program.outputHelp(); } -exit(); +//exit(); From d33d986f36d9eb6b44021db1a2c0341ae65b51d3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 10:50:52 -0400 Subject: [PATCH 27/39] update specs --- bin/embark | 7 +++--- boilerplate/spec/support/jasmine.json | 9 -------- demo/spec/contracts/simple_storage_spec.js | 26 ---------------------- demo/spec/support/jasmine.json | 9 -------- demo/test/simple_storage_spec.js | 26 ++++++++++++++++++++++ lib/deploy.js | 6 ----- lib/index.js | 7 ++++-- lib/test.js | 25 +++++++++------------ 8 files changed, 45 insertions(+), 70 deletions(-) delete mode 100644 boilerplate/spec/support/jasmine.json delete mode 100644 demo/spec/contracts/simple_storage_spec.js delete mode 100644 demo/spec/support/jasmine.json create mode 100644 demo/test/simple_storage_spec.js diff --git a/bin/embark b/bin/embark index 476897cd..f1bf7744 100755 --- a/bin/embark +++ b/bin/embark @@ -108,15 +108,16 @@ program.command('run [env]').description('run dapp').action(function(env_) { } }); -program.command('spec').description('run specs').action(function() { +program.command('spec').description('run tests').action(function() { var embarkConfig = readYaml.sync("./embark.yml"); if (embarkConfig.type === "grunt") { - run('jasmine'); + run('mocha'); } else { console.log("command not available in meteor or manual mode yet"); console.log("note: you can use embark tests with any framework"); + console.log("try running mocha test/"); } }); @@ -158,7 +159,7 @@ program.command('demo').description('create a working dapp with a SimpleStorage wrench.copyDirSyncRecursive(boilerPath, targetDir); wrench.copyDirSyncRecursive(demoPath + "/app", targetDir + "/app", {forceDelete: true}); wrench.copyDirSyncRecursive(demoPath + "/config", targetDir + "/config", {forceDelete: true}); - wrench.copyDirSyncRecursive(demoPath + "/spec", targetDir + "/spec", {forceDelete: true}); + wrench.copyDirSyncRecursive(demoPath + "/test", targetDir + "/test", {forceDelete: true}); cd(targetDir); run('npm install'); diff --git a/boilerplate/spec/support/jasmine.json b/boilerplate/spec/support/jasmine.json deleted file mode 100644 index a5f29329..00000000 --- a/boilerplate/spec/support/jasmine.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ] -} diff --git a/demo/spec/contracts/simple_storage_spec.js b/demo/spec/contracts/simple_storage_spec.js deleted file mode 100644 index 71d654e4..00000000 --- a/demo/spec/contracts/simple_storage_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -var EmbarkSpec = require('embark-framework').test; - -describe("SimpleStorage", function() { - beforeAll(function(done) { - EmbarkSpec(done); - //SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]); - }); - - it("should set constructor value", function(done) { - SimpleStorage.storedData(function(err, result) { - expect(result.toNumber()).toEqual(100); - done(); - }); - }); - - it("set storage value", function(done) { - SimpleStorage.set(150, function() { - SimpleStorage.get(function(err, result) { - console.log(arguments); - expect(result.toNumber()).toEqual(150); - done(); - }); - }); - }); - -}) diff --git a/demo/spec/support/jasmine.json b/demo/spec/support/jasmine.json deleted file mode 100644 index a5f29329..00000000 --- a/demo/spec/support/jasmine.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "spec_dir": "spec", - "spec_files": [ - "**/*[sS]pec.js" - ], - "helpers": [ - "helpers/**/*.js" - ] -} diff --git a/demo/test/simple_storage_spec.js b/demo/test/simple_storage_spec.js new file mode 100644 index 00000000..916c4c5e --- /dev/null +++ b/demo/test/simple_storage_spec.js @@ -0,0 +1,26 @@ +var assert = require('assert'); +var Embark = require('embark-framework'); +var EmbarkSpec = Embark.initTests(); + +describe("SimpleStorage", function(done) { + before(function(done) { + EmbarkSpec.deployAll(done); + }); + + it("should set constructor value", function(done) { + SimpleStorage.storedData(function(err, result) { + assert.equal(result.toNumber(), 100); + done(); + }); + }); + + it("set storage value", function(done) { + SimpleStorage.set(150, function() { + SimpleStorage.get(function(err, result) { + assert.equal(result.toNumber(), 150); + done(); + }); + }); + }); + +}) diff --git a/lib/deploy.js b/lib/deploy.js index dfebb4aa..0c6087e2 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -31,12 +31,8 @@ Deploy = function(env, contractFiles, blockchainConfig, contractsConfig, chainMa }; Deploy.prototype.deploy_contract = function(contractObject, contractParams, cb) { - console.log("called deploy_contract"); var callback = function(e, contract) { - console.log("got receipt"); - console.log(arguments); if(!e && contract.address !== undefined) { - console.log("Contract mined! Address: " + contract.address); cb(contract.address); } else { @@ -123,8 +119,6 @@ Deploy.prototype.deploy_a_contract = function(env, className, cb) { var _this = this; this.deploy_contract(contractObject, contractParams, function(contractAddress) { - console.log("response!"); - if (web3.eth.getCode(contractAddress) === "0x") { console.log("========="); console.log("contract was deployed at " + contractAddress + " but doesn't seem to be working"); diff --git a/lib/index.js b/lib/index.js index 844334ab..e27f4c1c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -66,8 +66,11 @@ Embark = { release: Release, - test: function(cb) { - var tests = new Test(cb); + initTests: function() { + var files = ["app/contracts/simple_storage.sol"]; + var tests = new Test(files, 'development'); + + return tests; } } diff --git a/lib/test.js b/lib/test.js index bd9a04a1..ce474a50 100644 --- a/lib/test.js +++ b/lib/test.js @@ -1,29 +1,24 @@ var ethersim = require('ethersim'); var web3 = require('web3'); -Test = function(cb) { - var Manager = ethersim.Manager; - var Provider = ethersim.Provider; +Test = function(contractFiles, _env) { + this.env = _env || 'development'; + this.web3 = web3; + this.web3.setProvider(ethersim.web3Provider()); + this.contractFiles = contractFiles; - var manager = new Manager(); - web3.setProvider(new Provider(manager)); - - Embark.init(web3); + Embark.init(this.web3); Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); Embark.contractsConfig.loadConfigFile('config/contracts.yml'); - var files = ["app/contracts/simple_storage.sol"]; + Embark.contractsConfig.init(this.contractFiles, this.env); +} - Embark.contractsConfig.init(files, 'development'); - - Embark.deployContracts('development', files, "/tmp/abi.js", "chains.json", false, false, function(abi) { - console.log("return abi"); - console.log(abi); +Test.prototype.deployAll = function(cb) { + Embark.deployContracts('development', this.contractFiles, "/tmp/abi.js", "chains.json", false, false, function(abi) { eval(abi); cb(); }); } -//Test.prototype.deploy_contract = function(className, params) - module.exports = Test; From d45f76beec1d30ebd0302a4c1305b14eb89e97cf Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 12:25:43 -0400 Subject: [PATCH 28/39] read embark config file to get contract files for testing --- bin/embark | 2 +- lib/index.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/embark b/bin/embark index f1bf7744..c160911a 100755 --- a/bin/embark +++ b/bin/embark @@ -112,7 +112,7 @@ program.command('spec').description('run tests').action(function() { var embarkConfig = readYaml.sync("./embark.yml"); if (embarkConfig.type === "grunt") { - run('mocha'); + run('mocha test/ --no-timeouts'); } else { console.log("command not available in meteor or manual mode yet"); diff --git a/lib/index.js b/lib/index.js index e27f4c1c..cd0a9209 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,6 +4,7 @@ var shelljs_global = require('shelljs/global'); var web3 = require('web3'); var commander = require('commander'); var wrench = require('wrench'); +var grunt = require('grunt'); //var Tests = require('./test.js'); var Blockchain = require('./blockchain.js'); @@ -67,8 +68,10 @@ Embark = { release: Release, initTests: function() { - var files = ["app/contracts/simple_storage.sol"]; - var tests = new Test(files, 'development'); + var embarkConfig = readYaml.sync("./embark.yml"); + var fileExpression = embarkConfig.contracts || ["app/contracts/**/*.sol", "app/contracts/**/*.se"]; + var contractFiles = grunt.file.expand(fileExpression); + var tests = new Test(contractFiles, 'development'); return tests; } From 82b9af2a14fb82a67c00f74de90297e764bbc55a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 17:49:54 -0400 Subject: [PATCH 29/39] get test config files from embark config --- lib/index.js | 5 ++++- lib/test.js | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index cd0a9209..5f02c392 100644 --- a/lib/index.js +++ b/lib/index.js @@ -71,7 +71,10 @@ Embark = { var embarkConfig = readYaml.sync("./embark.yml"); var fileExpression = embarkConfig.contracts || ["app/contracts/**/*.sol", "app/contracts/**/*.se"]; var contractFiles = grunt.file.expand(fileExpression); - var tests = new Test(contractFiles, 'development'); + var blockchainFile = embarkConfig.blockchainConfig || 'config/blockchain.yml'; + var contractFile = embarkConfig.contractsConfig || 'config/contracts.yml'; + + var tests = new Test(contractFiles, blockchainFile, contractFile, 'development'); return tests; } diff --git a/lib/test.js b/lib/test.js index ce474a50..bb7e8362 100644 --- a/lib/test.js +++ b/lib/test.js @@ -1,15 +1,15 @@ var ethersim = require('ethersim'); var web3 = require('web3'); -Test = function(contractFiles, _env) { +Test = function(contractFiles, blockchainFile, contractFile, _env) { this.env = _env || 'development'; this.web3 = web3; this.web3.setProvider(ethersim.web3Provider()); this.contractFiles = contractFiles; Embark.init(this.web3); - Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); - Embark.contractsConfig.loadConfigFile('config/contracts.yml'); + Embark.blockchainConfig.loadConfigFile(blockchainFile); + Embark.contractsConfig.loadConfigFile(contractFile); Embark.contractsConfig.init(this.contractFiles, this.env); } From a9fbce7f5b350facd3c2859d836617a57c595ac8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 18:22:59 -0400 Subject: [PATCH 30/39] use embark 1.0.0 --- boilerplate/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boilerplate/package.json b/boilerplate/package.json index e82b7d0f..7fa068e2 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,8 +10,8 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^0.9.3", - "grunt-embark": "^0.4.3", + "embark-framework": "1.0.0-beta.1", + "grunt-embark": "0.5.0", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", "grunt-contrib-concat": "^0.5.1", @@ -21,6 +21,7 @@ "grunt": "^0.4.5", "grunt-cli": "^0.1.13", "matchdep": "^0.3.0", + "mocha": "^2.2.5", "express": "^4.12.3", "read-yaml": "^1.0.0", "compression": "^1.4.3" From ea3f3ee3b058457c6cceabaf1650b00fe456341e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 18:33:00 -0400 Subject: [PATCH 31/39] update readme --- README.md | 63 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 88d3b449..35e3381f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +This Readme applies to Embark 1.0.0 Beta which is currently under development. For the old version please check the old [readme](https://github.com/iurimatias/embark-framework/blob/0.9.3/README.md) + What is embark ====== @@ -11,18 +13,18 @@ With Embark you can: * Do Test Driven Development with Contracts using Javascript. * Easily deploy to & use decentralized systems such as IPFS. * Keep track of deployed contracts, deploy only when truly needed. +* Manage different chains (e.g testnet, private net, livenet) * Quickly create advanced DApps using multiple contracts. See the [Wiki](https://github.com/iurimatias/embark-framework/wiki) for more details. Installation ====== -Requirements: geth (1.0.0), solc (0.1.0) or serpent (develop), node (0.12.2) and npm - -For specs: pyethereum, ethertdd.py +Requirements: geth (1.0.0), node (0.12.2) and npm +Optional: serpent (develop) if using contracts with Serpent ```Bash -$ npm install -g embark-framework grunt-cli +$ npm install -g embark-framework ``` See [Complete Installation Instructions](https://github.com/iurimatias/embark-framework/wiki/Installation). @@ -35,11 +37,19 @@ You can easily create a sample working DApp with the following: $ embark demo $ cd embark_demo ``` -To run the ethereum node for development purposes simply run: + +To run a ethereum rpc simulator simply run: + +```Bash +$ embark simulator +``` + +Or Alternatively, you can run a REAL ethereum node for development purposes: ```Bash $ embark blockchain ``` + By default embark blockchain will mine a minimum amount of ether and will only mine when new transactions come in. This is quite usefull to keep a low CPU. The option can be configured at config/blockchain.yml Then, in another command line: @@ -199,42 +209,41 @@ You can also define contract interfaces (Stubs) and actions to do on deployment Tests ====== -You can run specs with ```embark spec```, it will run any files ending *_spec.js under ```spec/```. +You can run specs with ```embark spec```, it will run any test files under ```test/```. Embark includes a testing lib to fastly run & test your contracts in a EVM. ```Javascript -# spec/contracts/simple_storage_spec.js -Embark = require('embark-framework'); -Embark.init(); -Embark.blockchainConfig.loadConfigFile('config/blockchain.yml'); -Embark.contractsConfig.loadConfigFile('config/contracts.yml'); +# test/simple_storage_spec.js +var assert = require('assert'); +var Embark = require('embark-framework'); +var EmbarkSpec = Embark.initTests(); -var files = ['app/contracts/simpleStorage.sol']; -Embark.contractsConfig.init(files, 'development'); - -var EmbarkSpec = Embark.tests(files); - -describe("SimpleStorage", function() { - beforeAll(function() { - // equivalent to initializing SimpleStorage with param 150 - SimpleStorage = EmbarkSpec.request("SimpleStorage", [150]); +describe("SimpleStorage", function(done) { + before(function(done) { + EmbarkSpec.deployAll(done); }); - it("should set constructor value", function() { - expect(SimpleStorage.storedData()).toEqual('150'); + it("should set constructor value", function(done) { + SimpleStorage.storedData(function(err, result) { + assert.equal(result.toNumber(), 100); + done(); + }); }); - it("set storage value", function() { - SimpleStorage.set(100); - expect(SimpleStorage.get()).toEqual('100'); + it("set storage value", function(done) { + SimpleStorage.set(150, function() { + SimpleStorage.get(function(err, result) { + assert.equal(result.toNumber(), 150); + done(); + }); + }); }); }) ``` -Embark uses [Jasmine](https://jasmine.github.io/2.3/introduction.html) by default, but you can use any testing framework you want. - +Embark uses [Mocha](http://mochajs.org/) by default, but you can use any testing framework you want. Working with different chains ====== From 75da13754941ea27edad14a663a14e2355902510 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 18:33:19 -0400 Subject: [PATCH 32/39] update to 1.0.0-beta.1 --- bin/embark | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/embark b/bin/embark index c160911a..5d4e7e5e 100755 --- a/bin/embark +++ b/bin/embark @@ -32,7 +32,7 @@ var deploy = function(env, embarkConfig, cb) { } program - .version('0.9.3') + .version('1.0.0-beta.1'); program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/package.json b/package.json index 750beabb..d0aeee5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "0.9.3", + "version": "1.0.0-beta.1", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From f6f05450bb4f3206a8dc0303160df01ee8151cfd Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 18:40:24 -0400 Subject: [PATCH 33/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35e3381f..5e0f7c9e 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Requirements: geth (1.0.0), node (0.12.2) and npm Optional: serpent (develop) if using contracts with Serpent ```Bash -$ npm install -g embark-framework +$ npm -g install embark-framework@1.0.0-beta.1 ``` See [Complete Installation Instructions](https://github.com/iurimatias/embark-framework/wiki/Installation). From 5cf452911323953f1a1bc4b6584bbbe9e472812f Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 18:52:30 -0400 Subject: [PATCH 34/39] update to 1.0.0 --- bin/embark | 2 +- boilerplate/package.json | 4 ++-- package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/embark b/bin/embark index 5d4e7e5e..11f20cd4 100755 --- a/bin/embark +++ b/bin/embark @@ -32,7 +32,7 @@ var deploy = function(env, embarkConfig, cb) { } program - .version('1.0.0-beta.1'); + .version('1.0.0'); program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/boilerplate/package.json b/boilerplate/package.json index 7fa068e2..31bbd5c7 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,8 +10,8 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "1.0.0-beta.1", - "grunt-embark": "0.5.0", + "embark-framework": "^1.0.0", + "grunt-embark": "^0.5.1", "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 d0aeee5b..74fc1432 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "1.0.0-beta.1", + "version": "1.0.0", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -24,7 +24,7 @@ "toposort": "^0.2.10", "web3": "^0.8.1", "wrench": "^1.5.8", - "ethersim": "/Users/iurimatias/Projects/projects/EtherSim" + "ethersim": "^0.1.0" }, "author": "Iuri Matias ", "contributors": [], From f42652f8f5d8bd14cd6dc308ee0fe8f0083bc4e5 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 18:54:30 -0400 Subject: [PATCH 35/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e0f7c9e..ad8b155d 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ See the [Wiki](https://github.com/iurimatias/embark-framework/wiki) for more det Installation ====== -Requirements: geth (1.0.0), node (0.12.2) and npm +Requirements: geth (1.1.3 or higher), node (0.12.2) and npm Optional: serpent (develop) if using contracts with Serpent ```Bash From 8b44f4fbe0ada745e9ba5a6d79bdf192202da841 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 12 Oct 2015 19:27:33 -0400 Subject: [PATCH 36/39] update to 1.0.1 --- bin/embark | 2 +- boilerplate/package.json | 2 +- package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/embark b/bin/embark index 11f20cd4..9b699e88 100755 --- a/bin/embark +++ b/bin/embark @@ -32,7 +32,7 @@ var deploy = function(env, embarkConfig, cb) { } program - .version('1.0.0'); + .version('1.0.1'); program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/boilerplate/package.json b/boilerplate/package.json index 31bbd5c7..6ec6d305 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,7 +10,7 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^1.0.0", + "embark-framework": "^1.0.1", "grunt-embark": "^0.5.1", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", diff --git a/package.json b/package.json index 74fc1432..3afd7ac6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "1.0.0", + "version": "1.0.1", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -24,7 +24,7 @@ "toposort": "^0.2.10", "web3": "^0.8.1", "wrench": "^1.5.8", - "ethersim": "^0.1.0" + "ethersim": "^0.1.1" }, "author": "Iuri Matias ", "contributors": [], From 283b26f4b3742ba5340fae5db9d3158086c93221 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 13 Oct 2015 12:00:03 -0400 Subject: [PATCH 37/39] exit embark deploy after contracts are deployed --- bin/embark | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/embark b/bin/embark index 9b699e88..1fc97439 100755 --- a/bin/embark +++ b/bin/embark @@ -56,7 +56,7 @@ program.command('deploy [env]').description('deploy contracts').action(function( run("grunt deploy_contracts:" + env); } else { - deploy(env, embarkConfig, function() {}); + deploy(env, embarkConfig, function() { exit(); }); } }); From 4cd0669819c22b098003ad40e8e80e069012d4c3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 13 Oct 2015 12:01:21 -0400 Subject: [PATCH 38/39] update to 1.0.2 --- bin/embark | 2 +- boilerplate/package.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/embark b/bin/embark index 1fc97439..5cf6f390 100755 --- a/bin/embark +++ b/bin/embark @@ -32,7 +32,7 @@ var deploy = function(env, embarkConfig, cb) { } program - .version('1.0.1'); + .version('1.0.2'); program.command('new [name]').description('New application').action(function(name) { if (name === undefined) { diff --git a/boilerplate/package.json b/boilerplate/package.json index 6ec6d305..addeb674 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,7 +10,7 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^1.0.1", + "embark-framework": "^1.0.2", "grunt-embark": "^0.5.1", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", diff --git a/package.json b/package.json index 3afd7ac6..adfbde25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-framework", - "version": "1.0.1", + "version": "1.0.2", "description": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From d07ddaf1e8012e689123e4d4fafd78d33a82d6e8 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 13 Oct 2015 16:15:51 -0400 Subject: [PATCH 39/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ad8b155d..53b4caf7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Requirements: geth (1.1.3 or higher), node (0.12.2) and npm Optional: serpent (develop) if using contracts with Serpent ```Bash -$ npm -g install embark-framework@1.0.0-beta.1 +$ npm -g install embark-framework ``` See [Complete Installation Instructions](https://github.com/iurimatias/embark-framework/wiki/Installation).