Skip to content

Commit

Permalink
Merge pull request #5 from tintinweb/fix/windows
Browse files Browse the repository at this point in the history
vyper compile not working on windows
  • Loading branch information
tintinweb authored Oct 21, 2020
2 parents 16bfa66 + 46ec93b commit 954861f
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 296 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 0.0.10
- fix: an issue where the compilation would fail on windows systems #4
- update: disabled mythx.io trial code
- update: disabled signature helper (not yet implemented)
- update: quick code cleanup
- fix: allow workspace relative `vyper.command` #3

## 0.0.9
- updated mythx library: switched from `armlet` to `mythxjs`.
- fix: make settings take effect immediately.
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ Note: Active features can be disabled by setting `Settings` → `Vyper` → `Mod

see [CHANGELOG](./CHANGELOG.md)

## 0.0.9
- updated mythx library: switched from `armlet` to `mythxjs`.
- fix: make settings take effect immediately.
### v0.0.10
- fix: an issue where the compilation would fail on windows systems #4
- update: disabled mythx.io trial code
- update: disabled signature helper (not yet implemented)
- update: quick code cleanup
- fix: allow workspace relative `vyper.command` #3

-----------------------------------------------------------------------------------------------------------
34 changes: 14 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Vyper",
"description": "Ethereum Vyper language support for Visual Studio Code",
"license": "MIT",
"version": "0.0.9",
"version": "0.0.10",
"keywords": [
"vyper",
"ethereum",
Expand Down Expand Up @@ -126,7 +126,7 @@
"fetchGrammar": "rm -f syntaxes/vyper.tmLanguage.json && python3 ./scripts/fetch_vyper_language_spec.py > syntaxes/vyper.tmLanguage.json"
},
"dependencies": {
"async": "^2.6.2",
"async": "^2.6.3",
"chai": "^4.2.0",
"mythxjs": "^1.3.1",
"shell-escape": "^0.2.0"
Expand Down
149 changes: 75 additions & 74 deletions src/extension.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';
/**
* @author github.com/tintinweb
* @license MIT
Expand All @@ -25,74 +25,74 @@ var activeEditor;


/** event funcs */
async function onDidSave(document){
if(document.languageId != settings.LANGUAGE_ID){
console.log("langid mismatch")
async function onDidSave(document) {
if (document.languageId != settings.LANGUAGE_ID) {
console.log("langid mismatch");
return;
}

//always run on save
if(settings.extensionConfig().compile.onSave){
mod_compile.compileContractCommand(document.uri)
if (settings.extensionConfig().compile.onSave) {
mod_compile.compileContractCommand(document);
}
}

async function onDidChange(event) {
if(vscode.window.activeTextEditor.document.languageId != settings.LANGUAGE_ID){
return;
}
if (vscode.window.activeTextEditor.document.languageId != settings.LANGUAGE_ID) {
return;
}

if(settings.extensionConfig().decoration.enable){
mod_deco.decorateWords(activeEditor, [
{
regex:"@\\b(public|payable|modifying)\\b",
captureGroup: 0,
},
{
regex:"\\b(send|raw_call|selfdestruct|raw_log|create_forwarder_to|blockhash)\\b",
captureGroup: 0,
hoverMessage: "❗**potentially unsafe** lowlevel call"
},
], mod_deco.styles.foreGroundWarning);
mod_deco.decorateWords(activeEditor, [
{
regex:"\\b(public|payable|modifying)\\b\\(",
captureGroup: 1,
},
], mod_deco.styles.foreGroundWarningUnderline);
mod_deco.decorateWords(activeEditor, [
{
regex:"\\b(\\.balance|msg\\.[\\w]+|block\\.[\\w]+)\\b",
captureGroup: 0,
}
], mod_deco.styles.foreGroundInfoUnderline);
mod_deco.decorateWords(activeEditor, [
{
regex:"@?\\b(private|nonrentant|constant)\\b",
captureGroup: 0,
},
], mod_deco.styles.foreGroundOk);
mod_deco.decorateWords(activeEditor, [
{
regex:"\\b(log)\\.",
captureGroup: 1,
},
{
regex:"\\b(clear)\\b\\(",
captureGroup: 1,
},
], mod_deco.styles.foreGroundNewEmit);
mod_deco.decorateWords(activeEditor, [
{
regex:"\\b(__init__|__default__)\\b",
captureGroup: 0,
},
], mod_deco.styles.boldUnderline);
}
if (settings.extensionConfig().decoration.enable) {
mod_deco.decorateWords(activeEditor, [
{
regex: "@\\b(public|payable|modifying)\\b",
captureGroup: 0,
},
{
regex: "\\b(send|raw_call|selfdestruct|raw_log|create_forwarder_to|blockhash)\\b",
captureGroup: 0,
hoverMessage: "❗**potentially unsafe** lowlevel call"
},
], mod_deco.styles.foreGroundWarning);
mod_deco.decorateWords(activeEditor, [
{
regex: "\\b(public|payable|modifying)\\b\\(",
captureGroup: 1,
},
], mod_deco.styles.foreGroundWarningUnderline);
mod_deco.decorateWords(activeEditor, [
{
regex: "\\b(\\.balance|msg\\.[\\w]+|block\\.[\\w]+)\\b",
captureGroup: 0,
}
], mod_deco.styles.foreGroundInfoUnderline);
mod_deco.decorateWords(activeEditor, [
{
regex: "@?\\b(private|nonrentant|constant)\\b",
captureGroup: 0,
},
], mod_deco.styles.foreGroundOk);
mod_deco.decorateWords(activeEditor, [
{
regex: "\\b(log)\\.",
captureGroup: 1,
},
{
regex: "\\b(clear)\\b\\(",
captureGroup: 1,
},
], mod_deco.styles.foreGroundNewEmit);
mod_deco.decorateWords(activeEditor, [
{
regex: "\\b(__init__|__default__)\\b",
captureGroup: 0,
},
], mod_deco.styles.boldUnderline);
}
}
function onInitModules(context, type) {
mod_hover.init(context, type)
mod_compile.init(context, type)
mod_hover.init(context, type);
mod_compile.init(context, type);
}

function onActivate(context) {
Expand All @@ -101,11 +101,11 @@ function onActivate(context) {
activeEditor = active;

registerDocType(settings.LANGUAGE_ID);

function registerDocType(type) {
context.subscriptions.push(
vscode.languages.reg
)
);

// taken from: https://github.com/Microsoft/vscode/blob/master/extensions/python/src/pythonMain.ts ; slightly modified
// autoindent while typing
Expand All @@ -120,16 +120,16 @@ function onActivate(context) {

context.subscriptions.push(
vscode.commands.registerCommand('vyper.compileContract', mod_compile.compileContractCommand)
)
if(!settings.extensionConfig().mode.active){
console.log("ⓘ activate extension: entering passive mode. not registering any active code augmentation support.")
);

if (!settings.extensionConfig().mode.active) {
console.log("ⓘ activate extension: entering passive mode. not registering any active code augmentation support.");
return;
}
/** module init */
onInitModules(context, type);
onDidChange()
onDidSave(active.document)
onDidChange();
onDidSave(active.document);

/** event setup */
/***** OnChange */
Expand All @@ -148,23 +148,24 @@ function onActivate(context) {
/***** OnSave */

vscode.workspace.onDidSaveTextDocument(document => {
onDidSave(document);
onDidSave(document);
}, null, context.subscriptions);

/****** OnOpen */
vscode.workspace.onDidOpenTextDocument(document => {
onDidSave(document);
onDidSave(document);
}, null, context.subscriptions);

/***** SignatureHelper */
/*
context.subscriptions.push(
vscode.languages.registerSignatureHelpProvider(
{language: type},
new mod_signatures.VyperSignatureHelpProvider(),
{ language: type },
new mod_signatures.VyperSignatureHelpProvider(),
'(', ','
)
);

)
);
*/

}
}
Expand Down
20 changes: 10 additions & 10 deletions src/features/analyze.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict'
'use strict';
/**
* @author github.com/tintinweb
* @license MIT
*
* */
const vscode = require('vscode');

const {Client} = require('mythxjs');
const { Client } = require('mythxjs');

const analyze = {
mythXjs : function (ethAddress, password, bytecode, deployedBytecode){
mythXjs: function (ethAddress, password, bytecode, deployedBytecode) {
return new Promise(async (resolve, reject) => {
//returns a promise!
const client = new Client(ethAddress, password, 'vscode-vyper-' + vscode.extensions.getExtension('tintinweb.vscode-vyper').packageJSON.version);
const client = new Client(ethAddress, password, 'vscode-vyper-' + vscode.extensions.getExtension('tintinweb.vscode-vyper').packageJSON.version);

await client.login();
const result = await client.analyze({
"bytecode": bytecode,
Expand All @@ -25,15 +25,15 @@ const analyze = {
resolve(analysisResult);
});
}
}
};

const mythXSeverityToVSCodeSeverity = {
"High": vscode.DiagnosticSeverity.Error,
"Medium": vscode.DiagnosticSeverity.Warning,
"Low": vscode.DiagnosticSeverity.Information,
}
};

module.exports = {
analyze:analyze,
mythXSeverityToVSCodeSeverity:mythXSeverityToVSCodeSeverity
}
analyze: analyze,
mythXSeverityToVSCodeSeverity: mythXSeverityToVSCodeSeverity
};
Loading

0 comments on commit 954861f

Please sign in to comment.