diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index 48405241a2..86701d9323 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/src/app.js b/apps/remix-ide/src/app.js index 3599de6400..25fc2e92b4 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' @@ -27,7 +28,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') @@ -185,7 +186,7 @@ class AppComponent { } } ) - const contextualListener = new EditorContextListener() + const contextualListener = new EditorContextListener(new AstWalker()) this.notification = new NotificationPlugin() 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/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 b9c2677840..4718b4dee6 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -5,7 +5,7 @@ import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable import { CompileTabLogic } from '@remix-ui/solidity-compiler' // eslint-disable-line 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/runTab/model/recorder.js b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js index a982a4b067..6178063843 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -178,7 +178,7 @@ class Recorder { run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, newContractFn) { this.setListen(false) logCallBack(`Running ${records.length} transaction(s) ...`) - async.eachOfSeries(records, function (tx, index, cb) { + async.eachOfSeries(records, (tx, index, cb) => { var record = this.resolveAddress(tx.record, accounts, options) var abi = abis[tx.record.abi] if (!abi) { @@ -239,7 +239,7 @@ class Recorder { record.data = { dataHex: data.data, funArgs: tx.record.parameters, funAbi: fnABI, contractBytecode: tx.record.bytecode, contractName: tx.record.contractName, timestamp: tx.timestamp } this.blockchain.runTx(record, confirmationCb, continueCb, promptCb, - function (err, txResult, rawAddress) { + (err, txResult, rawAddress) => { if (err) { console.error(err) return logCallBack(err + '. Execution failed at ' + index) 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/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 94cc78fb0b..39e1c3c413 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -1,6 +1,6 @@ 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 || [] 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 624c756357..4620e2de73 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 c3d0af408f..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 @@ -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 e8cd462564..8c7590857b 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']) @@ -140,7 +140,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) } @@ -201,7 +201,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/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 dbf0129ac8..f20fd124a5 100644 --- a/libs/remix-ui/helper/src/lib/remix-ui-helper.ts +++ b/libs/remix-ui/helper/src/lib/remix-ui-helper.ts @@ -99,3 +99,10 @@ 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/settings/src/lib/remix-ui-settings.tsx b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx index f86129a579..336fef5c0f 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -7,8 +7,7 @@ import './remix-ui-settings.css' import { ethereumVM, generateContractMetadat, personal, textWrapEventAction, useMatomoAnalytics, saveTokenToast, removeTokenToast } from './settingsAction' import { initialState, toastInitialState, toastReducer, settingReducer } from './settingsReducer' import { Toaster } from '@remix-ui/toaster'// eslint-disable-line -import { RemixUiThemeModule } from '@remix-ui/theme-module' -import { ThemeModule } from 'libs/remix-ui/theme-module/types/theme-module' +import { RemixUiThemeModule, ThemeModule} from '@remix-ui/theme-module' /* eslint-disable-next-line */ export interface RemixUiSettingsProps { diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 926f4b0385..434309e790 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -243,7 +243,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) } - 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) 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 95f3bf6d71..2af2d6de64 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' } }) @@ -282,7 +282,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 e9bc5d1a62..606c85fe6f 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 3dd6b16bbb..630c72d573 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 e248fc3ba0..6a15b5d85e 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",