diff --git a/CHANGELOG.md b/CHANGELOG.md index ee0c267..294a9de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 0.0.9 +- updated mythx library: switched from `armlet` to `mythxjs`. +- fix: make settings take effect immediately. + ## 0.0.8 - fix misused promises diff --git a/README.md b/README.md index 2fa48b0..9b140d0 100644 --- a/README.md +++ b/README.md @@ -90,13 +90,8 @@ Note: Active features can be disabled by setting `Settings` → `Vyper` → `Mod see [CHANGELOG](./CHANGELOG.md) -## 0.0.8 -- fix misused promises - -## 0.0.7 -- updated grammar -- fixed mythX issue due to API change -- fixed diagnostics handling: compiler warnings and mythx are now updated on a per file basis. -- fixed run compile / when file is opened the first time, not only on change. +## 0.0.9 +- updated mythx library: switched from `armlet` to `mythxjs`. +- fix: make settings take effect immediately. ----------------------------------------------------------------------------------------------------------- diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..61e7efc --- /dev/null +++ b/package-lock.json @@ -0,0 +1,226 @@ +{ + "name": "vscode-vyper", + "version": "0.0.9", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + }, + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "requires": { + "lodash": "^4.17.14" + } + }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + } + }, + "buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" + }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, + "chai-as-promised": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", + "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", + "requires": { + "check-error": "^1.0.2" + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "requires": { + "type-detect": "^4.0.0" + } + }, + "ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" + }, + "is-buffer": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" + }, + "jsonwebtoken": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", + "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", + "requires": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^5.6.0" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "requires": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" + }, + "lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=" + }, + "lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=" + }, + "lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" + }, + "lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "mythxjs": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/mythxjs/-/mythxjs-1.3.9.tgz", + "integrity": "sha512-FenbCFEdtFmPTr5GASpHNhu0QpjoqF14cfA9U+BCs1SqZUhr/t5F2A92Afy9xkKhVUM/oW4SxLZwf1oqlSr/8A==", + "requires": { + "axios": "^0.19.0", + "chai-as-promised": "^7.1.1", + "jsonwebtoken": "^8.5.1" + } + }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=" + }, + "safe-buffer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "shell-escape": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/shell-escape/-/shell-escape-0.2.0.tgz", + "integrity": "sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=" + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + } + } +} diff --git a/package.json b/package.json index cd09a18..0afc494 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "vscode-vyper", "displayName": "Vyper", "description": "Ethereum Vyper language support for Visual Studio Code", - "version": "0.0.8", + "license": "MIT", + "version": "0.0.9", "keywords": [ "vyper", "ethereum", @@ -125,8 +126,9 @@ "fetchGrammar": "rm -f syntaxes/vyper.tmLanguage.json && python3 ./scripts/fetch_vyper_language_spec.py > syntaxes/vyper.tmLanguage.json" }, "dependencies": { - "armlet": "^2.3.0", "async": "^2.6.2", + "chai": "^4.2.0", + "mythxjs": "^1.3.1", "shell-escape": "^0.2.0" } } diff --git a/src/extension.js b/src/extension.js index a2b181a..d5f6125 100644 --- a/src/extension.js +++ b/src/extension.js @@ -8,17 +8,14 @@ * */ /** imports */ -const vscode = require("vscode") -const crypto = require("crypto") - -const mod_deco = require("./features/deco.js") -const mod_signatures = require("./features/signatures.js") -const mod_hover = require("./features/hover/hover.js") -const mod_compile = require("./features/compile.js") -const mod_analyze = require("./features/analyze.js") +const vscode = require("vscode"); + +const mod_deco = require("./features/deco.js"); +const mod_signatures = require("./features/signatures.js"); +const mod_hover = require("./features/hover/hover.js"); +const mod_compile = require("./features/compile.js"); +const settings = require("./settings"); /** global vars */ -const VYPER_ID = "vyper"; -const vyperConfig = vscode.workspace.getConfiguration(VYPER_ID); var activeEditor; /** classdecs */ @@ -29,23 +26,23 @@ var activeEditor; /** event funcs */ async function onDidSave(document){ - if(document.languageId!=VYPER_ID){ + if(document.languageId != settings.LANGUAGE_ID){ console.log("langid mismatch") return; } //always run on save - if(vyperConfig.compile.onSave){ + if(settings.extensionConfig().compile.onSave){ mod_compile.compileContractCommand(document.uri) } } async function onDidChange(event) { - if(vscode.window.activeTextEditor.document.languageId!=VYPER_ID){ + if(vscode.window.activeTextEditor.document.languageId != settings.LANGUAGE_ID){ return; } - if(vyperConfig.decoration.enable){ + if(settings.extensionConfig().decoration.enable){ mod_deco.decorateWords(activeEditor, [ { regex:"@\\b(public|payable|modifying)\\b", @@ -94,9 +91,8 @@ async function onDidChange(event) { } } function onInitModules(context, type) { - mod_hover.init(context, type, vyperConfig) - mod_compile.init(context, type, vyperConfig) - //mod_analyze.init(context, type, vyperConfig) + mod_hover.init(context, type) + mod_compile.init(context, type) } function onActivate(context) { @@ -105,7 +101,7 @@ function onActivate(context) { if (!active || !active.document) return; activeEditor = active; - registerDocType(VYPER_ID); + registerDocType(settings.LANGUAGE_ID); function registerDocType(type) { context.subscriptions.push( @@ -127,7 +123,7 @@ function onActivate(context) { vscode.commands.registerCommand('vyper.compileContract', mod_compile.compileContractCommand) ) - if(!vyperConfig.mode.active){ + if(!settings.extensionConfig().mode.active){ console.log("ⓘ activate extension: entering passive mode. not registering any active code augmentation support.") return; } diff --git a/src/features/analyze.js b/src/features/analyze.js index 60da277..069fee4 100644 --- a/src/features/analyze.js +++ b/src/features/analyze.js @@ -1,32 +1,29 @@ +'use strict' /** * @author github.com/tintinweb * @license MIT * - * taken from the armlet example * */ +const vscode = require('vscode'); -const armlet = require('armlet') -const vscode = require('vscode') +const {Client} = require('mythxjs'); const analyze = { - mythX : function (ethAddress, password, bytecode, deployedBytecode){ - //returns a promise! - const client = new armlet.Client( - { - password: password, - ethAddress: ethAddress - }) - const data = { - "bytecode": bytecode, - "deployedBytecode": deployedBytecode - }; - return client.analyzeWithStatus( - { - "data": data, // required - "timeout": 2 * 60 * 1000, // optional, but can improve response time - "clientToolName": 'vscode-vyper-' + vscode.extensions.getExtension('tintinweb.vscode-vyper').packageJSON.version, - "noCacheLookup": false - }) + 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); + + await client.login(); + const result = await client.analyze({ + "bytecode": bytecode, + "deployedBytecode": deployedBytecode + }); + + const { uuid } = result; + const analysisResult = await client.getDetectedIssues(uuid); + resolve(analysisResult); + }); } } diff --git a/src/features/compile.js b/src/features/compile.js index a3866de..d16b5e2 100644 --- a/src/features/compile.js +++ b/src/features/compile.js @@ -1,3 +1,4 @@ +'use strict' /** * @author github.com/tintinweb * @license MIT @@ -5,17 +6,18 @@ * compilation related parts taken from: https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-compile-vyper (MIT) * */ -const vscode = require("vscode") +const vscode = require("vscode"); const path = require("path"); const exec = require("child_process").exec; const async = require("async"); -const mod_analyze = require("./analyze.js") +const mod_analyze = require("./analyze.js"); const shellescape = require('shell-escape'); +const settings = require("../settings"); + -var vyperConfig; var extensionContext; var compiler = { - name: "vyper", + name: settings.LANGUAGE_ID, version: null } @@ -47,7 +49,7 @@ compile.display = function(paths, options) { // Check that vyper is available, save its version function checkVyper(callback) { //allow anything as command - no shellescape to even allow python -m vyper --version etc... - exec(`${vyperConfig.command} --version`, function(err, stdout, stderr) { + exec(`${settings.extensionConfig().command} --version`, function(err, stdout, stderr) { if (err) return callback(`Error executing vyper:\n${stderr}`); @@ -60,7 +62,7 @@ function checkVyper(callback) { // Execute vyper for single source file function execVyper(source_path, callback) { const formats = ["abi", "bytecode", "bytecode_runtime"]; - const command = `${vyperConfig.command} -f${formats.join(",")} '${shellescape([source_path])}'`; + const command = `${settings.extensionConfig().command} -f${formats.join(",")} '${shellescape([source_path])}'`; exec(command, function(err, stdout, stderr) { if (err) @@ -173,8 +175,8 @@ function compileActiveFileCommand(contractFile) { vscode.window.showInformationMessage('[Compiler success] ' + Object.keys(success).join(",")) // precedence: (1) vyperConfig, otherwise (2) process.env - let password = vyperConfig.analysis.mythx.password || process.env.MYTHX_PASSWORD - let ethAddress = vyperConfig.analysis.mythx.ethAddress || process.env.MYTHX_ETH_ADDRESS + let password = settings.extensionConfig().analysis.mythx.password || process.env.MYTHX_PASSWORD + let ethAddress = settings.extensionConfig().analysis.mythx.ethAddress || process.env.MYTHX_ETH_ADDRESS //set to trial? if(ethAddress=="trial"){ @@ -203,22 +205,18 @@ function compileActiveFileCommand(contractFile) { } } - if(vyperConfig.analysis.onSave && ethAddress && password){ + if(settings.extensionConfig().analysis.onSave && ethAddress && password){ //if mythx is configured // bytecode for (let contractKey in success) { - mod_analyze.analyze.mythX(ethAddress, password, success[contractKey].bytecode, success[contractKey].deployedBytecode) + mod_analyze.analyze.mythXjs(ethAddress, password, success[contractKey].bytecode, success[contractKey].deployedBytecode) .then(result => { let diagIssues = [] - vscode.window.showInformationMessage('[MythX success] ' + contractKey) - const util = require('util'); - console.debug(`${util.inspect(result.status, {depth: null})}`); - console.debug(`${util.inspect(result.issues, {depth: null})}`); - result.issues.forEach(function(result){ - //console.log(result) - result.issues.forEach(function(issue){ + + result.forEach(function(_result){ + _result.issues.forEach(function(issue){ let shortmsg = `[${issue.severity}] ${issue.swcID}: ${issue.description.head}` - let errormsg = `[${issue.severity}] ${issue.swcID}: ${issue.swcTitle}\n${issue.description.head}\n${issue.description.tail}\n\nCovered Instructions/Paths: ${result.meta.coveredInstructions}/${result.meta.coveredPaths}` + let errormsg = `[${issue.severity}] ${issue.swcID}: ${issue.swcTitle}\n${issue.description.head}\n${issue.description.tail}\n\nCovered Instructions/Paths: ${_result.meta.coveredInstructions}/${_result.meta.coveredPaths}` let lineNr = 1 // we did not submit any source so just pin it to line 0 diagIssues.push({ @@ -232,6 +230,7 @@ function compileActiveFileCommand(contractFile) { }) }) diagnosticCollections.mythx.set(contractFile, diagIssues) + vscode.window.showInformationMessage(`[MythX success] ${contractKey}: ${diagIssues.length} issues`) }).catch(err => { vscode.window.showErrorMessage('[MythX error] ' + err) console.log(err) @@ -312,13 +311,12 @@ function compileActiveFile(contractFile) { }) } -function init(context, type, _vyperConfig) { +function init(context, type) { VYPER_ID = type diagnosticCollections.compiler = vscode.languages.createDiagnosticCollection('Vyper Compiler'); context.subscriptions.push(diagnosticCollections.compiler) diagnosticCollections.mythx = vscode.languages.createDiagnosticCollection('MythX Security Platform'); context.subscriptions.push(diagnosticCollections.mythx) - vyperConfig = _vyperConfig extensionContext = context } diff --git a/src/features/deco.js b/src/features/deco.js index de8e574..9e2a24e 100644 --- a/src/features/deco.js +++ b/src/features/deco.js @@ -1,3 +1,4 @@ +'use strict' /** * @author github.com/tintinweb * @license MIT diff --git a/src/features/hover/hover.js b/src/features/hover/hover.js index 179db27..dc37b88 100644 --- a/src/features/hover/hover.js +++ b/src/features/hover/hover.js @@ -1,9 +1,15 @@ +'use strict' +/** + * @author github.com/tintinweb + * @license MIT + * + * */ const vscode = require('vscode'); -const fs = require('fs') +const fs = require('fs'); const path = require("path"); +const settings = require("../../settings"); const builtinsArr = JSON.parse(fs.readFileSync(path.resolve(__dirname,'./builtins.json'))); -let vyperConfig; function createHover(name, snippet, type) { var text = Array(); @@ -60,7 +66,7 @@ function createHover(name, snippet, type) { } function provideHoverHandler(document, position, token, type) { - if (!vyperConfig.hover.enable) { + if (!settings.extensionConfig().hover.enable) { return; } const range = document.getWordRangeAtPosition(position, /(tx\.gasprice|tx\.origin|msg\.data|msg\.sender|msg\.sig|msg\.value|block\.coinbase|block\.difficulty|block\.gaslimit|block\.number|block\.timestamp|abi\.encodePacked|abi\.encodeWithSelector|abi\.encodeWithSignature|abi\.decode|abi\.encode|\.?[0-9_\w>]+)/); @@ -89,9 +95,7 @@ function provideHoverHandler(document, position, token, type) { } } -function init(context, type, config){ - vyperConfig = config; - +function init(context, type){ context.subscriptions.push( vscode.languages.registerHoverProvider(type, { provideHover(document, position, token) { diff --git a/src/settings.js b/src/settings.js new file mode 100644 index 0000000..1af42c8 --- /dev/null +++ b/src/settings.js @@ -0,0 +1,20 @@ +'use strict' +/** + * @author github.com/tintinweb + * @license MIT + * + * + * */ +/** imports */ +const vscode = require('vscode'); + +const LANGUAGE_ID = "vyper"; + +function extensionConfig() { + return vscode.workspace.getConfiguration(LANGUAGE_ID) +} + +module.exports = { + LANGUAGE_ID: LANGUAGE_ID, + extensionConfig: extensionConfig +} \ No newline at end of file