Merge pull request #833 from embark-framework/bug_fix/http-inception

Fix contracts with http import inceptions
This commit is contained in:
Iuri Matias 2018-09-14 18:15:52 -04:00 committed by GitHub
commit b53eb11285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -12,6 +12,7 @@ class File {
this.path = options.path; this.path = options.path;
this.basedir = options.basedir; this.basedir = options.basedir;
this.resolver = options.resolver; this.resolver = options.resolver;
this.downloadedImports = false;
} }
parseFileForImport(content, isHttpContract, callback) { parseFileForImport(content, isHttpContract, callback) {
@ -52,12 +53,12 @@ class File {
// We already parsed this file // We already parsed this file
return callback(null, newContent); return callback(null, newContent);
} }
self.downloadedImports = true;
async.each(filesToDownload, ((fileObj, eachCb) => { async.each(filesToDownload, ((fileObj, eachCb) => {
self.downloadFile(fileObj.fileRelativePath, fileObj.url, (_content) => { self.downloadFile(fileObj.fileRelativePath, fileObj.url, (_content) => {
eachCb(); eachCb();
}); });
}), (err) => { }), (err) => {
self.downloadedImports = true;
callback(err, newContent); callback(err, newContent);
}); });
} }
@ -98,7 +99,7 @@ class File {
fs.readFile(filename, next); fs.readFile(filename, next);
}, },
function parseForImports(content, next) { function parseForImports(content, next) {
self.parseFileForImport(content, true, (err) => { self.parseFileForImport(content.toString(), true, (err) => {
next(err, content); next(err, content);
}); });
} }

View File

@ -78,14 +78,16 @@ describe('embark.Config', function () {
"type": "http", "type": "http",
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol", "path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
"basedir": "", "basedir": "",
"resolver": undefined "resolver": undefined,
"downloadedImports": false
}, },
{ {
"filename": ".embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol", "filename": ".embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol",
"type": "http", "type": "http",
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol", "path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
"basedir": "", "basedir": "",
"resolver": undefined "resolver": undefined,
"downloadedImports": false
} }
]; ];
config.loadExternalContractsFiles(); config.loadExternalContractsFiles();