From 2a1ec1b2d7e7d4e16ea06d33783a898af988687f Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Sat, 17 Oct 2015 20:39:15 -0500 Subject: [PATCH 01/39] change back to old compiler --- lib/compiler.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index fddcd6b70..60acd74b6 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -13,25 +13,25 @@ Compiler.prototype.init = function(env) { }; Compiler.prototype.compile_solidity = function(contractFile) { - var source = fs.readFileSync(contractFile).toString(); - var output = solc.compile(source, 1); + var cmd, result, output, version, json, compiled_object; - if(output.errors && output.errors.length>0){ - throw new Error(output.errors[0]); - } + cmd = "solc --input-file " + contractFile + " --combined-json bin,abi"; - var json = output.contracts; + result = exec(cmd, {silent: true}); + output = result.output; - compiled_object = {} + json = JSON.parse(output).contracts; - for (var className in json) { - var contract = json[className]; - - compiled_object[className] = {}; - compiled_object[className].code = contract.bytecode; - compiled_object[className].info = {}; - compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); - } + 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].info = {}; + compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"] || contract["json-abi"]); + } return compiled_object; }; From e0d9931a74053366f4072992076d3361dfe1f8f3 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Sat, 17 Oct 2015 20:53:41 -0500 Subject: [PATCH 02/39] change back to original version of solc --- lib/compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compiler.js b/lib/compiler.js index 60acd74b6..64b1eee36 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -15,7 +15,7 @@ Compiler.prototype.init = function(env) { Compiler.prototype.compile_solidity = function(contractFile) { var cmd, result, output, version, json, compiled_object; - cmd = "solc --input-file " + contractFile + " --combined-json bin,abi"; + cmd = "solc " + contractFile + " --combined-json bin,abi"; result = exec(cmd, {silent: true}); output = result.output; From 63a16961bf947d20a2500d9701b06308d79d41c3 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Sun, 18 Oct 2015 00:17:42 -0500 Subject: [PATCH 03/39] Update package.json --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 53cb9e263..3bfe2faf2 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "mkdirp": "^0.5.1", "read-yaml": "^1.0.0", "shelljs": "^0.5.0", - "solc": "^0.1.3-2", "toposort": "^0.2.10", "web3": "^0.15.0", "wrench": "^1.5.8", From 916437fd4c1cd98e6ef361c04eac1f7a2b405df2 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Sun, 18 Oct 2015 00:21:58 -0500 Subject: [PATCH 04/39] Update compiler.js --- lib/compiler.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 64b1eee36..f274ebb15 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,8 +1,7 @@ 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; From ce36265c3962a717d6f2c8485903edd620c13df2 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 19 Oct 2015 19:51:53 -0400 Subject: [PATCH 05/39] Update blockchain.js --- lib/config/blockchain.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index 8a311d3bd..a6856a21e 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -38,6 +38,7 @@ BlockchainConfig.prototype.config = function(env) { gasLimit: config.gas_limit || 500000, gasPrice: config.gas_price || 10000000000000, rpcWhitelist: config.rpc_whitelist, + mine: config.mine, minerthreads: config.minerthreads, genesisBlock: config.genesis_block, datadir: config.datadir, From 4625fd6b5ad64659415908d38c2d52bb62dfacfd Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 19 Oct 2015 19:54:27 -0400 Subject: [PATCH 06/39] Update blockchain.js --- lib/blockchain.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index cb67b2d1e..bfa4794b5 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -37,10 +37,12 @@ Blockchain.prototype.generate_basic_command = function() { if(config.mine) cmd += "--mine "; - - if (config.genesisBlock !== void 0) { + + if (config.minerthreads !== void 0) + cmd += "--minerthreads \"" + config.minerthreads + "\" "; + + if (config.genesisBlock !== void 0) cmd += "--genesis=\"" + config.genesisBlock + "\" "; - } if (config.whisper) { cmd += "--shh "; @@ -49,7 +51,6 @@ Blockchain.prototype.generate_basic_command = function() { cmd += '--rpcapi "' + rpc_api.join(',') + '" '; - //TODO: this should be configurable cmd += "--maxpeers " + config.maxPeers + " "; if (config.account.password !== void 0) { From c488f69c47f97b34d8d347621700b9896be0d0f7 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 21:48:55 -0500 Subject: [PATCH 07/39] Put in NAT option in boilerplate --- boilerplate/config/blockchain.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index af5168004..21946d1fa 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -26,6 +26,8 @@ staging: bootnodes: boot: false enodes: [] #insert enode urls here. + nat: #NAT port mapping mechanism (any|none|upnp|pmp|extip:) + port: 30303 account: init: false address: @@ -40,6 +42,8 @@ production: bootnodes: boot: false enodes: [] + nat: #NAT port mapping mechanism (any|none|upnp|pmp|extip:) + port: 30303 account: init: false address: From 605352b738dfe7fba27764d5ee4a07d2fe84efe0 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 21:49:37 -0500 Subject: [PATCH 08/39] Get rid of console toggle --- boilerplate/config/blockchain.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 21946d1fa..fcb50bc71 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -10,7 +10,6 @@ development: max_peers: 0 gas_limit: 500000 gas_price: 10000000000000 - console: false account: init: true password: config/password @@ -22,7 +21,6 @@ staging: datadir: default network_id: 0 max_peers: 4 - console: true bootnodes: boot: false enodes: [] #insert enode urls here. @@ -38,7 +36,6 @@ production: datadir: default network_id: 1 max_peers: 4 - console: true bootnodes: boot: false enodes: [] From 76ec8442ee73bf7c5daaf4f041c054cc8ca66b9c Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 22:00:03 -0500 Subject: [PATCH 09/39] Update blockchain.js --- lib/blockchain.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockchain.js b/lib/blockchain.js index bfa4794b5..63218844c 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -20,6 +20,7 @@ Blockchain.prototype.generate_basic_command = function() { cmd += config.geth_extra_opts + " "; } + cmd += "--port " + config.port + " "; cmd += "--rpc "; cmd += "--rpcport " + config.rpcPort + " "; From 482a630294db56fc5b6fb0c57b2d13a3471d5da9 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 22:06:17 -0500 Subject: [PATCH 10/39] changes to bootnodes, kill console toggle option --- lib/blockchain.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index 63218844c..8e26736cc 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -81,15 +81,13 @@ Blockchain.prototype.run_command = function(address, use_tmp) { cmd += "--unlock " + address + " "; } - if (config.bootNodes !== undefined && config.bootNodes.boot == true){ - cmd += "--bootnodes "; + if (config.bootNodes.boot == true){ + cmd += "--bootnodes \""; for (var i = 0; i < config.bootNodes.enodes.length; i++){ - cmd += config.bootNodes.enodes[i] + " "; + cmd += config.bootNodes.enodes[i]; + if (i != config.bootNodes.enodes.lenth - 1) cmd += " "; } - } - - if (config.console_toggle) { - cmd += "console"; + cmd += "\""; } if (config.mine_when_needed) { From 94276e84073269934857b5a1d84df85a76b7d074 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 22:08:12 -0500 Subject: [PATCH 11/39] changes to rpc_api --- lib/blockchain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index 8e26736cc..45b748ae1 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -9,7 +9,7 @@ Blockchain.prototype.generate_basic_command = function() { var address = config.account.address; var cmd = "geth "; - var rpc_api = ['eth', 'web3']; + var rpc_api = ['eth', 'web3', 'admin', 'net', 'miner']; if (config.datadir !== "default") { cmd += "--datadir=\"" + config.datadir + "\" "; From ac268c0cd7e0d6d13858bd16fefffa0d54becd09 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 23:07:52 -0500 Subject: [PATCH 12/39] add NAT options --- lib/blockchain.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/blockchain.js b/lib/blockchain.js index 45b748ae1..1a986df08 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -80,6 +80,10 @@ Blockchain.prototype.run_command = function(address, use_tmp) { if (address !== void 0) { cmd += "--unlock " + address + " "; } + + if (config.nat !== "any"){ + cmd += "--nat \"" + config.nat "\""; + } if (config.bootNodes.boot == true){ cmd += "--bootnodes \""; From 6567706cfa62cc86a9930ab4e891b3d3e93f1020 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 20 Oct 2015 23:08:28 -0500 Subject: [PATCH 13/39] Update blockchain.yml --- boilerplate/config/blockchain.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index fcb50bc71..398835a1a 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -24,7 +24,7 @@ staging: bootnodes: boot: false enodes: [] #insert enode urls here. - nat: #NAT port mapping mechanism (any|none|upnp|pmp|extip:) + nat: any #NAT port mapping mechanism (any|none|upnp|pmp|extip:) port: 30303 account: init: false @@ -39,7 +39,7 @@ production: bootnodes: boot: false enodes: [] - nat: #NAT port mapping mechanism (any|none|upnp|pmp|extip:) + nat: any #NAT port mapping mechanism (any|none|upnp|pmp|extip:) port: 30303 account: init: false From 1228a639e740040fce5067b38072442a2a06a0ad Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Wed, 21 Oct 2015 00:06:06 -0500 Subject: [PATCH 14/39] update config --- lib/config/blockchain.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index a6856a21e..1cc9dd82b 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -38,6 +38,7 @@ BlockchainConfig.prototype.config = function(env) { gasLimit: config.gas_limit || 500000, gasPrice: config.gas_price || 10000000000000, rpcWhitelist: config.rpc_whitelist, + nat: config.nat, mine: config.mine, minerthreads: config.minerthreads, genesisBlock: config.genesis_block, From 2c1804d01f3aa826e1a71a22672b862572774cb0 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Wed, 21 Oct 2015 09:29:30 -0500 Subject: [PATCH 15/39] Update blockchain.js --- lib/blockchain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index 1a986df08..52695c06d 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -82,7 +82,7 @@ Blockchain.prototype.run_command = function(address, use_tmp) { } if (config.nat !== "any"){ - cmd += "--nat \"" + config.nat "\""; + cmd += "--nat \"" + config.nat + "\""; } if (config.bootNodes.boot == true){ From 480006a865af2d6dea2f35ca5a8efa2a1d5402fb Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Thu, 22 Oct 2015 08:11:13 -0500 Subject: [PATCH 16/39] Update blockchain.yml --- boilerplate/config/blockchain.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boilerplate/config/blockchain.yml b/boilerplate/config/blockchain.yml index 398835a1a..2e4b60e4f 100644 --- a/boilerplate/config/blockchain.yml +++ b/boilerplate/config/blockchain.yml @@ -2,6 +2,7 @@ development: rpc_host: localhost rpc_port: 8101 rpc_whitelist: "*" + mine: false minerthreads: 1 genesis_block: config/genesis/dev_genesis.json datadir: /tmp/embark @@ -19,6 +20,7 @@ staging: rpc_port: 8101 rpc_whitelist: "*" datadir: default + mine: false network_id: 0 max_peers: 4 bootnodes: @@ -35,6 +37,7 @@ production: rpc_whitelist: "*" datadir: default network_id: 1 + mine: false max_peers: 4 bootnodes: boot: false From d8881dd674783a503d2b48722bd24795da030208 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Fri, 23 Oct 2015 19:30:30 -0500 Subject: [PATCH 17/39] changes to bootpeers and ending console toggle --- lib/blockchain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index 52695c06d..73b6875a8 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -85,11 +85,11 @@ Blockchain.prototype.run_command = function(address, use_tmp) { cmd += "--nat \"" + config.nat + "\""; } - 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]; - if (i != config.bootNodes.enodes.lenth - 1) cmd += " "; + if (i != config.bootNodes.enodes.length - 1) cmd += " "; } cmd += "\""; } From 0ec7c88cd97c0a6e0e802d72bc88c190cc4885d8 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Sat, 24 Oct 2015 00:03:38 -0500 Subject: [PATCH 18/39] updating solc --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 3bfe2faf2..5817c1b63 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "mkdirp": "^0.5.1", "read-yaml": "^1.0.0", "shelljs": "^0.5.0", + "solc": "^0.1.6", "toposort": "^0.2.10", "web3": "^0.15.0", "wrench": "^1.5.8", From 9e8ebe9cb3c46317732b28e0f01c16df55b8a46b Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Sun, 25 Oct 2015 13:36:07 -0500 Subject: [PATCH 19/39] Update compiler.js --- lib/compiler.js | 68 +++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index f274ebb15..1bcdc0413 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -1,7 +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; @@ -11,26 +12,31 @@ Compiler.prototype.init = function(env) { var config = this.blockchainConfig.config(env); }; -Compiler.prototype.compile_solidity = function(contractFile) { - var cmd, result, output, version, json, compiled_object; +Compiler.prototype.compile_solidity = function(contractFiles) { + console.log("I HAVE REACHED HERE THROUGH GRUNT-EMBARK") + var source = '{ '; + for (var contractFile in contractFiles){ + source += '\'' + contractFile + '\': \'' + var file = fs.readFileSync(contractFile).toString() + '\''; - cmd = "solc " + contractFile + " --combined-json bin,abi"; + if (!contractFiles.length) source += ', ' + } + source += '}'; + + var output = solc.compile(source, 1); - result = exec(cmd, {silent: true}); - output = result.output; + var json = output.contracts; - json = JSON.parse(output).contracts; + compiled_object = {} - 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].info = {}; - compiled_object[className].info.abiDefinition = JSON.parse(contract["abi"] || contract["json-abi"]); - } + for (var className in json) { + var contract = json[className]; + + compiled_object[className] = {}; + compiled_object[className].code = contract.bytecode; + compiled_object[className].info = {}; + compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); + } return compiled_object; }; @@ -75,18 +81,24 @@ Compiler.prototype.compile_serpent = function(contractFile) { } -Compiler.prototype.compile = function(contractFile) { - var extension = contractFile.split('.')[1]; +Compiler.prototype.compile = function(contractFiles) { + var solidity = [], serpent = []; + + for (contract in contractFiles) { + var extension = contractFile.split('.')[1]; + if (extension === 'sol') { + solidity.push(contractFile); + } + else if (extension === 'se') { + serpent.push(contractFile); + } + else { + throw new Error("extension not known"); + } + } - if (extension === 'sol') { - return this.compile_solidity(contractFile); - } - else if (extension === 'se') { - return this.compile_serpent(contractFile); - } - else { - throw new Error("extension not known"); - } + if (solidity.length > 0) return compile_solidity(solidity); + if (serpent.length > 0) return compile_serpent(serpent); }; module.exports = Compiler; From 4b451f02909a369f65945ed644c3fd1659256d11 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Sun, 25 Oct 2015 13:37:57 -0500 Subject: [PATCH 20/39] Update contracts.js --- lib/config/contracts.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/config/contracts.js b/lib/config/contracts.js index 0e74e1d47..ac109af68 100644 --- a/lib/config/contracts.js +++ b/lib/config/contracts.js @@ -60,10 +60,10 @@ ContractsConfig.prototype.compileContracts = function(env) { options = contractsConfig[className]; if (options.args == null) continue; - ref = options.args; + ref = options.args; //get arguments for (j = 0; j < ref.length; j++) { arg = ref[j]; - if (arg[0] === "$") { + if (arg[0] === "$") { //check if they are a contract dependency if (this.contractDependencies[className] === void 0) { this.contractDependencies[className] = []; } @@ -77,26 +77,23 @@ ContractsConfig.prototype.compileContracts = function(env) { var all_compiled_contracts = {}; // compile files - for (j = 0; j < this.contractFiles.length; j++) { - contractFile = this.contractFiles[j]; + compiled_contracts = this.compiler.compile(this.contractFiles); + + for (var className in compiled_contracts) { + var contract = compiled_contracts[className]; - compiled_contracts = this.compiler.compile(contractFile); - for (var className in compiled_contracts) { - var contract = compiled_contracts[className]; + if (this.is_a_token(className, compiled_contracts)) { + continue; + } - if (this.is_a_token(className, compiled_contracts)) { - continue; - } - - all_compiled_contracts[className] = contract; - this.all_contracts.push(className); - this.contractDB[className] = { - args: [], - types: ['file'], - gasPrice: this.blockchainConfig.gasPrice, - gasLimit: this.blockchainConfig.gasLimit, - compiled: contract - } + all_compiled_contracts[className] = contract; + this.all_contracts.push(className); + this.contractDB[className] = { + args: [], + types: ['file'], + gasPrice: this.blockchainConfig.gasPrice, + gasLimit: this.blockchainConfig.gasLimit, + compiled: contract } } From a734eb2b7c30563936a75698463ed9e3eafc472e Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Sun, 25 Oct 2015 13:56:06 -0500 Subject: [PATCH 21/39] Update blockchain.js --- lib/blockchain.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index 73b6875a8..bee5d8969 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -9,7 +9,7 @@ Blockchain.prototype.generate_basic_command = function() { var address = config.account.address; var cmd = "geth "; - var rpc_api = ['eth', 'web3', 'admin', 'net', 'miner']; + var rpc_api = ['eth', 'web3']; if (config.datadir !== "default") { cmd += "--datadir=\"" + config.datadir + "\" "; @@ -20,7 +20,6 @@ Blockchain.prototype.generate_basic_command = function() { cmd += config.geth_extra_opts + " "; } - cmd += "--port " + config.port + " "; cmd += "--rpc "; cmd += "--rpcport " + config.rpcPort + " "; @@ -44,6 +43,7 @@ Blockchain.prototype.generate_basic_command = function() { if (config.genesisBlock !== void 0) cmd += "--genesis=\"" + config.genesisBlock + "\" "; + } if (config.whisper) { cmd += "--shh "; @@ -52,6 +52,7 @@ Blockchain.prototype.generate_basic_command = function() { cmd += '--rpcapi "' + rpc_api.join(',') + '" '; + //TODO: this should be configurable cmd += "--maxpeers " + config.maxPeers + " "; if (config.account.password !== void 0) { @@ -80,10 +81,6 @@ Blockchain.prototype.run_command = function(address, use_tmp) { if (address !== void 0) { cmd += "--unlock " + address + " "; } - - if (config.nat !== "any"){ - cmd += "--nat \"" + config.nat + "\""; - } if (config.bootNodes !== undefined && config.bootNodes.boot == true) { cmd += "--bootnodes \""; From ce7693eca2ce6ca7258f7502e42189fa46cc9ac7 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Sun, 25 Oct 2015 14:11:49 -0500 Subject: [PATCH 22/39] Update compiler.js --- lib/compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compiler.js b/lib/compiler.js index 1bcdc0413..ca668defd 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -84,7 +84,7 @@ Compiler.prototype.compile_serpent = function(contractFile) { Compiler.prototype.compile = function(contractFiles) { var solidity = [], serpent = []; - for (contract in contractFiles) { + for (var contractFile in contractFiles) { var extension = contractFile.split('.')[1]; if (extension === 'sol') { solidity.push(contractFile); From f2e4333d1ed4600b884ee4e357e67805d32d915f Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 26 Oct 2015 08:23:44 -0500 Subject: [PATCH 23/39] couple of forgotten things needed to be fixed up --- lib/compiler.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index ca668defd..37bc478ad 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -13,15 +13,19 @@ Compiler.prototype.init = function(env) { }; Compiler.prototype.compile_solidity = function(contractFiles) { - console.log("I HAVE REACHED HERE THROUGH GRUNT-EMBARK") - var source = '{ '; - for (var contractFile in contractFiles){ - source += '\'' + contractFile + '\': \'' - var file = fs.readFileSync(contractFile).toString() + '\''; +console.log(contractFiles.length); + var source = '{ \n'; + for (var i = 0; i < contractFiles.length; i++){ + source += '\'' + contractFiles[i] + '\': \'' + var file = fs.readFileSync(contractFiles[i]).toString(); - if (!contractFiles.length) source += ', ' + source += file + '\'\n'; + + if (i < contractFiles.length - 1) source += ', \n' } - source += '}'; + source += '\n}'; + + var output = solc.compile(source, 1); @@ -34,10 +38,12 @@ Compiler.prototype.compile_solidity = function(contractFiles) { compiled_object[className] = {}; compiled_object[className].code = contract.bytecode; + compiled_object[className].info = {}; compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); } + return compiled_object; }; @@ -83,22 +89,23 @@ Compiler.prototype.compile_serpent = function(contractFile) { Compiler.prototype.compile = function(contractFiles) { var solidity = [], serpent = []; + - for (var contractFile in contractFiles) { - var extension = contractFile.split('.')[1]; + for (var i = 0; i < contractFiles.length; i++) { + var extension = contractFiles[i].split('.')[1]; if (extension === 'sol') { - solidity.push(contractFile); + solidity.push(contractFiles[i]); } else if (extension === 'se') { - serpent.push(contractFile); + serpent.push(contractFiles[i]); } else { - throw new Error("extension not known"); + throw new Error("extension not known, got " + extension); } } - - if (solidity.length > 0) return compile_solidity(solidity); - if (serpent.length > 0) return compile_serpent(serpent); + console.log(solidity); + if (solidity.length > 0) return this.compile_solidity(solidity); + if (serpent.length > 0) return this.compile_serpent(serpent); }; module.exports = Compiler; From 867b7a16fcd4a82162458c997745b840c548f07a Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 26 Oct 2015 10:47:04 -0500 Subject: [PATCH 24/39] Update compiler.js --- lib/compiler.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 37bc478ad..74816d5a0 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -14,18 +14,11 @@ Compiler.prototype.init = function(env) { Compiler.prototype.compile_solidity = function(contractFiles) { console.log(contractFiles.length); - var source = '{ \n'; + var sources = {} + for (var i = 0; i < contractFiles.length; i++){ - source += '\'' + contractFiles[i] + '\': \'' - var file = fs.readFileSync(contractFiles[i]).toString(); - - source += file + '\'\n'; - - if (i < contractFiles.length - 1) source += ', \n' + sources[contractFiles[i]] = fs.readFileSync(contractFiles[i]).toString(); } - source += '\n}'; - - var output = solc.compile(source, 1); From f5595adb436ba78e48f7b6e1ca219d23081f8dfb Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 26 Oct 2015 18:42:56 -0500 Subject: [PATCH 25/39] Update compiler.js --- lib/compiler.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 74816d5a0..daf6b4121 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -13,14 +13,15 @@ Compiler.prototype.init = function(env) { }; Compiler.prototype.compile_solidity = function(contractFiles) { -console.log(contractFiles.length); - var sources = {} + + var input = {} for (var i = 0; i < contractFiles.length; i++){ - sources[contractFiles[i]] = fs.readFileSync(contractFiles[i]).toString(); + input[contractFiles[i].substring(14)] = fs.readFileSync(contractFiles[i]).toString(); } - - var output = solc.compile(source, 1); + + + var output = solc.compile({sources: input}, 1); var json = output.contracts; @@ -31,7 +32,6 @@ console.log(contractFiles.length); compiled_object[className] = {}; compiled_object[className].code = contract.bytecode; - compiled_object[className].info = {}; compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); } @@ -96,7 +96,7 @@ Compiler.prototype.compile = function(contractFiles) { throw new Error("extension not known, got " + extension); } } - console.log(solidity); + if (solidity.length > 0) return this.compile_solidity(solidity); if (serpent.length > 0) return this.compile_serpent(serpent); }; From b7c03ac06b09f86fc22541114d90aaba27b0a7a9 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 27 Oct 2015 11:12:55 -0500 Subject: [PATCH 26/39] Update compiler.js --- lib/compiler.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index daf6b4121..015dc843a 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -20,7 +20,6 @@ Compiler.prototype.compile_solidity = function(contractFiles) { input[contractFiles[i].substring(14)] = fs.readFileSync(contractFiles[i]).toString(); } - var output = solc.compile({sources: input}, 1); var json = output.contracts; @@ -35,7 +34,7 @@ Compiler.prototype.compile_solidity = function(contractFiles) { compiled_object[className].info = {}; compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); } - + //console.log(compiled_object); return compiled_object; }; From f864bb60987426e33766df5d341d83f0b381b61b Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 27 Oct 2015 11:51:30 -0500 Subject: [PATCH 27/39] compiling correctly and moved wall of code is_a_token I think is no longer necessary methinks...because now you can just draw up your coin as is. At the very least the function needs to be rewritten. In addition I moved the wall of code that you had a TODO to move on...and I put it in its own separate function configureContractsParameters. Let me know what we should do with is_a_token. --- lib/config/contracts.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/config/contracts.js b/lib/config/contracts.js index ac109af68..5045f8d63 100644 --- a/lib/config/contracts.js +++ b/lib/config/contracts.js @@ -41,8 +41,12 @@ ContractsConfig.prototype.config = function(env) { }; ContractsConfig.prototype.is_a_token = function(target, compiled_contracts) { - for (var className in compiled_contracts) { + for (var className in compiled_contracts) { //This needs some serious changing + if (this.contractStubs[className] && this.contractStubs[className].indexOf(target) >= 0) { + console.log("hit the condition") + console.log(this.contractStubs[className]); + console.log(this.contractStubs[className].indexOf(target)); return true; } } @@ -75,29 +79,30 @@ ContractsConfig.prototype.compileContracts = function(env) { } } - var all_compiled_contracts = {}; - // compile files - compiled_contracts = this.compiler.compile(this.contractFiles); - + + compiled_contracts = this.compiler.compile(this.contractFiles); //compile and push to contract DB + for (var className in compiled_contracts) { - var contract = compiled_contracts[className]; if (this.is_a_token(className, compiled_contracts)) { continue; } - all_compiled_contracts[className] = contract; this.all_contracts.push(className); this.contractDB[className] = { args: [], types: ['file'], gasPrice: this.blockchainConfig.gasPrice, gasLimit: this.blockchainConfig.gasLimit, - compiled: contract + compiled: compiled_contracts[className] } } - // TODO: move this + this.configureContractsParameters(contractsConfig); + this.sortContracts(); +}; + +ContractsConfig.prototype.configureContractsParameters = function(contractsConfig) { for(className in contractsConfig) { var contractConfig = contractsConfig[className]; @@ -123,7 +128,7 @@ ContractsConfig.prototype.compileContracts = function(env) { if (contractConfig.instanceOf !== undefined) { contract.types.push('instance'); contract.instanceOf = contractConfig.instanceOf; - contract.compiled = all_compiled_contracts[contractConfig.instanceOf]; + contract.compiled = compiled_contracts[contractConfig.instanceOf]; } if (contractConfig.address !== undefined) { contract.types.push('static'); @@ -139,8 +144,7 @@ ContractsConfig.prototype.compileContracts = function(env) { } } - this.sortContracts(); -}; +} ContractsConfig.prototype.sortContracts = function() { var converted_dependencies = [], i; @@ -162,4 +166,3 @@ ContractsConfig.prototype.sortContracts = function() { }; module.exports = ContractsConfig; - From 078e3240db49943cfcf2ff9e3eba2aa75db030aa Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 27 Oct 2015 11:54:43 -0500 Subject: [PATCH 28/39] Update compiler.js --- lib/compiler.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 015dc843a..0487db2c4 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -34,7 +34,6 @@ Compiler.prototype.compile_solidity = function(contractFiles) { compiled_object[className].info = {}; compiled_object[className].info.abiDefinition = JSON.parse(contract.interface); } - //console.log(compiled_object); return compiled_object; }; @@ -81,7 +80,6 @@ Compiler.prototype.compile_serpent = function(contractFile) { Compiler.prototype.compile = function(contractFiles) { var solidity = [], serpent = []; - for (var i = 0; i < contractFiles.length; i++) { var extension = contractFiles[i].split('.')[1]; @@ -95,7 +93,7 @@ Compiler.prototype.compile = function(contractFiles) { throw new Error("extension not known, got " + extension); } } - + //TODO: Get these compiling and returning together...problem might come with the JSON objects if (solidity.length > 0) return this.compile_solidity(solidity); if (serpent.length > 0) return this.compile_serpent(serpent); }; From a221b1b6b9dbd4d966e1ebc2ce7707fe02345472 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 27 Oct 2015 12:30:48 -0500 Subject: [PATCH 29/39] fixed interface issues, stubs work again --- lib/config/contracts.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/config/contracts.js b/lib/config/contracts.js index 5045f8d63..e6aca9aba 100644 --- a/lib/config/contracts.js +++ b/lib/config/contracts.js @@ -40,16 +40,10 @@ ContractsConfig.prototype.config = function(env) { return this.contractConfig[env]; }; -ContractsConfig.prototype.is_a_token = function(target, compiled_contracts) { - for (var className in compiled_contracts) { //This needs some serious changing +ContractsConfig.prototype.is_a_interface = function(target, className) { - if (this.contractStubs[className] && this.contractStubs[className].indexOf(target) >= 0) { - console.log("hit the condition") - console.log(this.contractStubs[className]); - console.log(this.contractStubs[className].indexOf(target)); - return true; - } - } + if (this.contractStubs[className] && this.contractStubs[className].indexOf(target) >= 0) + return true; return false; }; @@ -84,7 +78,7 @@ ContractsConfig.prototype.compileContracts = function(env) { for (var className in compiled_contracts) { - if (this.is_a_token(className, compiled_contracts)) { + if (this.is_a_interface(className, compiled_contracts)) { continue; } @@ -99,6 +93,7 @@ ContractsConfig.prototype.compileContracts = function(env) { } this.configureContractsParameters(contractsConfig); + this.sortContracts(); }; @@ -166,3 +161,4 @@ ContractsConfig.prototype.sortContracts = function() { }; module.exports = ContractsConfig; + From 8d2d4f8df4624d8ee155cc33e97a8a17a98496bd Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Wed, 28 Oct 2015 14:12:50 -0500 Subject: [PATCH 30/39] Throw errors for solidity compiler --- lib/compiler.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/compiler.js b/lib/compiler.js index 0487db2c4..54453fc96 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -21,6 +21,9 @@ Compiler.prototype.compile_solidity = function(contractFiles) { } var output = solc.compile({sources: input}, 1); + + if (output.errors.length > 0) + throw new Error ("Solidity errors: " + output.errors)) var json = output.contracts; From 1bd6c89f0cae215a413f14c72957884c3aafcf33 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Wed, 28 Oct 2015 14:20:14 -0500 Subject: [PATCH 31/39] small corrections --- lib/compiler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 54453fc96..49c5dcfd0 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -22,8 +22,8 @@ Compiler.prototype.compile_solidity = function(contractFiles) { var output = solc.compile({sources: input}, 1); - if (output.errors.length > 0) - throw new Error ("Solidity errors: " + output.errors)) + if (output.errors) + throw new Error ("Solidity errors: " + output.errors) var json = output.contracts; From 991abb2c7dcac987f427dbecf93815c1a8a05e01 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 8 Feb 2016 22:07:30 -0500 Subject: [PATCH 32/39] remove extra { --- lib/blockchain.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index bee5d8969..b09ff2999 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -43,7 +43,6 @@ Blockchain.prototype.generate_basic_command = function() { if (config.genesisBlock !== void 0) cmd += "--genesis=\"" + config.genesisBlock + "\" "; - } if (config.whisper) { cmd += "--shh "; From 3ec1fdb6d9bde0eff8c145d64aa003511b2bb794 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 14:44:40 -0500 Subject: [PATCH 33/39] add filename to compiler hash --- lib/compiler.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 49c5dcfd0..6dfb01ae2 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -15,13 +15,15 @@ Compiler.prototype.init = function(env) { Compiler.prototype.compile_solidity = function(contractFiles) { var input = {} - + for (var i = 0; i < contractFiles.length; i++){ - input[contractFiles[i].substring(14)] = fs.readFileSync(contractFiles[i]).toString(); + //console.log(contractFiles[i]); + //input[contractFiles[i].substring(14)] = fs.readFileSync(contractFiles[i]).toString(); + input[contractFiles[i].split('/')[3]] = fs.readFileSync(contractFiles[i]).toString(); } var output = solc.compile({sources: input}, 1); - + if (output.errors) throw new Error ("Solidity errors: " + output.errors) From ef94b9ad960ccc5f7d1279d43e8a304853e73c9d Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 15:05:04 -0500 Subject: [PATCH 34/39] remove extra minethreads config --- lib/blockchain.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/blockchain.js b/lib/blockchain.js index b09ff2999..2abb08afb 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -38,9 +38,6 @@ Blockchain.prototype.generate_basic_command = function() { if(config.mine) cmd += "--mine "; - if (config.minerthreads !== void 0) - cmd += "--minerthreads \"" + config.minerthreads + "\" "; - if (config.genesisBlock !== void 0) cmd += "--genesis=\"" + config.genesisBlock + "\" "; From 1b858514e8daa0d0eb1900270d5ea73725adac48 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 15:08:19 -0500 Subject: [PATCH 35/39] update chain manager spec --- test/chain_manager.js | 6 +++--- test/support/chain_manager.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/chain_manager.js b/test/chain_manager.js index 05b4ce64f..790df54dd 100644 --- a/test/chain_manager.js +++ b/test/chain_manager.js @@ -20,7 +20,7 @@ describe('embark.chain_manager', function() { chainManager.init('development', blockchainConfig, web3); it('should initialize chain', function() { - var chain = chainManager.chainManagerConfig['0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc'] + var chain = chainManager.chainManagerConfig['0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91'] assert.equal(chain != undefined, true); }); }); @@ -31,7 +31,7 @@ describe('embark.chain_manager', function() { chainManager.addContract("Foo", "123456", [], "0x123"); console.log(chainManager.chainManagerConfig); - var chain = chainManager.chainManagerConfig['0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc'] + var chain = chainManager.chainManagerConfig['0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91'] var contract = chain.contracts["d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b"] assert.equal(contract.name, "Foo"); @@ -58,7 +58,7 @@ describe('embark.chain_manager', function() { var chainFile = './test/support/chain_manager.json'; var content = fs.readFileSync(chainFile).toString(); - assert.equal(content, '{"0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b\":{"name":"Foo","address":"0x123"}}}}'); + assert.equal(content, '{"0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b\":{"name":"Foo","address":"0x123"}}}}'); }); }); diff --git a/test/support/chain_manager.json b/test/support/chain_manager.json index fdba38e8f..2108f66bc 100644 --- a/test/support/chain_manager.json +++ b/test/support/chain_manager.json @@ -1 +1 @@ -{"0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b":{"name":"Foo","address":"0x123"}}}} \ No newline at end of file +{"0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b":{"name":"Foo","address":"0x123"}}}} \ No newline at end of file From a74e0aaa8c050eeb9ccb761d98129bcee806d046 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 15:25:23 -0500 Subject: [PATCH 36/39] update compiler spec --- lib/compiler.js | 8 ++-- test/compiler.js | 8 ++-- test/support/contracts/other.se | 75 +++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 test/support/contracts/other.se diff --git a/lib/compiler.js b/lib/compiler.js index 6dfb01ae2..6c2866df9 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -43,9 +43,12 @@ Compiler.prototype.compile_solidity = function(contractFiles) { return compiled_object; }; -Compiler.prototype.compile_serpent = function(contractFile) { +Compiler.prototype.compile_serpent = function(contractFiles) { var cmd, result, output, json, compiled_object; + //TODO: figure out how to compile multiple files and get the correct json + var contractFile = contractFiles[0]; + cmd = "serpent compile " + contractFile; result = exec(cmd, {silent: true}); @@ -82,10 +85,9 @@ Compiler.prototype.compile_serpent = function(contractFile) { return compiled_object; } - Compiler.prototype.compile = function(contractFiles) { var solidity = [], serpent = []; - + for (var i = 0; i < contractFiles.length; i++) { var extension = contractFiles[i].split('.')[1]; if (extension === 'sol') { diff --git a/test/compiler.js b/test/compiler.js index 4abc6f03a..0d1b8d192 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -11,7 +11,7 @@ describe('embark.compiler', function() { it("should build a correct compiled object", function() { var compiler = new Compiler(); - var compiledFile = compiler.compile(files[0]); + var compiledFile = compiler.compile(files); assert.equal(compiledFile.SimpleStorage.code, '60606040526040516020806075833950608060405251600081905550604e8060276000396000f3606060405260e060020a60003504632a1afcd98114602e57806360fe47b11460365780636d4ce63c146040575b005b604460005481565b600435600055602c565b6000545b6060908152602090f3'); @@ -28,7 +28,7 @@ describe('embark.compiler', function() { it("throw an error", function() { var compiler = new Compiler(); - assert.throws(function() { compiler.compile(files[0]) }, Error); + assert.throws(function() { compiler.compile(files) }, Error); }); }); @@ -41,7 +41,7 @@ describe('embark.compiler', function() { it("should build a correct compiled object", function() { var compiler = new Compiler(); - var compiledFile = compiler.compile(files[0]); + var compiledFile = compiler.compile(files); assert.equal(compiledFile.cash.code, '6000603f536a0186a000000000000000006040604059905901600090526000815232816020015280905020556103658061003a60003961039f56600061047f537c010000000000000000000000000000000000000000000000000000000060003504638357984f81141561005f57600435604052604060405990590160009052600081526040518160200152809050205460605260206060f35b63693200ce8114156101465760043560a05260243560c0523260e0526040604059905901600090526000815260e051816020015280905020546101005260c051610100511215156101385760c0516040604059905901600090526000815260e05181602001528090502054036040604059905901600090526000815260e0518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516101c05260206101c0f3610145565b60006101e05260206101e0f35b5b6380b97fc081141561024c5760043560a05260243560c05260443561020052326102005114151561017e576000610220526020610220f35b6040604059905901600090526000815261020051816020015280905020546101005260c0516101005112151561023e5760c0516040604059905901600090526000815261020051816020015280905020540360406040599059016000905260008152610200518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516102e05260206102e0f361024b565b6000610300526020610300f35b5b634c764abc8114156102b4576004356103205260243561034052610340516040604059905901600090526000815261032051816020015280905020540360406040599059016000905260008152610320518160200152809050205560016103a05260206103a0f35b63a92c9b8381141561031c57600435610320526024356103405261034051604060405990590160009052600081526103205181602001528090502054016040604059905901600090526000815261032051816020015280905020556001610400526020610400f35b631d62e92281141561036357600435604052602435610420526104205160406040599059016000905260008152604051816020015280905020556001610460526020610460f35b505b6000f3'); @@ -59,7 +59,7 @@ describe('embark.compiler', function() { it("throw an error", function() { var compiler = new Compiler(); - assert.throws(function() { compiler.compile(files[0]) }, Error); + assert.throws(function() { compiler.compile(files) }, Error); }); }); diff --git a/test/support/contracts/other.se b/test/support/contracts/other.se new file mode 100644 index 000000000..c70f0c57b --- /dev/null +++ b/test/support/contracts/other.se @@ -0,0 +1,75 @@ +# This software (Augur) allows buying && selling event outcomes in ethereum +# Copyright (C) 2015 Forecast Foundation +# This program is free software; you can redistribute it &&/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is free software: you can redistribute it &&/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# Any questions please contact joey@augur.net + +data cashcoinBalances[] + +def init(): + # test initial funds + self.cashcoinBalances[tx.origin] = 100000*2^64 + +# @return: cash balance of address +def balance(address): + return(self.cashcoinBalances[address]) + +# should send values as fixed point in UI (1 is 2^64, 4 is 4*2^64, .5 is 2^63, etc.) +# so cashcoin fees could just go to root branch, or we could not have fees besides +# gas fee to do a send transaction +# @return: value sent, 0 if fails +def send(recver, value): + sender = tx.origin + senderBalance = self.cashcoinBalances[sender] + if(senderBalance >= value): + self.cashcoinBalances[sender] -= value + self.cashcoinBalances[recver] += value + return(value) + else: + return(0) + +# @return value of cash sent; fail is 0 +def sendFrom(recver, value, from): + if(from!=tx.origin): + return(0) + senderBalance = self.cashcoinBalances[from] + if(senderBalance >= value): + self.cashcoinBalances[from] -= value + self.cashcoinBalances[recver] += value + return(value) + else: + return(0) + +# make sure only coming from specific contracts +def subtractCash(ID, amount): + #if(!self.whitelist.check(msg.sender)): + # return(-1) + self.cashcoinBalances[ID] -= amount + return(1) + +def addCash(ID, amount): + #if(!self.whitelist.check(msg.sender)): + # return(-1) + self.cashcoinBalances[ID] += amount + return(1) + +def setCash(address, balance): + #if !self.whitelist.check(msg.sender): + # return(-1) + self.cashcoinBalances[address] = balance + return(1) From 2bbd5f418c1e777d7010fc83417acac4a406635e Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 15:36:56 -0500 Subject: [PATCH 37/39] comment out stub contract --- test/support/contracts/crowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/support/contracts/crowdsale.sol b/test/support/contracts/crowdsale.sol index a882dc819..dac324ffa 100644 --- a/test/support/contracts/crowdsale.sol +++ b/test/support/contracts/crowdsale.sol @@ -1,4 +1,4 @@ -contract token { mapping (address => uint) public coinBalanceOf; function token() {} function sendCoin(address receiver, uint amount) returns(bool sufficient) { } } +//contract token { mapping (address => uint) public coinBalanceOf; function token() {} function sendCoin(address receiver, uint amount) returns(bool sufficient) { } } contract Crowdsale { From 648382bd15f806b08ae7902b2161f6c8a8fd3c2a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 15:45:48 -0500 Subject: [PATCH 38/39] fix blockchain config specs --- lib/config/blockchain.js | 4 ++-- test/config.blockchain.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/config/blockchain.js b/lib/config/blockchain.js index 1cc9dd82b..d2110ed2f 100644 --- a/lib/config/blockchain.js +++ b/lib/config/blockchain.js @@ -38,8 +38,7 @@ BlockchainConfig.prototype.config = function(env) { gasLimit: config.gas_limit || 500000, gasPrice: config.gas_price || 10000000000000, rpcWhitelist: config.rpc_whitelist, - nat: config.nat, - mine: config.mine, + nat: config.nat || [], minerthreads: config.minerthreads, genesisBlock: config.genesis_block, datadir: config.datadir, @@ -48,6 +47,7 @@ BlockchainConfig.prototype.config = function(env) { deployTimeout: config.deploy_timeout || 20, networkId: networkId, maxPeers: config.max_peers || 4, + mine: config.mine || false, port: config.port || "30303", console_toggle: config.console || false, mine_when_needed: config.mine_when_needed || false, diff --git a/test/config.blockchain.js b/test/config.blockchain.js index 127d00032..94b6a1f90 100644 --- a/test/config.blockchain.js +++ b/test/config.blockchain.js @@ -69,12 +69,14 @@ describe('embark.config.blockchain', function() { bootNodes: [], whisper: false, minerthreads: 1, + nat: [], genesisBlock: 'config/genesis.json', datadir: '/tmp/embark', chains: 'chains_development.json', deployTimeout: 45, networkId: 0, maxPeers: 4, + mine: false, port: "30303", console_toggle: false, mine_when_needed: true, @@ -118,12 +120,14 @@ describe('embark.config.blockchain', function() { bootNodes: [], whisper: false, minerthreads: 1, + nat: [], genesisBlock: undefined, datadir: '/tmp/embark', chains: undefined, deployTimeout: 20, networkId: 0, maxPeers: 4, + mine: false, port: "30303", console_toggle: false, mine_when_needed: true, From 9c3f31e351df3055e76f33da1f0f453d08819d49 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 9 Feb 2016 15:57:16 -0500 Subject: [PATCH 39/39] update contracts config --- test/config.contracts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/config.contracts.js b/test/config.contracts.js index 63f303b9a..d9d70ce14 100644 --- a/test/config.contracts.js +++ b/test/config.contracts.js @@ -52,7 +52,8 @@ describe('embark.config.contracts', function() { }); it('add contracts to a list', function() { - assert.deepEqual(contractsConfig.all_contracts, [ "SimpleStorage", "AnotherStorage" ]); + //assert.deepEqual(contractsConfig.all_contracts, [ "SimpleStorage", "AnotherStorage" ]); + assert.deepEqual(contractsConfig.all_contracts, [ "AnotherStorage", "SimpleStorage" ]); }); });