From 70de15b1e80a913718b4059f32463f6051efa1a5 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 25 May 2022 14:36:24 +0530 Subject: [PATCH 001/106] install slither using remixd --- libs/remixd/src/bin/remixd.ts | 7 +++++++ libs/remixd/src/services/slitherClient.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index d0f52556e3..c93ca872ca 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -63,6 +63,7 @@ function errorHandler (error: any, service: string) { .description('Establish a two-way websocket connection between the local computer and Remix IDE for a folder') .option('-u, --remix-ide ', 'URL of remix instance allowed to connect') .option('-s, --shared-folder ', 'Folder to share with Remix IDE (Default: CWD)') + .option('-i, --install ', 'Module name to install locally') .option('-r, --read-only', 'Treat shared folder as read-only (experimental)') .on('--help', function () { console.log('\nExample:\n\n remixd -s ./shared_project -u http://localhost:8080') @@ -71,6 +72,12 @@ function errorHandler (error: any, service: string) { await warnLatestVersion() + if(program.install && !program.readOnly) { + const availableModulesToInstall = ['slither'] + const service = program.install + if(availableModulesToInstall.includes(program.install)) services[service](false)['install']() + } + if (!program.remixIde) { console.log('\x1b[33m%s\x1b[0m', '[WARN] You can only connect to remixd from one of the supported origins.') } else { diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index c689aba86a..e9b13170e1 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -14,7 +14,7 @@ export class SlitherClient extends PluginClient { constructor (private readOnly = false) { super() - this.methods = ['analyse'] + this.methods = ['analyse', 'install'] } setWebSocket (websocket: WS): void { @@ -25,6 +25,10 @@ export class SlitherClient extends PluginClient { this.currentSharedFolder = currentSharedFolder } + install (): void { + console.log('inside slither install method') + } + mapNpmDepsDir (list) { const remixNpmDepsPath = utils.absolutePath('.deps/npm', this.currentSharedFolder) const localNpmDepsPath = utils.absolutePath('node_modules', this.currentSharedFolder) From e7d4c0c0a055c1a27579d329b7ee2eabcffcba37 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 31 May 2022 14:26:09 +0530 Subject: [PATCH 002/106] install with deps --- libs/remixd/src/bin/remixd.ts | 1 + libs/remixd/src/services/slitherClient.ts | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index c93ca872ca..2dfd60ef38 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -76,6 +76,7 @@ function errorHandler (error: any, service: string) { const availableModulesToInstall = ['slither'] const service = program.install if(availableModulesToInstall.includes(program.install)) services[service](false)['install']() + process.exit(0) } if (!program.remixIde) { diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index e9b13170e1..3194d41fbc 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -26,7 +26,25 @@ export class SlitherClient extends PluginClient { } install (): void { - console.log('inside slither install method') + try { + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither requires Python 3.6+ and solc, the Solidity compiler.`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select is required to manage installing and setting different solc compiler versions.`) + const options = { cwd: this.currentSharedFolder, shell: true } + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`) + const pip3OP = execSync('pip3 --version', options) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: pip3 found: ${pip3OP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking solc availability...`) + const solcOP = execSync('solc --version', options) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc found: ${solcOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing slither...`) + const slitherOP = execSync('pip3 install slither-analyzer', options) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither installation output: ${slitherOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc-select...`) + const solcSelectOP = execSync('pip3 install solc-select', options) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`) + } catch (err) { + console.log(err) + } } mapNpmDepsDir (list) { From 0640069409db9ad2521f56f60483cd0c994afa1f Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 8 Jun 2022 17:53:26 +0530 Subject: [PATCH 003/106] improve logging --- libs/remixd/src/bin/remixd.ts | 5 +++-- libs/remixd/src/services/slitherClient.ts | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index 2dfd60ef38..fa4a47f85d 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -72,10 +72,11 @@ function errorHandler (error: any, service: string) { await warnLatestVersion() - if(program.install && !program.readOnly) { + if (program.install && !program.readOnly) { const availableModulesToInstall = ['slither'] const service = program.install - if(availableModulesToInstall.includes(program.install)) services[service](false)['install']() + if (availableModulesToInstall.includes(program.install)) services[service](false)['install']() + else console.log('\x1b[32m%s\x1b[0m', `[INFO] ${service} can not be installed using remixd`) process.exit(0) } diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index 3194d41fbc..d26d7d4aa4 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -27,8 +27,8 @@ export class SlitherClient extends PluginClient { install (): void { try { - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither requires Python 3.6+ and solc, the Solidity compiler.`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select is required to manage installing and setting different solc compiler versions.`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither requires Python3.6+ (pip3) and solc, the Solidity compiler. They should be installed on your system`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to manage setting different solc compiler versions.`) const options = { cwd: this.currentSharedFolder, shell: true } console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`) const pip3OP = execSync('pip3 --version', options) @@ -43,7 +43,7 @@ export class SlitherClient extends PluginClient { const solcSelectOP = execSync('pip3 install solc-select', options) console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`) } catch (err) { - console.log(err) + console.log('\x1b[31m%s\x1b[0m', `[Slither Installation]: Error occured: ${err}`) } } From 03b58b8d8dcd9880039fde9165d4f1e5ac515253 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 29 Jun 2022 14:46:59 +0530 Subject: [PATCH 004/106] bin folder deleted --- apps/remix-ide/bin/remix-ide | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 apps/remix-ide/bin/remix-ide diff --git a/apps/remix-ide/bin/remix-ide b/apps/remix-ide/bin/remix-ide deleted file mode 100755 index 887bab51fa..0000000000 --- a/apps/remix-ide/bin/remix-ide +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node -var path = require('path') -var httpServer = require('http-server') -var remixd = require('remixd') - -var server = httpServer.createServer({ - root: path.join(__dirname, '/../') -}) - -var folder = process.argv.length > 2 ? process.argv[2] : process.cwd() - -server.listen(8080, '127.0.0.1', function () {}) -var router = new remixd.Router(65520, remixd.services.sharedFolder, { remixIdeUrl: 'http://localhost:8080' }, (webSocket) => { - remixd.services.sharedFolder.setWebSocket(webSocket) - remixd.services.sharedFolder.setupNotifications(folder) - remixd.services.sharedFolder.sharedFolder(folder, false) -}) - -router.start() - -console.log('\x1b[33m%s\x1b[0m', 'Starting Remix IDE at http://localhost:8080 and sharing ' + folder) From ce73137f86ed28af3bbc9e1ee450f3ff53a86b2d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 27 Jun 2022 13:46:10 +0200 Subject: [PATCH 005/106] add matomo for the recorder --- apps/remix-ide/src/app/tabs/runTab/model/recorder.js | 2 ++ 1 file changed, 2 insertions(+) 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 6178063843..9961f1dbb6 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -258,7 +258,9 @@ class Recorder { } runScenario (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) { + _paq.push(['trackEvent', 'run', 'recorder', 'start']) if (!json) { + _paq.push(['trackEvent', 'run', 'recorder', 'wrong-json']) return cb('a json content must be provided') } if (typeof json === 'string') { From 286f15ecde869ed306c79721c4d2818f49b61259 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 27 Jun 2022 13:47:27 +0200 Subject: [PATCH 006/106] add a "live" mode to the recorder --- .../src/app/tabs/runTab/model/recorder.js | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) 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 9961f1dbb6..ac9c56ab46 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -1,16 +1,28 @@ var async = require('async') var ethutil = require('ethereumjs-util') var remixLib = require('@remix-project/remix-lib') +import { Plugin } from '@remixproject/engine' +import * as packageJson from '../../../../.././../../package.json' var EventManager = remixLib.EventManager var format = remixLib.execution.txFormat var txHelper = remixLib.execution.txHelper const helper = require('../../../../lib/helper') +const _paq = window._paq = window._paq || [] //eslint-disable-line + +const profile = { + name: 'recorder', + displayName: 'Recorder', + description: '', + version: packageJson.version, + methods: [ ] +} /** * Record transaction as long as the user create them. */ -class Recorder { +class Recorder extends Plugin { constructor (blockchain) { + super(profile) this.event = new EventManager() this.blockchain = blockchain this.data = { _listen: true, _replay: false, journal: [], _createdContracts: {}, _createdContractsReverse: {}, _usedAccounts: {}, _abis: {}, _contractABIReferences: {}, _linkReferences: {} } @@ -169,16 +181,29 @@ class Recorder { /** * run the list of records * + * @param {Object} records * @param {Object} accounts * @param {Object} options * @param {Object} abis + * @param {Object} linkReferences + * @param {Function} confirmationCb + * @param {Function} continueCb + * @param {Function} promptCb + * @param {Function} alertCb + * @param {Function} logCallBack + * @param {Function} live * @param {Function} newContractFn * */ - run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, newContractFn) { + run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, live, newContractFn) { this.setListen(false) logCallBack(`Running ${records.length} transaction(s) ...`) - async.eachOfSeries(records, (tx, index, cb) => { + async.eachOfSeries(records, async (tx, index, cb) => { + if (live && tx.record.type === 'constructor') { + // resolve the bytecode using the contract name, this ensure getting the last compiled one. + const data = await this.call('compilerArtefacts', 'getArtefactsByContractName', tx.record.contractName) + tx.record.bytecode = data.artefact.evm.bytecode.object + } var record = this.resolveAddress(tx.record, accounts, options) var abi = abis[tx.record.abi] if (!abi) { @@ -277,6 +302,7 @@ class Recorder { var options = json.options || {} var abis = json.abis || {} var linkReferences = json.linkReferences || {} + var live = json.live || false } catch (e) { return cb('Invalid Scenario File. Please try again') } @@ -285,7 +311,7 @@ class Recorder { return } - this.run(txArray, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, (abi, address, contractName) => { + this.run(txArray, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, live, (abi, address, contractName) => { cb(null, abi, address, contractName) }) } From 62daee915a89e6de45f70114ba3ff489589dccba Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 27 Jun 2022 13:47:48 +0200 Subject: [PATCH 007/106] activate recorder plugin --- apps/remix-ide/src/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 4eb9423d38..1b7c7b483a 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -321,7 +321,8 @@ class AppComponent { filePanel.slitherHandle, linkLibraries, deployLibraries, - openZeppelinProxy + openZeppelinProxy, + run.recorder ]) this.layout.panels = { @@ -355,7 +356,7 @@ class AppComponent { 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','storage', 'search','compileAndRun']) + await this.appManager.activatePlugin(['walkthrough','storage', 'search','compileAndRun', 'recorder']) this.appManager.on( 'filePanel', From f5c8c29e72d04c8d16b3c02dfdf027cb72c6d35e Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 27 Jun 2022 14:56:50 +0200 Subject: [PATCH 008/106] addd e2e test --- .../src/tests/ballot_0_4_11.test.ts | 2 +- apps/remix-ide-e2e/src/tests/recorder.test.ts | 132 ++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts index 28b03219fc..4dce13d891 100644 --- a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts @@ -78,7 +78,7 @@ module.exports = { browser .openFile('Untitled.sol') .clickLaunchIcon('udapp') - .click('*[data-id="settingsWeb3Mode"]') + .click('*[data-id="settingsWeb3Mode"]') .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="envNotification-modal-footer-ok-react"]') as any diff --git a/apps/remix-ide-e2e/src/tests/recorder.test.ts b/apps/remix-ide-e2e/src/tests/recorder.test.ts index 1b41d856da..b59848404f 100644 --- a/apps/remix-ide-e2e/src/tests/recorder.test.ts +++ b/apps/remix-ide-e2e/src/tests/recorder.test.ts @@ -95,6 +95,49 @@ module.exports = { status: 'true Transaction mined and execution succeed', 'decoded input': { 'uint256 _po': '10' } }) + + }, + + 'Run with live "mode"': function (browser: NightwatchBrowser) { + let addressRef: string + browser.addFile('scenario_live_mode.json', { content: JSON.stringify(liveModeScenario, null, '\t') }) + .addFile('scenario_live_mode_storage.sol', { content: testStorageForLiveMode }) + .clickLaunchIcon('solidity') + .click('*[data-id="compilerContainerCompileBtn"]') + .openFile('scenario_live_mode.json') + .clickLaunchIcon('udapp') + .click('*[data-id="deployAndRunClearInstances"]') + .click('i.runtransaction') + .pause(1000) + .clickInstance(0) + .getAddressAtPosition(0, (address) => { + addressRef = address + }) + .clickFunction('retrieve - call') + .perform((done) => { + browser.verifyCallReturnValue(addressRef, ['', '0:uint256: 350']) + .perform(() => done()) + }) + // change the init state and recompile the same contract. + .openFile('scenario_live_mode_storage.sol') + .setEditorValue(testStorageForLiveMode.replace('number = 350', 'number = 300')) + .pause(5000) + .clickLaunchIcon('solidity') + .click('*[data-id="compilerContainerCompileBtn"]') + .openFile('scenario_live_mode.json') + .clickLaunchIcon('udapp') + .click('*[data-id="deployAndRunClearInstances"]') + .click('i.runtransaction') + .pause(5000) + .clickInstance(0) + .getAddressAtPosition(0, (address) => { + addressRef = address + }) + .clickFunction('retrieve - call') + .perform((done) => { + browser.verifyCallReturnValue(addressRef, ['', '0:uint256: 300']) + .perform(() => done()) + }) .end() } } @@ -364,3 +407,92 @@ const scenario = { ] } } + +const liveModeScenario = { + "accounts": { + "account{0}": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4" + }, + "linkReferences": {}, + "live": true, + "transactions": [ + { + "timestamp": 1656329164297, + "record": { + "value": "0", + "parameters": [], + "abi": "0x8b8c9c14c8e1442e90dd6ff82bb9889ccfe5a54d88ef30776f11047ecce5fedb", + "contractName": "Storage", + "bytecode": "608060405234801561001057600080fd5b5060c88061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610604e577c010000000000000000000000000000000000000000000000000000000060003504632e64cec1811460535780636057361d146068575b600080fd5b60005460405190815260200160405180910390f35b60786073366004607a565b600055565b005b600060208284031215608b57600080fd5b503591905056fea264697066735822122091f1bc250ccda7caf2b0d9f67b0314d92233fdb5952b72cece72bd2a5d43cfc264736f6c63430008070033", + "linkReferences": {}, + "name": "", + "inputs": "()", + "type": "constructor", + "from": "account{0}" + } + } + ], + "abis": { + "0x8b8c9c14c8e1442e90dd6ff82bb9889ccfe5a54d88ef30776f11047ecce5fedb": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "num", + "type": "uint256" + } + ], + "name": "store", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "retrieve", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + } +} + +const testStorageForLiveMode = `// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +/** + * @title Storage + * @dev Store & retrieve value in a variable + * @custom:dev-run-script ./scripts/deploy_with_ethers.ts + */ +contract Storage { + + uint256 number; + + constructor () { + number = 350; + } + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + number = num; + } + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256){ + return number; + } +}` From 8072d25db125fde54b7a743da2ecf94c1b9ac072 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 29 Jun 2022 12:00:12 +0200 Subject: [PATCH 009/106] use const --- apps/remix-ide/src/app/tabs/runTab/model/recorder.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 ac9c56ab46..8ccc8ccd67 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -297,12 +297,12 @@ class Recorder extends Plugin { } try { - var txArray = json.transactions || [] - var accounts = json.accounts || [] - var options = json.options || {} - var abis = json.abis || {} - var linkReferences = json.linkReferences || {} - var live = json.live || false + const txArray = json.transactions || [] + const accounts = json.accounts || [] + const options = json.options || {} + const abis = json.abis || {} + const linkReferences = json.linkReferences || {} + const live = json.live || false } catch (e) { return cb('Invalid Scenario File. Please try again') } From 9dad1d52b68e69f58053395b7adc862ad487766f Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 29 Jun 2022 12:00:22 +0200 Subject: [PATCH 010/106] linting --- apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts index 4dce13d891..28b03219fc 100644 --- a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts @@ -78,7 +78,7 @@ module.exports = { browser .openFile('Untitled.sol') .clickLaunchIcon('udapp') - .click('*[data-id="settingsWeb3Mode"]') + .click('*[data-id="settingsWeb3Mode"]') .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="envNotification-modal-footer-ok-react"]') as any From 1706e854ac04de004a784263e9f2abf84d19952e Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 29 Jun 2022 13:23:02 +0200 Subject: [PATCH 011/106] live mode is define from the UI & general improvement --- apps/remix-ide-e2e/src/tests/recorder.test.ts | 1 + .../src/app/tabs/runTab/model/recorder.js | 29 ++++++----- apps/remix-ide/src/blockchain/blockchain.js | 2 +- .../remix-ui/run-tab/src/lib/actions/index.ts | 4 +- .../run-tab/src/lib/actions/recorder.ts | 7 +-- .../src/lib/components/recorderCardUI.tsx | 50 ++++++++++++++----- libs/remix-ui/run-tab/src/lib/types/index.ts | 2 +- .../run-tab/src/lib/types/recorder.d.ts | 2 +- 8 files changed, 64 insertions(+), 33 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/recorder.test.ts b/apps/remix-ide-e2e/src/tests/recorder.test.ts index b59848404f..ca3028bcbb 100644 --- a/apps/remix-ide-e2e/src/tests/recorder.test.ts +++ b/apps/remix-ide-e2e/src/tests/recorder.test.ts @@ -107,6 +107,7 @@ module.exports = { .openFile('scenario_live_mode.json') .clickLaunchIcon('udapp') .click('*[data-id="deployAndRunClearInstances"]') + .click('*[data-id="runtabLivemodeInput"]') .click('i.runtransaction') .pause(1000) .clickInstance(0) 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 8ccc8ccd67..550cf5fa26 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -191,15 +191,16 @@ class Recorder extends Plugin { * @param {Function} promptCb * @param {Function} alertCb * @param {Function} logCallBack - * @param {Function} live + * @param {Function} liveMode * @param {Function} newContractFn * */ - run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, live, newContractFn) { + run (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, liveMode, newContractFn) { this.setListen(false) - logCallBack(`Running ${records.length} transaction(s) ...`) + const liveMsg = liveMode ? ' in live mode' : '' + logCallBack(`Running ${records.length} transaction(s)${liveMsg} ...`) async.eachOfSeries(records, async (tx, index, cb) => { - if (live && tx.record.type === 'constructor') { + if (liveMode && tx.record.type === 'constructor') { // resolve the bytecode using the contract name, this ensure getting the last compiled one. const data = await this.call('compilerArtefacts', 'getArtefactsByContractName', tx.record.contractName) tx.record.bytecode = data.artefact.evm.bytecode.object @@ -282,7 +283,7 @@ class Recorder extends Plugin { }, () => { this.setListen(true) }) } - runScenario (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) { + runScenario (liveMode, json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) { _paq.push(['trackEvent', 'run', 'recorder', 'start']) if (!json) { _paq.push(['trackEvent', 'run', 'recorder', 'wrong-json']) @@ -296,13 +297,17 @@ class Recorder extends Plugin { } } + let txArray + let accounts + let options + let abis + let linkReferences try { - const txArray = json.transactions || [] - const accounts = json.accounts || [] - const options = json.options || {} - const abis = json.abis || {} - const linkReferences = json.linkReferences || {} - const live = json.live || false + txArray = json.transactions || [] + accounts = json.accounts || [] + options = json.options || {} + abis = json.abis || {} + linkReferences = json.linkReferences || {} } catch (e) { return cb('Invalid Scenario File. Please try again') } @@ -311,7 +316,7 @@ class Recorder extends Plugin { return } - this.run(txArray, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, live, (abi, address, contractName) => { + this.run(txArray, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, liveMode, (abi, address, contractName) => { cb(null, abi, address, contractName) }) } diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index 5f6d3ad6c6..60b27186cd 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -74,7 +74,7 @@ export class Blockchain extends Plugin { this.networkStatus = { network, error } this.event.trigger('networkStatus', [this.networkStatus]) }) - }, 1000) + }, 100000) } getCurrentNetworkStatus () { diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts index 60cfe8513f..9943cfc727 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/index.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts @@ -26,7 +26,7 @@ export const initRunTab = (udapp: RunTab) => async (reducerDispatch: React.Dispa setupEvents(plugin, dispatch) setInterval(() => { fillAccountsList(plugin, dispatch) - }, 1000) + }, 10000000) } export const setAccountAddress = (account: string) => setAccount(dispatch, account) @@ -54,7 +54,7 @@ export const getExecutionContext = () => getContext(plugin) export const executeTransactions = (instanceIndex: number, lookupOnly: boolean, funcABI: FuncABI, inputsValues: string, contractName: string, contractABI, contract, address, logMsg:string, mainnetPrompt: MainnetPrompt, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, funcIndex?: number) => runTransactions(plugin, dispatch, instanceIndex, lookupOnly, funcABI, inputsValues, contractName, contractABI, contract, address, logMsg, mainnetPrompt, gasEstimationPrompt, passphrasePrompt, funcIndex) export const loadFromAddress = (contract: ContractData, address: string) => loadAddress(plugin, dispatch, contract, address) export const storeNewScenario = async (prompt: (msg: string, defaultValue: string) => JSX.Element) => storeScenario(plugin, dispatch, prompt) -export const runScenario = (gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => runCurrentScenario(plugin, dispatch, gasEstimationPrompt, passphrasePrompt, confirmDialogContent) +export const runScenario = (liveMode: boolean, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => runCurrentScenario(liveMode, plugin, dispatch, gasEstimationPrompt, passphrasePrompt, confirmDialogContent) export const setScenarioPath = (path: string) => updateScenarioPath(dispatch, path) export const getFuncABIValues = (funcABI: FuncABI) => getFuncABIInputs(plugin, funcABI) export const setNetworkName = (networkName: string) => setNetworkNameFromProvider(dispatch, networkName) diff --git a/libs/remix-ui/run-tab/src/lib/actions/recorder.ts b/libs/remix-ui/run-tab/src/lib/actions/recorder.ts index 7f30ee1759..2bf910650b 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/recorder.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/recorder.ts @@ -36,12 +36,13 @@ export const storeScenario = async (plugin: RunTab, dispatch: React.Dispatch, file: string, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => { +const runScenario = (liveMode: boolean, plugin: RunTab, dispatch: React.Dispatch, file: string, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => { if (!file) return dispatch(displayNotification('Alert', 'Unable to run scenerio, no specified scenario file', 'OK', null)) plugin.fileManager.readFile(file).then((json) => { // TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily plugin.recorder.runScenario( + liveMode, json, (error, continueTxExecution, cancelCb) => { continueHandler(dispatch, gasEstimationPrompt, error, continueTxExecution, cancelCb) @@ -64,9 +65,9 @@ const runScenario = (plugin: RunTab, dispatch: React.Dispatch, file: string }).catch((error) => dispatch(displayNotification('Alert', error, 'OK', null))) } -export const runCurrentScenario = (plugin: RunTab, dispatch: React.Dispatch, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => { +export const runCurrentScenario = (liveMode: boolean, plugin: RunTab, dispatch: React.Dispatch, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => { const file = plugin.config.get('currentFile') if (!file) return dispatch(displayNotification('Alert', 'A scenario file has to be selected', 'Ok', null)) - runScenario(plugin, dispatch, file, gasEstimationPrompt, passphrasePrompt, confirmDialogContent) + runScenario(liveMode, plugin, dispatch, file, gasEstimationPrompt, passphrasePrompt, confirmDialogContent) } \ No newline at end of file diff --git a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx index 36e355e4b7..044626601e 100644 --- a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx @@ -1,15 +1,18 @@ // eslint-disable-next-line no-use-before-define -import React, {useState} from 'react' +import React, {useRef, useState} from 'react' import { RecorderProps } from '../types' +import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line export function RecorderUI (props: RecorderProps) { + const inputLive = useRef() const [toggleExpander, setToggleExpander] = useState(false) const triggerRecordButton = () => { props.storeScenario(props.scenarioPrompt) } const handleClickRunButton = () => { - props.runCurrentScenario(props.gasEstimationPrompt, props.passphrasePrompt, props.mainnetPrompt) + const liveMode = inputLive.current ? inputLive.current.checked : false + props.runCurrentScenario(liveMode, props.gasEstimationPrompt, props.passphrasePrompt, props.mainnetPrompt) } const toggleClass = () => { @@ -22,6 +25,15 @@ export function RecorderUI (props: RecorderProps) {
{props.count}
+ + Save transactions (deployed contracts and function executions) and replay then in an + another environment.
e.g Transactions created in Javascript VM can be replayed in the Injected Web3. +
+ + }> + +
@@ -29,17 +41,29 @@ export function RecorderUI (props: RecorderProps) {
-
-
- All transactions (deployed contracts and function executions) can be saved and replayed in - another environment. e.g Transactions created in Javascript VM can be replayed in the Injected Web3. -
-
- - -
+
+
+ + +
+
+ + Save {props.count} transaction(s) to JSON. + + + }> + + + + Run Transaction from the current scenario file. + + + }> + + +
) diff --git a/libs/remix-ui/run-tab/src/lib/types/index.ts b/libs/remix-ui/run-tab/src/lib/types/index.ts index 3e162ea9d6..c304d8815f 100644 --- a/libs/remix-ui/run-tab/src/lib/types/index.ts +++ b/libs/remix-ui/run-tab/src/lib/types/index.ts @@ -166,7 +166,7 @@ export interface ContractDropdownProps { export interface RecorderProps { storeScenario: (prompt: (msg: string, defaultValue: string) => JSX.Element) => void, - runCurrentScenario: (gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => void, + runCurrentScenario: (liveMode: boolean, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, confirmDialogContent: MainnetPrompt) => void, mainnetPrompt: MainnetPrompt, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, diff --git a/libs/remix-ui/run-tab/src/lib/types/recorder.d.ts b/libs/remix-ui/run-tab/src/lib/types/recorder.d.ts index 44f79bda4f..3c4ec18c20 100644 --- a/libs/remix-ui/run-tab/src/lib/types/recorder.d.ts +++ b/libs/remix-ui/run-tab/src/lib/types/recorder.d.ts @@ -9,7 +9,7 @@ export class Recorder { getAll: () => void; clearAll: () => void; run: (records, accounts, options, abis, linkReferences, confirmationCb, continueCb, promptCb, alertCb, logCallBack, newContractFn) => void - runScenario: (json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) => void + runScenario: (liveMode, json, continueCb, promptCb, alertCb, confirmationCb, logCallBack, cb) => void } import { Blockchain } from "./blockchain"; From 888c15d8349eafd5fa127a6379d7c7c4da403f86 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 29 Jun 2022 14:41:27 +0200 Subject: [PATCH 012/106] rollback setInterval --- apps/remix-ide/src/blockchain/blockchain.js | 2 +- libs/remix-ui/run-tab/src/lib/actions/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index 60b27186cd..5f6d3ad6c6 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -74,7 +74,7 @@ export class Blockchain extends Plugin { this.networkStatus = { network, error } this.event.trigger('networkStatus', [this.networkStatus]) }) - }, 100000) + }, 1000) } getCurrentNetworkStatus () { diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts index 9943cfc727..5dc0eb2de7 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/index.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts @@ -26,7 +26,7 @@ export const initRunTab = (udapp: RunTab) => async (reducerDispatch: React.Dispa setupEvents(plugin, dispatch) setInterval(() => { fillAccountsList(plugin, dispatch) - }, 10000000) + }, 1000) } export const setAccountAddress = (account: string) => setAccount(dispatch, account) From 74a39d871d22835725c432afa6541301802e9417 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 29 Jun 2022 15:01:42 +0200 Subject: [PATCH 013/106] fix tests --- apps/remix-ide-e2e/src/tests/recorder.test.ts | 8 ++++---- .../run-tab/src/lib/components/recorderCardUI.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/recorder.test.ts b/apps/remix-ide-e2e/src/tests/recorder.test.ts index ca3028bcbb..8e33df2842 100644 --- a/apps/remix-ide-e2e/src/tests/recorder.test.ts +++ b/apps/remix-ide-e2e/src/tests/recorder.test.ts @@ -42,7 +42,7 @@ module.exports = { .createContract(['12']) .clickInstance(0) .clickFunction('set - transact (not payable)', { types: 'uint256 _p', values: '34' }) - .click('i.savetransaction') + .click('.savetransaction') .waitForElementVisible('[data-id="udappNotify-modal-footer-ok-react"]') .execute(function () { const modalOk = document.querySelector('[data-id="udappNotify-modal-footer-ok-react"]') as any @@ -77,7 +77,7 @@ module.exports = { .selectContract('t2est') .pause(1000) .createContract([]) - .click('i.savetransaction') + .click('.savetransaction') .waitForElementVisible('[data-id="udappNotify-modal-footer-ok-react"]') .execute(function () { const modalOk = document.querySelector('[data-id="udappNotify-modal-footer-ok-react"]') as any @@ -108,7 +108,7 @@ module.exports = { .clickLaunchIcon('udapp') .click('*[data-id="deployAndRunClearInstances"]') .click('*[data-id="runtabLivemodeInput"]') - .click('i.runtransaction') + .click('.runtransaction') .pause(1000) .clickInstance(0) .getAddressAtPosition(0, (address) => { @@ -128,7 +128,7 @@ module.exports = { .openFile('scenario_live_mode.json') .clickLaunchIcon('udapp') .click('*[data-id="deployAndRunClearInstances"]') - .click('i.runtransaction') + .click('.runtransaction') .pause(5000) .clickInstance(0) .getAddressAtPosition(0, (address) => { diff --git a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx index 044626601e..eac98c0812 100644 --- a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx @@ -43,8 +43,8 @@ export function RecorderUI (props: RecorderProps) {
- - + +
Date: Wed, 29 Jun 2022 15:42:20 +0200 Subject: [PATCH 014/106] fix labels --- apps/remix-ide-e2e/src/tests/recorder.test.ts | 1 - .../run-tab/src/lib/components/recorderCardUI.tsx | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/recorder.test.ts b/apps/remix-ide-e2e/src/tests/recorder.test.ts index 8e33df2842..7e8748b737 100644 --- a/apps/remix-ide-e2e/src/tests/recorder.test.ts +++ b/apps/remix-ide-e2e/src/tests/recorder.test.ts @@ -414,7 +414,6 @@ const liveModeScenario = { "account{0}": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4" }, "linkReferences": {}, - "live": true, "transactions": [ { "timestamp": 1656329164297, diff --git a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx index eac98c0812..e7fb5c9795 100644 --- a/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx @@ -27,8 +27,7 @@ export function RecorderUI (props: RecorderProps) {
{props.count}
- Save transactions (deployed contracts and function executions) and replay then in an - another environment.
e.g Transactions created in Javascript VM can be replayed in the Injected Web3. + Save transactions (deployed contracts and function executions) and replay them in another environment.
e.g Transactions created in Javascript VM can be replayed in the Injected Web3.
}> @@ -44,12 +43,12 @@ export function RecorderUI (props: RecorderProps) {
- +
- Save {props.count} transaction(s) to JSON. + Save {props.count} transaction(s) as scenario file. }> @@ -57,7 +56,7 @@ export function RecorderUI (props: RecorderProps) { - Run Transaction from the current scenario file. + Run transaction(s) from the current scenario file. }> From 3c8b209c428d14f067e520f2389c85ebdbead976 Mon Sep 17 00:00:00 2001 From: ryestew Date: Thu, 16 Jun 2022 08:43:46 -0400 Subject: [PATCH 015/106] update titles --- libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx | 2 +- libs/remix-ui/run-tab/src/lib/components/account.tsx | 4 ++-- .../run-tab/src/lib/components/contractDropdownUI.tsx | 8 ++++---- libs/remix-ui/run-tab/src/lib/components/environment.tsx | 2 +- libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx | 2 +- libs/remix-ui/run-tab/src/lib/components/value.tsx | 4 ++-- libs/remix-ui/run-tab/src/lib/reducers/runTab.ts | 7 +++---- .../solidity-compiler/src/lib/compiler-container.tsx | 6 +++--- .../src/lib/solidity-unit-testing.tsx | 2 +- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx index 25dd08705b..45ea635d8b 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -331,7 +331,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { return { ...prevState, opt: { ...prevState.opt, debugWithGeneratedSources: checked } } }) }} type="checkbox" title="Debug with generated sources" /> - +
{ state.isLocalNodeUsed &&
{ diff --git a/libs/remix-ui/run-tab/src/lib/components/account.tsx b/libs/remix-ui/run-tab/src/lib/components/account.tsx index f8a74a1a34..1cb7aebc4c 100644 --- a/libs/remix-ui/run-tab/src/lib/components/account.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/account.tsx @@ -160,8 +160,8 @@ export function AccountUI (props: AccountProps) { accounts.map((value, index) => ) } -
- +
+
) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index df1831deaa..4abe432242 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -119,12 +119,12 @@ export function ContractDropdownUI (props: ContractDropdownProps) { if (enable) { setAtAddressOptions({ disabled: false, - title: 'Interact with the given contract.' + title: 'Interact with the given contract - needs the .abi file or compiled .sol file (with the same compiler settings)' }) } else { setAtAddressOptions({ disabled: true, - title: loadedAddress ? '⚠ Compile *.sol file or select *.abi file.' : '⚠ Compile *.sol file or select *.abi file & then enter the address of deployed contract.' + title: loadedAddress ? '⚠ Compile a *.sol file or select a *.abi file.' : '⚠ For use with a deployed contract and its .abi file or compiled .sol file (with the same compiler settings)' }) } } @@ -133,12 +133,12 @@ export function ContractDropdownUI (props: ContractDropdownProps) { if (enable) { setContractOptions({ disabled: false, - title: 'Select contract for Deploy or At Address.' + title: 'Select compiled a contract to deploy or to use with At Address.' }) } else { setContractOptions({ disabled: true, - title: loadType === 'sol' ? '⚠ Select and compile *.sol file to deploy or access a contract.' : '⚠ Selected *.abi file allows accessing contracts, select and compile *.sol file to deploy and access one.' + title: loadType === 'sol' ? '⚠ Select and compile *.sol file to deploy or access a contract.' : '⚠ When there is a compiled .sol file, the choice of contracts to deploy or to use with AtAddress is made here' }) } } diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index 4853f6f12b..9c22ce3751 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -29,7 +29,7 @@ export function EnvironmentUI (props: EnvironmentProps) { ) } - +
) diff --git a/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx b/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx index 19e7876a75..fb9c08c213 100644 --- a/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx @@ -10,7 +10,7 @@ export function GasPriceUI (props: GasPriceProps) { return (
- +
) } diff --git a/libs/remix-ui/run-tab/src/lib/components/value.tsx b/libs/remix-ui/run-tab/src/lib/components/value.tsx index 3b2008a5f1..fd1892b58b 100644 --- a/libs/remix-ui/run-tab/src/lib/components/value.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/value.tsx @@ -47,7 +47,7 @@ export function ValueUI (props: ValueProps) { return (
- +
{
- handleLanguageChange(e.target.value)} disabled={state.useFileConfiguration} value={state.language} className="custom-select" id="compilierLanguageSelector" title="Language specification available from Compiler >= v0.5.7"> @@ -789,7 +789,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
{ (!showFilePathInput && state.useFileConfiguration) && {} : openFile} className="py-2 remixui_compilerConfigPath" >{configFilePath === '' ? 'No file selected.' : configFilePath} } @@ -861,7 +861,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }> - '@custom:dev-run-script file_path'} direction='top'> + '@custom:dev-run-script file_path'} direction='top'> diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 30f1b2e0df..8f55fe2ea7 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -677,7 +677,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d
{ state.isLocalNodeUsed &&
{ From 4ac9c9d9e9677746499287f94a9f651030a609ab Mon Sep 17 00:00:00 2001 From: ryestew Date: Tue, 28 Jun 2022 16:52:07 -0400 Subject: [PATCH 017/106] update tooltips --- .../run-tab/src/lib/components/contractDropdownUI.tsx | 8 ++++---- libs/remix-ui/run-tab/src/lib/components/environment.tsx | 2 +- libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx | 2 +- libs/remix-ui/run-tab/src/lib/reducers/runTab.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index 4abe432242..900b7dc2c4 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -119,12 +119,12 @@ export function ContractDropdownUI (props: ContractDropdownProps) { if (enable) { setAtAddressOptions({ disabled: false, - title: 'Interact with the given contract - needs the .abi file or compiled .sol file (with the same compiler settings)' + title: 'Interact with the deployed contract - requires the .abi file or compiled .sol file to be selected in the editor (with the same compiler configuration)' }) } else { setAtAddressOptions({ disabled: true, - title: loadedAddress ? '⚠ Compile a *.sol file or select a *.abi file.' : '⚠ For use with a deployed contract and its .abi file or compiled .sol file (with the same compiler settings)' + title: loadedAddress ? 'Compile a *.sol file or select a *.abi file.' : 'To interact with a deployed contract, enter its address and compile its source *.sol file (with the same compiler settings) or select its .abi file in the editor. ' }) } } @@ -133,12 +133,12 @@ export function ContractDropdownUI (props: ContractDropdownProps) { if (enable) { setContractOptions({ disabled: false, - title: 'Select compiled a contract to deploy or to use with At Address.' + title: 'Select a compiled contract to deploy or to use with At Address.' }) } else { setContractOptions({ disabled: true, - title: loadType === 'sol' ? '⚠ Select and compile *.sol file to deploy or access a contract.' : '⚠ When there is a compiled .sol file, the choice of contracts to deploy or to use with AtAddress is made here' + title: loadType === 'sol' ? 'Select and compile *.sol file to deploy or access a contract.' : 'When there is a compiled .sol file, the choice of contracts to deploy or to use with AtAddress is made here.' }) } } diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index 9c22ce3751..c63f1ba88f 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -29,7 +29,7 @@ export function EnvironmentUI (props: EnvironmentProps) { ) } - +
) diff --git a/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx b/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx index fb9c08c213..a7c5335abd 100644 --- a/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/gasPrice.tsx @@ -10,7 +10,7 @@ export function GasPriceUI (props: GasPriceProps) { return (
- +
) } diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts index 11eff149ca..20ecb8b1ef 100644 --- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts +++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts @@ -115,14 +115,14 @@ export const runTabInitialState: RunTabState = { providerList: [{ id: 'vm-mode-london', dataId: 'settingsVMLondonMode', - title: 'Execution environment does not connect to any node. All data is stored in browser memory only.', + title: 'Execution environment is local to Remix. Data is only saved to browser memory and will vanish upon reload.', value: 'vm-london', fork: 'london', content: 'JavaScript VM (London)' }, { id: 'vm-mode-berlin', dataId: 'settingsVMBerlinMode', - title: 'Execution environment does not connect to any node. All data is stored in browser memory only.', + title: 'Execution environment is local to Remix. Data is only saved to browser memory and will vanish upon reload.', value: 'vm-berlin', fork: 'berlin', content: 'JavaScript VM (Berlin)' From 823e6c1a19dd87785ed0c236160cf12af8ed229b Mon Sep 17 00:00:00 2001 From: ryestew Date: Wed, 29 Jun 2022 10:05:33 -0400 Subject: [PATCH 018/106] Amount section now back to Value --- libs/remix-ui/run-tab/src/lib/components/value.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/value.tsx b/libs/remix-ui/run-tab/src/lib/components/value.tsx index fd1892b58b..6728639a45 100644 --- a/libs/remix-ui/run-tab/src/lib/components/value.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/value.tsx @@ -47,7 +47,7 @@ export function ValueUI (props: ValueProps) { return (
- +
Date: Fri, 24 Jun 2022 13:25:06 +0000 Subject: [PATCH 019/106] Bump eventsource from 1.1.0 to 1.1.2 Bumps [eventsource](https://github.com/EventSource/eventsource) from 1.1.0 to 1.1.2. - [Release notes](https://github.com/EventSource/eventsource/releases) - [Changelog](https://github.com/EventSource/eventsource/blob/master/HISTORY.md) - [Commits](https://github.com/EventSource/eventsource/compare/v1.1.0...v1.1.2) --- updated-dependencies: - dependency-name: eventsource dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6139c5e6c5..756ad82428 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6510,6 +6510,11 @@ boom@2.x.x: dependencies: hoek "2.x.x" +bootstrap@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.1.3.tgz#ba081b0c130f810fa70900acbc1c6d3c28fa8f34" + integrity sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q== + borc@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/borc/-/borc-2.1.2.tgz#6ce75e7da5ce711b963755117dd1b187f6f8cf19" @@ -9550,7 +9555,7 @@ ent@~2.2.0: resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= -entities@^2.0.0: +entities@^2.0.0, entities@^2.0.3: version "2.2.0" resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== @@ -10201,11 +10206,9 @@ events@^2.0.0: integrity sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg== eventsource@^1.0.7: - version "1.1.0" - resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-1.1.0.tgz#00e8ca7c92109e94b0ddf32dac677d841028cfaf" - integrity sha512-VSJjT5oCNrFvCS6igjzPAt5hBzQ2qPBFIbJ03zLI9SE0mxwZpMw6BfJrbFHm1a141AavMEB8JHmBhWAd66PfCg== - dependencies: - original "^1.0.0" + version "1.1.2" + resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-1.1.2.tgz#bc75ae1c60209e7cb1541231980460343eaea7c2" + integrity sha512-xAH3zWhgO2/3KIniEKYPr8plNSzlGINOUqYj0m0u7AB81iRw8b/3E73W6AuU+6klLbaSFmZnaETQ2lXPfAydrA== evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: version "1.0.3" @@ -17571,13 +17574,6 @@ ordered-read-streams@^1.0.0: dependencies: readable-stream "^2.0.1" -original@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/original/-/original-1.0.2.tgz#e442a61cffe1c5fd20a65f3261c26663b303f25f" - integrity sha512-hyBVl6iqqUOJ8FqRe+l/gS8H+kKYjrEndd5Pm1MfBtsEKA038HkkdbAl/72EAXGyonD/PFsvmVG+EvcIpliMBg== - dependencies: - url-parse "^1.4.3" - os-browserify@^0.3.0, os-browserify@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" @@ -20202,6 +20198,14 @@ rollup@1.31.1: "@types/node" "*" acorn "^7.1.0" +rss-parser@^3.12.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/rss-parser/-/rss-parser-3.12.0.tgz#b8888699ea46304a74363fbd8144671b2997984c" + integrity sha512-aqD3E8iavcCdkhVxNDIdg1nkBI17jgqF+9OqPS1orwNaOgySdpvq6B+DoONLhzjzwV8mWg37sb60e4bmLK117A== + dependencies: + entities "^2.0.3" + xml2js "^0.4.19" + rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -20332,7 +20336,7 @@ sax@0.5.x: resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1" integrity sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE= -sax@~1.2.4: +sax@>=0.6.0, sax@~1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -22901,7 +22905,7 @@ url-parse-lax@^3.0.0: dependencies: prepend-http "^2.0.0" -url-parse@^1.4.3, url-parse@^1.5.3: +url-parse@^1.5.3: version "1.5.10" resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1" integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ== @@ -24086,6 +24090,19 @@ xml-name-validator@^3.0.0: resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw== +xml2js@^0.4.19: + version "0.4.23" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.23.tgz#a0c69516752421eb2ac758ee4d4ccf58843eac66" + integrity sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug== + dependencies: + sax ">=0.6.0" + xmlbuilder "~11.0.0" + +xmlbuilder@~11.0.0: + version "11.0.1" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" + integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== + xmlchars@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" From d041d60fc4b4d77a64faf7f91f93344dd16e70c3 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 30 Jun 2022 13:22:11 +0530 Subject: [PATCH 020/106] remove unused files --- .prettierignore | 4 --- .prettierrc | 3 --- tslint.json | 65 ------------------------------------------------- 3 files changed, 72 deletions(-) delete mode 100644 .prettierignore delete mode 100644 .prettierrc delete mode 100644 tslint.json diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index d0b804da2a..0000000000 --- a/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -# Add files here to ignore them from prettier formatting - -/dist -/coverage diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 544138be45..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "singleQuote": true -} diff --git a/tslint.json b/tslint.json deleted file mode 100644 index d948508f0e..0000000000 --- a/tslint.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "rulesDirectory": ["node_modules/@nrwl/workspace/src/tslint"], - "linterOptions": { - "exclude": ["**/*"] - }, - "rules": { - "arrow-return-shorthand": true, - "callable-types": true, - "class-name": true, - "deprecation": { - "severity": "warn" - }, - "forin": true, - "import-blacklist": [true, "rxjs/Rx"], - "interface-over-type-literal": true, - "member-access": false, - "member-ordering": [ - true, - { - "order": [ - "static-field", - "instance-field", - "static-method", - "instance-method" - ] - } - ], - "no-arg": true, - "no-bitwise": true, - "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], - "no-construct": true, - "no-debugger": true, - "no-duplicate-super": true, - "no-empty": false, - "no-empty-interface": true, - "no-eval": true, - "no-inferrable-types": [true, "ignore-params"], - "no-misused-new": true, - "no-non-null-assertion": true, - "no-shadowed-variable": true, - "no-string-literal": false, - "no-string-throw": true, - "no-switch-case-fall-through": true, - "no-unnecessary-initializer": true, - "no-unused-expression": true, - "no-var-keyword": true, - "object-literal-sort-keys": false, - "prefer-const": true, - "radix": true, - "triple-equals": [true, "allow-null-check"], - "unified-signatures": true, - "variable-name": false, - - "nx-enforce-module-boundaries": [ - true, - { - "enforceBuildableLibDependency": true, - "allow": [], - "depConstraints": [ - { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] } - ] - } - ] - } -} From 05f1e45579477475eb7648615e4d3afe98f1d365 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 30 Jun 2022 13:38:27 +0530 Subject: [PATCH 021/106] remove deps --- package.json | 2 -- yarn.lock | 17 ----------------- 2 files changed, 19 deletions(-) diff --git a/package.json b/package.json index 2b29dab67e..f3c729203f 100644 --- a/package.json +++ b/package.json @@ -275,7 +275,6 @@ "csslint": "^1.0.2", "dotenv": "^8.2.0", "eslint": "6.8.0", - "eslint-config-prettier": "^6.11.0", "eslint-config-standard": "^14.1.1", "eslint-plugin-import": "2.20.2", "eslint-plugin-jsx-a11y": "6.4.1", @@ -313,7 +312,6 @@ "npm-run-all": "^4.0.2", "nyc": "^13.3.0", "onchange": "^3.2.1", - "prettier": "1.19.1", "request": "^2.83.0", "rimraf": "^2.6.1", "selenium-standalone": "^8.0.4", diff --git a/yarn.lock b/yarn.lock index 756ad82428..afbf76199d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9748,13 +9748,6 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" -eslint-config-prettier@^6.11.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz#7f93f6cb7d45a92f1537a70ecc06366e1ac6fed9" - integrity sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw== - dependencies: - get-stdin "^6.0.0" - eslint-config-standard@^14.1.1: version "14.1.1" resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-14.1.1.tgz#830a8e44e7aef7de67464979ad06b406026c56ea" @@ -11296,11 +11289,6 @@ get-stdin@^5.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" integrity sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g= -get-stdin@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" - integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== - get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -18715,11 +18703,6 @@ preserve@^0.2.0: resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks= -prettier@1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" - integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== - pretty-format@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" From 72b95a4e40f8356a0b03f009f3befcadf23a40c8 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 30 Jun 2022 14:05:28 +0530 Subject: [PATCH 022/106] fix linting --- package.json | 1 + yarn.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index f3c729203f..cced59ff97 100644 --- a/package.json +++ b/package.json @@ -172,6 +172,7 @@ "core-js": "^3.6.5", "deep-equal": "^1.0.1", "document-register-element": "1.13.1", + "eslint-config-prettier": "^8.5.0", "ethereumjs-util": "^7.0.10", "ethers": "^5.4.2", "ethjs-util": "^0.1.6", diff --git a/yarn.lock b/yarn.lock index afbf76199d..0e6a65aa76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9748,6 +9748,11 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1" + integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q== + eslint-config-standard@^14.1.1: version "14.1.1" resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-14.1.1.tgz#830a8e44e7aef7de67464979ad06b406026c56ea" From 1b233b3eea9963279ace49b5cc9bffec8ac50540 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 30 Jun 2022 15:04:13 +0530 Subject: [PATCH 023/106] update commands --- libs/remixd/src/services/slitherClient.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index d26d7d4aa4..ced33423bf 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -27,21 +27,26 @@ export class SlitherClient extends PluginClient { install (): void { try { - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither requires Python3.6+ (pip3) and solc, the Solidity compiler. They should be installed on your system`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to manage setting different solc compiler versions.`) + const solcVersion = '0.8.15' + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: requires Python3.6+ (pip3) to be installed on your system`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to set different solc compiler versions.`) const options = { cwd: this.currentSharedFolder, shell: true } console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`) const pip3OP = execSync('pip3 --version', options) console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: pip3 found: ${pip3OP.toString()}`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking solc availability...`) - const solcOP = execSync('solc --version', options) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc found: ${solcOP.toString()}`) console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing slither...`) const slitherOP = execSync('pip3 install slither-analyzer', options) console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither installation output: ${slitherOP.toString()}`) console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc-select...`) const solcSelectOP = execSync('pip3 install solc-select', options) console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc ${solcVersion}...`) + const solcInstallOP = execSync(`solc-select install ${solcVersion}`, options) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc installation output: ${solcInstallOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: setting solc version to ${solcVersion}...`) + const solcUseOP = execSync(`solc-select use ${solcVersion}`, options) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc setting installation output: ${solcUseOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: Slither is ready to use!`) } catch (err) { console.log('\x1b[31m%s\x1b[0m', `[Slither Installation]: Error occured: ${err}`) } From 2226b220c52e2910b5d02f0fb7f318b902ebae8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 08:28:19 +0000 Subject: [PATCH 024/106] Bump ejs from 3.1.6 to 3.1.8 Bumps [ejs](https://github.com/mde/ejs) from 3.1.6 to 3.1.8. - [Release notes](https://github.com/mde/ejs/releases) - [Changelog](https://github.com/mde/ejs/blob/main/CHANGELOG.md) - [Commits](https://github.com/mde/ejs/compare/v3.1.6...v3.1.8) --- updated-dependencies: - dependency-name: ejs dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 65 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0e6a65aa76..9ff99bef5b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5463,11 +5463,6 @@ async-settle@^1.0.0: dependencies: async-done "^1.2.2" -async@0.9.x: - version "0.9.2" - resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" - integrity sha512-l6ToIJIotphWahxxHyzK9bnLR6kM4jJIIgLShZeqLY7iboHoGkdgFl7W2/Ivi4SkMJYGKqW8vSuk0uKUj6qsSw== - async@^2.4.0, async@^2.5.0, async@^2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" @@ -5480,6 +5475,11 @@ async@^3.1.0: resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== +async@^3.2.3: + version "3.2.4" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" + integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -6571,6 +6571,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + brace@^0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/brace/-/brace-0.8.0.tgz#e826c6d5054cae5f607ad7b1c81236dd2cf01978" @@ -7350,7 +7357,7 @@ chalk@^3.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@^4.0.0, chalk@^4.1.0: +chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -7945,7 +7952,7 @@ compression@^1.7.4: concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== concat-stream@^1.5.0, concat-stream@^1.5.2: version "1.6.0" @@ -9426,11 +9433,11 @@ ee-first@1.1.1: integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= ejs@^3.1.5, ejs@^3.1.6: - version "3.1.6" - resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.6.tgz#5bfd0a0689743bb5268b3550cceeebbc1702822a" - integrity sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw== + version "3.1.8" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.8.tgz#758d32910c78047585c7ef1f92f9ee041c1c190b" + integrity sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ== dependencies: - jake "^10.6.1" + jake "^10.8.5" electron-to-chromium@^1.3.47, electron-to-chromium@^1.3.857: version "1.3.866" @@ -10657,11 +10664,11 @@ file-uri-to-path@2: integrity sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg== filelist@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.2.tgz#80202f21462d4d1c2e214119b1807c1bc0380e5b" - integrity sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ== + version "1.0.4" + resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.4.tgz#f78978a1e944775ff9e62e744424f215e58352b5" + integrity sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q== dependencies: - minimatch "^3.0.4" + minimatch "^5.0.1" filename-regex@^2.0.0: version "2.0.1" @@ -13672,13 +13679,13 @@ it-to-stream@^0.1.1: p-fifo "^1.0.0" readable-stream "^3.6.0" -jake@^10.6.1: - version "10.8.2" - resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.2.tgz#ebc9de8558160a66d82d0eadc6a2e58fbc500a7b" - integrity sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A== +jake@^10.8.5: + version "10.8.5" + resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46" + integrity sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw== dependencies: - async "0.9.x" - chalk "^2.4.2" + async "^3.2.3" + chalk "^4.0.2" filelist "^1.0.1" minimatch "^3.0.4" @@ -15816,7 +15823,7 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@*, minimatch@3.0.4, minimatch@^3.0.4: +minimatch@*, minimatch@3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== @@ -15830,6 +15837,20 @@ minimatch@^3.0.0, minimatch@^3.0.2: dependencies: brace-expansion "^1.0.0" +minimatch@^3.0.4: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimatch@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7" + integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg== + dependencies: + brace-expansion "^2.0.1" + minimist-options@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619" From 1b014e1558b99223486453017b6292692f7473f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 09:37:20 +0000 Subject: [PATCH 025/106] Bump async from 2.6.3 to 2.6.4 Bumps [async](https://github.com/caolan/async) from 2.6.3 to 2.6.4. - [Release notes](https://github.com/caolan/async/releases) - [Changelog](https://github.com/caolan/async/blob/v2.6.4/CHANGELOG.md) - [Commits](https://github.com/caolan/async/compare/v2.6.3...v2.6.4) --- updated-dependencies: - dependency-name: async dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- yarn.lock | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9ff99bef5b..33b9527543 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5464,18 +5464,13 @@ async-settle@^1.0.0: async-done "^1.2.2" async@^2.4.0, async@^2.5.0, async@^2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + version "2.6.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" + integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== dependencies: lodash "^4.17.14" -async@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" - integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== - -async@^3.2.3: +async@^3.1.0, async@^3.2.3: version "3.2.4" resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== From 6d979660dcade3f90ce84974a274223fb5ec6eaf Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 24 Jun 2022 14:48:29 +0530 Subject: [PATCH 026/106] update fork list --- libs/remix-lib/src/execution/forkAt.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/remix-lib/src/execution/forkAt.ts b/libs/remix-lib/src/execution/forkAt.ts index c5f1a1e981..8e45ce9acf 100644 --- a/libs/remix-lib/src/execution/forkAt.ts +++ b/libs/remix-lib/src/execution/forkAt.ts @@ -50,6 +50,14 @@ const forks = { { number: 12965000, name: 'london' + }, + { + number: 13773000, + name: 'arrowGlacier' + }, + { + number: 15050000, + name: 'grayGlacier' } ], 3: [ From 519cd58c6a49ce2154a9041b8674fef6a214d96d Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 1 Jul 2022 12:59:27 +0530 Subject: [PATCH 027/106] install slither as postinstall script --- libs/remixd/package.json | 3 ++- libs/remixd/src/bin/remixd.ts | 9 ------- libs/remixd/src/scripts/installSlither.ts | 25 +++++++++++++++++++ libs/remixd/src/services/slitherClient.ts | 29 +---------------------- 4 files changed, 28 insertions(+), 38 deletions(-) create mode 100644 libs/remixd/src/scripts/installSlither.ts diff --git a/libs/remixd/package.json b/libs/remixd/package.json index 451cc8db16..cfa23896f4 100644 --- a/libs/remixd/package.json +++ b/libs/remixd/package.json @@ -13,7 +13,8 @@ "npip": "npip", "lint": "eslint ./src --ext .ts", "build": "tsc -p ./ && chmod +x ./src/bin/remixd.js", - "dev": "nodemon" + "dev": "nodemon", + "postinstall": "node src/scripts/installSlither.js" }, "publishConfig": { "access": "public" diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index fa4a47f85d..d0f52556e3 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -63,7 +63,6 @@ function errorHandler (error: any, service: string) { .description('Establish a two-way websocket connection between the local computer and Remix IDE for a folder') .option('-u, --remix-ide ', 'URL of remix instance allowed to connect') .option('-s, --shared-folder ', 'Folder to share with Remix IDE (Default: CWD)') - .option('-i, --install ', 'Module name to install locally') .option('-r, --read-only', 'Treat shared folder as read-only (experimental)') .on('--help', function () { console.log('\nExample:\n\n remixd -s ./shared_project -u http://localhost:8080') @@ -72,14 +71,6 @@ function errorHandler (error: any, service: string) { await warnLatestVersion() - if (program.install && !program.readOnly) { - const availableModulesToInstall = ['slither'] - const service = program.install - if (availableModulesToInstall.includes(program.install)) services[service](false)['install']() - else console.log('\x1b[32m%s\x1b[0m', `[INFO] ${service} can not be installed using remixd`) - process.exit(0) - } - if (!program.remixIde) { console.log('\x1b[33m%s\x1b[0m', '[WARN] You can only connect to remixd from one of the supported origins.') } else { diff --git a/libs/remixd/src/scripts/installSlither.ts b/libs/remixd/src/scripts/installSlither.ts new file mode 100644 index 0000000000..a255110b38 --- /dev/null +++ b/libs/remixd/src/scripts/installSlither.ts @@ -0,0 +1,25 @@ +const { execSync } = require('child_process') // eslint-disable-line + +try { + const solcVersion = '0.8.15' + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: requires Python3.6+ (pip3) to be installed on your system`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to set different solc compiler versions.`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`) + const pip3OP = execSync('pip3 --version') + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: pip3 found: ${pip3OP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing slither...`) + const slitherOP = execSync('pip3 install slither-analyzer') + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither installation output: ${slitherOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc-select...`) + const solcSelectOP = execSync('pip3 install solc-select') + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc ${solcVersion}...`) + const solcInstallOP = execSync(`solc-select install ${solcVersion}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc installation output: ${solcInstallOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: setting solc version to ${solcVersion}...`) + const solcUseOP = execSync(`solc-select use ${solcVersion}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc setting installation output: ${solcUseOP.toString()}`) + console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: Slither is ready to use!`) +} catch (err) { + console.log('\x1b[31m%s\x1b[0m', `[Slither Installation]: Error occured: ${err}`) +} diff --git a/libs/remixd/src/services/slitherClient.ts b/libs/remixd/src/services/slitherClient.ts index ced33423bf..c689aba86a 100644 --- a/libs/remixd/src/services/slitherClient.ts +++ b/libs/remixd/src/services/slitherClient.ts @@ -14,7 +14,7 @@ export class SlitherClient extends PluginClient { constructor (private readOnly = false) { super() - this.methods = ['analyse', 'install'] + this.methods = ['analyse'] } setWebSocket (websocket: WS): void { @@ -25,33 +25,6 @@ export class SlitherClient extends PluginClient { this.currentSharedFolder = currentSharedFolder } - install (): void { - try { - const solcVersion = '0.8.15' - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: requires Python3.6+ (pip3) to be installed on your system`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select will be installed along with Slither to set different solc compiler versions.`) - const options = { cwd: this.currentSharedFolder, shell: true } - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: checking pip3 availability ...`) - const pip3OP = execSync('pip3 --version', options) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: pip3 found: ${pip3OP.toString()}`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing slither...`) - const slitherOP = execSync('pip3 install slither-analyzer', options) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: slither installation output: ${slitherOP.toString()}`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc-select...`) - const solcSelectOP = execSync('pip3 install solc-select', options) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc-select installation output: ${solcSelectOP.toString()}`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: installing solc ${solcVersion}...`) - const solcInstallOP = execSync(`solc-select install ${solcVersion}`, options) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc installation output: ${solcInstallOP.toString()}`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: setting solc version to ${solcVersion}...`) - const solcUseOP = execSync(`solc-select use ${solcVersion}`, options) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: solc setting installation output: ${solcUseOP.toString()}`) - console.log('\x1b[32m%s\x1b[0m', `[Slither Installation]: Slither is ready to use!`) - } catch (err) { - console.log('\x1b[31m%s\x1b[0m', `[Slither Installation]: Error occured: ${err}`) - } - } - mapNpmDepsDir (list) { const remixNpmDepsPath = utils.absolutePath('.deps/npm', this.currentSharedFolder) const localNpmDepsPath = utils.absolutePath('node_modules', this.currentSharedFolder) From cb94a6b81ef401fff4407c2ad5c2c79adb1dd1f8 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 15 Jun 2022 14:56:30 +0530 Subject: [PATCH 028/106] detect etherscan route --- apps/remix-ide/src/app/tabs/theme-module.js | 3 ++- libs/remix-core-plugin/src/index.ts | 1 + libs/remix-ui/workspace/src/lib/actions/index.ts | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index 2fd9e92e1a..2711fb0429 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -37,7 +37,8 @@ export class ThemeModule extends Plugin { themes.map((theme) => { this.themes[theme.name.toLocaleLowerCase()] = { ...theme, - url: window.location.origin + window.location.pathname + theme.url + // url: window.location.origin + window.location.pathname + theme.url + url: window.location.origin + '/' + theme.url } }) this._paq = _paq diff --git a/libs/remix-core-plugin/src/index.ts b/libs/remix-core-plugin/src/index.ts index 420fe2e6d7..5018bca7e2 100644 --- a/libs/remix-core-plugin/src/index.ts +++ b/libs/remix-core-plugin/src/index.ts @@ -8,3 +8,4 @@ export { GistHandler } from './lib/gist-handler' export * from './types/contract' export { LinkLibraries, DeployLibraries } from './lib/link-libraries' export { OpenZeppelinProxy } from './lib/openzeppelin-proxy' +export { fetchContractFromEtherscan } from './lib/helpers/fetch-etherscan' diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 81566828ac..5b6cba7e62 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -6,6 +6,7 @@ import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryR import { listenOnPluginEvents, listenOnProviderEvents } from './events' import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin } from './workspace' import { QueryParams } from '@remix-project/remix-lib' +import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line import JSZip from 'jszip' export * from './events' @@ -31,7 +32,6 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const localhostProvider = filePanelPlugin.fileProviders.localhost const params = queryParams.get() as UrlParametersType const workspaces = await getWorkspaces() || [] - dispatch(setWorkspaces(workspaces)) if (params.gist) { await createWorkspaceTemplate('gist-sample', 'gist-template') @@ -44,7 +44,13 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. dispatch(setCurrentWorkspace('code-sample')) const filePath = await loadWorkspacePreset('code-template') plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) - } else { + } else if (window.location.pathname && window.location.pathname !== '/') { + const route = window.location.pathname + if (route.startsWith('/address/0x') && route.length === 51) { + console.log('this is an etherscan url') + } + } + else { if (workspaces.length === 0) { await createWorkspaceTemplate('default_workspace', 'remixDefault') plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false }) From 209b890db0f1abf2256ad1bd18948fccfdf472e1 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 15 Jun 2022 18:58:02 +0530 Subject: [PATCH 029/106] access content from etherscan mail --- libs/remix-ui/workspace/src/lib/actions/index.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 5b6cba7e62..5c220be345 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -47,10 +47,18 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. } else if (window.location.pathname && window.location.pathname !== '/') { const route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { - console.log('this is an etherscan url') + const contractAddress = route.split('/')[2] + const network = {id: 1, name: 'main'} + const target = `/${network.name}` + const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) + await createWorkspaceTemplate('etherscan-code-sample', 'code-template') + plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) + dispatch(setCurrentWorkspace('etherscan-code-sample')) + const filePath = Object.keys(data.compilationTargets)[0] + await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } - } - else { + } else { if (workspaces.length === 0) { await createWorkspaceTemplate('default_workspace', 'remixDefault') plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false }) From 1c68619d811a829d5ef3c68c2be0322cf2c9e21c Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 16 Jun 2022 11:28:57 +0530 Subject: [PATCH 030/106] handle error --- .../workspace/src/lib/actions/index.ts | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 5c220be345..4b19f75948 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -23,6 +23,21 @@ export type UrlParametersType = { url: string } +const basicWorkspaceInit = async (workspaces, workspaceProvider) => { + if (workspaces.length === 0) { + await createWorkspaceTemplate('default_workspace', 'remixDefault') + plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false }) + dispatch(setCurrentWorkspace('default_workspace')) + await loadWorkspacePreset('remixDefault') + } else { + if (workspaces.length > 0) { + workspaceProvider.setWorkspace(workspaces[workspaces.length - 1]) + plugin.setWorkspace({ name: workspaces[workspaces.length - 1], isLocalhost: false }) + dispatch(setCurrentWorkspace(workspaces[workspaces.length - 1])) + } + } +} + export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.Dispatch) => { if (filePanelPlugin) { plugin = filePanelPlugin @@ -50,27 +65,22 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const contractAddress = route.split('/')[2] const network = {id: 1, name: 'main'} const target = `/${network.name}` - const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) - await createWorkspaceTemplate('etherscan-code-sample', 'code-template') - plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) - dispatch(setCurrentWorkspace('etherscan-code-sample')) - const filePath = Object.keys(data.compilationTargets)[0] - await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) - plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) - } - } else { - if (workspaces.length === 0) { - await createWorkspaceTemplate('default_workspace', 'remixDefault') - plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false }) - dispatch(setCurrentWorkspace('default_workspace')) - await loadWorkspacePreset('remixDefault') - } else { - if (workspaces.length > 0) { - workspaceProvider.setWorkspace(workspaces[workspaces.length - 1]) - plugin.setWorkspace({ name: workspaces[workspaces.length - 1], isLocalhost: false }) - dispatch(setCurrentWorkspace(workspaces[workspaces.length - 1])) + try { + const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) + await createWorkspaceTemplate('etherscan-code-sample', 'code-template') + plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) + dispatch(setCurrentWorkspace('etherscan-code-sample')) + const filePath = Object.keys(data.compilationTargets)[0] + await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) + } catch (error) { + if(error.message.includes('unable to retrieve contract data') || error.message.includes('unable to try fetching the source code')) + plugin.call('notification', 'toast', error.message) + await basicWorkspaceInit(workspaces, workspaceProvider) } } + } else { + await basicWorkspaceInit(workspaces, workspaceProvider) } listenOnPluginEvents(plugin) From e5dedfcda5def2216f46670c10fc82d1203d10d4 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 16 Jun 2022 12:09:40 +0530 Subject: [PATCH 031/106] fetch from testnets --- .../src/lib/helpers/fetch-etherscan.ts | 2 +- .../workspace/src/lib/actions/index.ts | 34 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts b/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts index 32264c32fa..b8e4434c9b 100644 --- a/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts +++ b/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts @@ -10,7 +10,7 @@ export const fetchContractFromEtherscan = async (plugin, network, contractAddres // etherscan api doc https://docs.etherscan.io/api-endpoints/contracts if (data.message === 'OK' && data.status === "1") { if (data.result.length) { - if (data.result[0].SourceCode === '') throw new Error('contract not verified in Etherscan') + if (data.result[0].SourceCode === '') throw new Error(`contract not verified on Etherscan ${network.name} network`) if (data.result[0].SourceCode.startsWith('{')) { data.result[0].SourceCode = JSON.parse(data.result[0].SourceCode.replace(/(?:\r\n|\r|\n)/g, '').replace(/^{{/,'{').replace(/}}$/,'}')) } diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 4b19f75948..0188219d1e 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -63,20 +63,28 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] - const network = {id: 1, name: 'main'} - const target = `/${network.name}` - try { - const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) - await createWorkspaceTemplate('etherscan-code-sample', 'code-template') - plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) - dispatch(setCurrentWorkspace('etherscan-code-sample')) - const filePath = Object.keys(data.compilationTargets)[0] - await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) - plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) - } catch (error) { - if(error.message.includes('unable to retrieve contract data') || error.message.includes('unable to try fetching the source code')) + const networks = [ + {id: 1, name: 'mainnet'}, + {id: 3, name: 'ropsten'}, + {id: 4, name: 'rinkeby'}, + {id: 42, name: 'kovan'}, + {id: 5, name: 'goerli'} + ] + plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) + for (const network of networks) { + const target = `/${network.name}` + try { + const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) + await createWorkspaceTemplate('etherscan-code-sample', 'code-template') + plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) + dispatch(setCurrentWorkspace('etherscan-code-sample')) + const filePath = Object.keys(data.compilationTargets)[0] + await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) + } catch (error) { plugin.call('notification', 'toast', error.message) - await basicWorkspaceInit(workspaces, workspaceProvider) + await basicWorkspaceInit(workspaces, workspaceProvider) + } } } } else { From 8fbad4d33eb7ebd7d49ebf8018ce9e4719d57434 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 16 Jun 2022 12:32:19 +0530 Subject: [PATCH 032/106] check api key --- .../workspace/src/lib/actions/index.ts | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 0188219d1e..d72a6e5b99 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -63,17 +63,19 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] - const networks = [ - {id: 1, name: 'mainnet'}, - {id: 3, name: 'ropsten'}, - {id: 4, name: 'rinkeby'}, - {id: 42, name: 'kovan'}, - {id: 5, name: 'goerli'} - ] - plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) - for (const network of networks) { - const target = `/${network.name}` - try { + try { + const etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') + if (!etherscanKey) throw new Error('unable to try fetching the source code from etherscan: etherscan access token not found. please go to the Remix settings page and provide an access token.') + const networks = [ + {id: 1, name: 'mainnet'}, + {id: 3, name: 'ropsten'}, + {id: 4, name: 'rinkeby'}, + {id: 42, name: 'kovan'}, + {id: 5, name: 'goerli'} + ] + plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) + for (const network of networks) { + const target = `/${network.name}` const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) await createWorkspaceTemplate('etherscan-code-sample', 'code-template') plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) @@ -81,10 +83,10 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const filePath = Object.keys(data.compilationTargets)[0] await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) - } catch (error) { + } + } catch (error) { plugin.call('notification', 'toast', error.message) await basicWorkspaceInit(workspaces, workspaceProvider) - } } } } else { From 10fa66a35d6b57498b06e1e8001632b0c9f6c05c Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 16 Jun 2022 18:32:07 +0530 Subject: [PATCH 033/106] fix loop --- apps/remix-ide/src/app/tabs/theme-module.js | 3 +- .../workspace/src/lib/actions/index.ts | 56 ++++++++++++------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index 2711fb0429..842a39422f 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -37,8 +37,7 @@ export class ThemeModule extends Plugin { themes.map((theme) => { this.themes[theme.name.toLocaleLowerCase()] = { ...theme, - // url: window.location.origin + window.location.pathname + theme.url - url: window.location.origin + '/' + theme.url + url: window.location.origin + ( window.location.pathname.startsWith('/address/') ? '/' : window.location.pathname ) + theme.url } }) this._paq = _paq diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index d72a6e5b99..072fa34e74 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -8,6 +8,7 @@ import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin import { QueryParams } from '@remix-project/remix-lib' import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line import JSZip from 'jszip' +import { networkInterfaces } from 'os' export * from './events' export * from './workspace' @@ -63,30 +64,45 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] + let data try { const etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') - if (!etherscanKey) throw new Error('unable to try fetching the source code from etherscan: etherscan access token not found. please go to the Remix settings page and provide an access token.') - const networks = [ - {id: 1, name: 'mainnet'}, - {id: 3, name: 'ropsten'}, - {id: 4, name: 'rinkeby'}, - {id: 42, name: 'kovan'}, - {id: 5, name: 'goerli'} - ] - plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) - for (const network of networks) { - const target = `/${network.name}` - const data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) - await createWorkspaceTemplate('etherscan-code-sample', 'code-template') - plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) - dispatch(setCurrentWorkspace('etherscan-code-sample')) - const filePath = Object.keys(data.compilationTargets)[0] - await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) - plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) + if (!etherscanKey) { + plugin.call('notification', 'toast', `Cannot look for contract address ${contractAddress}. Etherscan access token not found. Go to Remix settings page and save an access token.`) + await basicWorkspaceInit(workspaces, workspaceProvider) + } else { + const networks = [ + {id: 1, name: 'mainnet'}, + {id: 3, name: 'ropsten'}, + {id: 4, name: 'rinkeby'}, + {id: 42, name: 'kovan'}, + {id: 5, name: 'goerli'} + ] + plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) + let found = false + for (const network of networks) { + const target = `/${network.name}` + try{ + data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) + } catch (error) { + if ((error.message.startsWith('contract not verified on Etherscan') || error.message.startsWith('unable to retrieve contract data')) && network.id !== 5) + continue + else { + if (!found) await basicWorkspaceInit(workspaces, workspaceProvider) + break + } + } + found = true + await createWorkspaceTemplate('etherscan-code-sample', 'code-template') + plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) + dispatch(setCurrentWorkspace('etherscan-code-sample')) + const filePath = Object.keys(data.compilationTargets)[0] + await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) + } } } catch (error) { - plugin.call('notification', 'toast', error.message) - await basicWorkspaceInit(workspaces, workspaceProvider) + await basicWorkspaceInit(workspaces, workspaceProvider) } } } else { From dc80c727c1967d5297c0dd953a0fc87b5deea63f Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 16 Jun 2022 18:42:37 +0530 Subject: [PATCH 034/106] linting fix --- libs/remix-ui/workspace/src/lib/actions/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 072fa34e74..f0e9cae3e4 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -8,7 +8,6 @@ import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin import { QueryParams } from '@remix-project/remix-lib' import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line import JSZip from 'jszip' -import { networkInterfaces } from 'os' export * from './events' export * from './workspace' From b31589da16b70e59fd94f54095d39c0238ab3a9c Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 20 Jun 2022 13:09:08 +0530 Subject: [PATCH 035/106] default API key --- .../src/lib/helpers/fetch-etherscan.ts | 7 ++- .../workspace/src/lib/actions/index.ts | 61 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts b/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts index b8e4434c9b..16f6b284b8 100644 --- a/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts +++ b/libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts @@ -1,8 +1,11 @@ -export const fetchContractFromEtherscan = async (plugin, network, contractAddress, targetPath) => { +export const fetchContractFromEtherscan = async (plugin, network, contractAddress, targetPath, key?) => { let data const compilationTargets = {} + let etherscanKey - const etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') + if (!key) etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') + else etherscanKey = key + if (etherscanKey) { const endpoint = network.id == 1 ? 'api.etherscan.io' : 'api-' + network.name + '.etherscan.io' data = await fetch('https://' + endpoint + '/api?module=contract&action=getsourcecode&address=' + contractAddress + '&apikey=' + etherscanKey) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index f0e9cae3e4..5d67f99182 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -63,42 +63,39 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] + plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) let data try { - const etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') - if (!etherscanKey) { - plugin.call('notification', 'toast', `Cannot look for contract address ${contractAddress}. Etherscan access token not found. Go to Remix settings page and save an access token.`) - await basicWorkspaceInit(workspaces, workspaceProvider) - } else { - const networks = [ - {id: 1, name: 'mainnet'}, - {id: 3, name: 'ropsten'}, - {id: 4, name: 'rinkeby'}, - {id: 42, name: 'kovan'}, - {id: 5, name: 'goerli'} - ] - plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) - let found = false - for (const network of networks) { - const target = `/${network.name}` - try{ - data = await fetchContractFromEtherscan(plugin, network, contractAddress, target) - } catch (error) { - if ((error.message.startsWith('contract not verified on Etherscan') || error.message.startsWith('unable to retrieve contract data')) && network.id !== 5) - continue - else { - if (!found) await basicWorkspaceInit(workspaces, workspaceProvider) - break - } + let etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') + if (!etherscanKey) etherscanKey = '2HKUX5ZVASZIKWJM8MIQVCRUVZ6JAWT531' + const networks = [ + {id: 1, name: 'mainnet'}, + {id: 3, name: 'ropsten'}, + {id: 4, name: 'rinkeby'}, + {id: 42, name: 'kovan'}, + {id: 5, name: 'goerli'} + ] + plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) + let found = false + for (const network of networks) { + const target = `/${network.name}` + try{ + data = await fetchContractFromEtherscan(plugin, network, contractAddress, target, etherscanKey) + } catch (error) { + if ((error.message.startsWith('contract not verified on Etherscan') || error.message.startsWith('unable to retrieve contract data')) && network.id !== 5) + continue + else { + if (!found) await basicWorkspaceInit(workspaces, workspaceProvider) + break } - found = true - await createWorkspaceTemplate('etherscan-code-sample', 'code-template') - plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) - dispatch(setCurrentWorkspace('etherscan-code-sample')) - const filePath = Object.keys(data.compilationTargets)[0] - await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) - plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } + found = true + await createWorkspaceTemplate('etherscan-code-sample', 'code-template') + plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) + dispatch(setCurrentWorkspace('etherscan-code-sample')) + const filePath = Object.keys(data.compilationTargets)[0] + await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } } catch (error) { await basicWorkspaceInit(workspaces, workspaceProvider) From 1c3039c4b7c3a31186b58400c8c8443774a0ded8 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 23 Jun 2022 11:56:03 +0530 Subject: [PATCH 036/106] fetch contract feom GitHub --- apps/remix-ide/src/app/tabs/theme-module.js | 2 +- .../remix-ui/workspace/src/lib/actions/index.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index 842a39422f..ceb7192317 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -37,7 +37,7 @@ export class ThemeModule extends Plugin { themes.map((theme) => { this.themes[theme.name.toLocaleLowerCase()] = { ...theme, - url: window.location.origin + ( window.location.pathname.startsWith('/address/') ? '/' : window.location.pathname ) + theme.url + url: window.location.origin + ( window.location.pathname.startsWith('/address/') || window.location.pathname.endsWith('.sol') ? '/' : window.location.pathname ) + theme.url } }) this._paq = _paq diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 5d67f99182..208ebd139f 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -8,6 +8,7 @@ import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin import { QueryParams } from '@remix-project/remix-lib' import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line import JSZip from 'jszip' +import axios, { AxiosResponse } from 'axios' export * from './events' export * from './workspace' @@ -60,7 +61,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const filePath = await loadWorkspacePreset('code-template') plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } else if (window.location.pathname && window.location.pathname !== '/') { - const route = window.location.pathname + let route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) @@ -100,7 +101,19 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. } catch (error) { await basicWorkspaceInit(workspaces, workspaceProvider) } - } + } else if (route.endsWith('.sol')) { + if (route.includes('blob')) route = route.replace('/blob', '') + const response: AxiosResponse = await axios.get(`https://raw.githubusercontent.com${route}`) + let content + if (response.status === 200) { + content = response.data + await createWorkspaceTemplate('github-code-sample', 'code-template') + plugin.setWorkspace({ name: 'github-code-sample', isLocalhost: false }) + dispatch(setCurrentWorkspace('github-code-sample')) + await workspaceProvider.set(route, content) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(route)) + } else await basicWorkspaceInit(workspaces, workspaceProvider) + } else await basicWorkspaceInit(workspaces, workspaceProvider) } else { await basicWorkspaceInit(workspaces, workspaceProvider) } From cbd816197e350af22fd830de524c896aba10904b Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 23 Jun 2022 13:15:47 +0530 Subject: [PATCH 037/106] handle wrong github url --- libs/remix-ui/workspace/src/lib/actions/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 208ebd139f..b0cd59bbc2 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -103,10 +103,15 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. } } else if (route.endsWith('.sol')) { if (route.includes('blob')) route = route.replace('/blob', '') - const response: AxiosResponse = await axios.get(`https://raw.githubusercontent.com${route}`) - let content - if (response.status === 200) { - content = response.data + let response: AxiosResponse + try { + response = await axios.get(`https://raw.githubusercontent.com${route}`) + } catch (error) { + plugin.call('notification', 'toast', `cound not find ${route} on GitHub`) + await basicWorkspaceInit(workspaces, workspaceProvider) + } + if (response && response.status === 200) { + const content = response.data await createWorkspaceTemplate('github-code-sample', 'code-template') plugin.setWorkspace({ name: 'github-code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('github-code-sample')) From b5d66fae3207b924e51e1b6e95a81d8dacd72372 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 28 Jun 2022 13:02:49 +0530 Subject: [PATCH 038/106] add address in path --- libs/remix-ui/workspace/src/lib/actions/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index b0cd59bbc2..63ffaf3d0b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -79,8 +79,8 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) let found = false for (const network of networks) { - const target = `/${network.name}` - try{ + const target = `/${network.name}/${contractAddress}` + try { data = await fetchContractFromEtherscan(plugin, network, contractAddress, target, etherscanKey) } catch (error) { if ((error.message.startsWith('contract not verified on Etherscan') || error.message.startsWith('unable to retrieve contract data')) && network.id !== 5) From fbf22f7f38df10083b2de2828d4f0d620b5f1913 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 28 Jun 2022 13:38:46 +0530 Subject: [PATCH 039/106] crash fix --- libs/remix-ui/search/src/lib/reducers/Reducer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/search/src/lib/reducers/Reducer.ts b/libs/remix-ui/search/src/lib/reducers/Reducer.ts index 3e83b75aea..8ff867d1c8 100644 --- a/libs/remix-ui/search/src/lib/reducers/Reducer.ts +++ b/libs/remix-ui/search/src/lib/reducers/Reducer.ts @@ -46,7 +46,7 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action run: true } case 'SET_UNDO_ENABLED': - if(state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`]){ + if(action.payload.workspace && state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`]){ state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`].enabled = (action.payload.content === state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`].newContent) state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`].visible = (action.payload.content !== state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`].oldContent) } From 27d990ea699fe3be42db3f262886784da9b789d9 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 28 Jun 2022 14:08:00 +0530 Subject: [PATCH 040/106] toast update --- libs/remix-ui/workspace/src/lib/actions/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 63ffaf3d0b..c1af97d7a6 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -64,7 +64,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. let route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] - plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) + plugin.call('notification', 'toast', `Looking for contract(s) verified on different networks of Etherscan for contract address ${contractAddress}`) let data try { let etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') @@ -76,8 +76,8 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. {id: 42, name: 'kovan'}, {id: 5, name: 'goerli'} ] - plugin.call('notification', 'toast', `Looking for contract address ${contractAddress} on different networks`) let found = false + let foundOnNetworks = [] for (const network of networks) { const target = `/${network.name}/${contractAddress}` try { @@ -91,6 +91,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. } } found = true + foundOnNetworks.push(network.name) await createWorkspaceTemplate('etherscan-code-sample', 'code-template') plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('etherscan-code-sample')) @@ -98,6 +99,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } + plugin.call('notification', 'toast', `Added contract(s) verified on ${foundOnNetworks.join(',')} networks of Etherscan for contract address ${contractAddress}`) } catch (error) { await basicWorkspaceInit(workspaces, workspaceProvider) } From 90b63449532d77bafaed522db5f8c998063d0b0c Mon Sep 17 00:00:00 2001 From: Aniket <30843294+Aniket-Engg@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:18:21 +0530 Subject: [PATCH 041/106] linting fix --- libs/remix-ui/workspace/src/lib/actions/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index c1af97d7a6..28ca8e07d9 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -77,7 +77,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. {id: 5, name: 'goerli'} ] let found = false - let foundOnNetworks = [] + const foundOnNetworks = [] for (const network of networks) { const target = `/${network.name}/${contractAddress}` try { From a74bbc4f6f59c1e589a61ba46489869a4e1ab4e9 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 1 Jul 2022 14:41:11 +0530 Subject: [PATCH 042/106] add each file in workspace --- libs/remix-ui/workspace/src/lib/actions/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 28ca8e07d9..308c02a3a6 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -95,9 +95,9 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. await createWorkspaceTemplate('etherscan-code-sample', 'code-template') plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('etherscan-code-sample')) - const filePath = Object.keys(data.compilationTargets)[0] - await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) - plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) + let filePath + for (filePath in data.compilationTargets) + await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) } plugin.call('notification', 'toast', `Added contract(s) verified on ${foundOnNetworks.join(',')} networks of Etherscan for contract address ${contractAddress}`) } catch (error) { From c05aeea704838ee38a8763fa789e4ca21c84c32e Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 1 Jul 2022 19:31:30 +0530 Subject: [PATCH 043/106] update toasts --- libs/remix-ui/workspace/src/lib/actions/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 308c02a3a6..973eeb0820 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -64,8 +64,9 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. let route = window.location.pathname if (route.startsWith('/address/0x') && route.length === 51) { const contractAddress = route.split('/')[2] - plugin.call('notification', 'toast', `Looking for contract(s) verified on different networks of Etherscan for contract address ${contractAddress}`) + plugin.call('notification', 'toast', `Looking for contract(s) verified on different networks of Etherscan for contract address ${contractAddress} .....`) let data + let count = 0 try { let etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token') if (!etherscanKey) etherscanKey = '2HKUX5ZVASZIKWJM8MIQVCRUVZ6JAWT531' @@ -96,10 +97,12 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('etherscan-code-sample')) let filePath + count = count + (Object.keys(data.compilationTargets)).length for (filePath in data.compilationTargets) await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } - plugin.call('notification', 'toast', `Added contract(s) verified on ${foundOnNetworks.join(',')} networks of Etherscan for contract address ${contractAddress}`) + plugin.call('notification', 'toast', `Added ${count} verified contract${count === 1 ? '': 's'} from ${foundOnNetworks.join(',')} network${foundOnNetworks.length === 1 ? '': 's'} of Etherscan for contract address ${contractAddress} !!`) } catch (error) { await basicWorkspaceInit(workspaces, workspaceProvider) } From 87fccfd70ad24859e272939fab5db67a7aeefb32 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 4 Jul 2022 14:21:54 +0530 Subject: [PATCH 044/106] install using command --- libs/remixd/src/bin/remixd.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index d0f52556e3..9c561c5e65 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -63,6 +63,7 @@ function errorHandler (error: any, service: string) { .description('Establish a two-way websocket connection between the local computer and Remix IDE for a folder') .option('-u, --remix-ide ', 'URL of remix instance allowed to connect') .option('-s, --shared-folder ', 'Folder to share with Remix IDE (Default: CWD)') + .option('-i, --install ', 'Module name to install locally (Supported: ["slither"])') .option('-r, --read-only', 'Treat shared folder as read-only (experimental)') .on('--help', function () { console.log('\nExample:\n\n remixd -s ./shared_project -u http://localhost:8080') @@ -71,6 +72,11 @@ function errorHandler (error: any, service: string) { await warnLatestVersion() + if(program.install && !program.readOnly) { + if (program.install.toLowerCase() === 'slither') require('./../scripts/installSlither') + process.exit(0) + } + if (!program.remixIde) { console.log('\x1b[33m%s\x1b[0m', '[WARN] You can only connect to remixd from one of the supported origins.') } else { From ebfb66b7ba5ad9dd844aa2b01babdaf0822e8ecd Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 13 Jun 2022 13:18:26 +0200 Subject: [PATCH 045/106] fixing bug of saved path --- .../solidity-compiler/src/lib/compiler-container.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 26a526e510..1dae804ee3 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -71,7 +71,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => { api.setAppParameter('configFilePath', defaultPath) if (state.useFileConfiguration) { api.fileExists(defaultPath).then((exists) => { - if (!exists && state.useFileConfiguration) createNewConfigFile() + if (!exists && state.useFileConfiguration) { + configFilePathInput.current.value = defaultPath + createNewConfigFile() + } }) } setShowFilePathInput(false) From 95751d4ad8dd153d6690395b008c9ae5ac9a4e28 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 22 Jun 2022 12:45:59 +0200 Subject: [PATCH 046/106] clean path on cancel --- libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx | 1 + 1 file changed, 1 insertion(+) 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 1dae804ee3..b02b18d4c6 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -95,6 +95,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const listener = (event) => { if (configFilePathInput.current !== event.target) { setShowFilePathInput(false) + configFilePathInput.current.value = "" return; } }; From c324ce985a24fbcef8b642bd3e3aafd2c62e812c Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 4 Jul 2022 11:24:27 +0200 Subject: [PATCH 047/106] fixed create --- libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b02b18d4c6..8744dc6a33 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -93,7 +93,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { useEffect(() => { const listener = (event) => { - if (configFilePathInput.current !== event.target) { + if (configFilePathInput.current !== event.target && event.target.innerText !== "Create") { setShowFilePathInput(false) configFilePathInput.current.value = "" return; From 758794b9434e5bdb56f4dc86cd7bdfcb12a2aea0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 4 Jul 2022 11:05:58 +0200 Subject: [PATCH 048/106] update JSON structure --- .../remix-ide/src/app/tabs/runTab/model/recorder.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 550cf5fa26..caa758b180 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/recorder.js @@ -33,7 +33,13 @@ class Recorder extends Plugin { // convert to and from to tokens if (this.data._listen) { - var record = { value, parameters: payLoad.funArgs } + var record = { + value, + inputs: txHelper.serializeInputs(payLoad.funAbi), + parameters: payLoad.funArgs, + name: payLoad.funAbi.name, + type: payLoad.funAbi.type + } if (!to) { var abi = payLoad.contractABI var keccak = ethutil.bufferToHex(ethutil.keccakFromString(JSON.stringify(abi))) @@ -55,10 +61,7 @@ class Recorder extends Plugin { var creationTimestamp = this.data._createdContracts[to] record.to = `created{${creationTimestamp}}` record.abi = this.data._contractABIReferences[creationTimestamp] - } - record.name = payLoad.funAbi.name - record.inputs = txHelper.serializeInputs(payLoad.funAbi) - record.type = payLoad.funAbi.type + } for (var p in record.parameters) { var thisarg = record.parameters[p] var thistimestamp = this.data._createdContracts[thisarg] From a5bb53aef34c6601abcf0e24fab593d74dc1c430 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 23 Jun 2022 11:17:37 +0200 Subject: [PATCH 049/106] bug fix --- apps/remix-ide/src/app/plugins/storage.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/storage.ts b/apps/remix-ide/src/app/plugins/storage.ts index 32d5c90387..cd7ec1e162 100644 --- a/apps/remix-ide/src/app/plugins/storage.ts +++ b/apps/remix-ide/src/app/plugins/storage.ts @@ -15,14 +15,14 @@ export class StoragePlugin extends Plugin { async getStorage() { let storage = null if ('storage' in navigator && 'estimate' in navigator.storage && (window as any).remixFileSystem.name !== 'localstorage') { - storage = navigator.storage.estimate() + storage = await navigator.storage.estimate() } else { storage ={ usage: parseFloat(this.calculateLocalStorage()) * 1000, quota: 5000000, } } - const _paq = window._paq = window._paq || [] + const _paq = (window as any)._paq = (window as any)._paq || [] _paq.push(['trackEvent', 'Storage', 'used', this.formatString(storage)]); return storage } @@ -32,8 +32,8 @@ export class StoragePlugin extends Plugin { } calculateLocalStorage() { - var _lsTotal = 0 - var _xLen; var _x + let _lsTotal = 0 + let _xLen; let _x for (_x in localStorage) { // eslint-disable-next-line no-prototype-builtins if (!localStorage.hasOwnProperty(_x)) { From 98ffd7220288494b367ea004e2a22afdaaa856f9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 4 Jul 2022 12:33:28 +0200 Subject: [PATCH 050/106] handle openCodeEditor in monaco --- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 7787daeddf..46a5e76d9b 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -416,6 +416,20 @@ export const EditorUI = (props: EditorUIProps) => { editor.addCommand(monacoRef.current.KeyMod.CtrlCmd | monacoRef.current.KeyCode.US_MINUS, () => { editor.updateOptions({ fontSize: editor.getOption(43).fontSize - 1 }) }) + + const editorService = editor._codeEditorService; + const openEditorBase = editorService.openCodeEditor.bind(editorService); + editorService.openCodeEditor = async (input, source) => { + const result = await openEditorBase(input, source) + if (input && input.resource && input.resource.path) { + try { + await props.plugin.call('fileManager', 'open', input.resource.path) + } catch (e) { + console.log(e) + } + } + return result + } } function handleEditorWillMount (monaco) { From 9db15727eb090b2bffe1b5f63067ebf3ad7fd199 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 17 Jun 2022 17:35:19 +0200 Subject: [PATCH 051/106] renamed envs --- libs/remix-ui/run-tab/src/lib/reducers/runTab.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts index 20ecb8b1ef..c61d82905d 100644 --- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts +++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts @@ -118,26 +118,26 @@ export const runTabInitialState: RunTabState = { title: 'Execution environment is local to Remix. Data is only saved to browser memory and will vanish upon reload.', value: 'vm-london', fork: 'london', - content: 'JavaScript VM (London)' + content: 'Local VM (London)' }, { id: 'vm-mode-berlin', dataId: 'settingsVMBerlinMode', title: 'Execution environment is local to Remix. Data is only saved to browser memory and will vanish upon reload.', value: 'vm-berlin', fork: 'berlin', - content: 'JavaScript VM (Berlin)' + content: 'Local VM (Berlin)' }, { id: 'injected-mode', dataId: 'settingsInjectedMode', title: 'Execution environment has been provided by Metamask or similar provider.', value: 'injected', - content: 'Injected Web3' + content: 'Injected Provider - Metamask' }, { id: 'web3-mode', dataId: 'settingsWeb3Mode', title: `Execution environment connects to an external node. For security, only connect to trusted networks. If Remix is served via https and your node is accessed via http, it might not work. In this case, try cloning the repository and serving it via http.`, value: 'web3', - content: 'Web3 Provider' + content: 'JSON-RPC Provider' }], isRequesting: false, isSuccessful: false, From 4b7114417da89abef7025dfb7015b1a60d93998e Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 17 Jun 2022 17:47:01 +0200 Subject: [PATCH 052/106] e2e fix --- apps/remix-ide-e2e/src/tests/plugin_api.ts | 2 +- .../remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx | 2 +- libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx | 2 +- libs/remix-ui/run-tab/src/lib/css/run-tab.css | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index faabf03247..2f4aae42e0 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts @@ -188,7 +188,7 @@ module.exports = { .frameParent() .useCss() .clickLaunchIcon('udapp') - .waitForElementContainsText('#selectExEnvOptions option:checked', 'JavaScript VM (Berlin)') + .waitForElementContainsText('#selectExEnvOptions option:checked', 'Local VM (Berlin)') .clickLaunchIcon('localPlugin') .useXpath() // @ts-ignore diff --git a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx index 5c2800ef4d..6890c53f6d 100644 --- a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx @@ -12,7 +12,7 @@ export function InstanceContainerUI (props: InstanceContainerProps) { return (
-
handleChangeTokenState(e)} value={ githubToken } /> +
+ +
+
+
+
+ +
+ handleChangeUserNameState(e)} value={ githubUserName } /> +
+
+
+ +
+ handleChangeEmailState(e)} value={ githubEmail } /> +
+ + +
+
+
+
+
+ ) +} \ No newline at end of file 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 2de3ecd67b..7b112eef9c 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -8,6 +8,7 @@ import { ethereumVM, generateContractMetadat, personal, textWrapEventAction, use import { initialState, toastInitialState, toastReducer, settingReducer } from './settingsReducer' import { Toaster } from '@remix-ui/toaster'// eslint-disable-line import { RemixUiThemeModule, ThemeModule} from '@remix-ui/theme-module' +import { GithubSettings } from './github-settings' /* eslint-disable-next-line */ export interface RemixUiSettingsProps { @@ -347,7 +348,10 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
{state.message ? : null} {generalConfig()} - {token('gist')} + { saveTokenToast(props.config, dispatchToast, githubToken, "gist-access-token") }} + removeTokenToast={() => { removeTokenToast(props.config, dispatchToast, "gist-access-token") }} + /> {token('etherscan')} {swarmSettings()} {ipfsSettings()} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts new file mode 100644 index 0000000000..827820b870 --- /dev/null +++ b/libs/remix-ui/settings/src/types/index.ts @@ -0,0 +1,4 @@ +export interface GithubSettingsProps { + saveTokenToast: (githubToken: string) => void, + removeTokenToast: () => void +} diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx index 4972fbe68f..f6f4bf49df 100644 --- a/libs/remix-ui/workspace/src/lib/components/clone.tsx +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -2,7 +2,7 @@ import React from 'react' import { OverlayTrigger, Popover } from 'react-bootstrap'; const popover = ( - + Clone workspace
@@ -17,7 +17,7 @@ const popover = ( ) export const CloneWorkspace = () => ( - + ) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 95e1929cc0..c4d0e4d5f6 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -218,7 +218,7 @@ export function Workspace () { - +
handleChangeTokenState(e)} value={ githubToken } />
- +
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 7b112eef9c..62d1e07cfb 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -349,8 +349,16 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { {state.message ? : null} {generalConfig()} { saveTokenToast(props.config, dispatchToast, githubToken, "gist-access-token") }} - removeTokenToast={() => { removeTokenToast(props.config, dispatchToast, "gist-access-token") }} + saveTokenToast={(githubToken: string, githubUserName: string, githubEmail: string) => { + saveTokenToast(props.config, dispatchToast, githubToken, "gist-access-token") + saveTokenToast(props.config, dispatchToast, githubUserName, "github-user-name") + saveTokenToast(props.config, dispatchToast, githubEmail, "github-email") + }} + removeTokenToast={() => { + removeTokenToast(props.config, dispatchToast, "gist-access-token") + removeTokenToast(props.config, dispatchToast, "github-user-name") + removeTokenToast(props.config, dispatchToast, "github-email") + }} /> {token('etherscan')} {swarmSettings()} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts index 827820b870..b9f3fcfbd3 100644 --- a/libs/remix-ui/settings/src/types/index.ts +++ b/libs/remix-ui/settings/src/types/index.ts @@ -1,4 +1,4 @@ export interface GithubSettingsProps { - saveTokenToast: (githubToken: string) => void, + saveTokenToast: (githubToken: string, githubUserName: string, githubEmail: string) => void, removeTokenToast: () => void } diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx index f6f4bf49df..fa92552b22 100644 --- a/libs/remix-ui/workspace/src/lib/components/clone.tsx +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -3,21 +3,21 @@ import { OverlayTrigger, Popover } from 'react-bootstrap'; const popover = ( - Clone workspace + Clone Repository
) -export const CloneWorkspace = () => ( - - +export const CloneRepository = () => ( + + ) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index c4d0e4d5f6..40779306ee 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint import { FileExplorer } from './components/file-explorer' // eslint-disable-line import './css/remix-ui-workspace.css' import { FileSystemContext } from './contexts' -import { CloneWorkspace } from './components/clone' +import { CloneRepository } from './components/clone' const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -159,7 +159,6 @@ export function Workspace () { -
+ - - - -
handleChangeUserNameState(e)} value={ githubUserName } /> + handleChangeUserNameState(e)} value={ githubUserName } />
- handleChangeEmailState(e)} value={ githubEmail } /> + handleChangeEmailState(e)} value={ githubEmail } />
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 62d1e07cfb..19655dd281 100644 --- a/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx +++ b/libs/remix-ui/settings/src/lib/remix-ui-settings.tsx @@ -359,6 +359,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => { removeTokenToast(props.config, dispatchToast, "github-user-name") removeTokenToast(props.config, dispatchToast, "github-email") }} + config={props.config} /> {token('etherscan')} {swarmSettings()} diff --git a/libs/remix-ui/settings/src/types/index.ts b/libs/remix-ui/settings/src/types/index.ts index b9f3fcfbd3..5b4af8dfc1 100644 --- a/libs/remix-ui/settings/src/types/index.ts +++ b/libs/remix-ui/settings/src/types/index.ts @@ -1,4 +1,12 @@ export interface GithubSettingsProps { saveTokenToast: (githubToken: string, githubUserName: string, githubEmail: string) => void, - removeTokenToast: () => void + removeTokenToast: () => void, + config: { + exists: (key: string) => boolean, + get: (key: string) => string, + set: (key: string, content: string) => void, + clear: () => void, + getUnpersistedProperty: (key: string) => void, + setUnpersistedProperty: (key: string, value: string) => void + } } diff --git a/libs/remix-ui/workspace/src/lib/components/clone.tsx b/libs/remix-ui/workspace/src/lib/components/clone.tsx index fa92552b22..95ec9c6d88 100644 --- a/libs/remix-ui/workspace/src/lib/components/clone.tsx +++ b/libs/remix-ui/workspace/src/lib/components/clone.tsx @@ -18,6 +18,6 @@ const popover = ( export const CloneRepository = () => ( - + ) From 0aa21b2a6a9e2a12f296e963cf47fc3b9d88be16 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 20 Jun 2022 13:38:59 +0100 Subject: [PATCH 072/106] Set clone repository dispatch --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 4 ++++ libs/remix-ui/workspace/src/lib/contexts/index.ts | 3 ++- .../workspace/src/lib/providers/FileSystemProvider.tsx | 9 +++++++-- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 1b73f63cc0..154a9e9968 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -321,3 +321,7 @@ export const getWorkspaces = async (): Promise | undefined => { return workspaces } catch (e) {} } + +export const cloneRepository = async (url: string) => { + console.log('url: ', url) +} diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 792bed8188..1bd33c2529 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -29,5 +29,6 @@ export const FileSystemContext = createContext<{ dispatchHandleClickFile: (path: string, type: 'file' | 'folder' | 'gist') => Promise dispatchHandleExpandPath: (paths: string[]) => Promise, dispatchHandleDownloadFiles: () => Promise, - dispatchHandleRestoreBackup: () => Promise + dispatchHandleRestoreBackup: () => Promise, + dispatchCloneRepository: (url: string) => Promise }>(null) diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index fab8e652b5..86f4cccaf2 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line // eslint-disable-next-line @typescript-eslint/no-unused-vars import { FileSystemContext } from '../contexts' import { browserReducer, browserInitialState } from '../reducers/workspace' -import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles, restoreBackupZip } from '../actions' +import { initWorkspace, fetchDirectory, removeInputField, deleteWorkspace, clearPopUp, publishToGist, createNewFile, setFocusElement, createNewFolder, deletePath, renamePath, copyFile, copyFolder, runScript, emitContextMenuEvent, handleClickFile, handleExpandPath, addInputField, createWorkspace, fetchWorkspaceDirectory, renameWorkspace, switchToWorkspace, uploadFile, handleDownloadFiles, restoreBackupZip, cloneRepository } from '../actions' import { Modal, WorkspaceProps, WorkspaceTemplate } from '../types' // eslint-disable-next-line @typescript-eslint/no-unused-vars import { Workspace } from '../remix-ui-workspace' @@ -123,6 +123,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await restoreBackupZip() } + const dispatchCloneRepository = async (url: string) => { + await cloneRepository(url) + } + useEffect(() => { dispatchInitWorkspace() }, []) @@ -224,7 +228,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => { dispatchHandleClickFile, dispatchHandleExpandPath, dispatchHandleDownloadFiles, - dispatchHandleRestoreBackup + dispatchHandleRestoreBackup, + dispatchCloneRepository } return ( diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 40779306ee..0cf5b93feb 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -215,7 +215,8 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> - + + -
- - -) - -export const CloneRepository = () => ( - - - -) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 0cf5b93feb..f70bf31612 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -1,8 +1,8 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint-disable-line import { FileExplorer } from './components/file-explorer' // eslint-disable-line -import './css/remix-ui-workspace.css' import { FileSystemContext } from './contexts' -import { CloneRepository } from './components/clone' +import { TooltipPopup } from '@remix-ui/tooltip-popup' +import './css/remix-ui-workspace.css' const canUpload = window.File || window.FileReader || window.FileList || window.Blob @@ -14,6 +14,7 @@ export function Workspace () { const workspaceRenameInput = useRef() const workspaceCreateInput = useRef() const workspaceCreateTemplateInput = useRef() + const cloneUrlRef = useRef() useEffect(() => { resetFocus() @@ -125,6 +126,18 @@ export function Workspace () { workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` } + const handleTypingUrl = (event: React.KeyboardEvent) => { + if (event.key === 'Enter') { + const url = cloneUrlRef.current.value + + if (url) { + global.dispatchCloneRepository() + } else { + console.log('Please provide a valid github repository url.') + } + } + } + const createModalMessage = () => { return ( <> @@ -215,8 +228,17 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> - - + +
+ +
+
+ + ) + } + return (
@@ -228,17 +237,16 @@ export function Workspace () { className='far fa-upload remixui_menuicon' title='Restore Workspaces Backup'> - -
- -
-
+ { + e.stopPropagation() + cloneGitRepository() + }} + className='far fa-clone remixui_menuicon' + title='Clone Git Repository'> + switchWorkspace(e.target.value)} className="form-control custom-select"> + {/* { + const { code, title } = [{ code: 'NG', title: 'Nigeria' }].find(({ code }) => value === code) + + setSelectedCountry(value) + setToggleContents(<> {title}) + }} + > + + {toggleContents} + + + + {[{ code: 'NG', title: 'Nigeria' }].map(({ code, title }) => ( + {title} + ))} + + */} + switchWorkspace(e.target.value)} className="form-select"> - { - global.fs.browser.workspaces - .map((folder, index) => { - return - }) - } - - { global.fs.browser.workspaces.length <= 0 && } - +
From 9edfd398c88b29393eba6f86a5e04f9f6c45a5be Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 11:45:01 +0100 Subject: [PATCH 078/106] Clone cleanup --- apps/remix-ide/src/app/files/dgitProvider.js | 13 ++-- .../workspace/src/lib/actions/index.ts | 5 +- .../workspace/src/lib/actions/payload.ts | 18 +++++ .../workspace/src/lib/actions/workspace.ts | 26 +++++-- .../workspace/src/lib/reducers/workspace.ts | 58 ++++++++++++++-- .../workspace/src/lib/remix-ui-workspace.tsx | 68 ++++++++++--------- 6 files changed, 135 insertions(+), 53 deletions(-) diff --git a/apps/remix-ide/src/app/files/dgitProvider.js b/apps/remix-ide/src/app/files/dgitProvider.js index d4a1a26c8c..8b5ce925c5 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.js +++ b/apps/remix-ide/src/app/files/dgitProvider.js @@ -233,12 +233,11 @@ class DGitProvider extends Plugin { return this.calculateLocalStorage() } - async clone (input, workspaceName) { + async clone (input, workspaceName, workspaceExists = false) { const permission = await this.askUserPermission('clone', 'Import multiple files into your workspaces.') if (!permission) return false if (this.calculateLocalStorage() > 10000) throw new Error('The local storage of the browser is full.') - await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true) - + if (!workspaceExists) await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true) const cmd = { url: input.url, singleBranch: input.singleBranch, @@ -249,9 +248,11 @@ class DGitProvider extends Plugin { } const result = await git.clone(cmd) - setTimeout(async () => { - await this.call('fileManager', 'refresh') - }, 1000) + if (!workspaceExists) { + setTimeout(async () => { + await this.call('fileManager', 'refresh') + }, 1000) + } return result } diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 460aa1d1f8..7a5387474b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -33,9 +33,10 @@ const basicWorkspaceInit = async (workspaces: { name: string; isGitRepo: boolean } else { if (workspaces.length > 0) { const workspace = workspaces[workspaces.length - 1] + const workspaceName = (workspace || {}).name - workspaceProvider.setWorkspace(workspace.name) - plugin.setWorkspace({ name: (workspace || {}).name, isLocalhost: false }) + workspaceProvider.setWorkspace(workspaceName) + plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) dispatch(setCurrentWorkspace(workspace)) } } diff --git a/libs/remix-ui/workspace/src/lib/actions/payload.ts b/libs/remix-ui/workspace/src/lib/actions/payload.ts index 67b45d01f5..b663f60cfe 100644 --- a/libs/remix-ui/workspace/src/lib/actions/payload.ts +++ b/libs/remix-ui/workspace/src/lib/actions/payload.ts @@ -239,3 +239,21 @@ export const fsInitializationCompleted = () => { type: 'FS_INITIALIZATION_COMPLETED' } } + +export const cloneRepositoryRequest = () => { + return { + type: 'CLONE_REPOSITORY_REQUEST' + } +} + +export const cloneRepositorySuccess = () => { + return { + type: 'CLONE_REPOSITORY_SUCCESS' + } +} + +export const cloneRepositoryFailed = () => { + return { + type: 'CLONE_REPOSITORY_FAILED' + } +} diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index b0a3531f1d..ee8ade4f2b 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -1,7 +1,7 @@ import React from 'react' import { bufferToHex, keccakFromString } from 'ethereumjs-util' import axios, { AxiosResponse } from 'axios' -import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, displayPopUp, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload' +import { addInputFieldSuccess, cloneRepositoryFailed, cloneRepositoryRequest, cloneRepositorySuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, displayPopUp, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload' import { checkSlash, checkSpecialChars, createNonClashingTitle } from '@remix-ui/helper' import { JSONStandardInput, WorkspaceTemplate } from '../types' @@ -42,13 +42,13 @@ export const addInputField = async (type: 'file' | 'folder', path: string, cb?: return promise } -export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void) => { +export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void, isGitRepo: boolean = false) => { await plugin.fileManager.closeAllFiles() const promise = createWorkspaceTemplate(workspaceName, workspaceTemplateName) dispatch(createWorkspaceRequest(promise)) promise.then(async () => { - dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo: false })) + dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) await plugin.setWorkspaces(await getWorkspaces()) await plugin.workspaceCreated(workspaceName) @@ -334,12 +334,26 @@ export const cloneRepository = async (url: string) => { const token = config.get('currentFile') const repoConfig = { url, token } const urlArray = url.split('/') - let repoName = urlArray[urlArray.length - 1] + let repoName = urlArray.length > 0 ? urlArray[urlArray.length - 1] : '' try { repoName = await createNonClashingTitle(repoName, plugin.fileManager) - await plugin.call('dGitProvider', 'clone', repoConfig, repoName) - await plugin.call('manager', 'activatePlugin', 'dgit') + await createWorkspace(repoName, 'blank', true, null, true) + const promise = plugin.call('dGitProvider', 'clone', repoConfig, repoName, true) + + dispatch(cloneRepositoryRequest()) + promise.then(async () => { + const isActive = await plugin.call('manager', 'isActive', 'dgit') + + if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') + await fetchWorkspaceDirectory(repoName) + dispatch(cloneRepositorySuccess()) + }).catch((e) => { + dispatch(displayNotification('Clone Git Repository', 'An error occured: ' + e, 'Ok', null, async () => { + await deleteWorkspace(repoName) + dispatch(cloneRepositoryFailed()) + })) + }) } catch (e) { dispatch(displayPopUp('An error occured: ' + e)) } diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 36b8497f70..39f56a202f 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -18,6 +18,8 @@ export interface BrowserState { isSuccessfulDirectory: boolean, isRequestingWorkspace: boolean, isSuccessfulWorkspace: boolean, + isRequestingCloning: boolean, + isSuccessfulCloning: boolean, error: string, contextMenu: { registeredMenuItems: action[], @@ -53,8 +55,7 @@ export interface BrowserState { popup: string, focusEdit: string, focusElement: { key: string, type: 'file' | 'folder' | 'gist' }[], - initializingFS: boolean, - isGitRepo: boolean + initializingFS: boolean } export const browserInitialState: BrowserState = { @@ -67,6 +68,8 @@ export const browserInitialState: BrowserState = { isSuccessfulDirectory: false, isRequestingWorkspace: false, isSuccessfulWorkspace: false, + isRequestingCloning: false, + isSuccessfulCloning: false, error: null, contextMenu: { registeredMenuItems: [], @@ -102,8 +105,7 @@ export const browserInitialState: BrowserState = { popup: '', focusEdit: '', focusElement: [], - initializingFS: true, - isGitRepo: false + initializingFS: true } export const browserReducer = (state = browserInitialState, action: Action) => { @@ -451,14 +453,25 @@ export const browserReducer = (state = browserInitialState, action: Action) => { case 'RENAME_WORKSPACE': { const payload = action.payload as { oldName: string, workspaceName: string } - const workspaces = state.browser.workspaces.filter(({ name }) => name && (name !== payload.oldName)) + let renamedWorkspace + const workspaces = state.browser.workspaces.filter(({ name, isGitRepo }) => { + if (name && (name !== payload.oldName)) { + return true + } else { + renamedWorkspace = { + name: payload.workspaceName, + isGitRepo + } + return false + } + }) return { ...state, browser: { ...state.browser, currentWorkspace: payload.workspaceName, - workspaces: [...workspaces, payload.workspaceName], + workspaces: [...workspaces, renamedWorkspace], expandPath: [] } } @@ -597,6 +610,39 @@ export const browserReducer = (state = browserInitialState, action: Action) => { } } + case 'CLONE_REPOSITORY_REQUEST': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: true, + isSuccessfulCloning: false + } + } + } + + case 'CLONE_REPOSITORY_SUCCESS': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: true + } + } + } + + case 'CLONE_REPOSITORY_FAILED': { + return { + ...state, + browser: { + ...state.browser, + isRequestingCloning: false, + isSuccessfulCloning: false + } + } + } + case 'FS_INITIALIZATION_COMPLETED': { return { ...state, diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 0df9b8b53c..e911d9decf 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -290,39 +290,41 @@ export function Workspace () {
-
- { (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && - - } -
+ { global.fs.browser.isRequestingWorkspace || global.fs.browser.isRequestingCloning ?
+ :
+ { (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && + + } +
+ } { global.fs.localhost.isRequestingLocalhost ?
:
From df655ad3a26440ce31410bef83dfd7c3c094faf0 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 12:07:35 +0100 Subject: [PATCH 079/106] Restore target dependency build --- nx.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nx.json b/nx.json index bec616c17c..13cd26c2b2 100644 --- a/nx.json +++ b/nx.json @@ -173,5 +173,13 @@ "remix-ui-tooltip-popup": { "tags": [] } + }, + "targetDependencies": { + "build": [ + { + "target": "build", + "projects": "dependencies" + } + ] } } From 3631c4186f12802a99360940c79f2116024c8506 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 12:34:45 +0100 Subject: [PATCH 080/106] Restore linting config --- package.json | 2 +- workspace.json | 62 +++++++++++++++++++++++++------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index cced59ff97..54a2b7c8aa 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,remix-ws-templates,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,remix-ui-search", + "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,remix-ws-templates,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,remix-ui-search,remix-ui-tooltip-popup", "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,remix-ws-templates,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": "yarn run build:libs && lerna publish --skip-git && yarn run bumpVersion:libs", diff --git a/workspace.json b/workspace.json index 9261341d28..4a1f176ac2 100644 --- a/workspace.json +++ b/workspace.json @@ -1,35 +1,5 @@ { "version": 1, - "cli": { - "defaultCollection": "@nrwl/react" - }, - "defaultProject": "remix-ide", - "schematics": { - "@nrwl/workspace": { - "library": { - "linter": "eslint" - } - }, - "@nrwl/react": { - "application": { - "style": "css", - "linter": "eslint", - "babel": true - }, - "component": { - "style": "css" - }, - "library": { - "style": "css", - "linter": "eslint" - } - }, - "@nrwl/nx-plugin": { - "plugin": { - "linter": "eslint" - } - } - }, "projects": { "remix-ide": { "root": "apps/remix-ide", @@ -1299,5 +1269,35 @@ } } } - } + }, + "cli": { + "defaultCollection": "@nrwl/react" + }, + "schematics": { + "@nrwl/workspace": { + "library": { + "linter": "eslint" + } + }, + "@nrwl/react": { + "application": { + "style": "css", + "linter": "eslint", + "babel": true + }, + "component": { + "style": "css" + }, + "library": { + "style": "css", + "linter": "eslint" + } + }, + "@nrwl/nx-plugin": { + "plugin": { + "linter": "eslint" + } + } + }, + "defaultProject": "remix-ide" } From 15dd3cf1edb83ec92e1bf5c87556847e2ba0e9b0 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 14:55:58 +0100 Subject: [PATCH 081/106] Fixed tooltip library eslint config --- workspace.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/workspace.json b/workspace.json index 4a1f176ac2..02a11c683b 100644 --- a/workspace.json +++ b/workspace.json @@ -1260,11 +1260,12 @@ "projectType": "library", "architect": { "lint": { - "builder": "@nrwl/linter:eslint", + "builder": "@nrwl/linter:lint", "options": { - "lintFilePatterns": [ - "libs/remix-ui/tooltip-popup/**/*.{ts,tsx,js,jsx}" - ] + "linter": "eslint", + "config": "libs/remix-ui/tooltip-popup/.eslintrc.json", + "tsConfig": ["libs/remix-ui/tooltip-popup/tsconfig.lib.json"], + "exclude": ["**/node_modules/**"] } } } From 68242913475786065bb135698171ae09b3c22c1a Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 16:09:38 +0100 Subject: [PATCH 082/106] Fixed plugin api test --- .../src/commands/switchWorkspace.ts | 18 ++++++++++++++++++ apps/remix-ide-e2e/src/tests/plugin_api.ts | 8 ++++---- apps/remix-ide-e2e/src/types/index.d.ts | 3 ++- .../workspace/src/lib/remix-ui-workspace.tsx | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 apps/remix-ide-e2e/src/commands/switchWorkspace.ts diff --git a/apps/remix-ide-e2e/src/commands/switchWorkspace.ts b/apps/remix-ide-e2e/src/commands/switchWorkspace.ts new file mode 100644 index 0000000000..6219ddd218 --- /dev/null +++ b/apps/remix-ide-e2e/src/commands/switchWorkspace.ts @@ -0,0 +1,18 @@ +import { NightwatchBrowser } from 'nightwatch' +import EventEmitter from 'events' + +class switchWorkspace extends EventEmitter { + command (this: NightwatchBrowser, workspaceName: string): NightwatchBrowser { + this.api.waitForElementVisible('[data-id="workspacesSelect"]') + .click('[data-id="workspacesSelect"]') + .waitForElementVisible(`[data-id="dropdown-item-${workspaceName}"]`) + .click(`[data-id="dropdown-item-${workspaceName}"]`) + .perform((done) => { + done() + this.emit('complete') + }) + return this + } +} + +module.exports = switchWorkspace diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index 1c21c849ca..f05a2fe130 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts @@ -298,25 +298,25 @@ module.exports = { }, null, null) }, 'Should get all workspaces #group2': async function (browser: NightwatchBrowser) { - await clickAndCheckLog(browser, 'filePanel:getWorkspaces', ['default_workspace', 'emptyworkspace', 'testspace'], null, null) + await clickAndCheckLog(browser, 'filePanel:getWorkspaces', [{name:"default_workspace",isGitRepo:false}, {name:"emptyworkspace",isGitRepo:false}, {name:"testspace",isGitRepo:false}], null, null) }, 'Should have set workspace event #group2': async function (browser: NightwatchBrowser) { await clickAndCheckLog(browser, 'filePanel:createWorkspace', null, { event: 'setWorkspace', args: [{ name: 'newspace', isLocalhost: false }] }, 'newspace') }, 'Should have event when switching workspace #group2': async function (browser: NightwatchBrowser) { // @ts-ignore - browser.frameParent().useCss().clickLaunchIcon('filePanel').click('*[data-id="workspacesSelect"] option[value="default_workspace"]').useXpath().click('//*[@data-id="verticalIconsKindlocalPlugin"]').frame(0, async () => { + browser.frameParent().useCss().clickLaunchIcon('filePanel').switchWorkspace('default_workspace').useXpath().click('//*[@data-id="verticalIconsKindlocalPlugin"]').frame(0, async () => { await clickAndCheckLog(browser, null, null, { event: 'setWorkspace', args: [{ name: 'default_workspace', isLocalhost: false }] }, null) }) }, 'Should rename workspace #group2': async function (browser: NightwatchBrowser) { await clickAndCheckLog(browser, 'filePanel:renameWorkspace', null, null, ['default_workspace', 'renamed']) - await clickAndCheckLog(browser, 'filePanel:getWorkspaces', ['emptyworkspace', 'testspace', 'newspace', 'renamed'], null, null) + await clickAndCheckLog(browser, 'filePanel:getWorkspaces', [{name:"emptyworkspace",isGitRepo:false},{name:"testspace",isGitRepo:false},{name:"newspace",isGitRepo:false},{name:"renamed",isGitRepo:false}], null, null) }, 'Should delete workspace #group2': async function (browser: NightwatchBrowser) { await clickAndCheckLog(browser, 'filePanel:deleteWorkspace', null, null, ['testspace']) - await clickAndCheckLog(browser, 'filePanel:getWorkspaces', ['emptyworkspace', 'newspace', 'renamed'], null, null) + await clickAndCheckLog(browser, 'filePanel:getWorkspaces', [{name:"emptyworkspace",isGitRepo:false},{name:"newspace",isGitRepo:false},{name:"renamed",isGitRepo:false}], null, null) }, // DGIT 'Should have changes on new workspace #group3': async function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index f17e6b17de..eccd50bad5 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -62,7 +62,8 @@ declare module 'nightwatch' { clearConsole (this: NightwatchBrowser): NightwatchBrowser clearTransactions (this: NightwatchBrowser): NightwatchBrowser getBrowserLogs (this: NightwatchBrowser): NightwatchBrowser - currentSelectedFileIs (name: string): NightwatchBrowser + currentSelectedFileIs (name: string): NightwatchBrowser, + switchWorkspace: (workspaceName: string) => NightwatchBrowser } export interface NightwatchBrowser { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index e911d9decf..8bbe2a2703 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -262,7 +262,7 @@ export function Workspace () { { selectedWorkspace ? selectedWorkspace.name : currentWorkspace === LOCALHOST ? 'localhost' : NO_WORKSPACE } - + { global.fs.browser.workspaces.map(({ name, isGitRepo }, index) => ( { switchWorkspace(name) }} + data-id={`dropdown-item-${name}`} > { isGitRepo ?
From 004dbffc0c4051d58232873b672ea09b729a7837 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 17:44:18 +0100 Subject: [PATCH 083/106] Fixed url test --- .../src/commands/currentWorkspaceIs.ts | 18 +++++++++--------- apps/remix-ide-e2e/src/tests/url.test.ts | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts b/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts index a090735f45..26da9cf9c8 100644 --- a/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts +++ b/apps/remix-ide-e2e/src/commands/currentWorkspaceIs.ts @@ -3,15 +3,15 @@ import EventEmitter from 'events' class CurrentWorkspaceIs extends EventEmitter { command (this: NightwatchBrowser, name: string): NightwatchBrowser { - this.api - .execute(function () { - const el = document.querySelector('select[data-id="workspacesSelect"]') as HTMLSelectElement - return el.value - }, [], (result) => { - console.log(result) - this.api.assert.equal(result.value, name) - this.emit('complete') - }) + const browser = this.api + + browser.getText('[data-id="workspacesSelect"]', function (result) { + browser.assert.equal(result.value, name) + }) + .perform((done) => { + done() + this.emit('complete') + }) return this } } diff --git a/apps/remix-ide-e2e/src/tests/url.test.ts b/apps/remix-ide-e2e/src/tests/url.test.ts index a201b4ea36..00885338b4 100644 --- a/apps/remix-ide-e2e/src/tests/url.test.ts +++ b/apps/remix-ide-e2e/src/tests/url.test.ts @@ -29,6 +29,7 @@ module.exports = { .click('[for="autoCompile"]') // we set it too false again .click('[for="autoCompile"]') // back to True in the local storage .assert.containsText('*[data-id="compilerContainerCompileBtn"]', 'contract-76747f6e19.sol') + .clickLaunchIcon('filePanel') .currentWorkspaceIs('code-sample') .getEditorValue((content) => { browser.assert.ok(content && content.indexOf( @@ -57,6 +58,7 @@ module.exports = { .url('http://127.0.0.1:8080/#optimize=true&runs=300&evmVersion=istanbul&version=soljson-v0.7.4+commit.3f05b770.js&url=https://github.com/ethereum/remix-project/blob/master/apps/remix-ide/contracts/app/solidity/mode.sol&code=cHJhZ21hIHNvbGlkaXR5ID49MC42LjAgPDAuNy4wOwoKaW1wb3J0ICJodHRwczovL2dpdGh1Yi5jb20vT3BlblplcHBlbGluL29wZW56ZXBwZWxpbi1jb250cmFjdHMvYmxvYi9tYXN0ZXIvY29udHJhY3RzL2FjY2Vzcy9Pd25hYmxlLnNvbCI7Cgpjb250cmFjdCBHZXRQYWlkIGlzIE93bmFibGUgewogIGZ1bmN0aW9uIHdpdGhkcmF3KCkgZXh0ZXJuYWwgb25seU93bmVyIHsKICB9Cn0') .refresh() // we do one reload for making sure we already have the default workspace .pause(5000) + .clickLaunchIcon('filePanel') .currentWorkspaceIs('code-sample') .getEditorValue((content) => { browser.assert.ok(content && content.indexOf( @@ -113,7 +115,7 @@ module.exports = { .url('http://127.0.0.1:8080/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.6.12+commit.27d51765.js&url=https://raw.githubusercontent.com/EthVM/evm-source-verification/main/contracts/1/0x011e5846975c6463a8c6337eecf3cbf64e328884/input.json') .refresh() .pause(5000) - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="code-sample"]') + .switchWorkspace('code-sample') .openFile('@openzeppelin') .openFile('@openzeppelin/contracts') .openFile('@openzeppelin/contracts/access') From 057b1330fbc8b7d007792f7e2e9ea4a3a7345dd6 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 29 Jun 2022 18:07:19 +0100 Subject: [PATCH 084/106] Fixed solidity unit testing --- apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts index 30a2913891..7e61167107 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.test.ts @@ -181,7 +181,7 @@ module.exports = { .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_new' }) .waitForElementVisible('*[data-id="fileSystem-modal-footer-ok-react"]') .execute(function () { (document.querySelector('[data-id="fileSystem-modal-footer-ok-react"]') as HTMLElement).click() }) - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="workspace_new"]') + .currentWorkspaceIs('workspace_new') .waitForElementVisible('li[data-id="treeViewLitreeViewItem.deps/remix-tests/remix_tests.sol"]') .waitForElementVisible('li[data-id="treeViewLitreeViewItem.deps/remix-tests/remix_accounts.sol"]') .openFile('.deps/remix-tests/remix_tests.sol') From cb1620fe528255880c72ac24841abdc0ed9c232c Mon Sep 17 00:00:00 2001 From: David Disu Date: Thu, 30 Jun 2022 10:51:29 +0100 Subject: [PATCH 085/106] Fixed e2e tests --- .../src/tests/migrateFileSystem.test.ts | 4 ++-- apps/remix-ide-e2e/src/tests/workspace.test.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts b/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts index 3d04a3edfc..0914f6c2f5 100644 --- a/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts +++ b/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts @@ -81,7 +81,7 @@ module.exports = { // these are test data entries 'Should have a workspace_test #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000) - .click('*[data-id="workspacesSelect"] option[value="workspace_test"]') + .switchWorkspace('workspace_test') .waitForElementVisible('*[data-id="treeViewLitreeViewItemtest_contracts"]') }, 'Should have a sol file with test data #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) { @@ -103,7 +103,7 @@ module.exports = { }, 'Should have a empty workspace #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000) - .click('*[data-id="workspacesSelect"] option[value="emptyspace"]') + .switchWorkspace('emptyspace') }, // end of test data entries 'Should load with all storage blocked #group4': function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 95819b7598..aa0d2bbaf1 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -235,7 +235,7 @@ module.exports = { .pause(2000) .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]') .pause(2000) - .click('*[data-id="workspacesSelect"] option[value="workspace_name"]') + .switchWorkspace('workspace_name') .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]') }, @@ -249,23 +249,23 @@ module.exports = { .setValue('*[data-id="modalDialogCustomPromptTextRename"]', 'workspace_name_renamed') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .click('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') - .click('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') + .switchWorkspace('workspace_name_1') .pause(2000) .waitForElementNotPresent('*[data-id="treeViewLitreeViewItemtest.sol"]') - .waitForElementPresent('*[data-id="workspacesSelect"] option[value="workspace_name_renamed"]') - .click('*[data-id="workspacesSelect"] option[value="workspace_name_renamed"]') + .switchWorkspace('workspace_name_renamed') .pause(2000) .waitForElementVisible('*[data-id="treeViewLitreeViewItemtest.sol"]') }, 'Should delete a workspace #group1': function (browser: NightwatchBrowser) { browser - .click('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') + .switchWorkspace('workspace_name_1') .click('*[data-id="workspaceDelete"]') // delete workspace_name_1 .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .click('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') - .waitForElementNotPresent('*[data-id="workspacesSelect"] option[value="workspace_name_1"]') + .waitForElementVisible('[data-id="workspacesSelect"]') + .click('[data-id="workspacesSelect"]') + .waitForElementNotPresent(`[data-id="dropdown-item-workspace_name_1"]`) .end() }, From 22a668ccef018ee239d90756d818f457e694fe18 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 6 Jul 2022 14:15:09 +0100 Subject: [PATCH 086/106] Fixed found issues with clone UI --- .../settings/src/lib/github-settings.tsx | 4 ++-- .../settings/src/lib/settingsAction.ts | 4 ++-- .../workspace/src/lib/actions/workspace.ts | 22 ++++++++++++++----- .../workspace/src/lib/remix-ui-workspace.tsx | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/settings/src/lib/github-settings.tsx b/libs/remix-ui/settings/src/lib/github-settings.tsx index a52ca7507d..e7c9c3f2ce 100644 --- a/libs/remix-ui/settings/src/lib/github-settings.tsx +++ b/libs/remix-ui/settings/src/lib/github-settings.tsx @@ -46,8 +46,8 @@ export function GithubSettings (props: GithubSettingsProps) { return (
-
GitHub Access Token
-

Manage the access token used to publish to Gist and retrieve GitHub contents.

+
GitHub Credentials
+

Manage your GitHub credentials used to publish to Gist and retrieve GitHub contents.

Go to github token page (link below) to create a new token and save it in Remix. Make sure this token has only \'create gist\' permission.

https://github.com/settings/tokens

diff --git a/libs/remix-ui/settings/src/lib/settingsAction.ts b/libs/remix-ui/settings/src/lib/settingsAction.ts index b7a7eddd95..fc3bed1f4d 100644 --- a/libs/remix-ui/settings/src/lib/settingsAction.ts +++ b/libs/remix-ui/settings/src/lib/settingsAction.ts @@ -43,12 +43,12 @@ export const useMatomoAnalytics = (config, checked, dispatch) => { export const saveTokenToast = (config, dispatch, tokenValue, key) => { config.set('settings/' + key, tokenValue) - dispatch({ type: 'save', payload: { message: 'Access token has been saved' } }) + dispatch({ type: 'save', payload: { message: 'GitHub credentials updated' } }) } export const removeTokenToast = (config, dispatch, key) => { config.set('settings/' + key, '') - dispatch({ type: 'removed', payload: { message: 'Access token removed' } }) + dispatch({ type: 'removed', payload: { message: 'GitHub credentials removed' } }) } export const saveSwarmSettingsToast = (config, dispatch, privateBeeAddress, postageStampId) => { diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index ee8ade4f2b..12aab6f93d 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -331,7 +331,7 @@ export const getWorkspaces = async (): Promise<{name: string, isGitRepo: boolean export const cloneRepository = async (url: string) => { const config = plugin.registry.get('config').api - const token = config.get('currentFile') + const token = config.get('settings/gist-access-token') const repoConfig = { url, token } const urlArray = url.split('/') let repoName = urlArray.length > 0 ? urlArray[urlArray.length - 1] : '' @@ -349,10 +349,22 @@ export const cloneRepository = async (url: string) => { await fetchWorkspaceDirectory(repoName) dispatch(cloneRepositorySuccess()) }).catch((e) => { - dispatch(displayNotification('Clone Git Repository', 'An error occured: ' + e, 'Ok', null, async () => { - await deleteWorkspace(repoName) - dispatch(cloneRepositoryFailed()) - })) + const cloneModal = { + id: 'cloneGitRepository', + title: 'Clone Git Repository', + message: 'An error occured: ' + e, + modalType: 'modal', + okLabel: 'OK', + okFn: async () => { + await deleteWorkspace(repoName) + dispatch(cloneRepositoryFailed()) + }, + hideFn: async () => { + await deleteWorkspace(repoName) + dispatch(cloneRepositoryFailed()) + } + } + plugin.call('notification', 'modal', cloneModal) }) } catch (e) { dispatch(displayPopUp('An error occured: ' + e)) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 8bbe2a2703..5302d907ed 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -144,7 +144,7 @@ export function Workspace () { if (url) { global.dispatchCloneRepository(url) } else { - global.modal('Create Workspace', 'Please provide a valid github repository url.', 'OK', () => {}, '') + global.modal('Clone Git Repository', 'Please provide a valid git repository url.', 'OK', () => {}, '') } } From 438bd279c9674e90ddca5f98536ed4da810ba204 Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 6 Jul 2022 16:46:07 +0100 Subject: [PATCH 087/106] Fix failing test --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index ca54678a7b..accf71bdfb 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -41,7 +41,7 @@ module.exports = { .setValue('*[data-id="settingsTabGistAccessToken"]', '**********') .click('*[data-id="settingsTabSaveGistToken"]') .waitForElementVisible('*[data-shared="tooltipPopup"]', 5000) - .assert.containsText('*[data-shared="tooltipPopup"]', 'Access token has been saved') + .assert.containsText('*[data-shared="tooltipPopup"]', 'GitHub credentials updated') .pause(3000) }, From 5921febc35b94bb41c404fadac073b881f23466c Mon Sep 17 00:00:00 2001 From: David Disu Date: Wed, 6 Jul 2022 16:57:09 +0100 Subject: [PATCH 088/106] Fix generalSettings test --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index accf71bdfb..a4932b05fd 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -59,7 +59,7 @@ module.exports = { .pause(1000) .click('*[data-id="settingsTabRemoveGistToken"]') .waitForElementVisible('*[data-shared="tooltipPopup"]', 5000) - .assert.containsText('*[data-shared="tooltipPopup"]', 'Access token removed') + .assert.containsText('*[data-shared="tooltipPopup"]', 'GitHub credentials removed') .assert.containsText('*[data-id="settingsTabGistAccessToken"]', '') }, From 29e751756615078fb452e10b0c9cd5eb46de468e Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 7 Jul 2022 12:21:20 +0530 Subject: [PATCH 089/106] fix contract dropdown in UDApp --- .../src/lib/components/contractDropdownUI.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index 900b7dc2c4..b61563ef5b 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -57,10 +57,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) { content: currentFile }) enableAtAddress(true) - } else if (/.(.sol)$/.exec(currentFile) || - /.(.vy)$/.exec(currentFile) || // vyper - /.(.lex)$/.exec(currentFile) || // lexon - /.(.contract)$/.exec(currentFile)) { + } else if (isContractFile(currentFile)) { setAbiLabel({ display: 'none', content: '' @@ -115,6 +112,13 @@ export function ContractDropdownUI (props: ContractDropdownProps) { } } + const isContractFile = (file) => { + return /.(.sol)$/.exec(file) || + /.(.vy)$/.exec(file) || // vyper + /.(.lex)$/.exec(file) || // lexon + /.(.contract)$/.exec(file) + } + const enableAtAddress = (enable: boolean) => { if (enable) { setAtAddressOptions({ @@ -214,7 +218,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
- { (contractList[currentFile] || []).map((contract, index) => { return }) } @@ -258,7 +262,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
: '' }
-
or
+
or
Date: Thu, 7 Jul 2022 12:20:01 +0200 Subject: [PATCH 090/106] fixing bg color for custom-dropdown --- libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css index 29fd578d26..dab352564a 100644 --- a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css +++ b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css @@ -88,6 +88,7 @@ .custom-dropdown-items { padding: 0.25rem 0.25rem; border-radius: .25rem; + background: var(--light); } .custom-dropdown-items a { border-radius: .25rem; @@ -97,5 +98,6 @@ font-size: 0.875rem; padding: 0.25rem 0.25rem; width: auto; + color: var(--text); } \ No newline at end of file From 2d90f013a34a8cedadc8b06fdb7c0f5f0900f367 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 4 Jul 2022 19:23:02 +0200 Subject: [PATCH 091/106] add L2 networks --- apps/remix-ide/src/app.js | 6 ++ .../src/app/tabs/abstract-provider.tsx | 8 +-- .../tabs/injected-arbitrum-one-provider.tsx | 21 ++++++ .../app/tabs/injected-optimism-provider.tsx | 21 ++++++ .../src/app/tabs/injected-provider.tsx | 69 +++++++++++++++++++ apps/remix-ide/src/app/udapp/run-tab.js | 34 +++++++++ .../src/blockchain/execution-context.js | 20 ++++-- apps/remix-ide/src/remixAppManager.js | 2 +- 8 files changed, 171 insertions(+), 10 deletions(-) create mode 100644 apps/remix-ide/src/app/tabs/injected-arbitrum-one-provider.tsx create mode 100644 apps/remix-ide/src/app/tabs/injected-optimism-provider.tsx create mode 100644 apps/remix-ide/src/app/tabs/injected-provider.tsx diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 464356b902..d9c93fd4f6 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -29,6 +29,8 @@ import { HardhatProvider } from './app/tabs/hardhat-provider' import { GanacheProvider } from './app/tabs/ganache-provider' import { FoundryProvider } from './app/tabs/foundry-provider' import { ExternalHttpProvider } from './app/tabs/external-http-provider' +import { Injected0ptimismProvider } from './app/tabs/injected-optimism-provider' +import { InjectedArbitrumOneProvider } from './app/tabs/injected-arbitrum-one-provider' const isElectron = require('is-electron') @@ -181,6 +183,8 @@ class AppComponent { const ganacheProvider = new GanacheProvider(blockchain) const foundryProvider = new FoundryProvider(blockchain) const externalHttpProvider = new ExternalHttpProvider(blockchain) + const injected0ptimismProvider = new Injected0ptimismProvider(blockchain) + const injectedArbitrumOneProvider = new InjectedArbitrumOneProvider(blockchain) // ----------------- convert offset to line/column service ----------- const offsetToLineColumnConverter = new OffsetToLineColumnConverter() Registry.getInstance().put({ @@ -239,6 +243,8 @@ class AppComponent { ganacheProvider, foundryProvider, externalHttpProvider, + injected0ptimismProvider, + injectedArbitrumOneProvider, this.walkthroughService, search ]) diff --git a/apps/remix-ide/src/app/tabs/abstract-provider.tsx b/apps/remix-ide/src/app/tabs/abstract-provider.tsx index ff924a618a..31b1a4e317 100644 --- a/apps/remix-ide/src/app/tabs/abstract-provider.tsx +++ b/apps/remix-ide/src/app/tabs/abstract-provider.tsx @@ -3,21 +3,21 @@ import { AppModal, AlertModal, ModalTypes } from '@remix-ui/app' import { Blockchain } from '../../blockchain/blockchain' import { ethers } from 'ethers' -type JsonDataRequest = { +export type JsonDataRequest = { id: number, jsonrpc: string // version method: string, params: Array, } -type JsonDataResult = { +export type JsonDataResult = { id: number, jsonrpc: string // version result: any } -type RejectRequest = (error: Error) => void -type SuccessRequest = (data: JsonDataResult) => void +export type RejectRequest = (error: Error) => void +export type SuccessRequest = (data: JsonDataResult) => void export abstract class AbstractProvider extends Plugin { provider: ethers.providers.JsonRpcProvider diff --git a/apps/remix-ide/src/app/tabs/injected-arbitrum-one-provider.tsx b/apps/remix-ide/src/app/tabs/injected-arbitrum-one-provider.tsx new file mode 100644 index 0000000000..283dacdf24 --- /dev/null +++ b/apps/remix-ide/src/app/tabs/injected-arbitrum-one-provider.tsx @@ -0,0 +1,21 @@ +import * as packageJson from '../../../../../package.json' +import { InjectedProvider } from './injected-provider' + +const profile = { + name: 'injected-arbitrum-one-provider', + displayName: 'Injected Arbitrum One Provider', + kind: 'provider', + description: 'injected Arbitrum One Provider', + methods: ['sendAsync'], + version: packageJson.version +} + +export class InjectedArbitrumOneProvider extends InjectedProvider { + + constructor () { + super(profile) + this.chainName = 'Arbitrum One' + this.chainId = '0xa4b1' + this.rpcUrls = ['https://arb1.arbitrum.io/rpc'] + } +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/tabs/injected-optimism-provider.tsx b/apps/remix-ide/src/app/tabs/injected-optimism-provider.tsx new file mode 100644 index 0000000000..64c8c4e91a --- /dev/null +++ b/apps/remix-ide/src/app/tabs/injected-optimism-provider.tsx @@ -0,0 +1,21 @@ +import * as packageJson from '../../../../../package.json' +import { InjectedProvider } from './injected-provider' + +const profile = { + name: 'injected-optimism-provider', + displayName: 'Injected Optimism Provider', + kind: 'provider', + description: 'injected Optimism Provider', + methods: ['sendAsync'], + version: packageJson.version +} + +export class Injected0ptimismProvider extends InjectedProvider { + + constructor () { + super(profile) + this.chainName = 'Optimism' + this.chainId = '0xa' + this.rpcUrls = ['https://mainnet.optimism.io'] + } +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/tabs/injected-provider.tsx b/apps/remix-ide/src/app/tabs/injected-provider.tsx new file mode 100644 index 0000000000..a633c66a64 --- /dev/null +++ b/apps/remix-ide/src/app/tabs/injected-provider.tsx @@ -0,0 +1,69 @@ +import { Plugin } from '@remixproject/engine' +import { JsonDataRequest, RejectRequest, SuccessRequest } from './abstract-provider' +import { ethers } from 'ethers' +import Web3 from 'web3' + +export class InjectedProvider extends Plugin { + provider: any + chainName: string + chainId: string + rpcUrls: Array + + constructor (profile) { + super(profile) + this.provider = new Web3((window as any).ethereum) + } + + sendAsync (data: JsonDataRequest): Promise { + return new Promise((resolve, reject) => { + this.sendAsyncInternal(data, resolve, reject) + }) + } + + private async sendAsyncInternal (data: JsonDataRequest, resolve: SuccessRequest, reject: RejectRequest): Promise { + // Check the case where current environment is VM on UI and it still sends RPC requests + // This will be displayed on UI tooltip as 'cannot get account list: Environment Updated !!' + + try { + if ((window as any) && typeof (window as any).ethereum.enable === 'function') (window as any).ethereum.enable() + await addL2Network(this.chainName, this.chainId, this.rpcUrls) + const resultData = await this.provider.currentProvider.send(data.method, data.params) + resolve({ jsonrpc: '2.0', result: resultData.result, id: data.id }) + } catch (error) { + reject(error) + } + } +} + +export const addL2Network = async (chainName: string, chainId: string, rpcUrls: Array) => { + try { + await (window as any).ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: chainId }], + }); + } catch (switchError) { + // This error code indicates that the chain has not been added to MetaMask. + if (switchError.code === 4902) { + try { + await (window as any).ethereum.request({ + method: 'wallet_addEthereumChain', + params: [ + { + chainId: chainId, + chainName: chainName, + rpcUrls: rpcUrls, + }, + ], + }); + + await (window as any).ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: chainId }], + }); + } catch (addError) { + // handle "add" error + } + } + // handle other "switch" errors + } +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/udapp/run-tab.js b/apps/remix-ide/src/app/udapp/run-tab.js index cf71ad3780..c9912ecb4c 100644 --- a/apps/remix-ide/src/app/udapp/run-tab.js +++ b/apps/remix-ide/src/app/udapp/run-tab.js @@ -102,6 +102,7 @@ export class RunTab extends ViewPlugin { await this.call('blockchain', 'addProvider', { name: 'Hardhat Provider', + isInjected: false, provider: { async sendAsync (payload, callback) { try { @@ -116,6 +117,7 @@ export class RunTab extends ViewPlugin { await this.call('blockchain', 'addProvider', { name: 'Ganache Provider', + isInjected: false, provider: { async sendAsync (payload, callback) { try { @@ -130,6 +132,7 @@ export class RunTab extends ViewPlugin { await this.call('blockchain', 'addProvider', { name: 'Foundry Provider', + isInjected: false, provider: { async sendAsync (payload, callback) { try { @@ -144,6 +147,7 @@ export class RunTab extends ViewPlugin { await this.call('blockchain', 'addProvider', { name: 'Wallet Connect', + isInjected: false, provider: { async sendAsync (payload, callback) { try { @@ -169,6 +173,36 @@ export class RunTab extends ViewPlugin { } } }) + + await this.call('blockchain', 'addProvider', { + name: 'Optimism Provider', + isInjected: true, + provider: { + async sendAsync (payload, callback) { + try { + const result = await udapp.call('injected-optimism-provider', 'sendAsync', payload) + callback(null, result) + } catch (e) { + callback(e) + } + } + } + }) + + await this.call('blockchain', 'addProvider', { + name: 'Arbitrum One Provider', + isInjected: true, + provider: { + async sendAsync (payload, callback) { + try { + const result = await udapp.call('injected-arbitrum-one-provider', 'sendAsync', payload) + callback(null, result) + } catch (e) { + callback(e) + } + } + } + }) } writeFile (fileName, content) { diff --git a/apps/remix-ide/src/blockchain/execution-context.js b/apps/remix-ide/src/blockchain/execution-context.js index 95b4abe45d..b04e83d656 100644 --- a/apps/remix-ide/src/blockchain/execution-context.js +++ b/apps/remix-ide/src/blockchain/execution-context.js @@ -166,11 +166,21 @@ export class ExecutionContext { if (this.customNetWorks[context]) { var network = this.customNetWorks[context] - this.setProviderFromEndpoint(network.provider, { context: network.name }, (error) => { - if (error) infoCb(error) - cb() - }) - } + if (!this.customNetWorks[context].isInjected) { + this.setProviderFromEndpoint(network.provider, { context: network.name }, (error) => { + if (error) infoCb(error) + cb() + }) + } else { + // injected + this.askPermission() + this.executionContext = context + web3.setProvider(network.provider) + await this._updateChainContext() + this.event.trigger('contextChanged', [context]) + return cb() + } + } } currentblockGasLimit () { diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 9c00f8ab46..fbe147a67b 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -19,7 +19,7 @@ const sensitiveCalls = { } export function isNative(name) { - const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'solidity-logic', 'solidityStaticAnalysis', 'solidityUnitTesting', 'layout', 'notification', 'hardhat-provider', 'ganache-provider', 'foundry-provider', 'basic-http-provider'] + const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'solidity-logic', 'solidityStaticAnalysis', 'solidityUnitTesting', 'layout', 'notification', 'hardhat-provider', 'ganache-provider', 'foundry-provider', 'basic-http-provider', 'injected-optimism-provider', 'injected-arbitrum-one-provider'] return nativePlugins.includes(name) || requiredModules.includes(name) } From 2d6ba7d3db3d475011dae08e2338fc3c7746d1c1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Jul 2022 09:39:32 +0200 Subject: [PATCH 092/106] move custom dropdown to helper --- libs/remix-ui/helper/src/index.ts | 3 ++- .../src/lib/components/custom-dropdown.tsx | 0 libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename libs/remix-ui/{workspace => helper}/src/lib/components/custom-dropdown.tsx (100%) diff --git a/libs/remix-ui/helper/src/index.ts b/libs/remix-ui/helper/src/index.ts index 36d73ef523..9f050ea8b8 100644 --- a/libs/remix-ui/helper/src/index.ts +++ b/libs/remix-ui/helper/src/index.ts @@ -1,3 +1,4 @@ export * from './lib/remix-ui-helper' export * from './lib/helper-components' -export * from './lib/components/PluginViewWrapper' \ No newline at end of file +export * from './lib/components/PluginViewWrapper' +export * from './lib/components/custom-dropdown' \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/components/custom-dropdown.tsx b/libs/remix-ui/helper/src/lib/components/custom-dropdown.tsx similarity index 100% rename from libs/remix-ui/workspace/src/lib/components/custom-dropdown.tsx rename to libs/remix-ui/helper/src/lib/components/custom-dropdown.tsx diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 5302d907ed..0870442cb2 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef, useContext } from 'react' // eslint-disable-line import { Dropdown } from 'react-bootstrap' -import { CustomMenu, CustomToggle } from './components/custom-dropdown' +import { CustomMenu, CustomToggle } from '@remix-ui/helper' import { FileExplorer } from './components/file-explorer' // eslint-disable-line import { FileSystemContext } from './contexts' import './css/remix-ui-workspace.css' From ef5e310d4895c9fe3f56cd5c778bc5177b9680aa Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Jul 2022 10:02:55 +0200 Subject: [PATCH 093/106] use custom dropdown --- .../src/lib/components/environment.tsx | 60 +++++++++++++++---- libs/remix-ui/run-tab/src/lib/css/run-tab.css | 3 + 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index be6b4a3f94..0a311deb30 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -1,8 +1,13 @@ // eslint-disable-next-line no-use-before-define import React from 'react' import { EnvironmentProps } from '../types' +import { Dropdown } from 'react-bootstrap' +import { CustomMenu, CustomToggle } from '@remix-ui/helper' +import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line export function EnvironmentUI (props: EnvironmentProps) { + + const handleChangeExEnv = (env: string) => { const provider = props.providers.providerList.find(exEnv => exEnv.value === env) const fork = provider.fork // can be undefined if connected to an external source (web3 provider / injected) @@ -13,22 +18,55 @@ export function EnvironmentUI (props: EnvironmentProps) { props.setExecutionContext({ context, fork }) } + const currentProvider = props.providers.providerList.find(exEnv => exEnv.value === props.selectedEnv) + const bridges = { + 'Optimism Provider': 'https://www.optimism.io/apps/bridges', + 'Arbitrum One Provider': 'https://bridge.arbitrum.io/' + } + + + const isL2 = (provider) => provider && (provider.value === 'Optimism Provider' || provider.value === 'Arbitrum One Provider') return (
- + + + + { isL2(currentProvider) && 'L2 - '} + { currentProvider && currentProvider.content } + { currentProvider && bridges[currentProvider.value] && + Click here to open a bridge. + + }> + + } + + + { + props.providers.providerList.map(({ content, value }, index) => ( + { + handleChangeExEnv(value) + }} + data-id={`dropdown-item-${value}`} + > + { isL2({ value }) && 'L2 - ' }{ content } + + )) + } + +
diff --git a/libs/remix-ui/run-tab/src/lib/css/run-tab.css b/libs/remix-ui/run-tab/src/lib/css/run-tab.css index c4c65e4e01..2921381007 100644 --- a/libs/remix-ui/run-tab/src/lib/css/run-tab.css +++ b/libs/remix-ui/run-tab/src/lib/css/run-tab.css @@ -529,4 +529,7 @@ text-decoration: none; background-color: #007aa6; } +.udapp_selectExEnvOptions { + width: 100%; +} From 6e8d95a13bbd7c82fd74d01adab7e0c6e7287107 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 6 Jul 2022 12:24:07 +0200 Subject: [PATCH 094/106] fix tests --- .../src/commands/switchEnvironment.ts | 18 ++++++++++++++++++ apps/remix-ide-e2e/src/tests/ballot.test.ts | 5 +++-- .../src/tests/ballot_0_4_11.test.ts | 4 ++-- apps/remix-ide-e2e/src/tests/debugger.test.ts | 8 ++++---- apps/remix-ide-e2e/src/tests/plugin_api.ts | 4 ++-- apps/remix-ide-e2e/src/tests/providers.test.ts | 8 ++++---- .../src/tests/runAndDeploy.test.ts | 2 +- apps/remix-ide-e2e/src/tests/terminal.test.ts | 6 +++--- .../src/tests/transactionExecution.test.ts | 2 +- apps/remix-ide-e2e/src/types/index.d.ts | 1 + 10 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 apps/remix-ide-e2e/src/commands/switchEnvironment.ts diff --git a/apps/remix-ide-e2e/src/commands/switchEnvironment.ts b/apps/remix-ide-e2e/src/commands/switchEnvironment.ts new file mode 100644 index 0000000000..03564ced41 --- /dev/null +++ b/apps/remix-ide-e2e/src/commands/switchEnvironment.ts @@ -0,0 +1,18 @@ +import { NightwatchBrowser } from 'nightwatch' +import EventEmitter from 'events' + +class switchEnvironment extends EventEmitter { + command (this: NightwatchBrowser, provider: string): NightwatchBrowser { + this.api.waitForElementVisible('[data-id="settingsSelectEnvOptions"]') + .click('[data-id="settingsSelectEnvOptions"] button') + .waitForElementVisible(`[data-id="dropdown-item-${provider}"]`) + .click(`[data-id="dropdown-item-${provider}"]`) + .perform((done) => { + done() + this.emit('complete') + }) + return this + } +} + +module.exports = switchEnvironment diff --git a/apps/remix-ide-e2e/src/tests/ballot.test.ts b/apps/remix-ide-e2e/src/tests/ballot.test.ts index 9d2e9c5b07..0fd5fa1788 100644 --- a/apps/remix-ide-e2e/src/tests/ballot.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot.test.ts @@ -83,14 +83,15 @@ module.exports = { browser .openFile('Untitled.sol') .clickLaunchIcon('udapp') - .click('*[data-id="settingsSelectEnvOptions"] *[data-id="External Http Provider"]') - .waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]') + .switchEnvironment('web3') + .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="basic-http-provider-modal-footer-ok-react"]') as any modal.click() }) .pause(5000) + .waitForElementContainsText('#selectExEnvOptions button', 'External HTTP Provider') .execute(function () { const env: any = document.getElementById('selectExEnvOptions') diff --git a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts index 95696e3882..afe6a8545b 100644 --- a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts @@ -78,8 +78,8 @@ module.exports = { browser .openFile('Untitled.sol') .clickLaunchIcon('udapp') - .click('*[data-id="settingsSelectEnvOptions"] *[data-id="External Http Provider"]') - .waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]') + .switchEnvironment('web3') + .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="basic-http-provider-modal-footer-ok-react"]') as any diff --git a/apps/remix-ide-e2e/src/tests/debugger.test.ts b/apps/remix-ide-e2e/src/tests/debugger.test.ts index 9b8da7e7df..bc8db41a09 100644 --- a/apps/remix-ide-e2e/src/tests/debugger.test.ts +++ b/apps/remix-ide-e2e/src/tests/debugger.test.ts @@ -214,10 +214,10 @@ module.exports = { .setSolidityCompilerVersion('soljson-v0.8.7+commit.e28d00a7.js') .addFile('useDebugNodes.sol', sources[5]['useDebugNodes.sol']) // compile contract .clickLaunchIcon('udapp') - .click('*[data-id="settingsSelectEnvOptions"] *[data-id="External Http Provider"]') // select web3 provider with debug nodes URL - .clearValue('*[data-id="modalDialogCustomPromp"]') - .setValue('*[data-id="modalDialogCustomPromp"]', 'https://remix-rinkeby.ethdevops.io') - .modalFooterOKClick('basic-http-provider') + .switchEnvironment('web3') // select web3 provider with debug nodes URL + .clearValue('*[data-id="modalDialogCustomPromptText"]') + .setValue('*[data-id="modalDialogCustomPromptText"]', 'https://remix-rinkeby.ethdevops.io') + .modalFooterOKClick() .waitForElementPresent('*[title="Deploy - transact (not payable)"]', 65000) // wait for the compilation to succeed .clickLaunchIcon('debugger') .clearValue('*[data-id="debuggerTransactionInput"]') diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index f05a2fe130..c7ef41a231 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts @@ -188,7 +188,7 @@ module.exports = { .frameParent() .useCss() .clickLaunchIcon('udapp') - .waitForElementContainsText('#selectExEnvOptions option:checked', 'Remix VM (Berlin)') + .waitForElementContainsText('#selectExEnvOptions button', 'Remix VM (Berlin)') .clickLaunchIcon('localPlugin') .useXpath() // @ts-ignore @@ -391,7 +391,7 @@ module.exports = { .useCss() .clickLaunchIcon('pluginManager') .clickLaunchIcon('udapp') - .click('*[data-id="Hardhat Provider"]') + .switchEnvironment('Hardhat Provider') .modalFooterOKClick('hardhat-provider') .waitForElementContainsText('*[data-id="settingsNetworkEnv"]', 'Custom') // e.g Custom (1337) network .clickLaunchIcon('localPlugin') diff --git a/apps/remix-ide-e2e/src/tests/providers.test.ts b/apps/remix-ide-e2e/src/tests/providers.test.ts index fe6dcde8bf..5cb1048d91 100644 --- a/apps/remix-ide-e2e/src/tests/providers.test.ts +++ b/apps/remix-ide-e2e/src/tests/providers.test.ts @@ -10,7 +10,7 @@ module.exports = { 'Should switch to ganache provider, set a custom URL and fail to connect': function (browser: NightwatchBrowser) { browser.waitForElementVisible('div[data-id="remixIdeIconPanel"]', 10000) .clickLaunchIcon('udapp') - .click('*[data-id="Ganache Provider"]') + .switchEnvironment('Ganache Provider') .waitForElementVisible('*[data-id="ganache-providerModalDialogModalBody-react"]') .execute(() => { (document.querySelector('*[data-id="ganache-providerModalDialogModalBody-react"] input') as any).focus() @@ -25,7 +25,7 @@ module.exports = { }, 'Should switch to ganache provider, use the default ganache URL and succeed to connect': function (browser: NightwatchBrowser) { - browser.click('*[data-id="Ganache Provider"]') + browser.switchEnvironment('Ganache Provider') .waitForElementVisible('*[data-id="ganache-providerModalDialogModalBody-react"]') .modalFooterOKClick('ganache-provider') .waitForElementContainsText('*[data-id="settingsNetworkEnv"]', 'Custom (') @@ -33,7 +33,7 @@ module.exports = { 'Should switch to foundry provider, set a custom URL and fail to connect': function (browser: NightwatchBrowser) { browser.waitForElementVisible('div[data-id="remixIdeIconPanel"]', 10000) - .click('*[data-id="Foundry Provider"]') + .switchEnvironment('Foundry Provider') .waitForElementVisible('*[data-id="foundry-providerModalDialogModalBody-react"]') .execute(() => { (document.querySelector('*[data-id="foundry-providerModalDialogModalBody-react"] input') as any).focus() @@ -48,7 +48,7 @@ module.exports = { }, 'Should switch to foundry provider, use the default foundry URL and succeed to connect': function (browser: NightwatchBrowser) { - browser.click('*[data-id="Foundry Provider"]') + browser.switchEnvironment('Foundry Provider') .waitForElementVisible('*[data-id="foundry-providerModalDialogModalBody-react"]') .modalFooterOKClick('foundry-provider') .waitForElementContainsText('*[data-id="settingsNetworkEnv"]', 'Custom (') diff --git a/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts b/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts index dc00530bdd..6d87899d79 100644 --- a/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts +++ b/apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts @@ -32,7 +32,7 @@ module.exports = { 'Should sign message using account key #group2': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="settingsRemixRunSignMsg"]') - .click('select[id="selectExEnvOptions"] option[value="vm-berlin"]') + .switchEnvironment('vm-berlin') .pause(2000) .click('*[data-id="settingsRemixRunSignMsg"]') .pause(2000) diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index 59af766031..610875074f 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -50,8 +50,8 @@ module.exports = { browser .click('*[data-id="terminalClearConsole"]') // clear the terminal .clickLaunchIcon('udapp') - .click('*[data-id="settingsSelectEnvOptions"] *[data-id="External Http Provider"]') - .modalFooterOKClick('basic-http-provider') + .switchEnvironment('web3') + .modalFooterOKClick('envNotification') .executeScript('web3.eth.getAccounts()') .waitForElementContainsText('*[data-id="terminalJournal"]', '["', 60000) // we check if an array is present, don't need to check for the content .waitForElementContainsText('*[data-id="terminalJournal"]', '"]', 60000) @@ -95,7 +95,7 @@ module.exports = { browser .clickLaunchIcon('settings') .clickLaunchIcon('udapp') - .click('*[data-id="settingsVMLondonMode"]') + .switchEnvironment('vm-london') .click('*[data-id="terminalClearConsole"]') // clear the terminal .clickLaunchIcon('filePanel') .click('*[data-id="treeViewDivtreeViewItem"]') // make sure we create the file at the root folder diff --git a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts index 3eac406fcd..842da3b3c7 100644 --- a/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts +++ b/apps/remix-ide-e2e/src/tests/transactionExecution.test.ts @@ -161,7 +161,7 @@ module.exports = { browser .clickLaunchIcon('udapp') .clearTransactions() - .click('*[data-id="settingsVMLondonMode"]') // switch to London fork + .switchEnvironment('vm-london') // switch to London fork .selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') // this account will be used for this test suite .click('.udapp_contractActionsContainerSingle > button') .clickInstance(0) diff --git a/apps/remix-ide-e2e/src/types/index.d.ts b/apps/remix-ide-e2e/src/types/index.d.ts index eccd50bad5..9ba94f470b 100644 --- a/apps/remix-ide-e2e/src/types/index.d.ts +++ b/apps/remix-ide-e2e/src/types/index.d.ts @@ -64,6 +64,7 @@ declare module 'nightwatch' { getBrowserLogs (this: NightwatchBrowser): NightwatchBrowser currentSelectedFileIs (name: string): NightwatchBrowser, switchWorkspace: (workspaceName: string) => NightwatchBrowser + switchEnvironment: (provider: string) => NightwatchBrowser } export interface NightwatchBrowser { From 918465f785a10a73247769a451be7f05290ca41a Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Jul 2022 14:21:45 +0200 Subject: [PATCH 095/106] fix tests --- apps/remix-ide-e2e/src/tests/ballot.test.ts | 2 +- apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts | 2 +- apps/remix-ide-e2e/src/tests/debugger.test.ts | 2 +- apps/remix-ide-e2e/src/tests/terminal.test.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/ballot.test.ts b/apps/remix-ide-e2e/src/tests/ballot.test.ts index 0fd5fa1788..7d562d8e19 100644 --- a/apps/remix-ide-e2e/src/tests/ballot.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot.test.ts @@ -83,7 +83,7 @@ module.exports = { browser .openFile('Untitled.sol') .clickLaunchIcon('udapp') - .switchEnvironment('web3') + .switchEnvironment('External Http Provider') .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="basic-http-provider-modal-footer-ok-react"]') as any diff --git a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts index afe6a8545b..b6ac2edc53 100644 --- a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts @@ -78,7 +78,7 @@ module.exports = { browser .openFile('Untitled.sol') .clickLaunchIcon('udapp') - .switchEnvironment('web3') + .switchEnvironment('External Http Provider') .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="basic-http-provider-modal-footer-ok-react"]') as any diff --git a/apps/remix-ide-e2e/src/tests/debugger.test.ts b/apps/remix-ide-e2e/src/tests/debugger.test.ts index bc8db41a09..19aa196b60 100644 --- a/apps/remix-ide-e2e/src/tests/debugger.test.ts +++ b/apps/remix-ide-e2e/src/tests/debugger.test.ts @@ -214,7 +214,7 @@ module.exports = { .setSolidityCompilerVersion('soljson-v0.8.7+commit.e28d00a7.js') .addFile('useDebugNodes.sol', sources[5]['useDebugNodes.sol']) // compile contract .clickLaunchIcon('udapp') - .switchEnvironment('web3') // select web3 provider with debug nodes URL + .switchEnvironment('External Http Provider') // select web3 provider with debug nodes URL .clearValue('*[data-id="modalDialogCustomPromptText"]') .setValue('*[data-id="modalDialogCustomPromptText"]', 'https://remix-rinkeby.ethdevops.io') .modalFooterOKClick() diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index 610875074f..4a451eba20 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -50,7 +50,7 @@ module.exports = { browser .click('*[data-id="terminalClearConsole"]') // clear the terminal .clickLaunchIcon('udapp') - .switchEnvironment('web3') + .switchEnvironment('External Http Provider') .modalFooterOKClick('envNotification') .executeScript('web3.eth.getAccounts()') .waitForElementContainsText('*[data-id="terminalJournal"]', '["', 60000) // we check if an array is present, don't need to check for the content From 01d6856a28433d57dbffe1409c063fe0fb4e186f Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Jul 2022 14:31:05 +0200 Subject: [PATCH 096/106] notify if no injected provider --- apps/remix-ide/src/app/tabs/injected-provider.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/injected-provider.tsx b/apps/remix-ide/src/app/tabs/injected-provider.tsx index a633c66a64..77f36f08f5 100644 --- a/apps/remix-ide/src/app/tabs/injected-provider.tsx +++ b/apps/remix-ide/src/app/tabs/injected-provider.tsx @@ -11,7 +11,9 @@ export class InjectedProvider extends Plugin { constructor (profile) { super(profile) - this.provider = new Web3((window as any).ethereum) + if ((window as any).ethereum) { + this.provider = new Web3((window as any).ethereum) + } } sendAsync (data: JsonDataRequest): Promise { @@ -23,7 +25,10 @@ export class InjectedProvider extends Plugin { private async sendAsyncInternal (data: JsonDataRequest, resolve: SuccessRequest, reject: RejectRequest): Promise { // Check the case where current environment is VM on UI and it still sends RPC requests // This will be displayed on UI tooltip as 'cannot get account list: Environment Updated !!' - + if (!this.provider) { + this.call('notification', 'toast', 'No injected provider (e.g Metamask) has been found.') + return reject(new Error('no injected provider found.')) + } try { if ((window as any) && typeof (window as any).ethereum.enable === 'function') (window as any).ethereum.enable() await addL2Network(this.chainName, this.chainId, this.rpcUrls) From dbed44a3453b701166ffec828e84575efb6c6a44 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Jul 2022 14:43:56 +0200 Subject: [PATCH 097/106] fix tests --- apps/remix-ide-e2e/src/tests/ballot.test.ts | 2 +- apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts | 2 +- apps/remix-ide-e2e/src/tests/terminal.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/ballot.test.ts b/apps/remix-ide-e2e/src/tests/ballot.test.ts index 7d562d8e19..f857f1a385 100644 --- a/apps/remix-ide-e2e/src/tests/ballot.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot.test.ts @@ -84,7 +84,7 @@ module.exports = { .openFile('Untitled.sol') .clickLaunchIcon('udapp') .switchEnvironment('External Http Provider') - .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') + .waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="basic-http-provider-modal-footer-ok-react"]') as any diff --git a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts index b6ac2edc53..9a36ad67f4 100644 --- a/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts +++ b/apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts @@ -79,7 +79,7 @@ module.exports = { .openFile('Untitled.sol') .clickLaunchIcon('udapp') .switchEnvironment('External Http Provider') - .waitForElementPresent('[data-id="envNotification-modal-footer-ok-react"]') + .waitForElementPresent('[data-id="basic-http-provider-modal-footer-ok-react"]') .execute(function () { const modal = document.querySelector('[data-id="basic-http-provider-modal-footer-ok-react"]') as any diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index 4a451eba20..c061d8fd39 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -51,7 +51,7 @@ module.exports = { .click('*[data-id="terminalClearConsole"]') // clear the terminal .clickLaunchIcon('udapp') .switchEnvironment('External Http Provider') - .modalFooterOKClick('envNotification') + .modalFooterOKClick('basic-http-provider') .executeScript('web3.eth.getAccounts()') .waitForElementContainsText('*[data-id="terminalJournal"]', '["', 60000) // we check if an array is present, don't need to check for the content .waitForElementContainsText('*[data-id="terminalJournal"]', '"]', 60000) From f155b64a98978d0e459c220efde09ce884443481 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Jul 2022 15:14:44 +0200 Subject: [PATCH 098/106] update labels --- libs/remix-ui/run-tab/src/lib/components/environment.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx index 0a311deb30..6a346fcf53 100644 --- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx @@ -31,7 +31,7 @@ export function EnvironmentUI (props: EnvironmentProps) {