truffle-plugin-verify
Advanced tools
+2
-1
| { | ||
| "name": "truffle-plugin-verify", | ||
| "version": "0.1.0-alpha1", | ||
| "version": "0.1.0-alpha2", | ||
| "description": "", | ||
@@ -20,2 +20,3 @@ "repository": "https://github.com/rkalis/ethroulette", | ||
| "dependencies": { | ||
| "await-sleep": "0.0.1", | ||
| "axios": "^0.18.0", | ||
@@ -22,0 +23,0 @@ "querystring": "^0.2.0" |
+1
-6
@@ -45,8 +45,4 @@ # truffle-plugin-verify | ||
| This will return a `guid` which can be checked to see if the verification succeeded. This will be automated in a future release. | ||
| This can take some time, and will eventually either return `Pass - Verified` or `Fail - Unable to verify`. | ||
| ``` | ||
| https://api.etherscan.io/api?module=contract&action=checkverifystatus&apikey=MY_API_KEY&guid=MY_GUID | ||
| ``` | ||
| ## Limitations & Roadmap | ||
@@ -62,3 +58,2 @@ This plugin is in a very early version, so there is still a lot missing. Below is a non-exhaustive list of features that are currently missing from the plugin, that will be added in a later release. | ||
| * The plugin assumes it can find build artifacts under the `build/contracts/` directory (i.e. no support for custom paths) | ||
| * The plugin has no support to automatically check the verification status back from Etherscan | ||
| * The plugin can only verify one smart contract at a time, instead of automatically verifying all deployed contracts | ||
@@ -65,0 +60,0 @@ |
+47
-22
| const axios = require('axios') | ||
| const querystring = require('querystring') | ||
| const sleep = require('await-sleep') | ||
@@ -9,2 +10,42 @@ const API_URLS = { | ||
| const VerificationStatus = { | ||
| FAILED: 'Fail - Unable to verify', | ||
| SUCCESS: 'Pass - Verified', | ||
| PENDING: 'Pending in queue' | ||
| } | ||
| const sendVerifyRequest = async (apiUrl, apiKey, networkId, artifact) => { | ||
| return await axios.post( | ||
| apiUrl, | ||
| querystring.stringify({ | ||
| apikey: apiKey, | ||
| module: 'contract', | ||
| action: 'verifysourcecode', | ||
| // TODO: detect deployed networks | ||
| contractaddress: artifact.networks[`${networkId}`].address, | ||
| // TODO: Flatten multi-level contracts | ||
| sourceCode: artifact.source, | ||
| contractname: artifact.contractName, | ||
| compilerversion: `v${artifact.compiler.version.replace('.Emscripten.clang', '')}`, | ||
| optimizationUsed: 0, | ||
| runs: 200, | ||
| // constructorArguements: '$('#constructorArguements').val()' | ||
| }) | ||
| ) | ||
| } | ||
| const verificationStatus = async (apiUrl, apiKey, guid) => { | ||
| while (true) { | ||
| await sleep(1000) | ||
| const verificationResult = await axios.get( | ||
| `${apiUrl}?module=contract&action=checkverifystatus&apikey=${apiKey}&guid=${guid}` | ||
| ) | ||
| if (verificationResult.data.result !== VerificationStatus.PENDING) { | ||
| return verificationResult.data.result | ||
| } | ||
| } | ||
| } | ||
| module.exports = async (config) => { | ||
@@ -17,28 +58,12 @@ const networkId = (config.networks[config.network] || {}).network_id || 4 | ||
| const artifact = require(artifactPath) | ||
| const compilerVersion = `v${artifact.compiler.version.replace('.Emscripten.clang', '')}` | ||
| try { | ||
| const res = await axios.post( | ||
| apiUrl, | ||
| querystring.stringify({ | ||
| apikey: apiKey, | ||
| module: 'contract', | ||
| action: 'verifysourcecode', | ||
| // TODO: detect deployed networks | ||
| contractaddress: artifact.networks[`${networkId}`].address, | ||
| // TODO: Flatten multi-level contracts | ||
| sourceCode: artifact.source, | ||
| contractname: artifact.contractName, | ||
| compilerversion: compilerVersion, | ||
| optimizationUsed: 0, | ||
| runs: 200, | ||
| // constructorArguements: '$('#constructorArguements').val()' | ||
| }) | ||
| ) | ||
| // TODO: Auto-checking status & better error handling | ||
| const res = await sendVerifyRequest(apiUrl, apiKey, networkId, artifact) | ||
| // TODO: Better error handling | ||
| if (res.data && res.data.status === '1') { | ||
| const guid = res.data.result | ||
| console.log(`You can check your verification status with this guid: ${guid}`) | ||
| const status = await verificationStatus(apiUrl, apiKey, res.data.result) | ||
| console.log(status) | ||
| } else { | ||
| console.log(`Something went wrong\n${JSON.stringify(res.data)}`) | ||
| console.log(res.data.result) | ||
| } | ||
@@ -45,0 +70,0 @@ } catch (e) { |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
6132
5.94%67
39.58%3
50%61
-7.58%+ Added
+ Added