diff --git a/boilerplate/config/development/genesis.json b/boilerplate/config/development/genesis.json index 8df40402..4a50a438 100644 --- a/boilerplate/config/development/genesis.json +++ b/boilerplate/config/development/genesis.json @@ -1,5 +1,7 @@ { - "config": {}, + "config": { + "homesteadBlock": 1 + }, "nonce": "0x0000000000000042", "difficulty": "0x0", "alloc": { diff --git a/demo/config/development/genesis.json b/demo/config/development/genesis.json index 8df40402..4a50a438 100644 --- a/demo/config/development/genesis.json +++ b/demo/config/development/genesis.json @@ -1,5 +1,7 @@ { - "config": {}, + "config": { + "homesteadBlock": 1 + }, "nonce": "0x0000000000000042", "difficulty": "0x0", "alloc": { diff --git a/lib/contracts/compiler.js b/lib/contracts/compiler.js index f8052028..1757194f 100644 --- a/lib/contracts/compiler.js +++ b/lib/contracts/compiler.js @@ -106,6 +106,7 @@ class Compiler { // [2] classname const regex = /(.*):(.*)/; const className = contractName.match(regex)[2]; + const filename = contractName.match(regex)[1]; compiled_object[className] = {}; compiled_object[className].code = contract.bytecode; @@ -115,7 +116,9 @@ class Compiler { compiled_object[className].gasEstimates = contract.gasEstimates; compiled_object[className].functionHashes = contract.functionHashes; compiled_object[className].abiDefinition = JSON.parse(contract.interface); + compiled_object[className].filename = filename } + callback(null, compiled_object); } ], function (err, result) { diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 9799e4df..97c67b87 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -62,6 +62,7 @@ class ContractsManager { contract.gasEstimates = compiledContract.gasEstimates; contract.functionHashes = compiledContract.functionHashes; contract.abiDefinition = compiledContract.abiDefinition; + contract.filename = compiledContract.filename; contract.gas = (contractConfig && contractConfig.gas) || self.contractsConfig.gas || 'auto'; self.adjustGas(contract); diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index f9b2259b..e3103da2 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -105,18 +105,32 @@ class Deploy { return callback(new Error(err)); } + let contractCode = contract.code; + let contractsList = self.contractsManager.listContracts(); + for (let contractObj of contractsList) { + let filename = contractObj.filename; + let deployedAddress = contractObj.deployedAddress; + if (deployedAddress) { + deployedAddress = deployedAddress.substr(2); + } + let linkReference = '__' + filename + ":" + contractObj.className; + let toReplace = linkReference + "_".repeat(40 - linkReference.length); + contractCode = contractCode.replace(toReplace, deployedAddress); + } + // TODO: probably needs to be defaultAccount // TODO: it wouldn't necessary be the first address // use defined blockchain address or first address contractParams.push({ //from: this.web3.eth.coinbase, from: accounts[0], - data: "0x" + contract.code, + data: "0x" + contractCode, gas: contract.gas, gasPrice: contract.gasPrice }); self.logger.info("deploying " + contract.className.bold.cyan + " with ".green + contract.gas + " gas".green); + contractParams.push(function (err, transaction) { self.logger.contractsState(self.contractsManager.contractsState()); diff --git a/test_app/app/contracts/simple_storage.sol b/test_app/app/contracts/simple_storage.sol index 7c8ea15c..41d608d3 100644 --- a/test_app/app/contracts/simple_storage.sol +++ b/test_app/app/contracts/simple_storage.sol @@ -12,7 +12,7 @@ contract SimpleStorage { storedData = x; } - function set2(uint x, uint y) { + function set2(uint x, uint unusedGiveWarning) { storedData = x; } diff --git a/test_app/app/contracts/test.sol b/test_app/app/contracts/test.sol new file mode 100644 index 00000000..2618d93d --- /dev/null +++ b/test_app/app/contracts/test.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.4.11; + +library AMyLib { + + function add(uint _a, uint _b) returns (uint _c) { + return _a + _b; + } + +} + +contract Test { + + function testAdd() constant returns (uint _result) { + return AMyLib.add(1, 2); + } + +} diff --git a/test_app/config/development/genesis.json b/test_app/config/development/genesis.json index 8df40402..4a50a438 100644 --- a/test_app/config/development/genesis.json +++ b/test_app/config/development/genesis.json @@ -1,5 +1,7 @@ { - "config": {}, + "config": { + "homesteadBlock": 1 + }, "nonce": "0x0000000000000042", "difficulty": "0x0", "alloc": {