fix linting

pull/2064/head
yann300 3 years ago
parent 54700ee069
commit 9823e17172
  1. 21
      .eslintrc
  2. 2
      .eslintrc.json
  3. 159
      apps/remix-ide/src/app.js
  4. 8
      apps/remix-ide/src/app/files/dgitProvider.js
  5. 12
      apps/remix-ide/src/app/files/fileProvider.js
  6. 4
      apps/remix-ide/src/app/files/workspaceFileProvider.js
  7. 1
      apps/remix-ide/src/app/panels/terminal.js
  8. 2
      apps/remix-ide/src/app/tabs/compile-tab.js
  9. 2
      apps/remix-ide/src/app/tabs/debugger-tab.js
  10. 73
      apps/remix-ide/src/app/tabs/runTab/model/recorder.js
  11. 2
      apps/remix-ide/src/app/tabs/test-tab.js
  12. 40
      apps/remix-ide/src/blockchain/blockchain.js
  13. 6
      apps/remix-ide/src/blockchain/execution-context.js
  14. 1
      apps/remix-ide/src/blockchain/providers/injected.js
  15. 1
      apps/remix-ide/src/blockchain/providers/node.js
  16. 2
      apps/remix-ide/src/config.js
  17. 3
      apps/remix-ide/src/remixAppManager.js
  18. 4
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
  19. 5
      libs/remix-ui/helper/src/lib/remix-ui-helper.ts
  20. 6
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx

@ -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"
}
}
]
}

@ -1,6 +1,6 @@
{ {
"root": true, "root": true,
"ignorePatterns": ["**/*"], "ignorePatterns": [],
"plugins": ["@nrwl/nx"], "plugins": ["@nrwl/nx"],
"overrides": [ "overrides": [
{ {

@ -51,10 +51,9 @@ const { TabProxy } = require('./app/panels/tab-proxy.js')
class AppComponent { class AppComponent {
constructor () { constructor () {
const self = this this.appManager = new RemixAppManager({})
self.appManager = new RemixAppManager({}) this.queryParams = new QueryParams()
self.queryParams = new QueryParams() this._components = {}
self._components = {}
// setup storage // setup storage
const configStorage = new Storage('config-v0.8:') const configStorage = new Storage('config-v0.8:')
@ -63,54 +62,55 @@ class AppComponent {
Registry.getInstance().put({ api: config, name: 'config' }) Registry.getInstance().put({ api: config, name: 'config' })
// load file system // load file system
self._components.filesProviders = {} this._components.filesProviders = {}
self._components.filesProviders.browser = new FileProvider('browser') this._components.filesProviders.browser = new FileProvider('browser')
Registry.getInstance().put({ Registry.getInstance().put({
api: self._components.filesProviders.browser, api: this._components.filesProviders.browser,
name: 'fileproviders/browser' name: 'fileproviders/browser'
}) })
self._components.filesProviders.localhost = new RemixDProvider( this._components.filesProviders.localhost = new RemixDProvider(
self.appManager this.appManager
) )
Registry.getInstance().put({ Registry.getInstance().put({
api: self._components.filesProviders.localhost, api: this._components.filesProviders.localhost,
name: 'fileproviders/localhost' name: 'fileproviders/localhost'
}) })
self._components.filesProviders.workspace = new WorkspaceFileProvider() this._components.filesProviders.workspace = new WorkspaceFileProvider()
Registry.getInstance().put({ Registry.getInstance().put({
api: self._components.filesProviders.workspace, api: this._components.filesProviders.workspace,
name: 'fileproviders/workspace' name: 'fileproviders/workspace'
}) })
Registry.getInstance().put({ Registry.getInstance().put({
api: self._components.filesProviders, api: this._components.filesProviders,
name: 'fileproviders' name: 'fileproviders'
}) })
} }
async run () { async run () {
const self = this
// APP_MANAGER // APP_MANAGER
const appManager = self.appManager const appManager = this.appManager
const pluginLoader = self.appManager.pluginLoader const pluginLoader = this.appManager.pluginLoader
self.panels = {} this.panels = {}
self.workspace = pluginLoader.get() this.workspace = pluginLoader.get()
self.engine = new RemixEngine() this.engine = new RemixEngine()
self.engine.register(appManager) this.engine.register(appManager);
const matomoDomains = { const matomoDomains = {
'remix-alpha.ethereum.org': 27, 'remix-alpha.ethereum.org': 27,
'remix-beta.ethereum.org': 25, 'remix-beta.ethereum.org': 25,
'remix.ethereum.org': 23 'remix.ethereum.org': 23
} }
self.showMatamo = this.showMatamo =
matomoDomains[window.location.hostname] && matomoDomains[window.location.hostname] &&
!Registry.getInstance() !Registry.getInstance()
.get('config') .get('config')
.api.exists('settings/matomo-analytics') .api.exists('settings/matomo-analytics')
self.walkthroughService = new WalkthroughService( this.walkthroughService = new WalkthroughService(
appManager, appManager,
self.showMatamo this.showMatamo
) )
const hosts = ['127.0.0.1:8080', '192.168.0.101:8080', 'localhost:8080'] const hosts = ['127.0.0.1:8080', '192.168.0.101:8080', 'localhost:8080']
@ -124,10 +124,10 @@ class AppComponent {
// SERVICES // SERVICES
// ----------------- gist service --------------------------------- // ----------------- gist service ---------------------------------
self.gistHandler = new GistHandler() this.gistHandler = new GistHandler()
// ----------------- theme service --------------------------------- // ----------------- theme service ---------------------------------
self.themeModule = new ThemeModule() this.themeModule = new ThemeModule()
Registry.getInstance().put({ api: self.themeModule, name: 'themeModule' }) Registry.getInstance().put({ api: this.themeModule, name: 'themeModule' })
// ----------------- editor service ---------------------------- // ----------------- editor service ----------------------------
const editor = new Editor() // wrapper around ace editor const editor = new Editor() // wrapper around ace editor
@ -187,22 +187,22 @@ class AppComponent {
) )
const contextualListener = new EditorContextListener() const contextualListener = new EditorContextListener()
self.notification = new NotificationPlugin() this.notification = new NotificationPlugin()
const configPlugin = new ConfigPlugin() const configPlugin = new ConfigPlugin()
self.layout = new Layout() this.layout = new Layout()
const permissionHandler = new PermissionHandlerPlugin() const permissionHandler = new PermissionHandlerPlugin()
self.engine.register([ this.engine.register([
permissionHandler, permissionHandler,
self.layout, this.layout,
self.notification, this.notification,
self.gistHandler, this.gistHandler,
configPlugin, configPlugin,
blockchain, blockchain,
contentImport, contentImport,
self.themeModule, this.themeModule,
editor, editor,
fileManager, fileManager,
compilerMetadataGenerator, compilerMetadataGenerator,
@ -215,46 +215,46 @@ class AppComponent {
fetchAndCompile, fetchAndCompile,
dGitProvider, dGitProvider,
hardhatProvider, hardhatProvider,
self.walkthroughService this.walkthroughService
]) ])
// LAYOUT & SYSTEM VIEWS // LAYOUT & SYSTEM VIEWS
const appPanel = new MainPanel() 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) const tabProxy = new TabProxy(fileManager, editor)
self.engine.register([appPanel, tabProxy]) this.engine.register([appPanel, tabProxy])
// those views depend on app_manager // those views depend on app_manager
self.menuicons = new VerticalIcons() this.menuicons = new VerticalIcons()
self.sidePanel = new SidePanel() this.sidePanel = new SidePanel()
self.hiddenPanel = new HiddenPanel() this.hiddenPanel = new HiddenPanel()
const pluginManagerComponent = new PluginManagerComponent( const pluginManagerComponent = new PluginManagerComponent(
appManager, appManager,
self.engine this.engine
) )
const filePanel = new FilePanel(appManager) const filePanel = new FilePanel(appManager)
const landingPage = new LandingPage( const landingPage = new LandingPage(
appManager, appManager,
self.menuicons, this.menuicons,
fileManager, fileManager,
filePanel, filePanel,
contentImport contentImport
) )
self.settings = new SettingsTab( this.settings = new SettingsTab(
Registry.getInstance().get('config').api, Registry.getInstance().get('config').api,
editor, editor,
appManager appManager
) )
self.engine.register([ this.engine.register([
self.menuicons, this.menuicons,
landingPage, landingPage,
self.hiddenPanel, this.hiddenPanel,
self.sidePanel, this.sidePanel,
filePanel, filePanel,
pluginManagerComponent, pluginManagerComponent,
self.settings this.settings
]) ])
// CONTENT VIEWS & DEFAULT PLUGINS // CONTENT VIEWS & DEFAULT PLUGINS
@ -283,7 +283,7 @@ class AppComponent {
contentImport contentImport
) )
self.engine.register([ this.engine.register([
compileTab, compileTab,
run, run,
debug, debug,
@ -295,7 +295,7 @@ class AppComponent {
filePanel.slitherHandle filePanel.slitherHandle
]) ])
self.layout.panels = { this.layout.panels = {
tabs: { plugin: tabProxy, active: true }, tabs: { plugin: tabProxy, active: true },
editor: { plugin: editor, active: true }, editor: { plugin: editor, active: true },
main: { plugin: appPanel, active: false }, main: { plugin: appPanel, active: false },
@ -306,47 +306,46 @@ class AppComponent {
async activate () { async activate () {
const queryParams = new QueryParams() const queryParams = new QueryParams()
const params = queryParams.get() const params = queryParams.get()
const self = this
if (isElectron()) { if (isElectron()) {
self.appManager.activatePlugin('remixd') this.appManager.activatePlugin('remixd')
} }
try { try {
self.engine.register(await self.appManager.registeredPlugins()) this.engine.register(await this.appManager.registeredPlugins())
} catch (e) { } catch (e) {
console.log("couldn't register iframe plugins", e.message) console.log("couldn't register iframe plugins", e.message)
} }
await self.appManager.activatePlugin(['layout']) await this.appManager.activatePlugin(['layout'])
await self.appManager.activatePlugin(['notification']) await this.appManager.activatePlugin(['notification'])
await self.appManager.activatePlugin(['editor']) await this.appManager.activatePlugin(['editor'])
await self.appManager.activatePlugin(['permissionhandler', 'theme', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) await this.appManager.activatePlugin(['permissionhandler', 'theme', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter'])
await self.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs']) await this.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
await self.appManager.activatePlugin(['sidePanel']) // activating host plugin separately await this.appManager.activatePlugin(['sidePanel']) // activating host plugin separately
await self.appManager.activatePlugin(['home']) await this.appManager.activatePlugin(['home'])
await self.appManager.activatePlugin(['settings', 'config']) await this.appManager.activatePlugin(['settings', 'config'])
await self.appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'contextualListener', 'terminal', 'blockchain', 'fetchAndCompile', 'contentImport', 'gistHandler']) await this.appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'contextualListener', 'terminal', 'blockchain', 'fetchAndCompile', 'contentImport', 'gistHandler'])
await self.appManager.activatePlugin(['settings']) await this.appManager.activatePlugin(['settings'])
await self.appManager.activatePlugin(['walkthrough']) await this.appManager.activatePlugin(['walkthrough'])
self.appManager.on( this.appManager.on(
'filePanel', 'filePanel',
'workspaceInitializationCompleted', 'workspaceInitializationCompleted',
async () => { async () => {
await self.appManager.registerContextMenuItems() await this.appManager.registerContextMenuItems()
} }
) )
await self.appManager.activatePlugin(['filePanel']) await this.appManager.activatePlugin(['filePanel'])
// Set workspace after initial activation // Set workspace after initial activation
self.appManager.on('editor', 'editorMounted', () => { this.appManager.on('editor', 'editorMounted', () => {
if (Array.isArray(self.workspace)) { if (Array.isArray(this.workspace)) {
self.appManager this.appManager
.activatePlugin(self.workspace) .activatePlugin(this.workspace)
.then(async () => { .then(async () => {
try { try {
if (params.deactivate) { if (params.deactivate) {
await self.appManager.deactivatePlugin( await this.appManager.deactivatePlugin(
params.deactivate.split(',') params.deactivate.split(',')
) )
} }
@ -355,21 +354,21 @@ class AppComponent {
} }
if (params.code) { if (params.code) {
// if code is given in url we focus on solidity plugin // if code is given in url we focus on solidity plugin
self.menuicons.select('solidity') this.menuicons.select('solidity')
} else { } else {
// If plugins are loaded from the URL params, we focus on the last one. // If plugins are loaded from the URL params, we focus on the last one.
if ( if (
self.appManager.pluginLoader.current === 'queryParams' && this.appManager.pluginLoader.current === 'queryParams' &&
self.workspace.length > 0 this.workspace.length > 0
) { self.menuicons.select(self.workspace[self.workspace.length - 1]) } ) { this.menuicons.select(this.workspace[this.workspace.length - 1]) }
} }
if (params.call) { if (params.call) {
const callDetails = params.call.split('//') const callDetails = params.call.split('//')
if (callDetails.length > 1) { 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) // @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)
} }
} }
}) })
@ -377,7 +376,7 @@ class AppComponent {
} }
}) })
// activate solidity plugin // activate solidity plugin
self.appManager.activatePlugin(['solidity', 'udapp']) this.appManager.activatePlugin(['solidity', 'udapp'])
// Load and start the service who manager layout and frame // Load and start the service who manager layout and frame
} }
} }

@ -61,6 +61,7 @@ class DGitProvider extends Plugin {
corsProxy: 'https://corsproxy.remixproject.org/', corsProxy: 'https://corsproxy.remixproject.org/',
http, http,
onAuth: url => { onAuth: url => {
url
const auth = { const auth = {
username: input.token, username: input.token,
password: '' password: ''
@ -122,6 +123,7 @@ class DGitProvider extends Plugin {
try { try {
remotes = await git.listRemotes({ ...await this.getGitConfig() }) remotes = await git.listRemotes({ ...await this.getGitConfig() })
} catch (e) { } catch (e) {
console.log(e)
} }
return remotes return remotes
} }
@ -196,7 +198,7 @@ class DGitProvider extends Plugin {
async setIpfsConfig (config) { async setIpfsConfig (config) {
this.ipfsconfig = config this.ipfsconfig = config
return new Promise((resolve, reject) => { return new Promise((resolve) => {
resolve(this.checkIpfsConfig()) resolve(this.checkIpfsConfig())
}) })
} }
@ -409,7 +411,7 @@ class DGitProvider extends Plugin {
} catch (error) { } catch (error) {
throw new Error(error) throw new Error(error)
} }
}; }
async importIPFSFiles (config, cid, workspace) { async importIPFSFiles (config, cid, workspace) {
const ipfs = IpfsHttpClient(config) const ipfs = IpfsHttpClient(config)
@ -450,7 +452,7 @@ class DGitProvider extends Plugin {
} }
_xLen = ((localStorage[_x].length + _x.length) * 2) _xLen = ((localStorage[_x].length + _x.length) * 2)
_lsTotal += _xLen _lsTotal += _xLen
}; }
return (_lsTotal / 1024).toFixed(2) return (_lsTotal / 1024).toFixed(2)
} }

@ -87,7 +87,7 @@ class FileProvider {
} }
get (path, cb) { get (path, cb) {
cb = cb || function () {} cb = cb || function () { /* do nothing. */ }
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath) var exists = window.remixFileSystem.existsSync(unprefixedpath)
@ -98,7 +98,7 @@ class FileProvider {
} }
set (path, content, cb) { set (path, content, cb) {
cb = cb || function () {} cb = cb || function () { /* do nothing. */ }
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath) var exists = window.remixFileSystem.existsSync(unprefixedpath)
if (exists && window.remixFileSystem.readFileSync(unprefixedpath, 'utf8') === content) { if (exists && window.remixFileSystem.readFileSync(unprefixedpath, 'utf8') === content) {
@ -207,8 +207,8 @@ class FileProvider {
* @param {Function} visitFolder is a function called for each visited folders * @param {Function} visitFolder is a function called for each visited folders
*/ */
_copyFolderToJsonInternal (path, visitFile, visitFolder) { _copyFolderToJsonInternal (path, visitFile, visitFolder) {
visitFile = visitFile || (() => {}) visitFile = visitFile || function () { /* do nothing. */ }
visitFolder = visitFolder || (() => {}) visitFolder = visitFolder || function () { /* do nothing. */ }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const json = {} const json = {}
path = this.removePrefix(path) path = this.removePrefix(path)
@ -245,8 +245,8 @@ class FileProvider {
* @param {Function} visitFolder is a function called for each visited folders * @param {Function} visitFolder is a function called for each visited folders
*/ */
copyFolderToJson (path, visitFile, visitFolder) { copyFolderToJson (path, visitFile, visitFolder) {
visitFile = visitFile || (() => {}) visitFile = visitFile || function () { /* do nothing. */ }
visitFolder = visitFolder || (() => {}) visitFolder = visitFolder || function () { /* do nothing. */ }
return this._copyFolderToJsonInternal(path, visitFile, visitFolder) return this._copyFolderToJsonInternal(path, visitFile, visitFolder)
} }

@ -68,8 +68,8 @@ class WorkspaceFileProvider extends FileProvider {
} }
async copyFolderToJson (directory, visitFile, visitFolder) { async copyFolderToJson (directory, visitFile, visitFolder) {
visitFile = visitFile || (() => {}) visitFile = visitFile || function () { /* do nothing. */ }
visitFolder = visitFolder || (() => {}) visitFolder = visitFolder || function () { /* do nothing. */ }
const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g') const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g')
let json = await super._copyFolderToJsonInternal(directory, ({ path, content }) => { let json = await super._copyFolderToJsonInternal(directory, ({ path, content }) => {
visitFile({ path: path.replace(regex, ''), content }) visitFile({ path: path.replace(regex, ''), content })

@ -117,6 +117,7 @@ class Terminal extends Plugin {
scroll2bottom () { scroll2bottom () {
setTimeout(function () { setTimeout(function () {
// do nothing.
}, 0) }, 0)
} }
} }

@ -3,7 +3,7 @@ import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line import { SolidityCompiler } from '@remix-ui/solidity-compiler' // eslint-disable-line
import { CompileTabLogic } 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 { ViewPlugin } from '@remixproject/engine-web'
import QueryParams from '../../lib/query-params' import QueryParams from '../../lib/query-params'
// import { ICompilerApi } from '@remix-project/remix-lib-ts' // import { ICompilerApi } from '@remix-project/remix-lib-ts'

@ -1,5 +1,5 @@
import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line 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 { ViewPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line

@ -11,10 +11,9 @@ const helper = require('../../../../lib/helper')
*/ */
class Recorder { class Recorder {
constructor (blockchain) { constructor (blockchain) {
var self = this this.event = new EventManager()
self.event = new EventManager() this.blockchain = blockchain
self.blockchain = blockchain this.data = { _listen: true, _replay: false, journal: [], _createdContracts: {}, _createdContractsReverse: {}, _usedAccounts: {}, _abis: {}, _contractABIReferences: {}, _linkReferences: {} }
self.data = { _listen: true, _replay: false, journal: [], _createdContracts: {}, _createdContractsReverse: {}, _usedAccounts: {}, _abis: {}, _contractABIReferences: {}, _linkReferences: {} }
this.blockchain.event.register('initiatingTransaction', (timestamp, tx, payLoad) => { this.blockchain.event.register('initiatingTransaction', (timestamp, tx, payLoad) => {
if (tx.useCall) return if (tx.useCall) return
@ -33,11 +32,11 @@ class Recorder {
if (record.linkReferences && Object.keys(record.linkReferences).length) { if (record.linkReferences && Object.keys(record.linkReferences).length) {
for (var file in record.linkReferences) { for (var file in record.linkReferences) {
for (var lib in record.linkReferences[file]) { for (var lib in record.linkReferences[file]) {
self.data._linkReferences[lib] = '<address>' this.data._linkReferences[lib] = '<address>'
} }
} }
} }
self.data._abis[keccak] = abi this.data._abis[keccak] = abi
this.data._contractABIReferences[timestamp] = keccak this.data._contractABIReferences[timestamp] = keccak
} else { } else {
@ -57,8 +56,8 @@ class Recorder {
this.blockchain.getAccounts((error, accounts) => { this.blockchain.getAccounts((error, accounts) => {
if (error) return console.log(error) if (error) return console.log(error)
record.from = `account{${accounts.indexOf(from)}}` record.from = `account{${accounts.indexOf(from)}}`
self.data._usedAccounts[record.from] = from this.data._usedAccounts[record.from] = from
self.append(timestamp, record) this.append(timestamp, record)
}) })
} }
}) })
@ -128,9 +127,8 @@ class Recorder {
* *
*/ */
append (timestamp, record) { append (timestamp, record) {
var self = this this.data.journal.push({ timestamp, record })
self.data.journal.push({ timestamp, record }) this.event.trigger('newTxRecorded', [this.data.journal.length])
self.event.trigger('newTxRecorded', [self.data.journal.length])
} }
/** /**
@ -138,17 +136,16 @@ class Recorder {
* *
*/ */
getAll () { getAll () {
var self = this var records = [].concat(this.data.journal)
var records = [].concat(self.data.journal)
return { return {
accounts: self.data._usedAccounts, accounts: this.data._usedAccounts,
linkReferences: self.data._linkReferences, linkReferences: this.data._linkReferences,
transactions: records.sort((A, B) => { transactions: records.sort((A, B) => {
var stampA = A.timestamp var stampA = A.timestamp
var stampB = B.timestamp var stampB = B.timestamp
return stampA - stampB return stampA - stampB
}), }),
abis: self.data._abis abis: this.data._abis
} }
} }
@ -157,17 +154,16 @@ class Recorder {
* *
*/ */
clearAll () { clearAll () {
var self = this this.data._listen = true
self.data._listen = true this.data._replay = false
self.data._replay = false this.data.journal = []
self.data.journal = [] this.data._createdContracts = {}
self.data._createdContracts = {} this.data._createdContractsReverse = {}
self.data._createdContractsReverse = {} this.data._usedAccounts = {}
self.data._usedAccounts = {} this.data._abis = {}
self.data._abis = {} this.data._contractABIReferences = {}
self.data._contractABIReferences = {} this.data._linkReferences = {}
self.data._linkReferences = {} this.event.trigger('cleared', [])
self.event.trigger('cleared', [])
} }
/** /**
@ -180,11 +176,10 @@ class Recorder {
* *
*/ */
run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, newContractFn) { run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, newContractFn) {
var self = this this.setListen(false)
self.setListen(false)
logCallBack(`Running ${records.length} transaction(s) ...`) logCallBack(`Running ${records.length} transaction(s) ...`)
async.eachOfSeries(records, function (tx, index, cb) { async.eachOfSeries(records, function (tx, index, cb) {
var record = self.resolveAddress(tx.record, accounts, options) var record = this.resolveAddress(tx.record, accounts, options)
var abi = abis[tx.record.abi] var abi = abis[tx.record.abi]
if (!abi) { if (!abi) {
return alertCb('cannot find ABI for ' + tx.record.abi + '. Execution stopped at ' + index) 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) { if (record.linkReferences && Object.keys(record.linkReferences).length) {
for (var k in linkReferences) { for (var k in linkReferences) {
var link = linkReferences[k] var link = linkReferences[k]
var timestamp = self.extractTimestamp(link) var timestamp = this.extractTimestamp(link)
if (timestamp && self.data._createdContractsReverse[timestamp]) { if (timestamp && this.data._createdContractsReverse[timestamp]) {
link = self.data._createdContractsReverse[timestamp] link = this.data._createdContractsReverse[timestamp]
} }
tx.record.bytecode = format.linkLibraryStandardFromlinkReferences(k, link.replace('0x', ''), tx.record.bytecode, tx.record.linkReferences) tx.record.bytecode = format.linkLibraryStandardFromlinkReferences(k, link.replace('0x', ''), tx.record.bytecode, tx.record.linkReferences)
} }
@ -224,8 +219,8 @@ class Recorder {
isString = false isString = false
value = JSON.stringify(value) value = JSON.stringify(value)
} }
for (var timestamp in self.data._createdContractsReverse) { for (var timestamp in this.data._createdContractsReverse) {
value = value.replace(new RegExp('created\\{' + timestamp + '\\}', 'g'), self.data._createdContractsReverse[timestamp]) value = value.replace(new RegExp('created\\{' + timestamp + '\\}', 'g'), this.data._createdContractsReverse[timestamp])
} }
if (!isString) value = JSON.parse(value) if (!isString) value = JSON.parse(value)
tx.record.parameters[index] = value tx.record.parameters[index] = value
@ -243,7 +238,7 @@ class Recorder {
logCallBack(`(${index}) data: ${data.data}`) 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 } 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, this.blockchain.runTx(record, confirmationCb, continueCb, promptCb,
function (err, txResult, rawAddress) { function (err, txResult, rawAddress) {
if (err) { if (err) {
console.error(err) console.error(err)
@ -252,14 +247,14 @@ class Recorder {
if (rawAddress) { if (rawAddress) {
const address = helper.addressToString(rawAddress) const address = helper.addressToString(rawAddress)
// save back created addresses for the convertion from tokens to real adresses // save back created addresses for the convertion from tokens to real adresses
self.data._createdContracts[address] = tx.timestamp this.data._createdContracts[address] = tx.timestamp
self.data._createdContractsReverse[tx.timestamp] = address this.data._createdContractsReverse[tx.timestamp] = address
newContractFn(abi, address, record.contractName) newContractFn(abi, address, record.contractName)
} }
cb(err) cb(err)
} }
) )
}, () => { self.setListen(true) }) }, () => { this.setListen(true) })
} }
runScenario (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) { runScenario (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) {

@ -119,7 +119,7 @@ module.exports = class TestTab extends ViewPlugin {
usingWorker: canUseWorker(currentVersion), usingWorker: canUseWorker(currentVersion),
runs 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) if (error) return reject(error)
resolve(result) resolve(result)
}, (url, cb) => { }, (url, cb) => {

@ -303,7 +303,7 @@ export class Blockchain extends Plugin {
}, },
(data, runTxCallback) => { (data, runTxCallback) => {
// called for libraries deployment // 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) { runTx (args, confirmationCb, continueCb, promptCb, cb) {
const self = this
waterfall([ waterfall([
function getGasLimit (next) { (next) => { // getGasLimit
if (self.transactionContextAPI.getGasLimit) { if (this.transactionContextAPI.getGasLimit) {
return self.transactionContextAPI.getGasLimit(next) return this.transactionContextAPI.getGasLimit(next)
} }
next(null, 3000000) next(null, 3000000)
}, },
function queryValue (gasLimit, next) { (gasLimit, next) => { // queryValue
if (args.value) { if (args.value) {
return next(null, args.value, gasLimit) return next(null, args.value, gasLimit)
} }
if (args.useCall || !self.transactionContextAPI.getValue) { if (args.useCall || !this.transactionContextAPI.getValue) {
return next(null, 0, gasLimit) return next(null, 0, gasLimit)
} }
self.transactionContextAPI.getValue(function (err, value) { this.transactionContextAPI.getValue(function (err, value) {
next(err, value, gasLimit) next(err, value, gasLimit)
}) })
}, },
function getAccount (value, gasLimit, next) { (value, gasLimit, next) => { // getAccount
if (args.from) { if (args.from) {
return next(null, args.from, value, gasLimit) return next(null, args.from, value, gasLimit)
} }
if (self.transactionContextAPI.getAddress) { if (this.transactionContextAPI.getAddress) {
return self.transactionContextAPI.getAddress(function (err, address) { return this.transactionContextAPI.getAddress(function (err, address) {
next(err, address, value, gasLimit) next(err, address, value, gasLimit)
}) })
} }
self.getAccounts(function (err, accounts) { this.getAccounts(function (err, accounts) {
const address = accounts[0] const address = accounts[0]
if (err) return next(err) if (err) return next(err)
if (!address) return next('No accounts available') if (!address) return next('No accounts available')
// if (self.executionContext.isVM() && !self.providers.vm.accounts[address]) { if (this.executionContext.isVM() && !this.providers.vm.RemixSimulatorProvider.Accounts.accounts[address]) {
if (self.executionContext.isVM() && !self.providers.vm.RemixSimulatorProvider.Accounts.accounts[address]) {
return next('Invalid account selected') return next('Invalid account selected')
} }
next(null, address, value, gasLimit) 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 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 } 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() if (!tx.timestamp) tx.timestamp = Date.now()
const timestamp = tx.timestamp const timestamp = tx.timestamp
self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad]) this.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
self.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb, this.txRunner.rawRun(tx, confirmationCb, continueCb, promptCb,
async (error, result) => { async (error, result) => {
if (error) return next(error) if (error) return next(error)
const isVM = self.executionContext.isVM() const isVM = this.executionContext.isVM()
if (isVM && tx.useCall) { if (isVM && tx.useCall) {
try { try {
result.transactionHash = await self.web3().eth.getHashFromTagBySimulator(timestamp) result.transactionHash = await this.web3().eth.getHashFromTagBySimulator(timestamp)
} catch (e) { } catch (e) {
console.log('unable to retrieve back the "call" hash', e) console.log('unable to retrieve back the "call" hash', e)
} }
} }
const eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted') 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 && (typeof (error) !== 'string')) {
if (error.message) error = error.message if (error.message) error = error.message
else { else {
try { error = 'error: ' + JSON.stringify(error) } catch (e) {} try { error = 'error: ' + JSON.stringify(error) } catch (e) { console.log(e) }
} }
} }
next(error, result, tx) next(error, result, tx)

@ -129,9 +129,9 @@ export class ExecutionContext {
async executionContextChange (value, endPointUrl, confirmCb, infoCb, cb) { async executionContextChange (value, endPointUrl, confirmCb, infoCb, cb) {
const context = value.context const context = value.context
if (!cb) cb = () => {} if (!cb) cb = () => { /* Do nothing. */ }
if (!confirmCb) confirmCb = () => {} if (!confirmCb) confirmCb = () => { /* Do nothing. */ }
if (!infoCb) infoCb = () => {} if (!infoCb) infoCb = () => { /* Do nothing. */ }
if (context === 'vm') { if (context === 'vm') {
this.executionContext = context this.executionContext = context
this.currentFork = value.fork this.currentFork = value.fork

@ -17,6 +17,7 @@ class InjectedProvider {
} }
resetEnvironment () { resetEnvironment () {
/* Do nothing. */
} }
getBalanceInEther (address, cb) { getBalanceInEther (address, cb) {

@ -25,6 +25,7 @@ class NodeProvider {
} }
resetEnvironment () { resetEnvironment () {
/* Do nothing. */
} }
getBalanceInEther (address, cb) { getBalanceInEther (address, cb) {

@ -15,6 +15,7 @@ function Config (storage) {
this.items = JSON.parse(config) this.items = JSON.parse(config)
} }
} catch (exception) { } catch (exception) {
/* Do nothing. */
} }
this.exists = function (key) { this.exists = function (key) {
@ -31,6 +32,7 @@ function Config (storage) {
storage.set(CONFIG_FILE, JSON.stringify(this.items)) storage.set(CONFIG_FILE, JSON.stringify(this.items))
this.events.emit(key + '_changed', content) this.events.emit(key + '_changed', content)
} catch (exception) { } catch (exception) {
/* Do nothing. */
} }
} }

@ -1,4 +1,3 @@
/* global localStorage, fetch */
import { PluginManager } from '@remixproject/engine' import { PluginManager } from '@remixproject/engine'
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
import QueryParams from './lib/query-params' import QueryParams from './lib/query-params'
@ -174,7 +173,7 @@ class PluginLoader {
} }
this.loaders.queryParams = { this.loaders.queryParams = {
set: () => {}, set: () => { /* Do nothing. */ },
get: () => { get: () => {
const { activate } = queryParams.get() const { activate } = queryParams.get()
if (!activate) return [] if (!activate) return []

@ -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 { TransactionDebugger as Debugger } from '@remix-project/remix-debug' // eslint-disable-line
import { DebuggerUIProps } from './idebugger-api' // eslint-disable-line import { DebuggerUIProps } from './idebugger-api' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { isValidHash } from '@remix-ui/helper'
/* eslint-disable-next-line */ /* eslint-disable-next-line */
import './debugger-ui.css' import './debugger-ui.css'
const helper = require('../../../../../apps/remix-ide/src/lib/helper')
const _paq = (window as any)._paq = (window as any)._paq || [] const _paq = (window as any)._paq = (window as any)._paq || []
export const DebuggerUI = (props: DebuggerUIProps) => { export const DebuggerUI = (props: DebuggerUIProps) => {
@ -171,7 +171,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber: txNumber txNumber: txNumber
} }
}) })
if (!helper.isValidHash(txNumber)) { if (!isValidHash(txNumber)) {
setState(prevState => { setState(prevState => {
return { return {
...prevState, ...prevState,

@ -94,3 +94,8 @@ export const is0XPrefixed = (value) => {
export const isHexadecimal = (value) => { export const isHexadecimal = (value) => {
return /^[0-9a-fA-F]+$/.test(value) && (value.length % 2 === 0) 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)
}

@ -2,7 +2,7 @@ import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint
import semver from 'semver' import semver from 'semver'
import { CompilerContainerProps } from './types' import { CompilerContainerProps } from './types'
import { ConfigurationSettings } from '@remix-project/remix-lib-ts' import { ConfigurationSettings } from '@remix-project/remix-lib-ts'
import * as helper from '../../../../../apps/remix-ide/src/lib/helper' import { checkSpecialChars, extractNameFromKey } from '@remix-ui/helper'
import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity' import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity'
import { compilerReducer, compilerInitialState } from './reducers/compiler' import { compilerReducer, compilerInitialState } from './reducers/compiler'
import { resetEditorMode, listenToEvents } from './actions/compiler' import { resetEditorMode, listenToEvents } from './actions/compiler'
@ -350,7 +350,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
url = customUrl url = customUrl
api.setCompilerParameters({ version: selectedVersion }) api.setCompilerParameters({ version: selectedVersion })
} else { } else {
if (helper.checkSpecialChars(selectedVersion)) { if (checkSpecialChars(selectedVersion)) {
return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.') return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.')
} }
if (selectedVersion === 'builtin' || selectedVersion.indexOf('soljson') === 0) { if (selectedVersion === 'builtin' || selectedVersion.indexOf('soljson') === 0) {
@ -606,7 +606,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<button id="compileBtn" data-id="compilerContainerCompileBtn" className="btn btn-primary btn-block remixui_disabled mt-3" title="Compile" onClick={compile} disabled={disableCompileButton}> <button id="compileBtn" data-id="compilerContainerCompileBtn" className="btn btn-primary btn-block remixui_disabled mt-3" title="Compile" onClick={compile} disabled={disableCompileButton}>
<span> <span>
{ <i ref={compileIcon} className="fas fa-sync remixui_iconbtn" aria-hidden="true"></i> } { <i ref={compileIcon} className="fas fa-sync remixui_iconbtn" aria-hidden="true"></i> }
Compile { typeof state.compiledFileName === 'string' ? helper.extractNameFromKey(state.compiledFileName) || '<no file selected>' : '<no file selected>' } Compile { typeof state.compiledFileName === 'string' ? extractNameFromKey(state.compiledFileName) || '<no file selected>' : '<no file selected>' }
</span> </span>
</button> </button>
</header> </header>

Loading…
Cancel
Save