mirror of https://github.com/embarklabs/embark.git
look for contract import in dapp dir and node_modules
This commit is contained in:
parent
e3fde1ad22
commit
db61e355c1
|
@ -1,5 +1,20 @@
|
|||
let solc;
|
||||
|
||||
let fs = require('fs-extra');
|
||||
let path = require('path');
|
||||
|
||||
function findImports(filename) {
|
||||
console.dir(filename);
|
||||
if (!fs.existsSync(filename)) {
|
||||
if (fs.existsSync(path.join('./node_modules/', filename))) {
|
||||
return {contents: fs.readFileSync(path.join('./node_modules/', filename)).toString()};
|
||||
} else {
|
||||
return {error: 'File not found'};
|
||||
}
|
||||
}
|
||||
return {contents: fs.readFileSync(filename).toString()};
|
||||
}
|
||||
|
||||
process.on('message', function (msg) {
|
||||
if (msg.action === 'loadCompiler') {
|
||||
solc = require(msg.solcLocation);
|
||||
|
@ -8,7 +23,7 @@ process.on('message', function (msg) {
|
|||
|
||||
if (msg.action === 'compile') {
|
||||
// TODO: only available in 0.4.11; need to make versions warn about this
|
||||
let output = solc.compileStandardWrapper(JSON.stringify(msg.jsonObj));
|
||||
let output = solc.compileStandardWrapper(JSON.stringify(msg.jsonObj), findImports);
|
||||
process.send({result: "compilation", output: output});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
pragma solidity ^0.4.17;
|
||||
|
||||
contract SimpleStorageTest2 {
|
||||
uint public storedData;
|
||||
|
||||
function() public payable { }
|
||||
|
||||
function SimpleStorage(uint initialValue) public {
|
||||
storedData = initialValue;
|
||||
}
|
||||
|
||||
function set(uint x) public {
|
||||
storedData = x;
|
||||
}
|
||||
|
||||
function get() public view returns (uint retVal) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
"config": "config/",
|
||||
"versions": {
|
||||
"web3.js": "1.0.0-beta.27",
|
||||
"solc": "0.4.17",
|
||||
"solc": "0.4.21",
|
||||
"ipfs-api": "17.2.6"
|
||||
},
|
||||
"plugins": {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"jquery": "^1.11.3",
|
||||
"react": "^16.0.0",
|
||||
"react-bootstrap": "^0.32.0",
|
||||
"react-dom": "^16.2.0"
|
||||
"react-dom": "^16.2.0",
|
||||
"zeppelin-solidity": "^1.8.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
pragma solidity ^0.4.17;
|
||||
|
||||
import "another_folder/another_test.sol";
|
||||
import "zeppelin-solidity/contracts/ownership/Ownable.sol";
|
||||
|
||||
contract SimpleStorageTest is Ownable {
|
||||
uint public storedData;
|
||||
|
||||
function() public payable { }
|
||||
|
||||
function SimpleStorage(uint initialValue) public {
|
||||
storedData = initialValue;
|
||||
}
|
||||
|
||||
function set(uint x) public {
|
||||
storedData = x;
|
||||
}
|
||||
|
||||
function get() public view returns (uint retVal) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue