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,
"ignorePatterns": ["**/*"],
"ignorePatterns": [],
"plugins": ["@nrwl/nx"],
"overrides": [
{

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

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

@ -87,7 +87,7 @@ class FileProvider {
}
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
var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath)
@ -98,7 +98,7 @@ class FileProvider {
}
set (path, content, cb) {
cb = cb || function () {}
cb = cb || function () { /* do nothing. */ }
var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath)
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
*/
_copyFolderToJsonInternal (path, visitFile, visitFolder) {
visitFile = visitFile || (() => {})
visitFolder = visitFolder || (() => {})
visitFile = visitFile || function () { /* do nothing. */ }
visitFolder = visitFolder || function () { /* do nothing. */ }
return new Promise((resolve, reject) => {
const json = {}
path = this.removePrefix(path)
@ -245,8 +245,8 @@ class FileProvider {
* @param {Function} visitFolder is a function called for each visited folders
*/
copyFolderToJson (path, visitFile, visitFolder) {
visitFile = visitFile || (() => {})
visitFolder = visitFolder || (() => {})
visitFile = visitFile || function () { /* do nothing. */ }
visitFolder = visitFolder || function () { /* do nothing. */ }
return this._copyFolderToJsonInternal(path, visitFile, visitFolder)
}

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

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

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

@ -1,5 +1,5 @@
import { DebuggerUI } from '@remix-ui/debugger-ui' // eslint-disable-line
import { DebuggerApiMixin } from '@remixproject/debugger-plugin'
import { DebuggerApiMixin } from '@remixproject/debugger-plugin' // eslint-disable-line
import { ViewPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json'
import React from 'react' // eslint-disable-line

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

@ -119,7 +119,7 @@ module.exports = class TestTab extends ViewPlugin {
usingWorker: canUseWorker(currentVersion),
runs
}
this.testRunner.runTestSources(runningTest, compilerConfig, () => {}, () => {}, null, (error, result) => {
this.testRunner.runTestSources(runningTest, compilerConfig, () => { /* Do nothing. */ }, () => { /* Do nothing. */ }, null, (error, result) => {
if (error) return reject(error)
resolve(result)
}, (url, cb) => {

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

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

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

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

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

@ -1,4 +1,3 @@
/* global localStorage, fetch */
import { PluginManager } from '@remixproject/engine'
import { EventEmitter } from 'events'
import QueryParams from './lib/query-params'
@ -174,7 +173,7 @@ class PluginLoader {
}
this.loaders.queryParams = {
set: () => {},
set: () => { /* Do nothing. */ },
get: () => {
const { activate } = queryParams.get()
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 { DebuggerUIProps } from './idebugger-api' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { isValidHash } from '@remix-ui/helper'
/* eslint-disable-next-line */
import './debugger-ui.css'
const helper = require('../../../../../apps/remix-ide/src/lib/helper')
const _paq = (window as any)._paq = (window as any)._paq || []
export const DebuggerUI = (props: DebuggerUIProps) => {
@ -171,7 +171,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber: txNumber
}
})
if (!helper.isValidHash(txNumber)) {
if (!isValidHash(txNumber)) {
setState(prevState => {
return {
...prevState,

@ -94,3 +94,8 @@ export const is0XPrefixed = (value) => {
export const isHexadecimal = (value) => {
return /^[0-9a-fA-F]+$/.test(value) && (value.length % 2 === 0)
}
export const isValidHash = (hash) => { // 0x prefixed, hexadecimal, 64digit
const hexValue = hash.slice(2, hash.length)
return is0XPrefixed(hash) && /^[0-9a-fA-F]{64}$/.test(hexValue)
}

@ -2,7 +2,7 @@ import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint
import semver from 'semver'
import { CompilerContainerProps } from './types'
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 { compilerReducer, compilerInitialState } from './reducers/compiler'
import { resetEditorMode, listenToEvents } from './actions/compiler'
@ -350,7 +350,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
url = customUrl
api.setCompilerParameters({ version: selectedVersion })
} else {
if (helper.checkSpecialChars(selectedVersion)) {
if (checkSpecialChars(selectedVersion)) {
return console.log('loading ' + selectedVersion + ' not allowed, special chars not allowed.')
}
if (selectedVersion === 'builtin' || selectedVersion.indexOf('soljson') === 0) {
@ -606,7 +606,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<button id="compileBtn" data-id="compilerContainerCompileBtn" className="btn btn-primary btn-block remixui_disabled mt-3" title="Compile" onClick={compile} disabled={disableCompileButton}>
<span>
{ <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>
</button>
</header>

Loading…
Cancel
Save