Skip to content

Commit

Permalink
ask for MythX trial mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tintinweb committed Apr 29, 2019
1 parent 80ededc commit 0692a4b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@
},
"vyper.analysis.mythx.password": {
"type": "string",
"default": "trial",
"default": "",
"markdownDescription": "MythX Password. See https://mythx.io to get password"
},
"vyper.analysis.mythx.ethAddress": {
"type": "string",
"default": "0x0000000000000000000000000000000000000000",
"markdownDescription": "MetaMask ETH address used to login to MythX. See https://mythx.io"
"default": "initial",
"markdownDescription": "MetaMask ETH address used to login to MythX. Use 'trial' for trial mode. See https://mythx.io"
}
}
},
Expand Down
29 changes: 29 additions & 0 deletions src/features/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const mod_analyze = require("./analyze.js")
const shellescape = require('shell-escape');

var vyperConfig;
var extensionContext;
var compiler = {
name: "vyper",
version: null
Expand Down Expand Up @@ -220,6 +221,33 @@ function compileActiveFileCommand(contractFile) {
let password = vyperConfig.analysis.mythx.password || process.env.MYTHX_PASSWORD
let ethAddress = vyperConfig.analysis.mythx.ethAddress || process.env.MYTHX_ETH_ADDRESS

//set to trial?
if(ethAddress=="trial"){
ethAddress = "0x0000000000000000000000000000000000000000"
password = "trial"
}

//not set and never asked
if(ethAddress == "initial"){
if (typeof extensionContext.globalState.get("vyper.mythx.account.trial") === "undefined"){
vscode.window.showInformationMessage('[MythX ] Enable MythX security analysis trial mode?', "Free Trial", "Tell me more!", "No, Thanks!")
.then(choice => {
if(choice=="Free Trial"){
extensionContext.globalState.update("vyper.mythx.account.trial","useTrial")
return compileActiveFileCommand(contractFile)
} else if(choice=="Tell me more!"){
vscode.env.openExternal(vscode.Uri.parse("https://www.mythx.io/#faq"))
} else {
extensionContext.globalState.update("vyper.mythx.account.trial","noAsk")
}
})
}
if(extensionContext.globalState.get("vyper.mythx.account.trial") && extensionContext.globalState.get("vyper.mythx.account.trial")=="useTrial"){
ethAddress = "0x0000000000000000000000000000000000000000"
password = "trial"
}
}

if(vyperConfig.analysis.onSave && ethAddress && password){
//if mythx is configured
// bytecode
Expand Down Expand Up @@ -291,6 +319,7 @@ function init(context, type, _vyperConfig) {
diagnosticCollections.mythx = vscode.languages.createDiagnosticCollection('MythX Security Platform');
context.subscriptions.push(diagnosticCollections.mythx)
vyperConfig = _vyperConfig
extensionContext = context
}

module.exports = {
Expand Down

0 comments on commit 0692a4b

Please sign in to comment.