diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 75aca1f145..0000000000 --- a/.eslintrc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.base.json" - }, - "plugins": ["@typescript-eslint", "@nrwl/nx"], - "extends": "standard", - "rules": { - }, - "overrides": [ - { - "files": ["*.tsx"], - "rules": { - "@typescript-eslint/no-unused-vars": "off" - } - } - ] -} \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 6557fb70d1..226848ea37 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,6 @@ { "root": true, - "ignorePatterns": ["**/*"], + "ignorePatterns": [], "plugins": ["@nrwl/nx"], "overrides": [ { diff --git a/apps/remix-ide-e2e/src/tests/gist.test.ts b/apps/remix-ide-e2e/src/tests/gist.test.ts index 0fd6efa234..ce348cbdae 100644 --- a/apps/remix-ide-e2e/src/tests/gist.test.ts +++ b/apps/remix-ide-e2e/src/tests/gist.test.ts @@ -36,9 +36,9 @@ module.exports = { .addFile('File.sol', { content: '' }) .executeScript(`remix.loadgist('${gistid}')`) // .perform((done) => { if (runtimeBrowser === 'chrome') { browser.openFile('gists') } done() }) - .waitForElementVisible(`[data-id="treeViewLitreeViewItemgist-${gistid}"]`) - .click(`[data-id="treeViewLitreeViewItemgist-${gistid}"]`) - .openFile(`gist-${gistid}/README.txt`) + .waitForElementVisible(`[data-id="treeViewLitreeViewItem${gistid}"]`) + .click(`[data-id="treeViewLitreeViewItem${gistid}"]`) + .openFile(`${gistid}/README.txt`) // Remix publish to gist /* .click('*[data-id="fileExplorerNewFilepublishToGist"]') .pause(2000) @@ -140,9 +140,9 @@ module.exports = { }) .setValue('*[data-id="gisthandlerModalDialogModalBody-react"] input[data-id="modalDialogCustomPromp"]', testData.validGistId) .modalFooterOKClick('gisthandler') - .openFile(`gist-${testData.validGistId}/README.txt`) - .waitForElementVisible(`div[title='default_workspace/gist-${testData.validGistId}/README.txt']`) - .assert.containsText(`div[title='default_workspace/gist-${testData.validGistId}/README.txt'] > span`, 'README.txt') + .openFile(`${testData.validGistId}/README.txt`) + .waitForElementVisible(`div[title='default_workspace/${testData.validGistId}/README.txt']`) + .assert.containsText(`div[title='default_workspace/${testData.validGistId}/README.txt'] > span`, 'README.txt') .end() } } diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index 49ed612043..063487794a 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts @@ -64,7 +64,7 @@ const clearPayLoad = async (browser: NightwatchBrowser) => { }) } -const clickButton = async (browser: NightwatchBrowser, buttonText: string, waitResult: boolean = true) => { +const clickButton = async (browser: NightwatchBrowser, buttonText: string, waitResult: boolean = true) => { // eslint-disable-line return new Promise((resolve) => { browser.useXpath().waitForElementVisible(`//*[@data-id='${buttonText}']`).pause(100) .click(`//*[@data-id='${buttonText}']`, async () => { @@ -107,7 +107,7 @@ const checkForAcceptAndRemember = async function (browser: NightwatchBrowser) { * @return {Promise} */ -const clickAndCheckLog = async (browser: NightwatchBrowser, buttonText: string, methodResult: any, eventResult: any, payload: any, waitResult: boolean = true) => { +const clickAndCheckLog = async (browser: NightwatchBrowser, buttonText: string, methodResult: any, eventResult: any, payload: any, waitResult: boolean = true) => { // eslint-disable-line if (payload) { await setPayload(browser, payload) } else { diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts index feb70d7d62..da26b27793 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts @@ -202,10 +202,10 @@ module.exports = { .addFile('Storage.sol', sources[6]['Storage.sol']) .addFile('Owner.sol', sources[6]['Owner.sol']) .clickLaunchIcon('udapp') - .createContract('42') + .createContract('42, 24') .openFile('Storage.sol') .clickLaunchIcon('udapp') - .createContract('') // this creation will fail if the component hasn't been properly reset. + .createContract('102') // this creation will fail if the component hasn't been properly reset. .clickInstance(1) .clickFunction('store - transact (not payable)', { types: 'uint256 num', values: '24' }) .testFunction('last', // we check if the contract is actually reachable. @@ -375,7 +375,7 @@ contract C { /** * @dev Set contract deployer as owner */ - constructor(uint p) { + constructor(uint p, uint o) { owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor emit OwnerSet(address(0), owner); } @@ -412,6 +412,10 @@ contract C { uint256 number; + constructor(uint p) { + + } + /** * @dev Store value in variable * @param num value to store diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index bff8161c22..8caec27c66 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -11,6 +11,7 @@ import { VerticalIcons } from './app/components/vertical-icons' import { LandingPage } from './app/ui/landing-page/landing-page' import { MainPanel } from './app/components/main-panel' import { PermissionHandlerPlugin } from './app/plugins/permission-handler-plugin' +import { AstWalker } from '@remix-project/remix-astwalker' import { WalkthroughService } from './walkthroughService' @@ -28,7 +29,7 @@ const isElectron = require('is-electron') const remixLib = require('@remix-project/remix-lib') -const QueryParams = require('./lib/query-params') +import { QueryParams } from '@remix-project/remix-lib' const Storage = remixLib.Storage const RemixDProvider = require('./app/files/remixDProvider') const Config = require('./config') @@ -52,10 +53,9 @@ const { TabProxy } = require('./app/panels/tab-proxy.js') class AppComponent { constructor () { - const self = this - self.appManager = new RemixAppManager({}) - self.queryParams = new QueryParams() - self._components = {} + this.appManager = new RemixAppManager({}) + this.queryParams = new QueryParams() + this._components = {} // setup storage const configStorage = new Storage('config-v0.8:') @@ -64,54 +64,55 @@ class AppComponent { Registry.getInstance().put({ api: config, name: 'config' }) // load file system - self._components.filesProviders = {} - self._components.filesProviders.browser = new FileProvider('browser') + this._components.filesProviders = {} + this._components.filesProviders.browser = new FileProvider('browser') Registry.getInstance().put({ - api: self._components.filesProviders.browser, + api: this._components.filesProviders.browser, name: 'fileproviders/browser' }) - self._components.filesProviders.localhost = new RemixDProvider( - self.appManager + this._components.filesProviders.localhost = new RemixDProvider( + this.appManager ) Registry.getInstance().put({ - api: self._components.filesProviders.localhost, + api: this._components.filesProviders.localhost, name: 'fileproviders/localhost' }) - self._components.filesProviders.workspace = new WorkspaceFileProvider() + this._components.filesProviders.workspace = new WorkspaceFileProvider() Registry.getInstance().put({ - api: self._components.filesProviders.workspace, + api: this._components.filesProviders.workspace, name: 'fileproviders/workspace' }) Registry.getInstance().put({ - api: self._components.filesProviders, + api: this._components.filesProviders, name: 'fileproviders' }) } async run () { - const self = this // APP_MANAGER - const appManager = self.appManager - const pluginLoader = self.appManager.pluginLoader - self.panels = {} - self.workspace = pluginLoader.get() - self.engine = new RemixEngine() - self.engine.register(appManager) + const appManager = this.appManager + const pluginLoader = this.appManager.pluginLoader + this.panels = {} + this.workspace = pluginLoader.get() + this.engine = new RemixEngine() + this.engine.register(appManager); + + const matomoDomains = { 'remix-alpha.ethereum.org': 27, 'remix-beta.ethereum.org': 25, 'remix.ethereum.org': 23 } - self.showMatamo = + this.showMatamo = matomoDomains[window.location.hostname] && !Registry.getInstance() .get('config') .api.exists('settings/matomo-analytics') - self.walkthroughService = new WalkthroughService( + this.walkthroughService = new WalkthroughService( appManager, - self.showMatamo + this.showMatamo ) const hosts = ['127.0.0.1:8080', '192.168.0.101:8080', 'localhost:8080'] @@ -125,10 +126,10 @@ class AppComponent { // SERVICES // ----------------- gist service --------------------------------- - self.gistHandler = new GistHandler() + this.gistHandler = new GistHandler() // ----------------- theme service --------------------------------- - self.themeModule = new ThemeModule() - Registry.getInstance().put({ api: self.themeModule, name: 'themeModule' }) + this.themeModule = new ThemeModule() + Registry.getInstance().put({ api: this.themeModule, name: 'themeModule' }) // ----------------- editor service ---------------------------- const editor = new Editor() // wrapper around ace editor @@ -189,24 +190,24 @@ class AppComponent { } } ) - const contextualListener = new EditorContextListener() + const contextualListener = new EditorContextListener(new AstWalker()) - self.notification = new NotificationPlugin() + this.notification = new NotificationPlugin() const configPlugin = new ConfigPlugin() - self.layout = new Layout() + this.layout = new Layout() const permissionHandler = new PermissionHandlerPlugin() - self.engine.register([ + this.engine.register([ permissionHandler, - self.layout, - self.notification, - self.gistHandler, + this.layout, + this.notification, + this.gistHandler, configPlugin, blockchain, contentImport, - self.themeModule, + this.themeModule, editor, fileManager, compilerMetadataGenerator, @@ -220,46 +221,46 @@ class AppComponent { dGitProvider, storagePlugin, hardhatProvider, - self.walkthroughService + this.walkthroughService ]) // LAYOUT & SYSTEM VIEWS const appPanel = new MainPanel() - Registry.getInstance().put({ api: self.mainview, name: 'mainview' }) + Registry.getInstance().put({ api: this.mainview, name: 'mainview' }) const tabProxy = new TabProxy(fileManager, editor) - self.engine.register([appPanel, tabProxy]) + this.engine.register([appPanel, tabProxy]) // those views depend on app_manager - self.menuicons = new VerticalIcons() - self.sidePanel = new SidePanel() - self.hiddenPanel = new HiddenPanel() + this.menuicons = new VerticalIcons() + this.sidePanel = new SidePanel() + this.hiddenPanel = new HiddenPanel() const pluginManagerComponent = new PluginManagerComponent( appManager, - self.engine + this.engine ) const filePanel = new FilePanel(appManager) const landingPage = new LandingPage( appManager, - self.menuicons, + this.menuicons, fileManager, filePanel, contentImport ) - self.settings = new SettingsTab( + this.settings = new SettingsTab( Registry.getInstance().get('config').api, editor, appManager ) - self.engine.register([ - self.menuicons, + this.engine.register([ + this.menuicons, landingPage, - self.hiddenPanel, - self.sidePanel, + this.hiddenPanel, + this.sidePanel, filePanel, pluginManagerComponent, - self.settings + this.settings ]) // CONTENT VIEWS & DEFAULT PLUGINS @@ -288,7 +289,7 @@ class AppComponent { contentImport ) - self.engine.register([ + this.engine.register([ compileTab, run, debug, @@ -300,7 +301,7 @@ class AppComponent { filePanel.slitherHandle ]) - self.layout.panels = { + this.layout.panels = { tabs: { plugin: tabProxy, active: true }, editor: { plugin: editor, active: true }, main: { plugin: appPanel, active: false }, @@ -311,14 +312,13 @@ class AppComponent { async activate () { const queryParams = new QueryParams() const params = queryParams.get() - const self = this - + if (isElectron()) { - self.appManager.activatePlugin('remixd') + this.appManager.activatePlugin('remixd') } try { - self.engine.register(await self.appManager.registeredPlugins()) + this.engine.register(await this.appManager.registeredPlugins()) } catch (e) { console.log("couldn't register iframe plugins", e.message) } @@ -338,20 +338,20 @@ class AppComponent { 'filePanel', 'workspaceInitializationCompleted', async () => { - await self.appManager.registerContextMenuItems() + await this.appManager.registerContextMenuItems() } ) - await self.appManager.activatePlugin(['filePanel']) + await this.appManager.activatePlugin(['filePanel']) // Set workspace after initial activation - self.appManager.on('editor', 'editorMounted', () => { - if (Array.isArray(self.workspace)) { - self.appManager - .activatePlugin(self.workspace) + this.appManager.on('editor', 'editorMounted', () => { + if (Array.isArray(this.workspace)) { + this.appManager + .activatePlugin(this.workspace) .then(async () => { try { if (params.deactivate) { - await self.appManager.deactivatePlugin( + await this.appManager.deactivatePlugin( params.deactivate.split(',') ) } @@ -360,21 +360,21 @@ class AppComponent { } if (params.code) { // if code is given in url we focus on solidity plugin - self.menuicons.select('solidity') + this.menuicons.select('solidity') } else { // If plugins are loaded from the URL params, we focus on the last one. if ( - self.appManager.pluginLoader.current === 'queryParams' && - self.workspace.length > 0 - ) { self.menuicons.select(self.workspace[self.workspace.length - 1]) } + this.appManager.pluginLoader.current === 'queryParams' && + this.workspace.length > 0 + ) { this.menuicons.select(this.workspace[this.workspace.length - 1]) } } if (params.call) { const callDetails = params.call.split('//') if (callDetails.length > 1) { - self.appManager.call('notification', 'toast', `initiating ${callDetails[0]} ...`) + this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} ...`) // @todo(remove the timeout when activatePlugin is on 0.3.0) - self.appManager.call(...callDetails).catch(console.error) + this.appManager.call(...callDetails).catch(console.error) } } }) @@ -382,7 +382,7 @@ class AppComponent { } }) // activate solidity plugin - self.appManager.activatePlugin(['solidity', 'udapp']) + this.appManager.activatePlugin(['solidity', 'udapp']) // Load and start the service who manager layout and frame } } diff --git a/apps/remix-ide/src/app/files/dgitProvider.js b/apps/remix-ide/src/app/files/dgitProvider.js index 84a9af0c63..d52ab69053 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.js +++ b/apps/remix-ide/src/app/files/dgitProvider.js @@ -61,6 +61,7 @@ class DGitProvider extends Plugin { corsProxy: 'https://corsproxy.remixproject.org/', http, onAuth: url => { + url const auth = { username: input.token, password: '' @@ -131,6 +132,7 @@ class DGitProvider extends Plugin { try { remotes = await git.listRemotes({ ...await this.getGitConfig() }) } catch (e) { + console.log(e) } return remotes } @@ -208,7 +210,7 @@ class DGitProvider extends Plugin { async setIpfsConfig (config) { this.ipfsconfig = config - return new Promise((resolve, reject) => { + return new Promise((resolve) => { resolve(this.checkIpfsConfig()) }) } @@ -430,7 +432,7 @@ class DGitProvider extends Plugin { } catch (error) { throw new Error(error) } - }; + } async importIPFSFiles (config, cid, workspace) { const ipfs = IpfsHttpClient(config) @@ -471,7 +473,7 @@ class DGitProvider extends Plugin { } _xLen = ((localStorage[_x].length + _x.length) * 2) _lsTotal += _xLen - }; + } return (_lsTotal / 1024).toFixed(2) } diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index cb14eb12e6..47b6372ea6 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -87,6 +87,7 @@ class FileProvider { } async get (path, cb) { + cb = cb || function () { /* do nothing. */ } path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here var unprefixedpath = this.removePrefix(path) try { @@ -100,6 +101,7 @@ class FileProvider { } async set (path, content, cb) { + cb = cb || function () { /* do nothing. */ } var unprefixedpath = this.removePrefix(path) const exists = await window.remixFileSystem.exists(unprefixedpath) if (exists && await window.remixFileSystem.readFile(unprefixedpath, 'utf8') === content) { @@ -211,8 +213,8 @@ class FileProvider { * @param {Function} visitFolder is a function called for each visited folders */ async _copyFolderToJsonInternal (path, visitFile, visitFolder) { - visitFile = visitFile || (() => { }) - visitFolder = visitFolder || (() => { }) + visitFile = visitFile || function () { /* do nothing. */ } + visitFolder = visitFolder || function () { /* do nothing. */ } const json = {} path = this.removePrefix(path) @@ -248,8 +250,8 @@ class FileProvider { * @param {Function} visitFolder is a function called for each visited folders */ async copyFolderToJson (path, visitFile, visitFolder) { - visitFile = visitFile || (() => { }) - visitFolder = visitFolder || (() => { }) + visitFile = visitFile || function () { /* do nothing. */ } + visitFolder = visitFolder || function () { /* do nothing. */ } return await this._copyFolderToJsonInternal(path, visitFile, visitFolder) } diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index 3f8f9bf0ce..c616d3bd74 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -68,8 +68,8 @@ class WorkspaceFileProvider extends FileProvider { } async copyFolderToJson (directory, visitFile, visitFolder) { - visitFile = visitFile || (() => {}) - visitFolder = visitFolder || (() => {}) + visitFile = visitFile || function () { /* do nothing. */ } + visitFolder = visitFolder || function () { /* do nothing. */ } const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g') let json = await super._copyFolderToJsonInternal(directory, ({ path, content }) => { visitFile({ path: path.replace(regex, ''), content }) diff --git a/apps/remix-ide/src/app/panels/layout.ts b/apps/remix-ide/src/app/panels/layout.ts index 663692db26..085dbc120f 100644 --- a/apps/remix-ide/src/app/panels/layout.ts +++ b/apps/remix-ide/src/app/panels/layout.ts @@ -1,7 +1,7 @@ import { Plugin } from '@remixproject/engine' import { Profile } from '@remixproject/plugin-utils' import { EventEmitter } from 'events' -import QueryParams from '../../lib/query-params' +import { QueryParams } from '@remix-project/remix-lib' const profile: Profile = { name: 'layout', @@ -21,6 +21,12 @@ interface panels { terminal: panelState } +export type PanelConfiguration = { + minimizeterminal: boolean, + minimizesidepanel: boolean, + embed: boolean +} + export class Layout extends Plugin { event: any panels: panels @@ -77,7 +83,7 @@ export class Layout extends Plugin { } }) const queryParams = new QueryParams() - const params = queryParams.get() + const params = queryParams.get() as PanelConfiguration if (params.minimizeterminal || params.embed) { this.panels.terminal.minimized = true this.event.emit('change', this.panels) diff --git a/apps/remix-ide/src/app/panels/terminal.js b/apps/remix-ide/src/app/panels/terminal.js index fd17d8b450..0854f7586e 100644 --- a/apps/remix-ide/src/app/panels/terminal.js +++ b/apps/remix-ide/src/app/panels/terminal.js @@ -117,6 +117,7 @@ class Terminal extends Plugin { scroll2bottom () { setTimeout(function () { + // do nothing. }, 0) } } diff --git a/apps/remix-ide/src/app/plugins/config.ts b/apps/remix-ide/src/app/plugins/config.ts index 61f7cdd41f..e44d403a12 100644 --- a/apps/remix-ide/src/app/plugins/config.ts +++ b/apps/remix-ide/src/app/plugins/config.ts @@ -1,5 +1,5 @@ import { Plugin } from '@remixproject/engine' -import QueryParams from '../../lib/query-params' +import { QueryParams } from '@remix-project/remix-lib' import Registry from '../state/registry' const profile = { diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index bcc11fa2dd..4718b4dee6 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -3,9 +3,9 @@ import React from 'react' // eslint-disable-line import ReactDOM from 'react-dom' import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line import { CompileTabLogic } from '@remix-ui/solidity-compiler' // eslint-disable-line -import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' +import { CompilerApiMixin } from '@remixproject/solidity-compiler-plugin' // eslint-disable-line import { ViewPlugin } from '@remixproject/engine-web' -import QueryParams from '../../lib/query-params' +import { QueryParams } from '@remix-project/remix-lib' // import { ICompilerApi } from '@remix-project/remix-lib-ts' import * as packageJson from '../../../../../package.json' import { compilerConfigChangedToastMsg, compileToastMsg } from '@remix-ui/helper' diff --git a/apps/remix-ide/src/app/tabs/debugger-tab.js b/apps/remix-ide/src/app/tabs/debugger-tab.js index 741a433795..6ac7235c09 100644 --- a/apps/remix-ide/src/app/tabs/debugger-tab.js +++ b/apps/remix-ide/src/app/tabs/debugger-tab.js @@ -1,5 +1,5 @@ import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line -import { DebuggerApiMixin } from '@remixproject/debugger-plugin' +import { DebuggerApiMixin } from '@remixproject/debugger-plugin' // eslint-disable-line import { ViewPlugin } from '@remixproject/engine-web' import * as packageJson from '../../../../../package.json' import React from 'react' // eslint-disable-line diff --git a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js index a8b71b815e..6178063843 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -11,10 +11,9 @@ const helper = require('../../../../lib/helper') */ class Recorder { constructor (blockchain) { - var self = this - self.event = new EventManager() - self.blockchain = blockchain - self.data = { _listen: true, _replay: false, journal: [], _createdContracts: {}, _createdContractsReverse: {}, _usedAccounts: {}, _abis: {}, _contractABIReferences: {}, _linkReferences: {} } + this.event = new EventManager() + this.blockchain = blockchain + this.data = { _listen: true, _replay: false, journal: [], _createdContracts: {}, _createdContractsReverse: {}, _usedAccounts: {}, _abis: {}, _contractABIReferences: {}, _linkReferences: {} } this.blockchain.event.register('initiatingTransaction', (timestamp, tx, payLoad) => { if (tx.useCall) return @@ -33,11 +32,11 @@ class Recorder { if (record.linkReferences && Object.keys(record.linkReferences).length) { for (var file in record.linkReferences) { for (var lib in record.linkReferences[file]) { - self.data._linkReferences[lib] = '
' + this.data._linkReferences[lib] = '
' } } } - self.data._abis[keccak] = abi + this.data._abis[keccak] = abi this.data._contractABIReferences[timestamp] = keccak } else { @@ -57,8 +56,8 @@ class Recorder { this.blockchain.getAccounts((error, accounts) => { if (error) return console.log(error) record.from = `account{${accounts.indexOf(from)}}` - self.data._usedAccounts[record.from] = from - self.append(timestamp, record) + this.data._usedAccounts[record.from] = from + this.append(timestamp, record) }) } }) @@ -128,9 +127,8 @@ class Recorder { * */ append (timestamp, record) { - var self = this - self.data.journal.push({ timestamp, record }) - self.event.trigger('newTxRecorded', [self.data.journal.length]) + this.data.journal.push({ timestamp, record }) + this.event.trigger('newTxRecorded', [this.data.journal.length]) } /** @@ -138,17 +136,16 @@ class Recorder { * */ getAll () { - var self = this - var records = [].concat(self.data.journal) + var records = [].concat(this.data.journal) return { - accounts: self.data._usedAccounts, - linkReferences: self.data._linkReferences, + accounts: this.data._usedAccounts, + linkReferences: this.data._linkReferences, transactions: records.sort((A, B) => { var stampA = A.timestamp var stampB = B.timestamp return stampA - stampB }), - abis: self.data._abis + abis: this.data._abis } } @@ -157,17 +154,16 @@ class Recorder { * */ clearAll () { - var self = this - self.data._listen = true - self.data._replay = false - self.data.journal = [] - self.data._createdContracts = {} - self.data._createdContractsReverse = {} - self.data._usedAccounts = {} - self.data._abis = {} - self.data._contractABIReferences = {} - self.data._linkReferences = {} - self.event.trigger('cleared', []) + this.data._listen = true + this.data._replay = false + this.data.journal = [] + this.data._createdContracts = {} + this.data._createdContractsReverse = {} + this.data._usedAccounts = {} + this.data._abis = {} + this.data._contractABIReferences = {} + this.data._linkReferences = {} + this.event.trigger('cleared', []) } /** @@ -180,11 +176,10 @@ class Recorder { * */ run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, newContractFn) { - var self = this - self.setListen(false) + this.setListen(false) logCallBack(`Running ${records.length} transaction(s) ...`) - async.eachOfSeries(records, function (tx, index, cb) { - var record = self.resolveAddress(tx.record, accounts, options) + async.eachOfSeries(records, (tx, index, cb) => { + var record = this.resolveAddress(tx.record, accounts, options) var abi = abis[tx.record.abi] if (!abi) { return alertCb('cannot find ABI for ' + tx.record.abi + '. Execution stopped at ' + index) @@ -193,9 +188,9 @@ class Recorder { if (record.linkReferences && Object.keys(record.linkReferences).length) { for (var k in linkReferences) { var link = linkReferences[k] - var timestamp = self.extractTimestamp(link) - if (timestamp && self.data._createdContractsReverse[timestamp]) { - link = self.data._createdContractsReverse[timestamp] + var timestamp = this.extractTimestamp(link) + if (timestamp && this.data._createdContractsReverse[timestamp]) { + link = this.data._createdContractsReverse[timestamp] } tx.record.bytecode = format.linkLibraryStandardFromlinkReferences(k, link.replace('0x', ''), tx.record.bytecode, tx.record.linkReferences) } @@ -224,8 +219,8 @@ class Recorder { isString = false value = JSON.stringify(value) } - for (var timestamp in self.data._createdContractsReverse) { - value = value.replace(new RegExp('created\\{' + timestamp + '\\}', 'g'), self.data._createdContractsReverse[timestamp]) + for (var timestamp in this.data._createdContractsReverse) { + value = value.replace(new RegExp('created\\{' + timestamp + '\\}', 'g'), this.data._createdContractsReverse[timestamp]) } if (!isString) value = JSON.parse(value) tx.record.parameters[index] = value @@ -243,8 +238,8 @@ class Recorder { logCallBack(`(${index}) data: ${data.data}`) record.data = { dataHex: data.data, funArgs: tx.record.parameters, funAbi: fnABI, contractBytecode: tx.record.bytecode, contractName: tx.record.contractName, timestamp: tx.timestamp } - self.blockchain.runTx(record, confirmationCb, continueCb, promptCb, - function (err, txResult, rawAddress) { + this.blockchain.runTx(record, confirmationCb, continueCb, promptCb, + (err, txResult, rawAddress) => { if (err) { console.error(err) return logCallBack(err + '. Execution failed at ' + index) @@ -252,14 +247,14 @@ class Recorder { if (rawAddress) { const address = helper.addressToString(rawAddress) // save back created addresses for the convertion from tokens to real adresses - self.data._createdContracts[address] = tx.timestamp - self.data._createdContractsReverse[tx.timestamp] = address + this.data._createdContracts[address] = tx.timestamp + this.data._createdContractsReverse[tx.timestamp] = address newContractFn(abi, address, record.contractName) } cb(err) } ) - }, () => { self.setListen(true) }) + }, () => { this.setListen(true) }) } runScenario (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) { diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 40dd78b326..a03d74a846 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -119,7 +119,7 @@ module.exports = class TestTab extends ViewPlugin { usingWorker: canUseWorker(currentVersion), runs } - this.testRunner.runTestSources(runningTest, compilerConfig, () => {}, () => {}, null, (error, result) => { + this.testRunner.runTestSources(runningTest, compilerConfig, () => { /* Do nothing. */ }, () => { /* Do nothing. */ }, null, (error, result) => { if (error) return reject(error) resolve(result) }, (url, cb) => { diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index e973bdd2f9..78c8f1788d 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -1,6 +1,6 @@ import { Plugin } from '@remixproject/engine' import { EventEmitter } from 'events' -import QueryParams from '../../lib/query-params' +import { QueryParams } from '@remix-project/remix-lib' import * as packageJson from '../../../../../package.json' import Registry from '../state/registry' const _paq = window._paq = window._paq || [] diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index d3bc4e60ce..8b0ebfba87 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -303,7 +303,7 @@ export class Blockchain extends Plugin { }, (data, runTxCallback) => { // called for libraries deployment - this.runTx(data, confirmationCb, runTxCallback, promptCb, () => {}) + this.runTx(data, confirmationCb, runTxCallback, promptCb, () => { /* Do nothing. */ }) }) } @@ -422,72 +422,70 @@ export class Blockchain extends Plugin { } runTx (args, confirmationCb, continueCb, promptCb, cb) { - const self = this waterfall([ - function getGasLimit (next) { - if (self.transactionContextAPI.getGasLimit) { - return self.transactionContextAPI.getGasLimit(next) + (next) => { // getGasLimit + if (this.transactionContextAPI.getGasLimit) { + return this.transactionContextAPI.getGasLimit(next) } next(null, 3000000) }, - function queryValue (gasLimit, next) { + (gasLimit, next) => { // queryValue if (args.value) { return next(null, args.value, gasLimit) } - if (args.useCall || !self.transactionContextAPI.getValue) { + if (args.useCall || !this.transactionContextAPI.getValue) { return next(null, 0, gasLimit) } - self.transactionContextAPI.getValue(function (err, value) { + this.transactionContextAPI.getValue(function (err, value) { next(err, value, gasLimit) }) }, - function getAccount (value, gasLimit, next) { + (value, gasLimit, next) => { // getAccount if (args.from) { return next(null, args.from, value, gasLimit) } - if (self.transactionContextAPI.getAddress) { - return self.transactionContextAPI.getAddress(function (err, address) { + if (this.transactionContextAPI.getAddress) { + return this.transactionContextAPI.getAddress(function (err, address) { next(err, address, value, gasLimit) }) } - self.getAccounts(function (err, accounts) { + this.getAccounts(function (err, accounts) { const address = accounts[0] if (err) return next(err) if (!address) return next('No accounts available') - // if (self.executionContext.isVM() && !self.providers.vm.accounts[address]) { - if (self.executionContext.isVM() && !self.providers.vm.RemixSimulatorProvider.Accounts.accounts[address]) { + if (this.executionContext.isVM() && !this.providers.vm.RemixSimulatorProvider.Accounts.accounts[address]) { return next('Invalid account selected') } next(null, address, value, gasLimit) }) }, - function runTransaction (fromAddress, value, gasLimit, next) { + (fromAddress, value, gasLimit, next) => { // runTransaction const tx = { to: args.to, data: args.data.dataHex, useCall: args.useCall, from: fromAddress, value: value, gasLimit: gasLimit, timestamp: args.data.timestamp } const payLoad = { funAbi: args.data.funAbi, funArgs: args.data.funArgs, contractBytecode: args.data.contractBytecode, contractName: args.data.contractName, contractABI: args.data.contractABI, linkReferences: args.data.linkReferences } if (!tx.timestamp) tx.timestamp = Date.now() const timestamp = tx.timestamp - self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad]) - self.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb, + this.event.trigger('initiatingTransaction', [timestamp, tx, payLoad]) + this.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb, async (error, result) => { if (error) return next(error) - const isVM = self.executionContext.isVM() + const isVM = this.executionContext.isVM() if (isVM && tx.useCall) { try { - result.transactionHash = await self.web3().eth.getHashFromTagBySimulator(timestamp) + result.transactionHash = await this.web3().eth.getHashFromTagBySimulator(timestamp) } catch (e) { console.log('unable to retrieve back the "call" hash', e) } } const eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted') - self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad]) + this.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad]) if (error && (typeof (error) !== 'string')) { if (error.message) error = error.message else { - try { error = 'error: ' + JSON.stringify(error) } catch (e) {} + try { error = 'error: ' + JSON.stringify(error) } catch (e) { console.log(e) } } } next(error, result, tx) diff --git a/apps/remix-ide/src/blockchain/execution-context.js b/apps/remix-ide/src/blockchain/execution-context.js index 54e738b245..6f4a615b18 100644 --- a/apps/remix-ide/src/blockchain/execution-context.js +++ b/apps/remix-ide/src/blockchain/execution-context.js @@ -129,9 +129,9 @@ export class ExecutionContext { async executionContextChange (value, endPointUrl, confirmCb, infoCb, cb) { const context = value.context - if (!cb) cb = () => {} - if (!confirmCb) confirmCb = () => {} - if (!infoCb) infoCb = () => {} + if (!cb) cb = () => { /* Do nothing. */ } + if (!confirmCb) confirmCb = () => { /* Do nothing. */ } + if (!infoCb) infoCb = () => { /* Do nothing. */ } if (context === 'vm') { this.executionContext = context this.currentFork = value.fork diff --git a/apps/remix-ide/src/blockchain/providers/injected.js b/apps/remix-ide/src/blockchain/providers/injected.js index f1272dc058..ae52390a44 100644 --- a/apps/remix-ide/src/blockchain/providers/injected.js +++ b/apps/remix-ide/src/blockchain/providers/injected.js @@ -17,6 +17,7 @@ class InjectedProvider { } resetEnvironment () { + /* Do nothing. */ } getBalanceInEther (address, cb) { diff --git a/apps/remix-ide/src/blockchain/providers/node.js b/apps/remix-ide/src/blockchain/providers/node.js index b62158ec69..2896486064 100644 --- a/apps/remix-ide/src/blockchain/providers/node.js +++ b/apps/remix-ide/src/blockchain/providers/node.js @@ -25,6 +25,7 @@ class NodeProvider { } resetEnvironment () { + /* Do nothing. */ } getBalanceInEther (address, cb) { diff --git a/apps/remix-ide/src/config.js b/apps/remix-ide/src/config.js index adfc1fda9b..7e0a900f37 100644 --- a/apps/remix-ide/src/config.js +++ b/apps/remix-ide/src/config.js @@ -15,6 +15,7 @@ function Config (storage) { this.items = JSON.parse(config) } } catch (exception) { + /* Do nothing. */ } this.exists = function (key) { @@ -31,6 +32,7 @@ function Config (storage) { storage.set(CONFIG_FILE, JSON.stringify(this.items)) this.events.emit(key + '_changed', content) } catch (exception) { + /* Do nothing. */ } } diff --git a/apps/remix-ide/src/lib/query-params.js b/apps/remix-ide/src/lib/query-params.js deleted file mode 100644 index 739971fac2..0000000000 --- a/apps/remix-ide/src/lib/query-params.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict' - -// Allowing window to be overriden for testing -function QueryParams (_window) { - if (_window === undefined) _window = window - - this.get = function () { - var qs = _window.location.hash.substr(1) - - if (_window.location.search.length > 0) { - // use legacy query params instead of hash - _window.location.hash = _window.location.search.substr(1) - _window.location.search = '' - } - - var params = {} - var parts = qs.split('&') - for (var x in parts) { - var keyValue = parts[x].split('=') - if (keyValue[0] !== '') { - params[keyValue[0]] = keyValue[1] - } - } - return params - } - - this.update = function (params) { - var currentParams = this.get() - var keys = Object.keys(params) - for (var x in keys) { - currentParams[keys[x]] = params[keys[x]] - } - var queryString = '#' - var updatedKeys = Object.keys(currentParams) - for (var y in updatedKeys) { - queryString += updatedKeys[y] + '=' + currentParams[updatedKeys[y]] + '&' - } - _window.location.hash = queryString.slice(0, -1) - } -} - -module.exports = QueryParams diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 60543c9e2b..ce7ea97b27 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -1,7 +1,6 @@ -/* global localStorage, fetch */ import { PluginManager } from '@remixproject/engine' import { EventEmitter } from 'events' -import QueryParams from './lib/query-params' +import { QueryParams } from '@remix-project/remix-lib' import { IframePlugin } from '@remixproject/engine-web' const _paq = window._paq = window._paq || [] @@ -174,7 +173,7 @@ class PluginLoader { } this.loaders.queryParams = { - set: () => {}, + set: () => { /* Do nothing. */ }, get: () => { const { activate } = queryParams.get() if (!activate) return [] diff --git a/libs/remix-astwalker/src/sourceMappings.ts b/libs/remix-astwalker/src/sourceMappings.ts index 1246eb387b..869f495946 100644 --- a/libs/remix-astwalker/src/sourceMappings.ts +++ b/libs/remix-astwalker/src/sourceMappings.ts @@ -73,7 +73,7 @@ export class SourceMappings { lineBreaks.push(pos) } this.lineBreaks = lineBreaks - }; + } /** * Get a list of nodes that are at the given "position". diff --git a/libs/remix-astwalker/tsconfig.json b/libs/remix-astwalker/tsconfig.json index b516fcbd30..7f163468b2 100644 --- a/libs/remix-astwalker/tsconfig.json +++ b/libs/remix-astwalker/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "types": ["node"], - "module": "commonjs", - "esModuleInterop": true + "esModuleInterop": true }, "include": ["**/*.ts"] } \ No newline at end of file diff --git a/libs/remix-astwalker/tsconfig.lib.json b/libs/remix-astwalker/tsconfig.lib.json index ea82c38ae0..4c89a574be 100644 --- a/libs/remix-astwalker/tsconfig.lib.json +++ b/libs/remix-astwalker/tsconfig.lib.json @@ -1,16 +1,17 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, - "rootDir": "./src", - "types": ["node"] - }, - "exclude": [ - "**/*.spec.ts", - "tests/" - ], - "include": ["**/*.ts"] - } - \ No newline at end of file + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../dist/out-tsc", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": [ + "**/*.spec.ts", + "tests/" + ], + "include": ["**/*.ts"] +} diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index 7bd495e07d..2b88d26064 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -9,8 +9,14 @@ const profile = { methods: ['resolve', 'resolveAndSave', 'isExternalUrl'] } +export type ResolvedImport = { + content: string, + cleanUrl: string + type: string +} + export class CompilerImports extends Plugin { - previouslyHandled: {} + previouslyHandled: Record urlResolver: any constructor () { super(profile) @@ -64,9 +70,9 @@ export class CompilerImports extends Plugin { if (!loadingCb) loadingCb = () => {} if (!cb) cb = () => {} - var self = this + const self = this if (force) delete this.previouslyHandled[url] - var imported = this.previouslyHandled[url] + const imported = this.previouslyHandled[url] if (imported) { return cb(null, imported.content, imported.cleanUrl, imported.type, url) } diff --git a/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts b/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts index 706937da7a..63a7880382 100644 --- a/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts +++ b/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts @@ -2,8 +2,7 @@ import { Plugin } from '@remixproject/engine' import { compile } from '@remix-project/remix-solidity' import { util } from '@remix-project/remix-lib' - -const ethutil = require('ethereumjs-util') +import { toChecksumAddress } from 'ethereumjs-util' const profile = { name: 'fetchAndCompile', @@ -32,7 +31,7 @@ export class FetchAndCompile extends Plugin { * @return {CompilerAbstract} - compilation data targeting the given @arg contractAddress */ async resolve (contractAddress, codeAtAddress, targetPath) { - contractAddress = ethutil.toChecksumAddress(contractAddress) + contractAddress = toChecksumAddress(contractAddress) const localCompilation = async () => await this.call('compilerArtefacts', 'get', contractAddress) ? await this.call('compilerArtefacts', 'get', contractAddress) : await this.call('compilerArtefacts', 'get', '__last') ? await this.call('compilerArtefacts', 'get', '__last') : null diff --git a/libs/remix-core-plugin/src/lib/compiler-metadata.ts b/libs/remix-core-plugin/src/lib/compiler-metadata.ts index d194c0281d..dfd4ade1dd 100644 --- a/libs/remix-core-plugin/src/lib/compiler-metadata.ts +++ b/libs/remix-core-plugin/src/lib/compiler-metadata.ts @@ -27,11 +27,11 @@ export class CompilerMetadata extends Plugin { } onActivation () { - var self = this + const self = this this.on('solidity', 'compilationFinished', async (file, source, languageVersion, data) => { if (!await this.call('settings', 'get', 'settings/generate-contract-metadata')) return const compiler = new CompilerAbstract(languageVersion, data, source) - var path = self._extractPathOf(source.target) + const path = self._extractPathOf(source.target) compiler.visitContracts((contract) => { if (contract.file !== source.target) return (async () => { @@ -44,23 +44,23 @@ export class CompilerMetadata extends Plugin { } _extractPathOf (file) { - var reg = /(.*)(\/).*/ - var path = reg.exec(file) + const reg = /(.*)(\/).*/ + const path = reg.exec(file) return path ? path[1] : '/' } async _setArtefacts (content, contract, path) { content = content || '{}' - var metadata + let metadata try { metadata = JSON.parse(content) } catch (e) { console.log(e) } - var fileName = this._JSONFileName(path, contract.name) - var metadataFileName = this._MetadataFileName(path, contract.name) + const fileName = this._JSONFileName(path, contract.name) + const metadataFileName = this._MetadataFileName(path, contract.name) - var deploy = metadata.deploy || {} + const deploy = metadata.deploy || {} this.networks.forEach((network) => { deploy[network] = this._syncContext(contract, deploy[network] || {}) }) @@ -73,7 +73,7 @@ export class CompilerMetadata extends Plugin { } if (parsedMetadata) await this.call('fileManager', 'writeFile', metadataFileName, JSON.stringify(parsedMetadata, null, '\t')) - var data = { + const data = { deploy, data: { bytecode: contract.object.evm.bytecode, @@ -87,14 +87,14 @@ export class CompilerMetadata extends Plugin { } _syncContext (contract, metadata) { - var linkReferences = metadata.linkReferences - var autoDeployLib = metadata.autoDeployLib + let linkReferences = metadata.linkReferences + let autoDeployLib = metadata.autoDeployLib if (!linkReferences) linkReferences = {} if (autoDeployLib === undefined) autoDeployLib = true - for (var libFile in contract.object.evm.bytecode.linkReferences) { + for (const libFile in contract.object.evm.bytecode.linkReferences) { if (!linkReferences[libFile]) linkReferences[libFile] = {} - for (var lib in contract.object.evm.bytecode.linkReferences[libFile]) { + for (const lib in contract.object.evm.bytecode.linkReferences[libFile]) { if (!linkReferences[libFile][lib]) { linkReferences[libFile][lib] = '
' } diff --git a/libs/remix-core-plugin/src/lib/editor-context-listener.ts b/libs/remix-core-plugin/src/lib/editor-context-listener.ts index 9e73f6bc01..b20eb6e855 100644 --- a/libs/remix-core-plugin/src/lib/editor-context-listener.ts +++ b/libs/remix-core-plugin/src/lib/editor-context-listener.ts @@ -2,7 +2,6 @@ import { Plugin } from '@remixproject/engine' import { sourceMappingDecoder } from '@remix-project/remix-debug' -const { AstWalker } = require('@remix-project/remix-astwalker') const profile = { name: 'contextualListener', @@ -19,7 +18,7 @@ export class EditorContextListener extends Plugin { _activeHighlights: Array astWalker: any currentPosition: any - currentFile: String + currentFile: string nodes: Array results: any estimationObj: any @@ -28,7 +27,7 @@ export class EditorContextListener extends Plugin { contract: any activated: boolean - constructor () { + constructor (astWalker) { super(profile) this.activated = false this._index = { @@ -37,7 +36,7 @@ export class EditorContextListener extends Plugin { } this._activeHighlights = [] - this.astWalker = new AstWalker() + this.astWalker = astWalker } onActivation () { diff --git a/libs/remix-core-plugin/src/lib/gist-handler.ts b/libs/remix-core-plugin/src/lib/gist-handler.ts index 23ea64b937..0ef36a62ec 100644 --- a/libs/remix-core-plugin/src/lib/gist-handler.ts +++ b/libs/remix-core-plugin/src/lib/gist-handler.ts @@ -13,15 +13,17 @@ const profile = { version: '0.0.1' } +type GistCallBackFn = (gistId: string) => void + export class GistHandler extends Plugin { constructor () { super(profile) } - async handleLoad (gistId: String | null, cb: Function) { + async handleLoad (gistId: string | null, cb: GistCallBackFn) { if (!cb) cb = () => {} - var loadingFromGist = false + let loadingFromGist = false if (!gistId) { loadingFromGist = true let value @@ -83,9 +85,9 @@ export class GistHandler extends Plugin { return loadingFromGist } - load (gistId: String | null) { + load (gistId: string | null) { const self = this - return self.handleLoad(gistId, async (gistId: String | null) => { + return self.handleLoad(gistId, async (gistId: string | null) => { let data: any try { data = await (await fetch(`https://api.github.com/gists/${gistId}`)).json() as any @@ -114,7 +116,7 @@ export class GistHandler extends Plugin { const obj: StringByString = {} Object.keys(data.files).forEach((element) => { const path = element.replace(/\.\.\./g, '/') - obj['/' + 'gist-' + gistId + '/' + path] = data.files[element] + obj['/' + gistId + '/' + path] = data.files[element] }) this.call('fileManager', 'setBatchFiles', obj, 'workspace', true, async (errorSavingFiles: any) => { if (errorSavingFiles) { @@ -132,7 +134,7 @@ export class GistHandler extends Plugin { } const getGistId = (str) => { - var idr = /[0-9A-Fa-f]{8,}/ - var match = idr.exec(str) + const idr = /[0-9A-Fa-f]{8,}/ + const match = idr.exec(str) return match ? match[0] : null } diff --git a/libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts b/libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts index 57c3f3ed2e..ccb201aa47 100644 --- a/libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts +++ b/libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts @@ -11,7 +11,7 @@ const profile = { } export class OffsetToLineColumnConverter extends Plugin { - lineBreakPositionsByContent: {} + lineBreakPositionsByContent: Record> sourceMappingDecoder: any constructor () { super(profile) @@ -36,7 +36,7 @@ export class OffsetToLineColumnConverter extends Plugin { // if we don't have ast, we process the only one available content (applicable also for compiler older than 0.4.12) this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content) } else { - for (var filename in asts) { + for (const filename in asts) { const source = asts[filename] if (source.id === file) { this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) diff --git a/libs/remix-debug/src/cmdline/index.ts b/libs/remix-debug/src/cmdline/index.ts index c037df1524..16fdd65b6d 100644 --- a/libs/remix-debug/src/cmdline/index.ts +++ b/libs/remix-debug/src/cmdline/index.ts @@ -64,7 +64,7 @@ export class CmdLine { source.push('=> ' + (currentLineNumber + 1) + ': ' + currentLine) const startLine = lineColumnPos.start.line - for (var i = 1; i < 4; i++) { + for (let i = 1; i < 4; i++) { const line = content[startLine + i] source.push(' ' + (startLine + i + 1) + ': ' + line) } diff --git a/libs/remix-debug/src/code/breakpointManager.ts b/libs/remix-debug/src/code/breakpointManager.ts index c2f72ff4ba..f6f20e6f45 100644 --- a/libs/remix-debug/src/code/breakpointManager.ts +++ b/libs/remix-debug/src/code/breakpointManager.ts @@ -185,7 +185,7 @@ export class BreakpointManager { * @param {Object} sourceLocation - position of the breakpoint { file: '', row: ' in?: number out?: number diff --git a/libs/remix-debug/src/debugger/VmDebugger.ts b/libs/remix-debug/src/debugger/VmDebugger.ts index 4304d2e933..d064fc51a9 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.ts +++ b/libs/remix-debug/src/debugger/VmDebugger.ts @@ -113,11 +113,11 @@ export class VmDebuggerLogic { const address = this._traceManager.getCurrentCalledAddressAt(index) if (!this.storageResolver) return - var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) + const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) storageViewer.storageRange().then((storage) => { if (this.stepManager.currentStepIndex === index) { - var header = storageViewer.isComplete(address) ? '[Completely Loaded]' : '[Partially Loaded]' + const header = storageViewer.isComplete(address) ? '[Completely Loaded]' : '[Partially Loaded]' this.event.trigger('traceManagerStorageUpdate', [storage, header]) } }).catch((_error) => { @@ -197,10 +197,10 @@ export class VmDebuggerLogic { if (index === this.traceLength - 1) { return this.event.trigger('traceStorageUpdate', [{}]) } - var storageJSON = {} - for (var k in this.addresses) { - var address = this.addresses[k] - var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) + const storageJSON = {} + for (const k in this.addresses) { + const address = this.addresses[k] + const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) try { storageJSON[address] = await storageViewer.storageRange() } catch (e) { diff --git a/libs/remix-debug/src/debugger/debugger.ts b/libs/remix-debug/src/debugger/debugger.ts index 7a82d358fb..231c2d57f2 100644 --- a/libs/remix-debug/src/debugger/debugger.ts +++ b/libs/remix-debug/src/debugger/debugger.ts @@ -81,7 +81,7 @@ export class Debugger { sources[genSource.name] = { content: genSource.contents } } } - var lineColumnPos = await this.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, sources, astSources) + const lineColumnPos = await this.offsetToLineColumnConverter.offsetToLineColumn(rawLocation, rawLocation.file, sources, astSources) this.event.trigger('newSourceLocation', [lineColumnPos, rawLocation, generatedSources, address]) } else { this.event.trigger('newSourceLocation', [null]) diff --git a/libs/remix-debug/src/debugger/solidityLocals.ts b/libs/remix-debug/src/debugger/solidityLocals.ts index c7f25d01b8..ca173e4abd 100644 --- a/libs/remix-debug/src/debugger/solidityLocals.ts +++ b/libs/remix-debug/src/debugger/solidityLocals.ts @@ -22,7 +22,7 @@ export class DebuggerSolidityLocals { init (sourceLocation) { this._sourceLocation = sourceLocation - var decodeTimeout = null + let decodeTimeout = null if (!this.storageResolver) { return this.event.trigger('solidityLocalsMessage', ['storage not ready']) } @@ -76,11 +76,11 @@ export class DebuggerSolidityLocals { if (error) { return error } - var stack = result[0].value - var memory = result[1].value - var calldata = result[3].value + const stack = result[0].value + const memory = result[1].value + const calldata = result[3].value try { - var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: result[2].value }, this.storageResolver, this.traceManager) + const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: result[2].value }, this.storageResolver, this.traceManager) solidityLocals(this.stepManager.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, calldata, sourceLocation, cursor).then((locals) => { if (!cursor) { if (!locals['error']) { diff --git a/libs/remix-debug/src/debugger/stepManager.ts b/libs/remix-debug/src/debugger/stepManager.ts index 4572d7b8e8..1a64977e97 100644 --- a/libs/remix-debug/src/debugger/stepManager.ts +++ b/libs/remix-debug/src/debugger/stepManager.ts @@ -55,8 +55,8 @@ export class DebuggerStepManager { this.revertionPoint = this.currentCall.return return this.event.trigger('revertWarning', [revertedReason]) } - for (var k = callsPath.length - 2; k >= 0; k--) { - var parent = callsPath[k] + for (let k = callsPath.length - 2; k >= 0; k--) { + const parent = callsPath[k] if (!parent.reverted) continue this.revertionPoint = parent.return this.event.trigger('revertWarning', ['parenthasthrown']) @@ -139,7 +139,7 @@ export class DebuggerStepManager { jumpOut (solidityMode) { if (!this.traceManager.isLoaded()) return - var step = this.traceManager.findStepOut(this.currentStepIndex) + let step = this.traceManager.findStepOut(this.currentStepIndex) if (solidityMode) { step = this.resolveToReducedTrace(step, 0) } @@ -200,7 +200,7 @@ export class DebuggerStepManager { if (!this.debugger.callTree.reducedTrace.length) { return value } - var nextSource = util.findClosestIndex(value, this.debugger.callTree.reducedTrace) + let nextSource = util.findClosestIndex(value, this.debugger.callTree.reducedTrace) nextSource = nextSource + incr if (nextSource <= 0) { nextSource = 0 diff --git a/libs/remix-debug/src/solidity-decoder/decodeInfo.ts b/libs/remix-debug/src/solidity-decoder/decodeInfo.ts index d506e5ca3e..44c620615a 100644 --- a/libs/remix-debug/src/solidity-decoder/decodeInfo.ts +++ b/libs/remix-debug/src/solidity-decoder/decodeInfo.ts @@ -27,7 +27,7 @@ function mapping (type, stateDefinitions, contractName) { const keyType = parseType(keyTypeName, stateDefinitions, contractName, 'storage') const valueType = parseType(valueTypeName, stateDefinitions, contractName, 'storage') - var underlyingTypes = { + const underlyingTypes = { keyType: keyType, valueType: valueType } @@ -329,9 +329,9 @@ function computeOffsets (types, stateDefinitions, contractName, location) { offset: 0, slot: 0 } - for (var i in types) { - var variable = types[i] - var type = parseType(variable.typeDescriptions.typeString, stateDefinitions, contractName, location) + for (const i in types) { + const variable = types[i] + const type = parseType(variable.typeDescriptions.typeString, stateDefinitions, contractName, location) if (!type) { console.log('unable to retrieve decode info of ' + variable.typeDescriptions.typeString) return null diff --git a/libs/remix-debug/src/solidity-decoder/internalCallTree.ts b/libs/remix-debug/src/solidity-decoder/internalCallTree.ts index d84e023047..b5440d2d7d 100644 --- a/libs/remix-debug/src/solidity-decoder/internalCallTree.ts +++ b/libs/remix-debug/src/solidity-decoder/internalCallTree.ts @@ -262,7 +262,7 @@ async function includeVariableDeclaration (tree, step, sourceLocation, scopeId, // so, either this is the direct value, or the offset in memory. That depends on the type. if (variableDeclaration.name !== '') { states = tree.solidityProxy.extractStatesDefinitions() - var location = extractLocationFromAstVariable(variableDeclaration) + let location = extractLocationFromAstVariable(variableDeclaration) location = location === 'default' ? 'storage' : location // we push the new local variable in our tree tree.scopes[scopeId].locals[variableDeclaration.name] = { diff --git a/libs/remix-debug/src/solidity-decoder/localDecoder.ts b/libs/remix-debug/src/solidity-decoder/localDecoder.ts index 70df3e9715..4d697e9cc4 100644 --- a/libs/remix-debug/src/solidity-decoder/localDecoder.ts +++ b/libs/remix-debug/src/solidity-decoder/localDecoder.ts @@ -10,7 +10,7 @@ export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, mem memory = formatMemory(memory) let anonymousIncr = 1 for (const local in scope.locals) { - var variable = scope.locals[local] + const variable = scope.locals[local] if (variable.stackDepth < stack.length && variable.sourceLocation.start <= currentSourceLocation.start) { let name = variable.name if (name.indexOf('$') !== -1) { diff --git a/libs/remix-debug/src/solidity-decoder/stateDecoder.ts b/libs/remix-debug/src/solidity-decoder/stateDecoder.ts index 709faff99c..531c7abee7 100644 --- a/libs/remix-debug/src/solidity-decoder/stateDecoder.ts +++ b/libs/remix-debug/src/solidity-decoder/stateDecoder.ts @@ -10,8 +10,8 @@ import { computeOffsets } from './decodeInfo' */ export async function decodeState (stateVars, storageResolver) { const ret = {} - for (var k in stateVars) { - var stateVar = stateVars[k] + for (const k in stateVars) { + const stateVar = stateVars[k] try { const decoded = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver) decoded.constant = stateVar.constant diff --git a/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts b/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts index eb5eff4d30..21c7e41208 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts @@ -50,7 +50,7 @@ export class ArrayType extends RefType { } else { size = new BN(this.arraySize) } - var k = toBN(0) + const k = toBN(0) for (; k.lt(size) && k.ltn(300); k.iaddn(1)) { try { ret.push(await this.underlyingType.decodeFromStorage(currentLocation, storageResolver)) @@ -92,8 +92,8 @@ export class ArrayType extends RefType { if (skip) offset = offset + (32 * skip) let limit = length - skip if (limit > 10) limit = 10 - for (var k = 0; k < limit; k++) { - var contentOffset = offset + for (let k = 0; k < limit; k++) { + const contentOffset = offset ret.push(this.underlyingType.decodeFromMemory(contentOffset, memory)) offset += 32 } diff --git a/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts b/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts index 85cf69ef88..bb11dd0778 100644 --- a/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts +++ b/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts @@ -42,7 +42,7 @@ export class DynamicByteArray extends RefType { } return { value: '0x' + ret.replace(/(00)+$/, ''), length: '0x' + length.toString(16), type: this.typeName } } else { - var size = parseInt(value.substr(value.length - 2, 2), 16) / 2 + const size = parseInt(value.substr(value.length - 2, 2), 16) / 2 return { value: '0x' + value.substr(0, size * 2), length: '0x' + size.toString(16), type: this.typeName } } } diff --git a/libs/remix-debug/src/solidity-decoder/types/Struct.ts b/libs/remix-debug/src/solidity-decoder/types/Struct.ts index 1995471ffb..b11f12f533 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Struct.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Struct.ts @@ -13,7 +13,7 @@ export class Struct extends RefType { async decodeFromStorage (location, storageResolver) { const ret = {} - for (var item of this.members) { + for (const item of this.members) { const globalLocation = { offset: location.offset + item.storagelocation.offset, slot: add(location.slot, item.storagelocation.slot) @@ -31,8 +31,8 @@ export class Struct extends RefType { decodeFromMemoryInternal (offset, memory) { const ret = {} this.members.map((item, i) => { - var contentOffset = offset - var member = item.type.decodeFromMemory(contentOffset, memory) + const contentOffset = offset + const member = item.type.decodeFromMemory(contentOffset, memory) ret[item.name] = member if (!(item.type instanceof Mapping)) offset += 32 }) diff --git a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts index 60d3a8ebed..2aeae677fe 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts @@ -27,7 +27,7 @@ export class ValueType { */ async decodeFromStorage (location, storageResolver) { try { - var value = await extractHexValue(location, storageResolver, this.storageBytes) + const value = await extractHexValue(location, storageResolver, this.storageBytes) return { value: this.decodeValue(value), type: this.typeName } } catch (e) { console.log(e) diff --git a/libs/remix-debug/src/source/sourceMappingDecoder.ts b/libs/remix-debug/src/source/sourceMappingDecoder.ts index 5024c3b43b..04b3bcb9ba 100644 --- a/libs/remix-debug/src/source/sourceMappingDecoder.ts +++ b/libs/remix-debug/src/source/sourceMappingDecoder.ts @@ -142,7 +142,7 @@ export function nodesAtPosition (astNodeType, position, ast) { const astWalker = new AstWalker() const found = [] const callback = function (node) { - var nodeLocation = sourceLocationFromAstNode(node) + const nodeLocation = sourceLocationFromAstNode(node) if (!nodeLocation) { return } diff --git a/libs/remix-debug/src/storage/mappingPreimages.ts b/libs/remix-debug/src/storage/mappingPreimages.ts index a7fb99740b..fceb13b89e 100644 --- a/libs/remix-debug/src/storage/mappingPreimages.ts +++ b/libs/remix-debug/src/storage/mappingPreimages.ts @@ -13,7 +13,7 @@ export async function decodeMappingsKeys (web3, storage, corrections) { const ret = {} if (!corrections.length) corrections.push({ offset: 0, slot: 0 }) for (const hashedLoc in storage) { - var preimage + let preimage try { const key = storage[hashedLoc].key for (const k in corrections) { diff --git a/libs/remix-debug/src/storage/storageResolver.ts b/libs/remix-debug/src/storage/storageResolver.ts index c0090c8b52..62a9f7df32 100644 --- a/libs/remix-debug/src/storage/storageResolver.ts +++ b/libs/remix-debug/src/storage/storageResolver.ts @@ -85,7 +85,7 @@ export class StorageResolver { * - If @arg slot is not cached, the corresponding value will be resolved and the next 1000 slots. */ async storageRangeInternal (self, slotKey, tx, stepIndex, address) { - var cached = this.fromCache(self, address) + const cached = this.fromCache(self, address) if (cached && cached.storage[slotKey]) { // we have the current slot in the cache and maybe the next 1000... return cached.storage } diff --git a/libs/remix-debug/src/trace/traceCache.ts b/libs/remix-debug/src/trace/traceCache.ts index 411e8e617c..cf23de75cb 100644 --- a/libs/remix-debug/src/trace/traceCache.ts +++ b/libs/remix-debug/src/trace/traceCache.ts @@ -62,7 +62,7 @@ export class TraceCache { if (!validReturnStep) { this.currentCall.call.reverted = reverted } - var parent = this.currentCall.parent + const parent = this.currentCall.parent if (parent) this.currentCall = { call: parent.call, parent: parent.parent } return } @@ -123,12 +123,12 @@ export class TraceCache { accumulateStorageChanges (index, address, storage) { const ret = Object.assign({}, storage) - for (var k in this.storageChanges) { + for (const k in this.storageChanges) { const changesIndex = this.storageChanges[k] if (changesIndex > index) { return ret } - var sstore = this.sstore[changesIndex] + const sstore = this.sstore[changesIndex] if (sstore.address === address && sstore.key) { ret[sstore.hashedKey] = { key: sstore.key, diff --git a/libs/remix-debug/src/trace/traceManager.ts b/libs/remix-debug/src/trace/traceManager.ts index e96e28f8d3..408bfd8ceb 100644 --- a/libs/remix-debug/src/trace/traceManager.ts +++ b/libs/remix-debug/src/trace/traceManager.ts @@ -48,7 +48,7 @@ export class TraceManager { this.isLoading = false return true } - var mes = tx.hash + ' is not a contract invocation or contract creation.' + const mes = tx.hash + ' is not a contract invocation or contract creation.' console.log(mes) this.isLoading = false throw new Error(mes) @@ -290,7 +290,7 @@ export class TraceManager { waterfall (calls, stepindex, cb) { const ret = [] let retError = null - for (var call in calls) { + for (const call in calls) { calls[call].apply(this, [stepindex, function (error, result) { retError = error ret.push({ error: error, value: result }) diff --git a/libs/remix-debug/src/trace/traceStepManager.ts b/libs/remix-debug/src/trace/traceStepManager.ts index 9890bf57ef..bcbccfe2e1 100644 --- a/libs/remix-debug/src/trace/traceStepManager.ts +++ b/libs/remix-debug/src/trace/traceStepManager.ts @@ -40,7 +40,7 @@ export class TraceStepManager { const call = util.findCall(currentStep, this.traceAnalyser.traceCache.callsTree.call) const subCalls = Object.keys(call.calls) if (subCalls.length) { - var callStart = util.findLowerBound(currentStep, subCalls) + 1 + const callStart = util.findLowerBound(currentStep, subCalls) + 1 if (subCalls.length > callStart) { return parseInt(subCalls[callStart]) - 1 } diff --git a/libs/remix-lib/src/execution/txFormat.ts b/libs/remix-lib/src/execution/txFormat.ts index 70bf991aee..86081dad6f 100644 --- a/libs/remix-lib/src/execution/txFormat.ts +++ b/libs/remix-lib/src/execution/txFormat.ts @@ -37,7 +37,7 @@ export function encodeData (funABI, values, contractbyteCode) { */ export function encodeParams (params, funAbi, callback) { let data: Buffer | string = '' - let dataHex: string = '' + let dataHex = '' let funArgs if (params.indexOf('raw:0x') === 0) { // in that case we consider that the input is already encoded and *does not* contain the method signature @@ -167,7 +167,7 @@ export function encodeConstructorCallAndDeployLibraries (contractName, contract, export function buildData (contractName, contract, contracts, isConstructor, funAbi, params, callback, callbackStep, callbackDeployLibrary) { let funArgs = [] let data: Buffer | string = '' - let dataHex: string = '' + let dataHex = '' if (params.indexOf('raw:0x') === 0) { // in that case we consider that the input is already encoded and *does not* contain the method signature diff --git a/libs/remix-lib/src/execution/txListener.ts b/libs/remix-lib/src/execution/txListener.ts index 06c5f2c216..533a501d3b 100644 --- a/libs/remix-lib/src/execution/txListener.ts +++ b/libs/remix-lib/src/execution/txListener.ts @@ -369,7 +369,7 @@ export class TxListener { const abiCoder = new ethers.utils.AbiCoder() const decoded = abiCoder.decode(inputTypes, data) const ret = {} - for (var k in abi.inputs) { + for (const k in abi.inputs) { ret[abi.inputs[k].type + ' ' + abi.inputs[k].name] = decoded[k] } return ret diff --git a/libs/remix-lib/src/execution/txRunnerVM.ts b/libs/remix-lib/src/execution/txRunnerVM.ts index 428f377b39..e2b2322a89 100644 --- a/libs/remix-lib/src/execution/txRunnerVM.ts +++ b/libs/remix-lib/src/execution/txRunnerVM.ts @@ -106,7 +106,7 @@ export class TxRunnerVM { const coinbases = ['0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a', '0x8945a1288dc78a6d8952a92c77aee6730b414778', '0x94d76e24f818426ae84aa404140e8d5f60e10e7e'] const difficulties = [new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10)] - var block = Block.fromBlockData({ + const block = Block.fromBlockData({ header: { timestamp: timestamp || (new Date().getTime() / 1000 | 0), number: self.blockNumber, diff --git a/libs/remix-lib/src/execution/txRunnerWeb3.ts b/libs/remix-lib/src/execution/txRunnerWeb3.ts index c62b655fb8..1da52c8049 100644 --- a/libs/remix-lib/src/execution/txRunnerWeb3.ts +++ b/libs/remix-lib/src/execution/txRunnerWeb3.ts @@ -52,7 +52,7 @@ export class TxRunnerWeb3 { return callback(err, resp) } this.event.trigger('transactionBroadcasted', [resp]) - var listenOnResponse = () => { + const listenOnResponse = () => { // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { const receipt = await tryTillReceiptAvailable(resp, this.getWeb3()) diff --git a/libs/remix-lib/src/execution/typeConversion.ts b/libs/remix-lib/src/execution/typeConversion.ts index 54659c1721..22332629f2 100644 --- a/libs/remix-lib/src/execution/typeConversion.ts +++ b/libs/remix-lib/src/execution/typeConversion.ts @@ -10,13 +10,13 @@ export function toInt (h) { return h } -export var stringify = convertToString +export const stringify = convertToString function convertToString (v) { try { if (v instanceof Array) { const ret = [] - for (var k in v) { + for (const k in v) { ret.push(convertToString(v[k])) } return ret diff --git a/libs/remix-lib/src/helpers/uiHelper.ts b/libs/remix-lib/src/helpers/uiHelper.ts index 56caca5e81..cab35f54a5 100644 --- a/libs/remix-lib/src/helpers/uiHelper.ts +++ b/libs/remix-lib/src/helpers/uiHelper.ts @@ -45,13 +45,13 @@ export function tryConvertAsciiFormat (memorySlot) { */ export function formatCss (css1, css2) { let ret = '' - for (const arg in arguments) { - for (const k in arguments[arg]) { - if (arguments[arg][k] && ret.indexOf(k) === -1) { + for (const arg in arguments) { // eslint-disable-line + for (const k in arguments[arg]) { // eslint-disable-line + if (arguments[arg][k] && ret.indexOf(k) === -1) { // eslint-disable-line if (k.indexOf('*') === 0) { - ret += arguments[arg][k] + ret += arguments[arg][k] // eslint-disable-line } else { - ret += k + ':' + arguments[arg][k] + ';' + ret += k + ':' + arguments[arg][k] + ';' // eslint-disable-line } } } diff --git a/libs/remix-lib/src/index.ts b/libs/remix-lib/src/index.ts index 1ba94fdd21..54646e326e 100644 --- a/libs/remix-lib/src/index.ts +++ b/libs/remix-lib/src/index.ts @@ -19,6 +19,7 @@ import { TxRunnerVM } from './execution/txRunnerVM' import { TxRunnerWeb3 } from './execution/txRunnerWeb3' import * as txResultHelper from './helpers/txResultHelper' export { ICompilerApi, ConfigurationSettings } from './types/ICompilerApi' +export { QueryParams } from './query-params' const helpers = { ui: uiHelper, diff --git a/libs/remix-lib/src/query-params.ts b/libs/remix-lib/src/query-params.ts new file mode 100644 index 0000000000..7e89b226ff --- /dev/null +++ b/libs/remix-lib/src/query-params.ts @@ -0,0 +1,38 @@ +'use strict' + +export class QueryParams { + + update (params) { + const currentParams = this.get() + const keys = Object.keys(params) + for (const x in keys) { + currentParams[keys[x]] = params[keys[x]] + } + let queryString = '#' + const updatedKeys = Object.keys(currentParams) + for (const y in updatedKeys) { + queryString += updatedKeys[y] + '=' + currentParams[updatedKeys[y]] + '&' + } + window.location.hash = queryString.slice(0, -1) + } + + get () { + const qs = window.location.hash.substr(1) + + if (window.location.search.length > 0) { + // use legacy query params instead of hash + window.location.hash = window.location.search.substr(1) + window.location.search = '' + } + + const params = {} + const parts = qs.split('&') + for (const x in parts) { + const keyValue = parts[x].split('=') + if (keyValue[0] !== '') { + params[keyValue[0]] = keyValue[1] + } + } + return params + } +} diff --git a/libs/remix-lib/src/storage.ts b/libs/remix-lib/src/storage.ts index e00a33e32c..02278cc47f 100644 --- a/libs/remix-lib/src/storage.ts +++ b/libs/remix-lib/src/storage.ts @@ -10,7 +10,7 @@ export class Storage { if (typeof window !== 'undefined') { this.safeKeys().forEach(function (name) { if (name.indexOf('sol-cache-file-', 0) === 0) { - var content = window.localStorage.getItem(name) + const content = window.localStorage.getItem(name) window.localStorage.setItem(name.replace(/^sol-cache-file-/, 'sol:'), content) window.localStorage.removeItem(name) } diff --git a/libs/remix-lib/src/types/ICompilerApi.ts b/libs/remix-lib/src/types/ICompilerApi.ts index 1a6166b2aa..62f86b5652 100644 --- a/libs/remix-lib/src/types/ICompilerApi.ts +++ b/libs/remix-lib/src/types/ICompilerApi.ts @@ -34,7 +34,7 @@ export interface ICompilerApi { open: (file: string) => void saveCurrentFile: () => void - logToTerminal: (log: terminalLog) => {} + logToTerminal: (log: terminalLog) => void compileWithHardhat: (configPath: string) => Promise } diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.ts b/libs/remix-lib/src/web3Provider/web3VmProvider.ts index 49fa4d80a9..ecc006da9e 100644 --- a/libs/remix-lib/src/web3Provider/web3VmProvider.ts +++ b/libs/remix-lib/src/web3Provider/web3VmProvider.ts @@ -152,7 +152,7 @@ export class Web3VmProvider { const log = data.execResult.logs[l] const topics = [] if (log[1].length > 0) { - for (var k in log[1]) { + for (const k in log[1]) { topics.push('0x' + log[1][k].toString('hex')) } } else { diff --git a/libs/remix-simulator/src/methods/txProcess.ts b/libs/remix-simulator/src/methods/txProcess.ts index 75173af309..f269ca1baf 100644 --- a/libs/remix-simulator/src/methods/txProcess.ts +++ b/libs/remix-simulator/src/methods/txProcess.ts @@ -35,7 +35,7 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac } export function processTx (txRunnerInstance, payload, isCall, callback) { - let { from, to, data, value, gas } = payload.params[0] + let { from, to, data, value, gas } = payload.params[0] // eslint-disable-line gas = gas || 3000000 const callbacks = { diff --git a/libs/remix-simulator/src/provider.ts b/libs/remix-simulator/src/provider.ts index 3bbdadaa82..1e274e96f5 100644 --- a/libs/remix-simulator/src/provider.ts +++ b/libs/remix-simulator/src/provider.ts @@ -77,11 +77,11 @@ export class Provider { disconnect () { return false - }; + } supportsSubscriptions () { return true - }; + } on (type, cb) { this.vmContext.logsManager.addListener(type, cb) diff --git a/libs/remix-solidity/src/compiler/compiler-utils.ts b/libs/remix-solidity/src/compiler/compiler-utils.ts index 0a90e69adf..310cc50f1c 100644 --- a/libs/remix-solidity/src/compiler/compiler-utils.ts +++ b/libs/remix-solidity/src/compiler/compiler-utils.ts @@ -1,5 +1,5 @@ -const semver = require('semver') -const minixhr = require('minixhr') +import * as semver from 'semver' +import * as minixhr from 'minixhr' /* global Worker */ export const baseURLBin = 'https://binaries.soliditylang.org/bin' diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index 8f1a08b4e9..4a7903f5f5 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -103,7 +103,7 @@ export class Compiler { onInternalCompilerLoaded (): void { if (this.state.worker === null) { - const compiler: any = typeof (window) !== 'undefined' && window['Module'] ? require('solc/wrapper')(window['Module']) : require('solc') + const compiler: any = typeof (window) !== 'undefined' && window['Module'] ? require('solc/wrapper')(window['Module']) : require('solc') // eslint-disable-line this.state.compileJSON = (source: SourceWithTarget) => { const missingInputs: string[] = [] const missingInputsCallback = (path: string) => { @@ -170,7 +170,7 @@ export class Compiler { loadRemoteVersion (version: string): void { console.log(`Loading remote solc version ${version} ...`) - const compiler: any = require('solc') + const compiler: any = require('solc') // eslint-disable-line compiler.loadRemoteVersion(version, (err, remoteCompiler) => { if (err) { console.error('Error in loading remote solc compiler: ', err) diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index b8fd320f00..70487c97f3 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -14,7 +14,7 @@ function regexIndexOf (inputString: string, regex: RegExp, startpos = 0) { } export function writeTestAccountsContract (accounts: string[]) { - const testAccountContract = require('../sol/tests_accounts.sol') + const testAccountContract = require('../sol/tests_accounts.sol') // eslint-disable-line let body = `address[${accounts.length}] memory accounts;` if (!accounts.length) body += ';' else { @@ -152,7 +152,7 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts if (result.error) error.push(result.error) const errors = (result.errors || error).filter((e) => e.type === 'Error' || e.severity === 'error') if (errors.length > 0) { - if (!isBrowser) require('signale').fatal(errors) + if (!isBrowser) require('signale').fatal(errors) // eslint-disable-line return cb(new CompilationErrors(errors)) } cb(err, result.contracts, result.sources) // return callback with contract details & ASTs @@ -217,7 +217,7 @@ export function compileContractSources (sources: SrcIfc, newCompConfig: any, imp if (result.error) error.push(result.error) const errors = (result.errors || error).filter((e) => e.type === 'Error' || e.severity === 'error') if (errors.length > 0) { - if (!isBrowser) require('signale').fatal(errors) + if (!isBrowser) require('signale').fatal(errors) // eslint-disable-line return cb(new CompilationErrors(errors)) } cb(err, result.contracts, result.sources) // return callback with contract details & ASTs diff --git a/libs/remix-tests/src/fileSystem.ts b/libs/remix-tests/src/fileSystem.ts index 7b3729ebda..c758b6ae61 100644 --- a/libs/remix-tests/src/fileSystem.ts +++ b/libs/remix-tests/src/fileSystem.ts @@ -1,6 +1,6 @@ // Extend fs import path from 'path' -const fs: any = require('fs') +const fs: any = require('fs') // eslint-disable-line // https://github.com/mikeal/node-utils/blob/master/file/lib/main.js fs.walkSync = function (start: string, callback) { diff --git a/libs/remix-tests/src/index.ts b/libs/remix-tests/src/index.ts index 37862a47c6..5adef21ecf 100644 --- a/libs/remix-tests/src/index.ts +++ b/libs/remix-tests/src/index.ts @@ -2,5 +2,5 @@ export { runTestFiles } from './runTestFiles' export { UnitTestRunner } from './runTestSources' export { runTest } from './testRunner' export * from './types' -export const assertLibCode = require('../sol/tests.sol') +export const assertLibCode = require('../sol/tests.sol') // eslint-disable-line export { writeTestAccountsContract } from './compiler' diff --git a/libs/remix-tests/src/run.ts b/libs/remix-tests/src/run.ts index 8228ced38b..45b89df5e7 100644 --- a/libs/remix-tests/src/run.ts +++ b/libs/remix-tests/src/run.ts @@ -32,7 +32,7 @@ function mapOptimize (v: string) { return optimize[v] } -const version = require('../package.json').version +const version = require('../package.json').version // eslint-disable-line commander.version(version) diff --git a/libs/remix-tests/src/runTestFiles.ts b/libs/remix-tests/src/runTestFiles.ts index dbf2b16e46..ebaaf27f98 100644 --- a/libs/remix-tests/src/runTestFiles.ts +++ b/libs/remix-tests/src/runTestFiles.ts @@ -22,7 +22,7 @@ export function runTestFiles (filepath: string, isDirectory: boolean, web3: Web3 opts = opts || {} compilerConfig = compilerConfig || {} as CompilerConfiguration const sourceASTs: any = {} - const { Signale } = require('signale') + const { Signale } = require('signale') // eslint-disable-line // signale configuration const options = { types: { diff --git a/libs/remix-ui/app/src/index.ts b/libs/remix-ui/app/src/index.ts index e706f1ad94..47c95554fd 100644 --- a/libs/remix-ui/app/src/index.ts +++ b/libs/remix-ui/app/src/index.ts @@ -1,5 +1,5 @@ export { default as RemixApp } from './lib/remix-app/remix-app' -export { dispatchModalContext } from './lib/remix-app/context/context' +export { dispatchModalContext, AppContext } from './lib/remix-app/context/context' export { ModalProvider } from './lib/remix-app/context/provider' export { AppModal } from './lib/remix-app/interface/index' export { AlertModal } from './lib/remix-app/interface/index' diff --git a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx index 8d36d75cda..cf5456dc38 100644 --- a/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx @@ -1,6 +1,5 @@ import React, { useEffect, useRef, useState } from 'react' -import { ModalDialog } from '@remix-ui/modal-dialog' -import { ModalDialogProps } from 'libs/remix-ui/modal-dialog/src/lib/types' +import { ModalDialog, ModalDialogProps } from '@remix-ui/modal-dialog' import { ModalTypes } from '../../types' interface ModalWrapperProps extends ModalDialogProps { diff --git a/libs/remix-ui/app/src/lib/remix-app/context/context.tsx b/libs/remix-ui/app/src/lib/remix-app/context/context.tsx index a60b3e5409..ca69771f80 100644 --- a/libs/remix-ui/app/src/lib/remix-app/context/context.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/context/context.tsx @@ -1,7 +1,6 @@ import React from 'react' import { AlertModal, AppModal } from '../interface' import { ModalInitialState } from '../state/modals' -import { ModalTypes } from '../types' export const AppContext = React.createContext(null) diff --git a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx index 947475d84b..6845ce88b1 100644 --- a/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx +++ b/libs/remix-ui/app/src/lib/remix-app/remix-app.tsx @@ -7,6 +7,7 @@ import DragBar from './components/dragbar/dragbar' import { AppProvider } from './context/provider' import AppDialogs from './components/modals/dialogs' import DialogViewPlugin from './components/modals/dialogViewPlugin' +import { AppContext } from './context/context' interface IRemixAppUi { app: any @@ -96,7 +97,7 @@ const RemixApp = (props: IRemixAppUi) => { {components.sidePanel}
- +
{components.hiddenPanel} diff --git a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx index 92ef7cf768..2220bc1d1b 100644 --- a/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx +++ b/libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx @@ -13,10 +13,11 @@ interface ICopyToClipboard { className?: string, title?: string, children?: JSX.Element, - getContent?: () => {} + getContent?: () => any } export const CopyToClipboard = (props: ICopyToClipboard) => { - let { content, tip = 'Copy', icon = 'fa-copy', direction = 'right', children, getContent, ...otherProps } = props + const { tip = 'Copy', icon = 'fa-copy', direction = 'right', getContent, children, ...otherProps } = props + let { content } = props const [message, setMessage] = useState(tip) const copyData = () => { diff --git a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx index 5b9a0cd93f..a9a8200e9b 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -6,9 +6,9 @@ import VmDebuggerHead from './vm-debugger/vm-debugger-head' // eslint-disable-li import { TransactionDebugger as Debugger } from '@remix-project/remix-debug' // eslint-disable-line import { DebuggerUIProps } from './idebugger-api' // eslint-disable-line import { Toaster } from '@remix-ui/toaster' // eslint-disable-line +import { isValidHash } from '@remix-ui/helper' /* eslint-disable-next-line */ import './debugger-ui.css' -const helper = require('../../../../../apps/remix-ide/src/lib/helper') const _paq = (window as any)._paq = (window as any)._paq || [] export const DebuggerUI = (props: DebuggerUIProps) => { @@ -171,7 +171,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { txNumber: txNumber } }) - if (!helper.isValidHash(txNumber)) { + if (!isValidHash(txNumber)) { setState(prevState => { return { ...prevState, diff --git a/libs/remix-ui/debugger-ui/src/types/index.ts b/libs/remix-ui/debugger-ui/src/types/index.ts index ee5e02a85f..5168102bb5 100644 --- a/libs/remix-ui/debugger-ui/src/types/index.ts +++ b/libs/remix-ui/debugger-ui/src/types/index.ts @@ -16,6 +16,8 @@ export interface ExtractData { export type ExtractFunc = (json: any, parent?: any) => ExtractData export type FormatSelfFunc = (key: string | number, data: ExtractData) => JSX.Element +export type RegisterEventType = (type: string, listener: any) => void // listener is a function +export type TriggerEventType = (type: string, payload: Array) => void export interface DropdownPanelProps { dropdownName: string, dropdownMessage?: string, @@ -26,8 +28,8 @@ export interface DropdownPanelProps { loading?: boolean, extractFunc?: ExtractFunc, formatSelfFunc?: FormatSelfFunc, - registerEvent?: Function, - triggerEvent?: Function, + registerEvent?: RegisterEventType, + triggerEvent?: TriggerEventType, loadMoreEvent?: string, loadMoreCompletedEvent?: string, bodyStyle?: React.CSSProperties, diff --git a/libs/remix-ui/editor-context-view/src/lib/remix-ui-editor-context-view.tsx b/libs/remix-ui/editor-context-view/src/lib/remix-ui-editor-context-view.tsx index 7e25e32592..50e7fd477c 100644 --- a/libs/remix-ui/editor-context-view/src/lib/remix-ui-editor-context-view.tsx +++ b/libs/remix-ui/editor-context-view/src/lib/remix-ui-editor-context-view.tsx @@ -10,7 +10,7 @@ export type astNode = { id: number, children?: Array, typeDescriptions: any, - nodeType: String, + nodeType: string, src: string // e.g "142:1361:0" } @@ -21,7 +21,7 @@ export type nodePositionLight = { } export type astNodeLight = { - fileTarget: String, + fileTarget: string, nodeId: number, position: nodePositionLight } @@ -39,7 +39,7 @@ export interface RemixUiEditorContextViewProps { openFile: (fileName: string) => void, getLastCompilationResult: () => any, offsetToLineColumn: (position: any, file: any, sources: any, asts: any) => any, - getCurrentFileName: () => String + getCurrentFileName: () => string onContextListenerChanged: (listener: onContextListenerChangedListener) => void onCurrentFileChanged: (listener: ononCurrentFileChangedListener) => void referencesOf: (nodes: astNode) => Array diff --git a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts index 4b9eb28d1c..f20fd124a5 100644 --- a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts +++ b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts @@ -94,3 +94,15 @@ export const is0XPrefixed = (value) => { export const isHexadecimal = (value) => { return /^[0-9a-fA-F]+$/.test(value) && (value.length % 2 === 0) } + +export const isValidHash = (hash) => { // 0x prefixed, hexadecimal, 64digit + const hexValue = hash.slice(2, hash.length) + return is0XPrefixed(hash) && /^[0-9a-fA-F]{64}$/.test(hexValue) +} + +export const shortenHexData = (data) => { + if (!data) return '' + if (data.length < 5) return data + const len = data.length + return data.slice(0, 5) + '...' + data.slice(len - 5, len) +} diff --git a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx index b358c8f503..1fa810ef79 100644 --- a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx +++ b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx @@ -5,7 +5,7 @@ import JSZip from 'jszip' import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line import { Toaster } from '@remix-ui/toaster' // eslint-disable-line import PluginButton from './components/pluginButton' // eslint-disable-line -import QueryParams from '../../../../../apps/remix-ide/src/lib/query-params' +import { QueryParams } from '@remix-project/remix-lib' import { ThemeContext, themes } from './themeContext' declare global { interface Window { @@ -186,7 +186,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { try { node.dispatchEvent(new MouseEvent('click')) } catch (e) { - var evt = document.createEvent('MouseEvents') + const evt = document.createEvent('MouseEvents') evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null) node.dispatchEvent(evt) @@ -202,9 +202,9 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { zip.file(path, content) }) zip.generateAsync({ type: 'blob' }).then(function (blob) { - var today = new Date() - var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate() - var time = today.getHours() + 'h' + today.getMinutes() + 'min' + const today = new Date() + const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate() + const time = today.getHours() + 'h' + today.getMinutes() + 'min' saveAs(blob, `remix-backup-at-${time}-${date}.zip`) }).catch((e) => { plugin.call('notification', 'toast', e.message) diff --git a/libs/remix-ui/modal-dialog/src/index.ts b/libs/remix-ui/modal-dialog/src/index.ts index 5226389ef8..42e4552307 100644 --- a/libs/remix-ui/modal-dialog/src/index.ts +++ b/libs/remix-ui/modal-dialog/src/index.ts @@ -1,2 +1,3 @@ export * from './lib/modal-dialog-custom' export * from './lib/remix-ui-modal-dialog' +export * from './lib/types/index' diff --git a/libs/remix-ui/panel/src/lib/main/main-panel.tsx b/libs/remix-ui/panel/src/lib/main/main-panel.tsx index 4ea7dc20f2..0b59d665e3 100644 --- a/libs/remix-ui/panel/src/lib/main/main-panel.tsx +++ b/libs/remix-ui/panel/src/lib/main/main-panel.tsx @@ -1,13 +1,16 @@ /* eslint-disable no-unused-expressions */ -import { AppContext } from 'libs/remix-ui/app/src/lib/remix-app/context/context' -import React, { useContext, useEffect, useLayoutEffect, useRef, useState } from 'react' // eslint-disable-line +import React, { useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line import DragBar from '../dragbar/dragbar' import RemixUIPanelPlugin from '../plugins/panel-plugin' import { PluginRecord } from '../types' import './main-panel.css' -const RemixUIMainPanel = () => { - const appContext = useContext(AppContext) +export type RemixUIMainPanelProps = { + Context: React.Context +} + +const RemixUIMainPanel = (props: RemixUIMainPanelProps) => { + const appContext = useContext(props.Context) const [plugins, setPlugins] = useState([]) const editorRef = useRef(null) const mainPanelRef = useRef(null) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx b/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx index 26ffee6476..6977ee2ed9 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { Profile } from '@remixproject/plugin-utils' import React from 'react' // eslint-disable-line no-use-before-define -import { PluginManagerComponent, PluginManagerProfile } from '../../types' +import { PluginManagerComponent } from '../../types' import InactivePluginCard from './InactivePluginCard' import ModuleHeading from './moduleHeading' @@ -11,16 +11,6 @@ interface InactivePluginCardContainerProps { inactiveProfiles: Profile[] } -interface LocalPluginInterface { - profile: Partial - activateService: {} - requestQueue: [] - options: { queueTimeout: number } - id: number - pendingRequest: {} - listener: [] - iframe: {} -} function InactivePluginCardContainer ({ pluginComponent }: InactivePluginCardContainerProps) { const activatePlugin = (pluginName: string) => { pluginComponent.activateP(pluginName) diff --git a/libs/remix-ui/plugin-manager/src/types.d.ts b/libs/remix-ui/plugin-manager/src/types.d.ts index 66ee57bc77..36a4ebdba2 100644 --- a/libs/remix-ui/plugin-manager/src/types.d.ts +++ b/libs/remix-ui/plugin-manager/src/types.d.ts @@ -74,7 +74,7 @@ export class PluginManagerComponent extends ViewPlugin extends Plugin implements app: PluginApi // eslint-disable-line no-undef engine: Engine htmlElement: HTMLDivElement - views: { root: null, items: {} } + views: { root: null, items: Record } localPlugin: LocalPlugin // eslint-disable-line no-use-before-define pluginNames: string[] inactivePlugins: Profile[] @@ -149,7 +149,7 @@ export interface RemixUiPluginManagerProps { declare class PluginLoader { get currentLoader(): any donotAutoReload: string[] - loaders: {} + loaders: Record current: string set(plugin: any, actives: any): void get(): any diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 7fab3aa9d4..74dade661e 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -16,6 +16,7 @@ export function ContractGUI (props: ContractGUIProps) { dataId: string }>({ title: '', content: '', classList: '', dataId: '' }) const multiFields = useRef>([]) + const basicInputRef = useRef() useEffect(() => { if (props.title) { @@ -26,6 +27,10 @@ export function ContractGUI (props: ContractGUIProps) { setTitle(props.funcABI.type === 'receive' ? '(receive)' : '(fallback)') } setBasicInput('') + // we have the reset the fields before reseting the previous references. + basicInputRef.current.value = '' + multiFields.current.filter((el) => el !== null && el !== undefined).forEach((el) => el.value = '') + multiFields.current = [] }, [props.title, props.funcABI]) useEffect(() => { @@ -166,6 +171,7 @@ export function ContractGUI (props: ContractGUIProps) { placeholder={props.inputs} title={props.funcABI.type === 'fallback' || props.funcABI.type === 'receive' ? `'(${props.funcABI.type}')` : props.inputs} onChange={handleBasicInput} + ref={basicInputRef} style={{ visibility: !((props.funcABI.inputs && props.funcABI.inputs.length > 0) || (props.funcABI.type === 'fallback') || (props.funcABI.type === 'receive')) ? 'hidden' : 'visible' }} /> { }) } - const isSolFileSelected = (currentFile: string = '') => { + const isSolFileSelected = (currentFile = '') => { if (!currentFile) currentFile = api.currentFile if (!currentFile) return false const extention = currentFile.substr(currentFile.length - 3, currentFile.length) @@ -350,7 +350,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { url = customUrl api.setCompilerParameters({ version: selectedVersion }) } else { - if (helper.checkSpecialChars(selectedVersion)) { + if (checkSpecialChars(selectedVersion)) { return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') } if (selectedVersion === 'builtin' || selectedVersion.indexOf('soljson') === 0) { @@ -606,7 +606,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index bb301dc402..368a5e1875 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -1,8 +1,6 @@ import { ICompilerApi } from '@remix-project/remix-lib-ts' -import { getValidLanguage } from '@remix-project/remix-solidity' - -const Compiler = require('@remix-project/remix-solidity').Compiler -const EventEmitter = require('events') +import { getValidLanguage, Compiler} from '@remix-project/remix-solidity' +import { EventEmitter } from 'events' declare global { interface Window { @@ -132,7 +130,7 @@ export class CompileTabLogic { } // TODO readd saving current file this.api.saveCurrentFile() - var currentFile = this.api.currentFile + const currentFile = this.api.currentFile return this.compileFile(currentFile) } catch (err) { console.error(err) diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts index 2b6a23fa5a..7b72df59f2 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/contract-parser.ts @@ -47,7 +47,7 @@ export function parseContracts (contractName, contract, source) { } const retrieveMetadataHash = function (bytecode) { - var match = /a165627a7a72305820([0-9a-f]{64})0029$/.exec(bytecode) + let match = /a165627a7a72305820([0-9a-f]{64})0029$/.exec(bytecode) if (!match) { match = /a265627a7a72305820([0-9a-f]{64})6c6578706572696d656e74616cf50037$/.exec(bytecode) } diff --git a/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts b/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts index 5ee522018b..5871a4d2cd 100644 --- a/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts +++ b/libs/remix-ui/terminal/src/lib/actions/terminalAction.ts @@ -22,7 +22,7 @@ export const registerCommandAction = (name: string, command, activate, dispatch: } commands[name] = function () { - const args = [...arguments] + const args = [...arguments] // eslint-disable-line const steps = [] const root = { steps, cmd: name, gidx: 0, idx: 0 } const ITEM = { root, cmd: name } @@ -62,7 +62,7 @@ export const registerCommandAction = (name: string, command, activate, dispatch: Object.keys(commands).forEach(function makeScopedCommand (cmd) { const command = _commands[cmd] scopedCommands[cmd] = function _command () { - const args = [...arguments] + const args = [...arguments] // eslint-disable-line command(args, scopedCommands, el => append(cmd, args, el)) } }) @@ -80,28 +80,28 @@ export const filterFnAction = (name: string, filterFn, dispatch: React.Dispatch< export const registerLogScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch) => { on('scriptRunner', commandName, (msg) => { - commandFn.log.apply(commandFn, msg.data) + commandFn.log.apply(commandFn, msg.data) // eslint-disable-line dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) }) } export const registerInfoScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch) => { on('scriptRunner', commandName, (msg) => { - commandFn.info.apply(commandFn, msg.data) + commandFn.info.apply(commandFn, msg.data) // eslint-disable-line dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) }) } export const registerWarnScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch) => { on('scriptRunner', commandName, (msg) => { - commandFn.warn.apply(commandFn, msg.data) + commandFn.warn.apply(commandFn, msg.data) // eslint-disable-line dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) }) } export const registerErrorScriptRunnerAction = (on, commandName, commandFn, dispatch: React.Dispatch) => { on('scriptRunner', commandName, (msg) => { - commandFn.error.apply(commandFn, msg.data) + commandFn.error.apply(commandFn, msg.data) // eslint-disable-line dispatch({ type: commandName, payload: { commandFn, message: msg.data } }) }) } diff --git a/libs/remix-ui/terminal/src/lib/components/Context.tsx b/libs/remix-ui/terminal/src/lib/components/Context.tsx index d5234f9526..9648b3b094 100644 --- a/libs/remix-ui/terminal/src/lib/components/Context.tsx +++ b/libs/remix-ui/terminal/src/lib/components/Context.tsx @@ -1,17 +1,16 @@ import React from 'react' // eslint-disable-line -import helper from 'apps/remix-ide/src/lib/helper' - -const remixLib = require('@remix-project/remix-lib') -const typeConversion = remixLib.execution.typeConversion +import { shortenHexData } from '@remix-ui/helper' +import { execution } from '@remix-project/remix-lib' +const typeConversion = execution.typeConversion const Context = ({ opts, provider }: { opts, provider: string }) => { const data = opts.tx || '' - const from = opts.from ? helper.shortenHexData(opts.from) : '' + const from = opts.from ? shortenHexData(opts.from) : '' let to = opts.to - if (data.to) to = to + ' ' + helper.shortenHexData(data.to) + if (data.to) to = to + ' ' + shortenHexData(data.to) const val = data.value - let hash = data.hash ? helper.shortenHexData(data.hash) : '' - const input = data.input ? helper.shortenHexData(data.input) : '' + let hash = data.hash ? shortenHexData(data.hash) : '' + const input = data.input ? shortenHexData(data.input) : '' const logs = opts.logs && opts.logs.decoded && opts.logs.decoded.length ? opts.logs.decoded.length : 0 const block = data.receipt ? data.receipt.blockNumber : data.blockNumber || '' const i = data.receipt ? data.transactionIndex : data.transactionIndex @@ -44,7 +43,7 @@ const Context = ({ opts, provider }: { opts, provider: string }) => { ) } else { - hash = helper.shortenHexData(data.blockHash) + hash = shortenHexData(data.blockHash) return (
diff --git a/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx b/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx index 4cb3b96473..acfbc0399e 100644 --- a/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx +++ b/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx @@ -1,16 +1,15 @@ -import React, { useState } from 'react' // eslint-disable-line -import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line -import helper from 'apps/remix-ide/src/lib/helper' +import React from 'react' // eslint-disable-line +import { shortenHexData } from '@remix-ui/helper' import CheckTxStatus from './ChechTxStatus' // eslint-disable-line import showTable from './Table' +import { execution } from '@remix-project/remix-lib' -const remixLib = require('@remix-project/remix-lib') -const typeConversion = remixLib.execution.typeConversion +const typeConversion = execution.typeConversion const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDetails, modal }) => { const to = resolvedData.contractName + '.' + resolvedData.fn const from = tx.from ? tx.from : ' - ' - const input = tx.input ? helper.shortenHexData(tx.input) : '' + const input = tx.input ? shortenHexData(tx.input) : '' const txType = 'call' const debug = (event, tx) => { diff --git a/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx b/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx index 64d58248bf..84603d6a1c 100644 --- a/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx +++ b/libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx @@ -1,12 +1,10 @@ -import React, { useState } from 'react' // eslint-disable-line -import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line +import React from 'react' // eslint-disable-line import CheckTxStatus from './ChechTxStatus' // eslint-disable-line import Context from './Context' // eslint-disable-line import showTable from './Table' - -const remixLib = require('@remix-project/remix-lib') -const typeConversion = remixLib.execution.typeConversion +import { execution } from '@remix-project/remix-lib' +const typeConversion = execution.typeConversion const RenderKnownTransactions = ({ tx, receipt, resolvedData, logs, index, plugin, showTableHash, txDetails, modal, provider }) => { const debug = (event, tx) => { diff --git a/libs/remix-ui/terminal/src/lib/components/Table.tsx b/libs/remix-ui/terminal/src/lib/components/Table.tsx index 360b80aa49..6260cb824e 100644 --- a/libs/remix-ui/terminal/src/lib/components/Table.tsx +++ b/libs/remix-ui/terminal/src/lib/components/Table.tsx @@ -1,9 +1,8 @@ -import React, { useState } from 'react' // eslint-disable-line +import React from 'react' // eslint-disable-line import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line -import helper from 'apps/remix-ide/src/lib/helper' - -const remixLib = require('@remix-project/remix-lib') -const typeConversion = remixLib.execution.typeConversion +import { shortenHexData } from '@remix-ui/helper' +import { execution } from '@remix-project/remix-lib' +const typeConversion = execution.typeConversion const showTable = (opts, showTableHash) => { let msg = '' @@ -184,7 +183,7 @@ const showTable = (opts, showTableHash) => { data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`} > - {helper.shortenHexData(opts.input)} + {shortenHexData(opts.input)} diff --git a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx index 5633513493..f5a2a8868a 100644 --- a/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx +++ b/libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx @@ -105,7 +105,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { registerCommandAction('error', _blocksRenderer('error'), { activate: true }, dispatch) registerCommandAction('script', function execute (args, scopedCommands) { - var script = String(args[0]) + const script = String(args[0]) _shell(script, scopedCommands, function (error, output) { if (error) scriptRunnerDispatch({ type: 'error', payload: { message: error } }) if (output) scriptRunnerDispatch({ type: 'script', payload: { message: '5' } }) @@ -281,7 +281,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => { const filterUndefined = (el) => el !== undefined && el !== null return function logger (args) { const types = args.filter(filterUndefined).map(type => type) - const values = javascriptserialize.apply(null, args.filter(filterUndefined)).map(function (val, idx) { + const values = javascriptserialize.apply(null, args.filter(filterUndefined)).map(function (val, idx) { // eslint-disable-line if (typeof args[idx] === 'string') { const el = document.createElement('div') el.innerHTML = args[idx].replace(/(\r\n|\n|\r)/gm, '
') diff --git a/libs/remix-ui/terminal/src/lib/utils/utils.ts b/libs/remix-ui/terminal/src/lib/utils/utils.ts index 62091ee9c8..3ea77b6ed5 100644 --- a/libs/remix-ui/terminal/src/lib/utils/utils.ts +++ b/libs/remix-ui/terminal/src/lib/utils/utils.ts @@ -14,9 +14,9 @@ export const matched = (arr, value) => arr.map(x => Object.keys(x).some(x => x.s const findDeep = (object, fn, found = { break: false, value: undefined }) => { if (typeof object !== 'object' || object === null) return - for (var i in object) { + for (const i in object) { if (found.break) break - var el = object[i] + let el = object[i] if (el && el.innerText !== undefined && el.innerText !== null) el = el.innerText if (fn(el, i, object)) { found.value = el diff --git a/libs/remix-ui/theme-module/src/index.ts b/libs/remix-ui/theme-module/src/index.ts index 63469ca72e..f83499af53 100644 --- a/libs/remix-ui/theme-module/src/index.ts +++ b/libs/remix-ui/theme-module/src/index.ts @@ -1 +1,2 @@ export * from './lib/remix-ui-theme-module'; +export * from '../types/theme-module' diff --git a/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx b/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx index 9a8e22143c..077da4edba 100644 --- a/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx +++ b/libs/remix-ui/theme-module/src/lib/remix-ui-theme-module.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import React, { useEffect, useRef, useState } from 'react'; -import { Theme, ThemeModule } from '../../types/theme-module'; +import React, { useEffect, useState } from 'react'; +import { ThemeModule } from '../../types/theme-module'; import './remix-ui-theme-module.module.css'; /* eslint-disable-next-line */ diff --git a/libs/remix-ui/theme-module/types/theme-module.d.ts b/libs/remix-ui/theme-module/types/theme-module.ts similarity index 94% rename from libs/remix-ui/theme-module/types/theme-module.d.ts rename to libs/remix-ui/theme-module/types/theme-module.ts index 42dc836dfb..6d6935fde1 100644 --- a/libs/remix-ui/theme-module/types/theme-module.d.ts +++ b/libs/remix-ui/theme-module/types/theme-module.ts @@ -1,10 +1,10 @@ import { Plugin } from "@remixproject/engine/lib/abstract"; import { EventEmitter } from "events"; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export class ThemeModule extends Plugin { +export interface ThemeModule extends Plugin { currentThemeState: Record; + constructor(registry: any): any; // eslint-disable-next-line @typescript-eslint/no-explicit-any - constructor(registry: any); events: EventEmitter; _deps: { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 146156f698..ae248d6fa8 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -9,11 +9,18 @@ import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin export * from './events' export * from './workspace' -const QueryParams = require('../../../../../../apps/remix-ide/src/lib/query-params') +import { QueryParams } from '@remix-project/remix-lib' + const queryParams = new QueryParams() let plugin, dispatch: React.Dispatch +export type UrlParametersType = { + gist: string, + code: string, + url: string +} + export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.Dispatch) => { if (filePanelPlugin) { plugin = filePanelPlugin @@ -21,7 +28,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. setPlugin(plugin, dispatch) const workspaceProvider = filePanelPlugin.fileProviders.workspace const localhostProvider = filePanelPlugin.fileProviders.localhost - const params = queryParams.get() + const params = queryParams.get() as UrlParametersType const workspaces = await getWorkspaces() || [] dispatch(setWorkspaces(workspaces)) @@ -84,6 +91,12 @@ export const removeInputField = async (path: string) => { dispatch(removeInputFieldSuccess(path)) } +export type SolidityConfiguration = { + version: string, + optimize: string, + runs: string +} + export const publishToGist = async (path?: string, type?: string) => { // If 'id' is not defined, it is not a gist update but a creation so we have to take the files from the browser explorer. const folder = path || '/' @@ -97,8 +110,9 @@ export const publishToGist = async (path?: string, type?: string) => { if (!accessToken) { dispatch(displayNotification('Authorize Token', 'Remix requires an access token (which includes gists creation permission). Please go to the settings tab to create one.', 'Close', null, () => {})) } else { + const params = queryParams.get() as SolidityConfiguration const description = 'Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=' + - queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&runs=' + queryParams.get().runs + '&gist=' + params.version + '&optimize=' + params.optimize + '&runs=' + params.runs + '&gist=' const gists = new Gists({ token: accessToken }) if (id) { diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index b463a94a5a..0d6fce12ce 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -4,8 +4,8 @@ import axios, { AxiosResponse } from 'axios' import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload' import { checkSlash, checkSpecialChars } from '@remix-ui/helper' -const examples = require('../../../../../../apps/remix-ide/src/app/editor/examples') -const QueryParams = require('../../../../../../apps/remix-ide/src/lib/query-params') +import { examples } from '../templates/examples' +import { QueryParams } from '@remix-project/remix-lib' const LOCALHOST = ' - connect to localhost - ' const NO_WORKSPACE = ' - none - ' @@ -69,9 +69,15 @@ export const createWorkspaceTemplate = async (workspaceName: string, template: ' } } +export type UrlParametersType = { + gist: string, + code: string, + url: string +} + export const loadWorkspacePreset = async (template: 'gist-template' | 'code-template' | 'default-template' = 'default-template') => { const workspaceProvider = plugin.fileProviders.workspace - const params = queryParams.get() + const params = queryParams.get() as UrlParametersType switch (template) { case 'code-template': diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index f89fb9338e..5ae7de8d05 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -287,7 +287,7 @@ export const FileExplorer = (props: FileExplorerProps) => { }) } - const editModeOn = (path: string, type: string, isNew: boolean = false) => { + const editModeOn = (path: string, type: string, isNew = false) => { if (props.readonly) return props.toast('Cannot write/modify file system in read only mode.') setState(prevState => { return { ...prevState, focusEdit: { ...prevState.focusEdit, element: path, isNew, type } } diff --git a/apps/remix-ide/src/app/editor/examples.js b/libs/remix-ui/workspace/src/lib/templates/examples.ts similarity index 99% rename from apps/remix-ide/src/app/editor/examples.js rename to libs/remix-ui/workspace/src/lib/templates/examples.ts index 4f60ffa646..0d3c0c4941 100644 --- a/apps/remix-ide/src/app/editor/examples.js +++ b/libs/remix-ui/workspace/src/lib/templates/examples.ts @@ -331,7 +331,7 @@ To run a script, right click on file name in the file explorer and click 'Run'. Output from script will appear in remix terminal. ` -module.exports = { +export const examples = { storage: { name: 'contracts/1_Storage.sol', content: storage }, owner: { name: 'contracts/2_Owner.sol', content: owner }, ballot: { name: 'contracts/3_Ballot.sol', content: ballot }, diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index c139bbc803..2f30fc4339 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -54,7 +54,7 @@ export class RemixURLResolver { } // eslint-disable-next-line no-useless-catch try { - const req: string = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}` + const req = `https://raw.githubusercontent.com/${root}/${reference}/${filePath}` const response: AxiosResponse = await axios.get(req) return { content: response.data, cleanUrl: root + '/' + filePath } } catch (e) { diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index 8440ae0ce7..c6bff13a89 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -12,7 +12,7 @@ import * as program from 'commander' async function warnLatestVersion () { const latest = await latestVersion('@remix-project/remixd') - const pjson = require('../../package.json') + const pjson = require('../../package.json') // eslint-disable-line if (semver.eq(latest, pjson.version)) { console.log('\x1b[32m%s\x1b[0m', `[INFO] you are using the latest version ${latest}`) } else if (semver.gt(latest, pjson.version)) { @@ -37,7 +37,7 @@ const ports = { folder: 65520 } -const killCallBack: Array = [] +const killCallBack: Array = [] // any is function function startService (service: S, callback: (ws: WS, sharedFolderClient: servicesList.Sharedfolder, error?:Error) => void) { const socket = new WebSocket(ports[service], { remixIdeUrl: program.remixIde }, () => services[service](program.readOnly || false)) socket.start(callback) @@ -54,7 +54,7 @@ function errorHandler (error: any, service: string) { } (async () => { - const { version } = require('../../package.json') + const { version } = require('../../package.json') // eslint-disable-line program.version(version, '-v, --version') program diff --git a/libs/remixd/src/services/gitClient.ts b/libs/remixd/src/services/gitClient.ts index d4658df554..71f691a8a6 100644 --- a/libs/remixd/src/services/gitClient.ts +++ b/libs/remixd/src/services/gitClient.ts @@ -1,6 +1,6 @@ import * as WS from 'ws' // eslint-disable-line import { PluginClient } from '@remixproject/plugin' -const { spawn } = require('child_process') +const { spawn } = require('child_process') // eslint-disable-line export class GitClient extends PluginClient { methods: Array diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index 62400debda..48e268f4b2 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -1,6 +1,6 @@ import * as WS from 'ws' // eslint-disable-line import { PluginClient } from '@remixproject/plugin' -const { spawn } = require('child_process') +const { spawn } = require('child_process') // eslint-disable-line export class HardhatClient extends PluginClient { methods: Array diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index 24e485045d..1187bd694e 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -5,7 +5,7 @@ import { PluginClient } from '@remixproject/plugin' import { existsSync, readFileSync, readdirSync, unlink } from 'fs' import { OutputStandard } from '../types' // eslint-disable-line import * as utils from '../utils' -const { spawn, execSync } = require('child_process') +const { spawn, execSync } = require('child_process') // eslint-disable-line export class SlitherClient extends PluginClient { methods: Array @@ -73,7 +73,7 @@ export class SlitherClient extends PluginClient { analyse (filePath: string, compilerConfig: Record) { return new Promise((resolve, reject) => { if (this.readOnly) { - const errMsg: string = '[Slither Analysis]: Cannot analyse in read-only mode' + const errMsg = '[Slither Analysis]: Cannot analyse in read-only mode' return reject(new Error(errMsg)) } const options = { cwd: this.currentSharedFolder, shell: true } @@ -136,7 +136,7 @@ export class SlitherClient extends PluginClient { const solcRemaps = remaps ? `--solc-remaps "${remaps}"` : '' const outputFile: string = 'remix-slitherReport_' + Math.floor(Date.now() / 1000) + '.json' - const cmd: string = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}` + const cmd = `slither ${filePath} ${solcArgs} ${solcRemaps} --json ${outputFile}` console.log('\x1b[32m%s\x1b[0m', '[Slither Analysis]: Running Slither...') // Added `stdio: 'ignore'` as for contract with NPM imports analysis which is exported in 'stderr' // get too big and hangs the process. We process analysis from the report file only diff --git a/package.json b/package.json index 2e0b696d45..dc47278bd3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "workspace-schematic": "nx workspace-schematic", "dep-graph": "nx dep-graph", "help": "nx help", - "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab,remix-ui-permission-handle", + "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab,remix-ui-permission-handler", "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "publish:libs": "npm run build:libs && lerna publish --skip-git && npm run bumpVersion:libs",