mirror of https://github.com/embarklabs/embark.git
commit
d72ee89cbf
|
@ -2,6 +2,7 @@ development:
|
||||||
rpc_host: localhost
|
rpc_host: localhost
|
||||||
rpc_port: 8101
|
rpc_port: 8101
|
||||||
rpc_whitelist: "*"
|
rpc_whitelist: "*"
|
||||||
|
mine: false
|
||||||
minerthreads: 1
|
minerthreads: 1
|
||||||
genesis_block: config/genesis/dev_genesis.json
|
genesis_block: config/genesis/dev_genesis.json
|
||||||
datadir: /tmp/embark
|
datadir: /tmp/embark
|
||||||
|
@ -10,7 +11,6 @@ development:
|
||||||
max_peers: 0
|
max_peers: 0
|
||||||
gas_limit: 500000
|
gas_limit: 500000
|
||||||
gas_price: 10000000000000
|
gas_price: 10000000000000
|
||||||
console: false
|
|
||||||
account:
|
account:
|
||||||
init: true
|
init: true
|
||||||
password: config/password
|
password: config/password
|
||||||
|
@ -20,12 +20,14 @@ staging:
|
||||||
rpc_port: 8101
|
rpc_port: 8101
|
||||||
rpc_whitelist: "*"
|
rpc_whitelist: "*"
|
||||||
datadir: default
|
datadir: default
|
||||||
|
mine: false
|
||||||
network_id: 0
|
network_id: 0
|
||||||
max_peers: 4
|
max_peers: 4
|
||||||
console: true
|
|
||||||
bootnodes:
|
bootnodes:
|
||||||
boot: false
|
boot: false
|
||||||
enodes: [] #insert enode urls here.
|
enodes: [] #insert enode urls here.
|
||||||
|
nat: any #NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
|
||||||
|
port: 30303
|
||||||
account:
|
account:
|
||||||
init: false
|
init: false
|
||||||
address:
|
address:
|
||||||
|
@ -35,11 +37,13 @@ production:
|
||||||
rpc_whitelist: "*"
|
rpc_whitelist: "*"
|
||||||
datadir: default
|
datadir: default
|
||||||
network_id: 1
|
network_id: 1
|
||||||
|
mine: false
|
||||||
max_peers: 4
|
max_peers: 4
|
||||||
console: true
|
|
||||||
bootnodes:
|
bootnodes:
|
||||||
boot: false
|
boot: false
|
||||||
enodes: []
|
enodes: []
|
||||||
|
nat: any #NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
|
||||||
|
port: 30303
|
||||||
account:
|
account:
|
||||||
init: false
|
init: false
|
||||||
address:
|
address:
|
||||||
|
|
|
@ -38,9 +38,8 @@ Blockchain.prototype.generate_basic_command = function() {
|
||||||
if(config.mine)
|
if(config.mine)
|
||||||
cmd += "--mine ";
|
cmd += "--mine ";
|
||||||
|
|
||||||
if (config.genesisBlock !== void 0) {
|
if (config.genesisBlock !== void 0)
|
||||||
cmd += "--genesis=\"" + config.genesisBlock + "\" ";
|
cmd += "--genesis=\"" + config.genesisBlock + "\" ";
|
||||||
}
|
|
||||||
|
|
||||||
if (config.whisper) {
|
if (config.whisper) {
|
||||||
cmd += "--shh ";
|
cmd += "--shh ";
|
||||||
|
@ -79,15 +78,13 @@ Blockchain.prototype.run_command = function(address, use_tmp) {
|
||||||
cmd += "--unlock " + address + " ";
|
cmd += "--unlock " + address + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.bootNodes !== undefined && config.bootNodes.boot == true){
|
if (config.bootNodes !== undefined && config.bootNodes.boot == true) {
|
||||||
cmd += "--bootnodes ";
|
cmd += "--bootnodes \"";
|
||||||
for (var i = 0; i < config.bootNodes.enodes.length; i++){
|
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.length - 1) cmd += " ";
|
||||||
}
|
}
|
||||||
}
|
cmd += "\"";
|
||||||
|
|
||||||
if (config.console_toggle) {
|
|
||||||
cmd += "console";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.mine_when_needed) {
|
if (config.mine_when_needed) {
|
||||||
|
|
|
@ -12,14 +12,21 @@ Compiler.prototype.init = function(env) {
|
||||||
var config = this.blockchainConfig.config(env);
|
var config = this.blockchainConfig.config(env);
|
||||||
};
|
};
|
||||||
|
|
||||||
Compiler.prototype.compile_solidity = function(contractFile) {
|
Compiler.prototype.compile_solidity = function(contractFiles) {
|
||||||
var source = fs.readFileSync(contractFile).toString();
|
|
||||||
var output = solc.compile(source, 1);
|
|
||||||
|
|
||||||
if(output.errors && output.errors.length>0){
|
var input = {}
|
||||||
throw new Error(output.errors[0]);
|
|
||||||
|
for (var i = 0; i < contractFiles.length; i++){
|
||||||
|
//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)
|
||||||
|
|
||||||
var json = output.contracts;
|
var json = output.contracts;
|
||||||
|
|
||||||
compiled_object = {}
|
compiled_object = {}
|
||||||
|
@ -36,9 +43,12 @@ Compiler.prototype.compile_solidity = function(contractFile) {
|
||||||
return compiled_object;
|
return compiled_object;
|
||||||
};
|
};
|
||||||
|
|
||||||
Compiler.prototype.compile_serpent = function(contractFile) {
|
Compiler.prototype.compile_serpent = function(contractFiles) {
|
||||||
var cmd, result, output, json, compiled_object;
|
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;
|
cmd = "serpent compile " + contractFile;
|
||||||
|
|
||||||
result = exec(cmd, {silent: true});
|
result = exec(cmd, {silent: true});
|
||||||
|
@ -75,19 +85,24 @@ Compiler.prototype.compile_serpent = function(contractFile) {
|
||||||
return compiled_object;
|
return compiled_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Compiler.prototype.compile = function(contractFiles) {
|
||||||
|
var solidity = [], serpent = [];
|
||||||
|
|
||||||
Compiler.prototype.compile = function(contractFile) {
|
for (var i = 0; i < contractFiles.length; i++) {
|
||||||
var extension = contractFile.split('.')[1];
|
var extension = contractFiles[i].split('.')[1];
|
||||||
|
if (extension === 'sol') {
|
||||||
if (extension === 'sol') {
|
solidity.push(contractFiles[i]);
|
||||||
return this.compile_solidity(contractFile);
|
}
|
||||||
}
|
else if (extension === 'se') {
|
||||||
else if (extension === 'se') {
|
serpent.push(contractFiles[i]);
|
||||||
return this.compile_serpent(contractFile);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
throw new Error("extension not known, got " + extension);
|
||||||
throw new Error("extension not known");
|
}
|
||||||
}
|
}
|
||||||
|
//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);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Compiler;
|
module.exports = Compiler;
|
||||||
|
|
|
@ -38,6 +38,7 @@ BlockchainConfig.prototype.config = function(env) {
|
||||||
gasLimit: config.gas_limit || 500000,
|
gasLimit: config.gas_limit || 500000,
|
||||||
gasPrice: config.gas_price || 10000000000000,
|
gasPrice: config.gas_price || 10000000000000,
|
||||||
rpcWhitelist: config.rpc_whitelist,
|
rpcWhitelist: config.rpc_whitelist,
|
||||||
|
nat: config.nat || [],
|
||||||
minerthreads: config.minerthreads,
|
minerthreads: config.minerthreads,
|
||||||
genesisBlock: config.genesis_block,
|
genesisBlock: config.genesis_block,
|
||||||
datadir: config.datadir,
|
datadir: config.datadir,
|
||||||
|
@ -46,6 +47,7 @@ BlockchainConfig.prototype.config = function(env) {
|
||||||
deployTimeout: config.deploy_timeout || 20,
|
deployTimeout: config.deploy_timeout || 20,
|
||||||
networkId: networkId,
|
networkId: networkId,
|
||||||
maxPeers: config.max_peers || 4,
|
maxPeers: config.max_peers || 4,
|
||||||
|
mine: config.mine || false,
|
||||||
port: config.port || "30303",
|
port: config.port || "30303",
|
||||||
console_toggle: config.console || false,
|
console_toggle: config.console || false,
|
||||||
mine_when_needed: config.mine_when_needed || false,
|
mine_when_needed: config.mine_when_needed || false,
|
||||||
|
|
|
@ -40,12 +40,10 @@ ContractsConfig.prototype.config = function(env) {
|
||||||
return this.contractConfig[env];
|
return this.contractConfig[env];
|
||||||
};
|
};
|
||||||
|
|
||||||
ContractsConfig.prototype.is_a_token = function(target, compiled_contracts) {
|
ContractsConfig.prototype.is_a_interface = function(target, className) {
|
||||||
for (var className in compiled_contracts) {
|
|
||||||
if (this.contractStubs[className] && this.contractStubs[className].indexOf(target) >= 0) {
|
if (this.contractStubs[className] && this.contractStubs[className].indexOf(target) >= 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,10 +58,10 @@ ContractsConfig.prototype.compileContracts = function(env) {
|
||||||
options = contractsConfig[className];
|
options = contractsConfig[className];
|
||||||
if (options.args == null) continue;
|
if (options.args == null) continue;
|
||||||
|
|
||||||
ref = options.args;
|
ref = options.args; //get arguments
|
||||||
for (j = 0; j < ref.length; j++) {
|
for (j = 0; j < ref.length; j++) {
|
||||||
arg = ref[j];
|
arg = ref[j];
|
||||||
if (arg[0] === "$") {
|
if (arg[0] === "$") { //check if they are a contract dependency
|
||||||
if (this.contractDependencies[className] === void 0) {
|
if (this.contractDependencies[className] === void 0) {
|
||||||
this.contractDependencies[className] = [];
|
this.contractDependencies[className] = [];
|
||||||
}
|
}
|
||||||
|
@ -75,32 +73,31 @@ 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(contractFile);
|
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)) {
|
for (var className in compiled_contracts) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
all_compiled_contracts[className] = contract;
|
if (this.is_a_interface(className, compiled_contracts)) {
|
||||||
this.all_contracts.push(className);
|
continue;
|
||||||
this.contractDB[className] = {
|
}
|
||||||
args: [],
|
|
||||||
types: ['file'],
|
this.all_contracts.push(className);
|
||||||
gasPrice: this.blockchainConfig.gasPrice,
|
this.contractDB[className] = {
|
||||||
gasLimit: this.blockchainConfig.gasLimit,
|
args: [],
|
||||||
compiled: contract
|
types: ['file'],
|
||||||
}
|
gasPrice: this.blockchainConfig.gasPrice,
|
||||||
|
gasLimit: this.blockchainConfig.gasLimit,
|
||||||
|
compiled: compiled_contracts[className]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this
|
this.configureContractsParameters(contractsConfig);
|
||||||
|
|
||||||
|
this.sortContracts();
|
||||||
|
};
|
||||||
|
|
||||||
|
ContractsConfig.prototype.configureContractsParameters = function(contractsConfig) {
|
||||||
for(className in contractsConfig) {
|
for(className in contractsConfig) {
|
||||||
var contractConfig = contractsConfig[className];
|
var contractConfig = contractsConfig[className];
|
||||||
|
|
||||||
|
@ -126,7 +123,7 @@ ContractsConfig.prototype.compileContracts = function(env) {
|
||||||
if (contractConfig.instanceOf !== undefined) {
|
if (contractConfig.instanceOf !== undefined) {
|
||||||
contract.types.push('instance');
|
contract.types.push('instance');
|
||||||
contract.instanceOf = contractConfig.instanceOf;
|
contract.instanceOf = contractConfig.instanceOf;
|
||||||
contract.compiled = all_compiled_contracts[contractConfig.instanceOf];
|
contract.compiled = compiled_contracts[contractConfig.instanceOf];
|
||||||
}
|
}
|
||||||
if (contractConfig.address !== undefined) {
|
if (contractConfig.address !== undefined) {
|
||||||
contract.types.push('static');
|
contract.types.push('static');
|
||||||
|
@ -142,8 +139,7 @@ ContractsConfig.prototype.compileContracts = function(env) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sortContracts();
|
}
|
||||||
};
|
|
||||||
|
|
||||||
ContractsConfig.prototype.sortContracts = function() {
|
ContractsConfig.prototype.sortContracts = function() {
|
||||||
var converted_dependencies = [], i;
|
var converted_dependencies = [], i;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"read-yaml": "^1.0.0",
|
"read-yaml": "^1.0.0",
|
||||||
"shelljs": "^0.5.0",
|
"shelljs": "^0.5.0",
|
||||||
"solc": "^0.1.3-2",
|
"solc": "^0.1.6",
|
||||||
"toposort": "^0.2.10",
|
"toposort": "^0.2.10",
|
||||||
"web3": "^0.15.0",
|
"web3": "^0.15.0",
|
||||||
"wrench": "^1.5.8",
|
"wrench": "^1.5.8",
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('embark.chain_manager', function() {
|
||||||
chainManager.init('development', blockchainConfig, web3);
|
chainManager.init('development', blockchainConfig, web3);
|
||||||
|
|
||||||
it('should initialize chain', function() {
|
it('should initialize chain', function() {
|
||||||
var chain = chainManager.chainManagerConfig['0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc']
|
var chain = chainManager.chainManagerConfig['0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91']
|
||||||
assert.equal(chain != undefined, true);
|
assert.equal(chain != undefined, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -31,7 +31,7 @@ describe('embark.chain_manager', function() {
|
||||||
chainManager.addContract("Foo", "123456", [], "0x123");
|
chainManager.addContract("Foo", "123456", [], "0x123");
|
||||||
|
|
||||||
console.log(chainManager.chainManagerConfig);
|
console.log(chainManager.chainManagerConfig);
|
||||||
var chain = chainManager.chainManagerConfig['0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc']
|
var chain = chainManager.chainManagerConfig['0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91']
|
||||||
var contract = chain.contracts["d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b"]
|
var contract = chain.contracts["d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b"]
|
||||||
|
|
||||||
assert.equal(contract.name, "Foo");
|
assert.equal(contract.name, "Foo");
|
||||||
|
@ -58,7 +58,7 @@ describe('embark.chain_manager', function() {
|
||||||
|
|
||||||
var chainFile = './test/support/chain_manager.json';
|
var chainFile = './test/support/chain_manager.json';
|
||||||
var content = fs.readFileSync(chainFile).toString();
|
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"}}}}');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('embark.compiler', function() {
|
||||||
it("should build a correct compiled object", function() {
|
it("should build a correct compiled object", function() {
|
||||||
var compiler = new Compiler();
|
var compiler = new Compiler();
|
||||||
|
|
||||||
var compiledFile = compiler.compile(files[0]);
|
var compiledFile = compiler.compile(files);
|
||||||
|
|
||||||
assert.equal(compiledFile.SimpleStorage.code, '60606040526040516020806075833950608060405251600081905550604e8060276000396000f3606060405260e060020a60003504632a1afcd98114602e57806360fe47b11460365780636d4ce63c146040575b005b604460005481565b600435600055602c565b6000545b6060908152602090f3');
|
assert.equal(compiledFile.SimpleStorage.code, '60606040526040516020806075833950608060405251600081905550604e8060276000396000f3606060405260e060020a60003504632a1afcd98114602e57806360fe47b11460365780636d4ce63c146040575b005b604460005481565b600435600055602c565b6000545b6060908152602090f3');
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ describe('embark.compiler', function() {
|
||||||
it("throw an error", function() {
|
it("throw an error", function() {
|
||||||
var compiler = new Compiler();
|
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() {
|
it("should build a correct compiled object", function() {
|
||||||
var compiler = new Compiler();
|
var compiler = new Compiler();
|
||||||
|
|
||||||
var compiledFile = compiler.compile(files[0]);
|
var compiledFile = compiler.compile(files);
|
||||||
|
|
||||||
assert.equal(compiledFile.cash.code, '6000603f536a0186a000000000000000006040604059905901600090526000815232816020015280905020556103658061003a60003961039f56600061047f537c010000000000000000000000000000000000000000000000000000000060003504638357984f81141561005f57600435604052604060405990590160009052600081526040518160200152809050205460605260206060f35b63693200ce8114156101465760043560a05260243560c0523260e0526040604059905901600090526000815260e051816020015280905020546101005260c051610100511215156101385760c0516040604059905901600090526000815260e05181602001528090502054036040604059905901600090526000815260e0518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516101c05260206101c0f3610145565b60006101e05260206101e0f35b5b6380b97fc081141561024c5760043560a05260243560c05260443561020052326102005114151561017e576000610220526020610220f35b6040604059905901600090526000815261020051816020015280905020546101005260c0516101005112151561023e5760c0516040604059905901600090526000815261020051816020015280905020540360406040599059016000905260008152610200518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516102e05260206102e0f361024b565b6000610300526020610300f35b5b634c764abc8114156102b4576004356103205260243561034052610340516040604059905901600090526000815261032051816020015280905020540360406040599059016000905260008152610320518160200152809050205560016103a05260206103a0f35b63a92c9b8381141561031c57600435610320526024356103405261034051604060405990590160009052600081526103205181602001528090502054016040604059905901600090526000815261032051816020015280905020556001610400526020610400f35b631d62e92281141561036357600435604052602435610420526104205160406040599059016000905260008152604051816020015280905020556001610460526020610460f35b505b6000f3');
|
assert.equal(compiledFile.cash.code, '6000603f536a0186a000000000000000006040604059905901600090526000815232816020015280905020556103658061003a60003961039f56600061047f537c010000000000000000000000000000000000000000000000000000000060003504638357984f81141561005f57600435604052604060405990590160009052600081526040518160200152809050205460605260206060f35b63693200ce8114156101465760043560a05260243560c0523260e0526040604059905901600090526000815260e051816020015280905020546101005260c051610100511215156101385760c0516040604059905901600090526000815260e05181602001528090502054036040604059905901600090526000815260e0518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516101c05260206101c0f3610145565b60006101e05260206101e0f35b5b6380b97fc081141561024c5760043560a05260243560c05260443561020052326102005114151561017e576000610220526020610220f35b6040604059905901600090526000815261020051816020015280905020546101005260c0516101005112151561023e5760c0516040604059905901600090526000815261020051816020015280905020540360406040599059016000905260008152610200518160200152809050205560c0516040604059905901600090526000815260a05181602001528090502054016040604059905901600090526000815260a0518160200152809050205560c0516102e05260206102e0f361024b565b6000610300526020610300f35b5b634c764abc8114156102b4576004356103205260243561034052610340516040604059905901600090526000815261032051816020015280905020540360406040599059016000905260008152610320518160200152809050205560016103a05260206103a0f35b63a92c9b8381141561031c57600435610320526024356103405261034051604060405990590160009052600081526103205181602001528090502054016040604059905901600090526000815261032051816020015280905020556001610400526020610400f35b631d62e92281141561036357600435604052602435610420526104205160406040599059016000905260008152604051816020015280905020556001610460526020610460f35b505b6000f3');
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ describe('embark.compiler', function() {
|
||||||
it("throw an error", function() {
|
it("throw an error", function() {
|
||||||
var compiler = new Compiler();
|
var compiler = new Compiler();
|
||||||
|
|
||||||
assert.throws(function() { compiler.compile(files[0]) }, Error);
|
assert.throws(function() { compiler.compile(files) }, Error);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -69,12 +69,14 @@ describe('embark.config.blockchain', function() {
|
||||||
bootNodes: [],
|
bootNodes: [],
|
||||||
whisper: false,
|
whisper: false,
|
||||||
minerthreads: 1,
|
minerthreads: 1,
|
||||||
|
nat: [],
|
||||||
genesisBlock: 'config/genesis.json',
|
genesisBlock: 'config/genesis.json',
|
||||||
datadir: '/tmp/embark',
|
datadir: '/tmp/embark',
|
||||||
chains: 'chains_development.json',
|
chains: 'chains_development.json',
|
||||||
deployTimeout: 45,
|
deployTimeout: 45,
|
||||||
networkId: 0,
|
networkId: 0,
|
||||||
maxPeers: 4,
|
maxPeers: 4,
|
||||||
|
mine: false,
|
||||||
port: "30303",
|
port: "30303",
|
||||||
console_toggle: false,
|
console_toggle: false,
|
||||||
mine_when_needed: true,
|
mine_when_needed: true,
|
||||||
|
@ -118,12 +120,14 @@ describe('embark.config.blockchain', function() {
|
||||||
bootNodes: [],
|
bootNodes: [],
|
||||||
whisper: false,
|
whisper: false,
|
||||||
minerthreads: 1,
|
minerthreads: 1,
|
||||||
|
nat: [],
|
||||||
genesisBlock: undefined,
|
genesisBlock: undefined,
|
||||||
datadir: '/tmp/embark',
|
datadir: '/tmp/embark',
|
||||||
chains: undefined,
|
chains: undefined,
|
||||||
deployTimeout: 20,
|
deployTimeout: 20,
|
||||||
networkId: 0,
|
networkId: 0,
|
||||||
maxPeers: 4,
|
maxPeers: 4,
|
||||||
|
mine: false,
|
||||||
port: "30303",
|
port: "30303",
|
||||||
console_toggle: false,
|
console_toggle: false,
|
||||||
mine_when_needed: true,
|
mine_when_needed: true,
|
||||||
|
|
|
@ -52,7 +52,8 @@ describe('embark.config.contracts', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('add contracts to a list', 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" ]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"0xb6611efad4ee3eb16e1349241b7015a5ed447e51d251372ef2704f63b5ad5cfc":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b":{"name":"Foo","address":"0x123"}}}}
|
{"0x021a83120c235da14ec41c513dabf7e56e5d8a820177df9da3d1fd2b9c2daf91":{"contracts":{"d5d91a8825c5c253dff531ddda2354c4014f5699b7bcbea70207cfdcb37b6c8b":{"name":"Foo","address":"0x123"}}}}
|
|
@ -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 {
|
contract Crowdsale {
|
||||||
|
|
||||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
# 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)
|
Loading…
Reference in New Issue