-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a193da
commit 500bace
Showing
9 changed files
with
667 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,32 @@ | ||
'use strict'; | ||
const rp = require('request-promise'); | ||
|
||
function getCompilerVersion (parsedData, map) { | ||
module.exports.getCompilerVersion = async (parsedData, map) => { | ||
let compiler; | ||
return new Promise(function (resolve, reject){ | ||
try{ | ||
if(parsedData[0].type != 'PragmaStatement') { | ||
reject(new Error('No Pragma Specified !!!')); | ||
} else { | ||
throw new Error('No Pragma Specified!!!'); | ||
}else { | ||
const pragmaVersion = parsedData[0].start_version.version; | ||
if(Object.keys(map.compilers).indexOf(parsedData[0].start_version.version) > -1){ | ||
compiler = map.compilers[parsedData[0].start_version.version]; | ||
resolve(compiler); | ||
} else { | ||
return compiler; | ||
}else { | ||
const options = { | ||
method: 'GET', | ||
uri: 'https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/list.json', | ||
}; | ||
|
||
rp(options) | ||
.then(function (result) { | ||
const data = JSON.parse(result); | ||
if(!data.releases.hasOwnProperty(pragmaVersion)) { | ||
reject(new Error('Unsupported Compiler Version')); | ||
} else { | ||
const commit = data.releases[pragmaVersion]; | ||
resolve(commit.slice(8, 30)); | ||
} | ||
}) | ||
.catch(function (err) { | ||
reject(err); | ||
}); | ||
const result = await rp(options); | ||
const data = JSON.parse(result); | ||
if(!data.releases.hasOwnProperty(pragmaVersion)) { | ||
throw new Error('Unsupported Compiler Version!!!'); | ||
}else { | ||
const commit = data.releases[pragmaVersion]; | ||
return commit.slice(8, 30); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
module.exports.getCompilerVersion = getCompilerVersion; | ||
}catch(err) { | ||
throw err; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.