From d9970eefa1b6ac14c9f4e618092f68793c934bc6 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 18 Aug 2021 08:30:44 +0200 Subject: [PATCH 01/21] removed swarm from home tab --- apps/remix-ide/src/app/ui/landing-page/landing-page.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 60d762472f..744b5c988b 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -538,7 +538,6 @@ export class LandingPage extends ViewPlugin {
-
From eb9c482083684125ad02cda530afb2da41fb16a3 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Mon, 9 Aug 2021 16:34:17 +0100 Subject: [PATCH 02/21] Show errors on every compilation --- libs/remix-ui/renderer/src/lib/renderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 4f0795875c..643580b721 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -57,7 +57,7 @@ export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugi setMessageText(text) setEditorOptions(options) setClose(false) - }, [message]) + }, [message, opt]) const getPositionDetails = (msg: any) => { const result = { } as Record From fc5f3829e11eb3f974da5511add422191cd7caf9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 11 Aug 2021 16:15:14 +0200 Subject: [PATCH 03/21] display global variables while debugging --- libs/remix-simulator/src/methods/blocks.ts | 2 ++ .../src/methods/transactions.ts | 3 ++ libs/remix-simulator/test/blocks.ts | 1 + .../debugger-ui/src/lib/debugger-ui.tsx | 12 +++++++- .../src/lib/vm-debugger/global-variables.tsx | 28 +++++++++++++++++++ .../src/lib/vm-debugger/vm-debugger-head.tsx | 1 + .../src/lib/vm-debugger/vm-debugger.tsx | 4 ++- 7 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx diff --git a/libs/remix-simulator/src/methods/blocks.ts b/libs/remix-simulator/src/methods/blocks.ts index 7ac7bc179f..d40f13c491 100644 --- a/libs/remix-simulator/src/methods/blocks.ts +++ b/libs/remix-simulator/src/methods/blocks.ts @@ -41,6 +41,7 @@ export class Blocks { } const b = { + baseFeePerGas: '0x01', number: this.toHex(block.header.number), hash: this.toHex(block.hash()), parentHash: this.toHex(block.header.parentHash), @@ -73,6 +74,7 @@ export class Blocks { const block = this.vmContext.blocks[payload.params[0]] const b = { + baseFeePerGas: '0x01', number: this.toHex(block.header.number), hash: this.toHex(block.hash()), parentHash: this.toHex(block.header.parentHash), diff --git a/libs/remix-simulator/src/methods/transactions.ts b/libs/remix-simulator/src/methods/transactions.ts index 91f1f00a30..fcbf57f960 100644 --- a/libs/remix-simulator/src/methods/transactions.ts +++ b/libs/remix-simulator/src/methods/transactions.ts @@ -193,6 +193,7 @@ export class Transactions { blockNumber: '0x' + txBlock.header.number.toString('hex'), from: receipt.from, gas: Web3.utils.toHex(receipt.gas), + chainId: '0xb', // 'gasPrice': '2000000000000', // 0x123 gasPrice: '0x4a817c800', // 20000000000 hash: receipt.transactionHash, @@ -239,6 +240,7 @@ export class Transactions { blockNumber: '0x' + txBlock.header.number.toString('hex'), from: receipt.from, gas: Web3.utils.toHex(receipt.gas), + chainId: '0xb', // 'gasPrice': '2000000000000', // 0x123 gasPrice: '0x4a817c800', // 20000000000 hash: receipt.transactionHash, @@ -282,6 +284,7 @@ export class Transactions { from: receipt.from, gas: Web3.utils.toHex(receipt.gas), // 'gasPrice': '2000000000000', // 0x123 + chainId: '0xb', gasPrice: '0x4a817c800', // 20000000000 hash: receipt.transactionHash, input: receipt.input, diff --git a/libs/remix-simulator/test/blocks.ts b/libs/remix-simulator/test/blocks.ts index 7a78b44ed8..9ef7df7537 100644 --- a/libs/remix-simulator/test/blocks.ts +++ b/libs/remix-simulator/test/blocks.ts @@ -18,6 +18,7 @@ describe('blocks', () => { const block = await web3.eth.getBlock(0) const expectedBlock = { + baseFeePerGas: '0x01', difficulty: '69762765929000', extraData: '0x0', gasLimit: 8000000, 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 ac802457e2..0def604fdc 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -20,6 +20,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => { contractAddress: null, to: null }, + currentBlock: null, + currentTransaction: null, blockNumber: null, txNumber: '', debugging: false, @@ -137,6 +139,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => { contractAddress: null, to: null }, + currentBlock: null, + currentTransaction: null, blockNumber: null, ready: { vmDebugger: false, @@ -182,8 +186,12 @@ export const DebuggerUI = (props: DebuggerUIProps) => { console.error(e) } let currentReceipt + let currentBlock + let currentTransaction try { currentReceipt = await web3.eth.getTransactionReceipt(txNumber) + currentBlock = await web3.eth.getBlock(currentReceipt.blockHash) + currentTransaction = await web3.eth.getTransaction(txNumber) } catch (e) { setState(prevState => { return { @@ -220,6 +228,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => { txNumber, debugging: true, currentReceipt, + currentBlock, + currentTransaction, debugger: debuggerInstance, toastMessage: `debugging ${txNumber}`, validationError: '' @@ -293,7 +303,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { { state.debugging && } { state.debugging && } - { state.debugging && } + { state.debugging && } ) } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx new file mode 100644 index 0000000000..ae6a3dc15f --- /dev/null +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx @@ -0,0 +1,28 @@ +import React from 'react' // eslint-disable-line +import DropdownPanel from './dropdown-panel' // eslint-disable-line +import { BN } from 'ethereumjs-util' + +export const GlobalVariables = ({ block, receipt, tx }) => { + console.log(block, receipt, tx) + // see https://docs.soliditylang.org/en/latest/units-and-global-variables.html#block-and-transaction-properties + const globals = { + 'block.basefee': (new BN(block.baseFeePerGas.replace('0x', ''), 'hex')).toString(10) + ` Wei (${block.baseFeePerGas})`, + 'block.chainid': tx.chainId, + 'block.coinbase': block.miner, + 'block.difficulty': block.difficulty, + 'block.gaslimit': block.gasLimit, + 'block.number': block.number, + 'block.timestamp': block.timestamp, + 'msg.sender': tx.from, + 'msg.sig': tx.input.substring(0, 10), + 'msg.value': tx.value + ' Wei', + 'tx.origin': tx.from + } + return ( +
+ +
+ ) +} + +export default GlobalVariables diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx index 8a951cf4fa..3a58c1d2f4 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx @@ -15,6 +15,7 @@ export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent } }) 'remaining gas': '-', 'loaded address': '-' }) + const [solidityState, setSolidityState] = useState({ calldata: null, message: null diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx index a02b95a377..5bfad2c186 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx @@ -6,8 +6,9 @@ import StackPanel from './stack-panel' // eslint-disable-line import StoragePanel from './storage-panel' // eslint-disable-line import ReturnValuesPanel from './dropdown-panel' // eslint-disable-line import FullStoragesChangesPanel from './full-storages-changes' // eslint-disable-line +import GlobalVariables from './global-variables' // eslint-disable-line -export const VmDebugger = ({ vmDebugger: { registerEvent } }) => { +export const VmDebugger = ({ vmDebugger: { registerEvent }, currentBlock, currentReceipt, currentTransaction }) => { const [calldataPanel, setCalldataPanel] = useState(null) const [memoryPanel, setMemoryPanel] = useState(null) const [callStackPanel, setCallStackPanel] = useState(null) @@ -58,6 +59,7 @@ export const VmDebugger = ({ vmDebugger: { registerEvent } }) => { + From 9f9f319baa31c407be97a6739584000c0355a647 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 18 Aug 2021 10:09:03 +0200 Subject: [PATCH 04/21] remove console.log --- .../debugger-ui/src/lib/vm-debugger/global-variables.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx index ae6a3dc15f..db26cf980b 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/global-variables.tsx @@ -3,7 +3,6 @@ import DropdownPanel from './dropdown-panel' // eslint-disable-line import { BN } from 'ethereumjs-util' export const GlobalVariables = ({ block, receipt, tx }) => { - console.log(block, receipt, tx) // see https://docs.soliditylang.org/en/latest/units-and-global-variables.html#block-and-transaction-properties const globals = { 'block.basefee': (new BN(block.baseFeePerGas.replace('0x', ''), 'hex')).toString(10) + ` Wei (${block.baseFeePerGas})`, From 10d524051d8daf7302bc4fe98ea97c19e1048d33 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 18 Aug 2021 10:14:45 +0200 Subject: [PATCH 05/21] update chanId for javascript VM --- libs/remix-simulator/src/methods/transactions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-simulator/src/methods/transactions.ts b/libs/remix-simulator/src/methods/transactions.ts index fcbf57f960..90e3df270f 100644 --- a/libs/remix-simulator/src/methods/transactions.ts +++ b/libs/remix-simulator/src/methods/transactions.ts @@ -193,7 +193,7 @@ export class Transactions { blockNumber: '0x' + txBlock.header.number.toString('hex'), from: receipt.from, gas: Web3.utils.toHex(receipt.gas), - chainId: '0xb', + chainId: '0xd05', // 'gasPrice': '2000000000000', // 0x123 gasPrice: '0x4a817c800', // 20000000000 hash: receipt.transactionHash, @@ -240,7 +240,7 @@ export class Transactions { blockNumber: '0x' + txBlock.header.number.toString('hex'), from: receipt.from, gas: Web3.utils.toHex(receipt.gas), - chainId: '0xb', + chainId: '0xd05', // 'gasPrice': '2000000000000', // 0x123 gasPrice: '0x4a817c800', // 20000000000 hash: receipt.transactionHash, @@ -284,7 +284,7 @@ export class Transactions { from: receipt.from, gas: Web3.utils.toHex(receipt.gas), // 'gasPrice': '2000000000000', // 0x123 - chainId: '0xb', + chainId: '0xd05', gasPrice: '0x4a817c800', // 20000000000 hash: receipt.transactionHash, input: receipt.input, From 2a446d302ef9408794b19594a3f5d5cb870c9be3 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 18 Aug 2021 09:15:07 +0200 Subject: [PATCH 06/21] label word-break fixed --- apps/remix-ide/src/app/ui/TreeView.js | 2 +- libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/ui/TreeView.js b/apps/remix-ide/src/app/ui/TreeView.js index 413f49f667..a282cafbd6 100644 --- a/apps/remix-ide/src/app/ui/TreeView.js +++ b/apps/remix-ide/src/app/ui/TreeView.js @@ -27,7 +27,7 @@ var css = csjs` word-break: break-all; } .label_key { - min-width: 15%; + min-width: max-content; max-width: 80%; word-break: break-word; } diff --git a/libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.css b/libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.css index 7e8fbee405..97b2f4fd48 100644 --- a/libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.css +++ b/libs/remix-ui/tree-view/src/lib/remix-ui-tree-view.css @@ -23,7 +23,7 @@ word-break: break-all; } .label_key { - min-width: 15%; + min-width: max-content; max-width: 80%; word-break: break-word; } From b0ddc0bd1166bfb0fab488a07e939ece6cf305fd Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Aug 2021 12:01:19 +0200 Subject: [PATCH 07/21] fix formatting value if error --- libs/remix-debug/src/solidity-decoder/localDecoder.ts | 2 +- libs/remix-debug/src/solidity-decoder/stateDecoder.ts | 4 ++-- libs/remix-debug/src/solidity-decoder/types/ArrayType.ts | 6 +++--- .../src/solidity-decoder/types/DynamicByteArray.ts | 6 +++--- libs/remix-debug/src/solidity-decoder/types/StringType.ts | 4 ++-- libs/remix-debug/src/solidity-decoder/types/Struct.ts | 2 +- libs/remix-debug/src/solidity-decoder/types/ValueType.ts | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libs/remix-debug/src/solidity-decoder/localDecoder.ts b/libs/remix-debug/src/solidity-decoder/localDecoder.ts index 9564efc93b..70df3e9715 100644 --- a/libs/remix-debug/src/solidity-decoder/localDecoder.ts +++ b/libs/remix-debug/src/solidity-decoder/localDecoder.ts @@ -21,7 +21,7 @@ export async function solidityLocals (vmtraceIndex, internalTreeCall, stack, mem locals[name] = await variable.type.decodeFromStack(variable.stackDepth, stack, memory, storageResolver, calldata, cursor, variable) } catch (e) { console.log(e) - locals[name] = '' + locals[name] = { error: '' } } } } diff --git a/libs/remix-debug/src/solidity-decoder/stateDecoder.ts b/libs/remix-debug/src/solidity-decoder/stateDecoder.ts index b7908da3c3..709faff99c 100644 --- a/libs/remix-debug/src/solidity-decoder/stateDecoder.ts +++ b/libs/remix-debug/src/solidity-decoder/stateDecoder.ts @@ -25,7 +25,7 @@ export async function decodeState (stateVars, storageResolver) { ret[stateVar.name] = decoded } catch (e) { console.log(e) - ret[stateVar.name] = '' + ret[stateVar.name] = { error: '' } } } return ret @@ -64,6 +64,6 @@ export async function solidityState (storageResolver, astList, contractName) { try { return await decodeState(stateVars, storageResolver) } catch (e) { - return '' + return { error: '' } } } diff --git a/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts b/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts index 3792579531..eb5eff4d30 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts @@ -36,7 +36,7 @@ export class ArrayType extends RefType { } catch (e) { console.log(e) return { - value: '', + error: '', type: this.typeName } } @@ -56,7 +56,7 @@ export class ArrayType extends RefType { ret.push(await this.underlyingType.decodeFromStorage(currentLocation, storageResolver)) } catch (e) { return { - value: '', + error: '', type: this.typeName } } @@ -84,7 +84,7 @@ export class ArrayType extends RefType { } if (isNaN(length)) { return { - value: '', + error: '', type: 'Error' } } diff --git a/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts b/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts index 5ac37c1ea2..85cf69ef88 100644 --- a/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts +++ b/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts @@ -16,7 +16,7 @@ export class DynamicByteArray extends RefType { value = await extractHexValue(location, storageResolver, this.storageBytes) } catch (e) { console.log(e) - return { value: '', type: this.typeName } + return { error: '', type: this.typeName } } const length = new BN(value, 16) if (length.testn(0)) { @@ -27,7 +27,7 @@ export class DynamicByteArray extends RefType { currentSlot = await readFromStorage(dataPos, storageResolver) } catch (e) { console.log(e) - return { value: '', type: this.typeName } + return { error: '', type: this.typeName } } while (length.gt(new BN(ret.length)) && ret.length < 32000) { currentSlot = currentSlot.replace('0x', '') @@ -37,7 +37,7 @@ export class DynamicByteArray extends RefType { currentSlot = await readFromStorage(dataPos, storageResolver) } catch (e) { console.log(e) - return { value: '', type: this.typeName } + return { error: '', type: this.typeName } } } return { value: '0x' + ret.replace(/(00)+$/, ''), length: '0x' + length.toString(16), type: this.typeName } diff --git a/libs/remix-debug/src/solidity-decoder/types/StringType.ts b/libs/remix-debug/src/solidity-decoder/types/StringType.ts index 8e31b3d17f..2ca56484db 100644 --- a/libs/remix-debug/src/solidity-decoder/types/StringType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/StringType.ts @@ -15,7 +15,7 @@ export class StringType extends DynamicByteArray { decoded = await super.decodeFromStorage(location, storageResolver) } catch (e) { console.log(e) - return '' + return { error: '' } } return format(decoded) } @@ -25,7 +25,7 @@ export class StringType extends DynamicByteArray { return await super.decodeFromStack(stackDepth, stack, memory, null, calldata, variableDetails) } catch (e) { console.log(e) - return '' + return { error: '' } } } diff --git a/libs/remix-debug/src/solidity-decoder/types/Struct.ts b/libs/remix-debug/src/solidity-decoder/types/Struct.ts index f6ea2748bc..1995471ffb 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Struct.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Struct.ts @@ -22,7 +22,7 @@ export class Struct extends RefType { ret[item.name] = await item.type.decodeFromStorage(globalLocation, storageResolver) } catch (e) { console.log(e) - ret[item.name] = '' + ret[item.name] = { error: '' } } } return { value: ret, type: this.typeName } diff --git a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts index 63bd4ae0f0..262cfcbb10 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts @@ -31,7 +31,7 @@ export class ValueType { return { value: this.decodeValue(value), type: this.typeName } } catch (e) { console.log(e) - return { value: '', type: this.typeName } + return { error: '', type: this.typeName } } } From 0ae9f9b5328a5e0ee0e6a55a35bd66df8bdb5516 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 10 Aug 2021 12:01:41 +0200 Subject: [PATCH 08/21] fix input parameters --- libs/remix-debug/src/solidity-decoder/types/StringType.ts | 4 ++-- libs/remix-debug/src/solidity-decoder/types/ValueType.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-debug/src/solidity-decoder/types/StringType.ts b/libs/remix-debug/src/solidity-decoder/types/StringType.ts index 2ca56484db..849b8f65a3 100644 --- a/libs/remix-debug/src/solidity-decoder/types/StringType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/StringType.ts @@ -20,9 +20,9 @@ export class StringType extends DynamicByteArray { return format(decoded) } - async decodeFromStack (stackDepth, stack, memory, calldata, variableDetails?) { + async decodeFromStack (stackDepth, stack, memory, storageResolver, calldata, cursor, variableDetails?) { try { - return await super.decodeFromStack(stackDepth, stack, memory, null, calldata, variableDetails) + return await super.decodeFromStack(stackDepth, stack, memory, storageResolver, calldata, cursor, variableDetails) } catch (e) { console.log(e) return { error: '' } diff --git a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts index 262cfcbb10..60d3a8ebed 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts @@ -43,7 +43,7 @@ export class ValueType { * @param {String} - memory * @return {Object} - decoded value */ - async decodeFromStack (stackDepth, stack, memory, calldata, variableDetails?) { + async decodeFromStack (stackDepth, stack, memory, storageResolver, calldata, cursor, variableDetails?) { let value if (stackDepth >= stack.length) { value = this.decodeValue('') From 0e6c04194aa73fa649fb2c370c6327c8712164cc Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 12 Aug 2021 12:11:58 +0200 Subject: [PATCH 09/21] remove editor dependency from solidity compiler --- apps/remix-ide/src/app/editor/editor.js | 2 +- apps/remix-ide/src/app/tabs/compile-tab.js | 1 - libs/remix-ui/renderer/src/lib/renderer.tsx | 7 +++---- .../solidity-compiler/src/lib/actions/compiler.ts | 6 +++--- .../solidity-compiler/src/lib/compiler-container.tsx | 4 ++-- .../solidity-compiler/src/lib/logic/compileTabLogic.ts | 2 +- .../solidity-compiler/src/lib/solidity-compiler.tsx | 10 +++++----- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 2 -- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index 88466a6e26..92b4b0cb8d 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -49,7 +49,7 @@ const profile = { name: 'editor', description: 'service - editor', version: packageJson.version, - methods: ['highlight', 'discardHighlight', 'discardHighlightAt', 'clearAnnotations', 'addAnnotation'] + methods: ['highlight', 'discardHighlight', 'discardHighlightAt', 'clearAnnotations', 'addAnnotation', 'gotoLine'] } class Editor extends Plugin { diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 6d84a9721f..63faf345af 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -55,7 +55,6 @@ class CompileTab extends ViewPlugin { this.compileTabLogic = new CompileTabLogic( this.queryParams, this.fileManager, - this.editor, this.config, this.fileProvider, this.contentImport, diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 643580b721..f909d06568 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -4,12 +4,11 @@ interface RendererProps { message: any; opt?: any, plugin: any, - editor: any, config: any, fileManager: any } -export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugin }: RendererProps) => { +export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: RendererProps) => { const [messageText, setMessageText] = useState(null) const [editorOptions, setEditorOptions] = useState({ useSpan: false, @@ -101,13 +100,13 @@ export const Renderer = ({ message, opt = {}, editor, config, fileManager, plugi if (provider) { provider.exists(errFile).then(() => { fileManager.open(errFile) - editor.gotoLine(errLine, errCol) + plugin.call('editor', 'gotoLine', errLine, errCol) }).catch(error => { if (error) return console.log(error) }) } } else { - editor.gotoLine(errLine, errCol) + plugin.call('editor', 'gotoLine', errLine, errCol) } } diff --git a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts index 1cba2adff9..359e6269f7 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -26,8 +26,8 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch) => { }) } -export const listenToEvents = (editor, compileTabLogic) => (dispatch: React.Dispatch) => { - editor.event.register('sessionSwitched', () => { +export const listenToEvents = (compileTabLogic) => (dispatch: React.Dispatch) => { + compileTabLogic.on('editor', 'sessionSwitched', () => { dispatch(setEditorMode('sessionSwitched')) }) @@ -39,7 +39,7 @@ export const listenToEvents = (editor, compileTabLogic) => (dispatch: React.Disp dispatch(setCompilerMode('compilationDuration', speed)) }) - editor.event.register('contentChanged', () => { + compileTabLogic.on('editor', 'contentChanged', () => { dispatch(setEditorMode('contentChanged')) }) 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 882899a34e..98ec8e8c11 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -18,7 +18,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { editor, config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line + const { config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -59,7 +59,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const currentFileName = config.get('currentFile') currentFile(currentFileName) - listenToEvents(editor, compileTabLogic)(dispatch) + listenToEvents(compileTabLogic)(dispatch) }, []) useEffect(() => { diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 83b688f104..7ec31b31c1 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -18,7 +18,7 @@ export class CompileTab extends Plugin { public compilerImport public event - constructor (public queryParams, public fileManager, public editor, public config, public fileProvider, public contentImport) { + constructor (public queryParams, public fileManager, public config, public fileProvider, public contentImport) { super(profile) this.event = new EventEmitter() this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 3fd3f800fb..83f05d6409 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { editor, config, queryParams, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { config, queryParams, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -78,19 +78,19 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>
- +
- { compileErrors.error && } + { compileErrors.error && } { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { if (config.get('hideWarnings')) { if (err.severity !== 'warning') { - return + return } } else { - return + return } }) }
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 31c95e9e1f..782e4adabb 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -9,7 +9,6 @@ export interface SolidityCompilerProps { compileTabLogic: any, currentFile: string, contractsDetails: Record, - editor: any, config: any, fileProvider: any, fileManager: any, @@ -23,7 +22,6 @@ export interface SolidityCompilerProps { } export interface CompilerContainerProps { - editor: any, config: any, queryParams: any, compileTabLogic: any, From bea98e0a1f79c8d09fd13ac6122ba98282c822af Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 12 Aug 2021 14:16:48 +0200 Subject: [PATCH 10/21] refactorqueryParams --- apps/remix-ide/src/app/tabs/compile-tab.js | 10 +++++++++- .../src/lib/compiler-container.tsx | 10 +++++----- .../src/lib/logic/compileTabLogic.ts | 20 +++++++++---------- .../src/lib/solidity-compiler.tsx | 4 ++-- .../solidity-compiler/src/lib/types/index.ts | 3 +-- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 63faf345af..60432ac944 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -52,7 +52,7 @@ class CompileTab extends ViewPlugin { eventHandlers: {}, loading: false } - this.compileTabLogic = new CompileTabLogic( + this.compileTabLogic = new CompileTabLogic(this, this.queryParams, this.fileManager, this.config, @@ -277,6 +277,14 @@ class CompileTab extends ViewPlugin { , this.el) } + getParameters () { + return this.queryParams.get() + } + + setParameters (params) { + this.queryParams.update(params) + } + onActivation () { this.call('manager', 'activatePlugin', 'solidity-logic') this.listenToEvents() 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 98ec8e8c11..cf6ceba0dc 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -18,7 +18,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { config, queryParams, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line + const { api, config, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -65,7 +65,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { useEffect(() => { if (compileTabLogic && compileTabLogic.compiler) { setState(prevState => { - const params = queryParams.get() + const params = api.getParameters() const optimize = params.optimize === 'false' ? false : params.optimize === 'true' ? true : null const runs = params.runs const evmVersion = params.evmVersion @@ -152,7 +152,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { allVersions = [...allVersions, ...versions] selectedVersion = state.defaultVersion - if (queryParams.get().version) selectedVersion = queryParams.get().version + if (api.getParameters().version) selectedVersion = api.getParameters().version // Check if version is a URL and corresponding filename starts with 'soljson' if (selectedVersion.startsWith('https://')) { const urlArr = selectedVersion.split('/') @@ -321,7 +321,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) } updateCurrentVersion(selectedVersion) - queryParams.update({ version: selectedVersion }) + api.setParameters({ version: selectedVersion }) let url if (customUrl !== '') { @@ -331,7 +331,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { }) updateCurrentVersion(selectedVersion) url = customUrl - queryParams.update({ version: selectedVersion }) + api.setParameters({ version: selectedVersion }) } else if (selectedVersion === 'builtin') { let location: string | Location = window.document.location let path = location.pathname diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 7ec31b31c1..cded031940 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -18,46 +18,46 @@ export class CompileTab extends Plugin { public compilerImport public event - constructor (public queryParams, public fileManager, public config, public fileProvider, public contentImport) { + constructor (public api, public fileManager, public config, public fileProvider, public contentImport) { super(profile) this.event = new EventEmitter() this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) } init () { - this.optimize = this.queryParams.get().optimize + this.optimize = this.api.getParameters().optimize this.optimize = this.optimize === 'true' - this.queryParams.update({ optimize: this.optimize }) + this.api.setParameters({ optimize: this.optimize }) this.compiler.set('optimize', this.optimize) - this.runs = this.queryParams.get().runs + this.runs = this.api.getParameters().runs this.runs = this.runs && this.runs !== 'undefined' ? this.runs : 200 - this.queryParams.update({ runs: this.runs }) + this.api.setParameters({ runs: this.runs }) this.compiler.set('runs', this.runs) - this.evmVersion = this.queryParams.get().evmVersion + this.evmVersion = this.api.getParameters().evmVersion if (this.evmVersion === 'undefined' || this.evmVersion === 'null' || !this.evmVersion) { this.evmVersion = null } - this.queryParams.update({ evmVersion: this.evmVersion }) + this.api.setParameters({ evmVersion: this.evmVersion }) this.compiler.set('evmVersion', this.evmVersion) } setOptimize (newOptimizeValue) { this.optimize = newOptimizeValue - this.queryParams.update({ optimize: this.optimize }) + this.api.setParameters({ optimize: this.optimize }) this.compiler.set('optimize', this.optimize) } setRuns (runs) { this.runs = runs - this.queryParams.update({ runs: this.runs }) + this.api.setParameters({ runs: this.runs }) this.compiler.set('runs', this.runs) } setEvmVersion (newEvmVersion) { this.evmVersion = newEvmVersion - this.queryParams.update({ evmVersion: this.evmVersion }) + this.api.setParameters({ evmVersion: this.evmVersion }) this.compiler.set('evmVersion', this.evmVersion) } diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 83f05d6409..35b96ee48e 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { config, queryParams, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { config, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -78,7 +78,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>
- +
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 782e4adabb..f2701bc08c 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -5,7 +5,6 @@ export interface SolidityCompilerProps { } | Record compileErrors: any, isHardHatProject: boolean, - queryParams: any, compileTabLogic: any, currentFile: string, contractsDetails: Record, @@ -22,8 +21,8 @@ export interface SolidityCompilerProps { } export interface CompilerContainerProps { + api: any, config: any, - queryParams: any, compileTabLogic: any, tooltip: (message: string | JSX.Element) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, From 4a7b6c08d4c7f719ccb23fc23cf788d506a336dd Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 11:25:38 +0200 Subject: [PATCH 11/21] fix remove qureryParam parameter --- apps/remix-ide/src/app/tabs/compile-tab.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 60432ac944..fe70d8f66e 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -53,7 +53,6 @@ class CompileTab extends ViewPlugin { loading: false } this.compileTabLogic = new CompileTabLogic(this, - this.queryParams, this.fileManager, this.config, this.fileProvider, From 8a83cc35aaa1172a0fc82a036e6dbd4157c3d4ac Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 11:25:55 +0200 Subject: [PATCH 12/21] remove config parameter --- apps/remix-ide/src/app/tabs/compile-tab.js | 8 +++++++ libs/remix-ui/renderer/src/lib/renderer.tsx | 7 +++--- .../src/lib/compiler-container.tsx | 24 +++++++++---------- .../src/lib/logic/compileTabLogic.ts | 2 +- .../src/lib/solidity-compiler.tsx | 12 +++++----- .../solidity-compiler/src/lib/types/index.ts | 6 ++--- 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index fe70d8f66e..0486159a1d 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -284,6 +284,14 @@ class CompileTab extends ViewPlugin { this.queryParams.update(params) } + getConfiguration (name) { + return this.config.get(name) + } + + setConfiguration (name, value) { + this.config.set(name, value) + } + onActivation () { this.call('manager', 'activatePlugin', 'solidity-logic') this.listenToEvents() diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index f909d06568..4dbce52da8 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -4,11 +4,10 @@ interface RendererProps { message: any; opt?: any, plugin: any, - config: any, fileManager: any } -export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: RendererProps) => { +export const Renderer = ({ message, opt = {}, fileManager, plugin }: RendererProps) => { const [messageText, setMessageText] = useState(null) const [editorOptions, setEditorOptions] = useState({ useSpan: false, @@ -76,7 +75,7 @@ export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: Ren } const addAnnotation = (file, error) => { - if (file === config.get('currentFile')) { + if (file === plugin.getConfiguration('currentFile')) { plugin.call('editor', 'addAnnotation', error, file) } } @@ -94,7 +93,7 @@ export const Renderer = ({ message, opt = {}, config, fileManager, plugin }: Ren } const _errorClick = (errFile, errLine, errCol) => { - if (errFile !== config.get('currentFile')) { + if (errFile !== plugin.getConfiguration('currentFile')) { // TODO: refactor with this._components.contextView.jumpTo const provider = fileManager.fileProviderOf(errFile) if (provider) { 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 cf6ceba0dc..b63213d364 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -18,7 +18,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { api, config, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line + const { api, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -56,7 +56,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { _updateVersionSelector(selectedVersion) } }) - const currentFileName = config.get('currentFile') + const currentFileName = api.getConfiguration('currentFile') currentFile(currentFileName) listenToEvents(compileTabLogic)(dispatch) @@ -72,10 +72,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => { return { ...prevState, - hideWarnings: config.get('hideWarnings') || false, - autoCompile: config.get('autoCompile') || false, - includeNightlies: config.get('includeNightlies') || false, - optimise: (optimize !== null) && (optimize !== undefined) ? optimize : config.get('optimise') || false, + hideWarnings: api.getConfiguration('hideWarnings') || false, + autoCompile: api.getConfiguration('autoCompile') || false, + includeNightlies: api.getConfiguration('includeNightlies') || false, + optimise: (optimize !== null) && (optimize !== undefined) ? optimize : api.getConfiguration('optimise') || false, runs: (runs !== null) && (runs !== 'null') && (runs !== undefined) && (runs !== 'undefined') ? runs : 200, evmVersion: (evmVersion !== null) && (evmVersion !== 'null') && (evmVersion !== undefined) && (evmVersion !== 'undefined') ? evmVersion : 'default' } @@ -228,7 +228,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } const isSolFileSelected = (currentFile = '') => { - if (!currentFile) currentFile = config.get('currentFile') + if (!currentFile) currentFile = api.getConfiguration('currentFile') if (!currentFile) return false const extention = currentFile.substr(currentFile.length - 3, currentFile.length) return extention.toLowerCase() === 'sol' || extention.toLowerCase() === 'yul' @@ -297,7 +297,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { } const compile = () => { - const currentFile = config.get('currentFile') + const currentFile = api.getConfiguration('currentFile') if (!isSolFileSelected()) return @@ -406,7 +406,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const handleAutoCompile = (e) => { const checked = e.target.checked - config.set('autoCompile', checked) + api.setConfiguration('autoCompile', checked) setState(prevState => { return { ...prevState, autoCompile: checked } }) @@ -415,7 +415,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const handleOptimizeChange = (value) => { const checked = !!value - config.set('optimise', checked) + api.setConfiguration('optimise', checked) compileTabLogic.setOptimize(checked) if (compileTabLogic.optimize) { compileTabLogic.setRuns(parseInt(state.runs)) @@ -441,7 +441,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const handleHideWarningsChange = (e) => { const checked = e.target.checked - config.set('hideWarnings', checked) + api.setConfiguration('hideWarnings', checked) state.autoCompile && compile() setState(prevState => { return { ...prevState, hideWarnings: checked } @@ -452,7 +452,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const checked = e.target.checked if (!checked) handleLoadVersion(state.defaultVersion) - config.set('includeNightlies', checked) + api.setConfiguration('includeNightlies', checked) setState(prevState => { return { ...prevState, includeNightlies: checked } }) diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index cded031940..764086b55b 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -124,7 +124,7 @@ export class CompileTab extends Plugin { } this.fileManager.saveCurrentFile() this.event.emit('removeAnnotations') - var currentFile = this.config.get('currentFile') + var currentFile = this.api.getConfiguration('currentFile') return this.compileFile(currentFile) } catch (err) { console.error(err) diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 35b96ee48e..9c2e2130c7 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { config, compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -78,19 +78,19 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>
- +
- { compileErrors.error && } + { compileErrors.error && } { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { - if (config.get('hideWarnings')) { + if (plugin.getConfiguration('hideWarnings')) { if (err.severity !== 'warning') { - return + return } } else { - return + return } }) }
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index f2701bc08c..b0fa52ba71 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -8,7 +8,6 @@ export interface SolidityCompilerProps { compileTabLogic: any, currentFile: string, contractsDetails: Record, - config: any, fileProvider: any, fileManager: any, contentImport: any, @@ -16,13 +15,14 @@ export interface SolidityCompilerProps { on: (...args) => void, setHardHatCompilation: (value: boolean) => void, setSelectedVersion: (value: string) => void, - configurationSettings: ConfigurationSettings + configurationSettings: ConfigurationSettings, + getConfiguration: (value: string) => string, + setConfiguration: (name: string, value: string) => void }, } export interface CompilerContainerProps { api: any, - config: any, compileTabLogic: any, tooltip: (message: string | JSX.Element) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, From 94dd0280ff530d921b8a284207462b1684a06af7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 11:33:14 +0200 Subject: [PATCH 13/21] remove currentFile dep --- libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx | 3 ++- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 9c2e2130c7..9f2a147ae6 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { compileTabLogic, currentFile, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { compileTabLogic, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -75,6 +75,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
) + const currentFile = plugin.getConfiguration('currentFile') return ( <>
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index b0fa52ba71..3e7bba0757 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -6,7 +6,6 @@ export interface SolidityCompilerProps { compileErrors: any, isHardHatProject: boolean, compileTabLogic: any, - currentFile: string, contractsDetails: Record, fileProvider: any, fileManager: any, From 552a9d6d144d3f88e2759c0c6c761085ae1d1e3c Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 11:36:32 +0200 Subject: [PATCH 14/21] remove config dep left over --- apps/remix-ide/src/app/tabs/compile-tab.js | 1 - .../remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 0486159a1d..c97dc2f1f2 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -54,7 +54,6 @@ class CompileTab extends ViewPlugin { } this.compileTabLogic = new CompileTabLogic(this, this.fileManager, - this.config, this.fileProvider, this.contentImport, this.setCompileErrors.bind(this) diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 764086b55b..0cced8b342 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -18,7 +18,7 @@ export class CompileTab extends Plugin { public compilerImport public event - constructor (public api, public fileManager, public config, public fileProvider, public contentImport) { + constructor (public api, public fileManager, public contentImport) { super(profile) this.event = new EventEmitter() this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) From a18bc70b85574b615863a8c7eaca88e4408e647c Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 12:03:13 +0200 Subject: [PATCH 15/21] remove file provider dep --- apps/remix-ide/src/app/tabs/compile-tab.js | 9 +++++---- .../publish-to-storage/src/lib/publish-to-storage.tsx | 6 +++--- libs/remix-ui/publish-to-storage/src/lib/types/index.ts | 2 +- .../solidity-compiler/src/lib/contract-selection.tsx | 4 ++-- .../solidity-compiler/src/lib/solidity-compiler.tsx | 4 ++-- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 3 +-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index c97dc2f1f2..1efa35ffdb 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -54,10 +54,7 @@ class CompileTab extends ViewPlugin { } this.compileTabLogic = new CompileTabLogic(this, this.fileManager, - this.fileProvider, - this.contentImport, - this.setCompileErrors.bind(this) - ) + this.contentImport) this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() this.contractMap = {} @@ -200,6 +197,10 @@ class CompileTab extends ViewPlugin { return this.compileTabLogic.compiler.state.lastCompilationResult } + addExternalFile (fileName, content) { + this.fileProvider.addExternal(fileName, content) + } + /** * compile using @arg fileName. * The module UI will be updated accordingly to the new compilation result. diff --git a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx index de14a65a2f..f34ab4393b 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx +++ b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx @@ -5,7 +5,7 @@ import { publishToIPFS } from './publishToIPFS' import { publishToSwarm } from './publishOnSwarm' export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { - const { storage, fileProvider, fileManager, contract, resetStorage } = props + const { api, storage, fileManager, contract, resetStorage } = props const [state, setState] = useState({ modal: { title: '', @@ -29,7 +29,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) // triggered each time there's a new verified publish (means hash correspond) - fileProvider.addExternal('swarm/' + result.item.hash, result.item.content) + api.addExternalFile('swarm/' + result.item.hash, result.item.content) } catch (err) { let parseError = err try { @@ -43,7 +43,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) // triggered each time there's a new verified publish (means hash correspond) - fileProvider.addExternal('ipfs/' + result.item.hash, result.item.content) + api.addExternalFile('ipfs/' + result.item.hash, result.item.content) } catch (err) { modal('IPFS Publish Failed', publishMessageFailed(storage, err)) } diff --git a/libs/remix-ui/publish-to-storage/src/lib/types/index.ts b/libs/remix-ui/publish-to-storage/src/lib/types/index.ts index 928315c621..75b29bb1ba 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/types/index.ts +++ b/libs/remix-ui/publish-to-storage/src/lib/types/index.ts @@ -1,6 +1,6 @@ export interface RemixUiPublishToStorageProps { + api: any, storage: string, - fileProvider: any, fileManager: any, contract: any, resetStorage: () => void diff --git a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx index 489707b28e..41ebb0ece8 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx @@ -7,7 +7,7 @@ import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line import './css/style.css' export const ContractSelection = (props: ContractSelectionProps) => { - const { contractMap, fileProvider, fileManager, contractsDetails, modal } = props + const { api, contractMap, fileManager, contractsDetails, modal } = props const [contractList, setContractList] = useState([]) const [selectedContract, setSelectedContract] = useState('') const [storage, setStorage] = useState(null) @@ -234,7 +234,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { No Contract Compiled Yet } - + ) } diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 9f2a147ae6..764a728f9f 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { compileTabLogic, fileProvider, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { compileTabLogic, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -80,7 +80,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { <>
- +
{ compileErrors.error && } diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 3e7bba0757..fedaaab6e1 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -7,7 +7,6 @@ export interface SolidityCompilerProps { isHardHatProject: boolean, compileTabLogic: any, contractsDetails: Record, - fileProvider: any, fileManager: any, contentImport: any, call: (...args) => void @@ -32,11 +31,11 @@ export interface CompilerContainerProps { configurationSettings: ConfigurationSettings } export interface ContractSelectionProps { + api: any, contractMap: { file: string } | Record, fileManager: any, - fileProvider: any, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, contractsDetails: Record } From 0be2e2793f83c0bf24f86d6d82b5552419a4fb8b Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 12:32:51 +0200 Subject: [PATCH 16/21] remove fileManager dep --- apps/remix-ide/src/app/tabs/compile-tab.js | 36 +++++++++++++++++-- .../src/lib/publish-to-storage.tsx | 6 ++-- .../src/lib/publishOnSwarm.tsx | 20 +++++------ .../src/lib/publishToIPFS.tsx | 20 +++++------ .../publish-to-storage/src/lib/types/index.ts | 1 - libs/remix-ui/renderer/src/lib/renderer.tsx | 7 ++-- .../src/lib/compiler-container.tsx | 2 +- .../src/lib/contract-selection.tsx | 4 +-- .../src/lib/logic/compileTabLogic.ts | 14 ++++---- .../src/lib/solidity-compiler.tsx | 10 +++--- .../solidity-compiler/src/lib/types/index.ts | 2 -- 11 files changed, 72 insertions(+), 50 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 1efa35ffdb..5ed189813f 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -52,9 +52,7 @@ class CompileTab extends ViewPlugin { eventHandlers: {}, loading: false } - this.compileTabLogic = new CompileTabLogic(this, - this.fileManager, - this.contentImport) + this.compileTabLogic = new CompileTabLogic(this, this.contentImport) this.compiler = this.compileTabLogic.compiler this.compileTabLogic.init() this.contractMap = {} @@ -292,6 +290,38 @@ class CompileTab extends ViewPlugin { this.config.set(name, value) } + readFile (fileName) { + return this.call('fileManager', 'readFile', fileName) + } + + fileProviderOf (fileName) { + return this.fileManager.fileProviderOf(fileName) + } + + getFileManagerMode () { + return this.fileManager.mode + } + + fileExists (fileName) { + return this.call('fileManager', 'exists', fileName) + } + + writeFile (fileName, content) { + return this.call('fileManager', 'writeFile', fileName, content) + } + + readFile (fileName) { + return this.call('fileManager', 'readFile', fileName) + } + + saveCurrentFile () { + return this.fileManager.saveCurrentFile() + } + + open (fileName) { + return this.call('fileManager', 'open', fileName) + } + onActivation () { this.call('manager', 'activatePlugin', 'solidity-logic') this.listenToEvents() diff --git a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx index f34ab4393b..f8f5878aa0 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx +++ b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx @@ -5,7 +5,7 @@ import { publishToIPFS } from './publishToIPFS' import { publishToSwarm } from './publishOnSwarm' export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { - const { api, storage, fileManager, contract, resetStorage } = props + const { api, storage, contract, resetStorage } = props const [state, setState] = useState({ modal: { title: '', @@ -25,7 +25,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { } else { if (storage === 'swarm') { try { - const result = await publishToSwarm(contract, fileManager) + const result = await publishToSwarm(contract, api) modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) // triggered each time there's a new verified publish (means hash correspond) @@ -39,7 +39,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { } } else { try { - const result = await publishToIPFS(contract, fileManager) + const result = await publishToIPFS(contract, api) modal(`Published ${contract.name}'s Metadata`, publishMessage(result.uploaded)) // triggered each time there's a new verified publish (means hash correspond) diff --git a/libs/remix-ui/publish-to-storage/src/lib/publishOnSwarm.tsx b/libs/remix-ui/publish-to-storage/src/lib/publishOnSwarm.tsx index 785d00b895..a8a39343a9 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/publishOnSwarm.tsx +++ b/libs/remix-ui/publish-to-storage/src/lib/publishOnSwarm.tsx @@ -2,7 +2,7 @@ import swarm from 'swarmgw' const swarmgw = swarm() -export const publishToSwarm = async (contract, fileManager) => { +export const publishToSwarm = async (contract, api) => { // gather list of files to publish const sources = [] let metadata @@ -38,16 +38,14 @@ export const publishToSwarm = async (contract, fileManager) => { throw new Error('Error while extracting the hash from metadata.json') } - fileManager.fileProviderOf(fileName).get(fileName, (error, content) => { - if (error) { - console.log(error) - } else { - sources.push({ - content: content, - hash: hash, - filename: fileName - }) - } + api.readFile(fileName).then((content) => { + sources.push({ + content: content, + hash: hash, + filename: fileName + }) + }).catch((error) => { + console.log(error) }) })) // publish the list of sources in order, fail if any failed diff --git a/libs/remix-ui/publish-to-storage/src/lib/publishToIPFS.tsx b/libs/remix-ui/publish-to-storage/src/lib/publishToIPFS.tsx index 8b9a369565..605157c552 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/publishToIPFS.tsx +++ b/libs/remix-ui/publish-to-storage/src/lib/publishToIPFS.tsx @@ -6,7 +6,7 @@ const ipfsNodes = [ new IpfsClient({ host: '127.0.0.1', port: 5001, protocol: 'http' }) ] -export const publishToIPFS = async (contract, fileManager) => { +export const publishToIPFS = async (contract, api) => { // gather list of files to publish const sources = [] let metadata @@ -42,16 +42,14 @@ export const publishToIPFS = async (contract, fileManager) => { throw new Error('Error while extracting the hash from metadata.json') } - fileManager.fileProviderOf(fileName).get(fileName, (error, content) => { - if (error) { - console.log(error) - } else { - sources.push({ - content: content, - hash: hash, - filename: fileName - }) - } + api.readFile(fileName).then((content) => { + sources.push({ + content: content, + hash: hash, + filename: fileName + }) + }).catch((error) => { + console.log(error) }) })) // publish the list of sources in order, fail if any failed diff --git a/libs/remix-ui/publish-to-storage/src/lib/types/index.ts b/libs/remix-ui/publish-to-storage/src/lib/types/index.ts index 75b29bb1ba..53a351baee 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/types/index.ts +++ b/libs/remix-ui/publish-to-storage/src/lib/types/index.ts @@ -1,7 +1,6 @@ export interface RemixUiPublishToStorageProps { api: any, storage: string, - fileManager: any, contract: any, resetStorage: () => void } diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index 4dbce52da8..8b4799a4f0 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -4,10 +4,9 @@ interface RendererProps { message: any; opt?: any, plugin: any, - fileManager: any } -export const Renderer = ({ message, opt = {}, fileManager, plugin }: RendererProps) => { +export const Renderer = ({ message, opt = {}, plugin }: RendererProps) => { const [messageText, setMessageText] = useState(null) const [editorOptions, setEditorOptions] = useState({ useSpan: false, @@ -95,10 +94,10 @@ export const Renderer = ({ message, opt = {}, fileManager, plugin }: RendererPro const _errorClick = (errFile, errLine, errCol) => { if (errFile !== plugin.getConfiguration('currentFile')) { // TODO: refactor with this._components.contextView.jumpTo - const provider = fileManager.fileProviderOf(errFile) + const provider = plugin.fileProviderOf(errFile) if (provider) { provider.exists(errFile).then(() => { - fileManager.open(errFile) + plugin.open(errFile) plugin.call('editor', 'gotoLine', errLine, errCol) }).catch(error => { if (error) return console.log(error) 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 b63213d364..6e59535a4a 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -197,7 +197,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { // Load solc compiler version according to pragma in contract file const _setCompilerVersionFromPragma = (filename: string) => { if (!state.allversions) return - compileTabLogic.fileManager.readFile(filename).then(data => { + api.readFile(filename).then(data => { const pragmaArr = data.match(/(pragma solidity (.+?);)/g) if (pragmaArr && pragmaArr.length === 1) { const pragmaStr = pragmaArr[0].replace('pragma solidity', '').trim() diff --git a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx index 41ebb0ece8..7b85038aa6 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx @@ -7,7 +7,7 @@ import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line import './css/style.css' export const ContractSelection = (props: ContractSelectionProps) => { - const { api, contractMap, fileManager, contractsDetails, modal } = props + const { api, contractMap, contractsDetails, modal } = props const [contractList, setContractList] = useState([]) const [selectedContract, setSelectedContract] = useState('') const [storage, setStorage] = useState(null) @@ -234,7 +234,7 @@ export const ContractSelection = (props: ContractSelectionProps) => { No Contract Compiled Yet } - + ) } diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts index 0cced8b342..4b9be01c92 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts @@ -18,7 +18,7 @@ export class CompileTab extends Plugin { public compilerImport public event - constructor (public api, public fileManager, public contentImport) { + constructor (public api, public contentImport) { super(profile) this.event = new EventEmitter() this.compiler = new Compiler((url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) @@ -79,7 +79,7 @@ export class CompileTab extends Plugin { */ compileFile (target) { if (!target) throw new Error('No target provided for compiliation') - const provider = this.fileManager.fileProviderOf(target) + const provider = this.api.fileProviderOf(target) if (!provider) throw new Error(`cannot compile ${target}. Does not belong to any explorer`) return new Promise((resolve, reject) => { provider.get(target, (error, content) => { @@ -93,14 +93,14 @@ export class CompileTab extends Plugin { } async isHardhatProject () { - if (this.fileManager.mode === 'localhost') { - return await this.fileManager.exists('hardhat.config.js') + if (this.api.getFileManagerMode() === 'localhost') { + return await this.api.fileExists('hardhat.config.js') } else return false } runCompiler (hhCompilation) { try { - if (this.fileManager.mode === 'localhost' && hhCompilation) { + if (this.api.getFileManagerMode() === 'localhost' && hhCompilation) { const { currentVersion, optimize, runs } = this.compiler.state if (currentVersion) { const fileContent = `module.exports = { @@ -114,7 +114,7 @@ export class CompileTab extends Plugin { } ` const configFilePath = 'remix-compiler.config.js' - this.fileManager.setFileContent(configFilePath, fileContent) + this.api.writeFile(configFilePath, fileContent) this.call('hardhat', 'compile', configFilePath).then((result) => { this.call('terminal', 'log', { type: 'info', value: result }) }).catch((error) => { @@ -122,7 +122,7 @@ export class CompileTab extends Plugin { }) } } - this.fileManager.saveCurrentFile() + this.api.saveCurrentFile() this.event.emit('removeAnnotations') var currentFile = this.api.getConfiguration('currentFile') return this.compileFile(currentFile) diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 764a728f9f..13e0ac9352 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { compileTabLogic, fileManager, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -80,18 +80,18 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { <>
- +
- { compileErrors.error && } + { compileErrors.error && } { compileErrors.error && (compileErrors.error.mode === 'panic') && modal('Error', panicMessage(compileErrors.error.formattedMessage), 'Close', null) } { compileErrors.errors && compileErrors.errors.length && compileErrors.errors.map((err, index) => { if (plugin.getConfiguration('hideWarnings')) { if (err.severity !== 'warning') { - return + return } } else { - return + return } }) }
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index fedaaab6e1..3987e3a0c3 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -7,7 +7,6 @@ export interface SolidityCompilerProps { isHardHatProject: boolean, compileTabLogic: any, contractsDetails: Record, - fileManager: any, contentImport: any, call: (...args) => void on: (...args) => void, @@ -35,7 +34,6 @@ export interface ContractSelectionProps { contractMap: { file: string } | Record, - fileManager: any, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, contractsDetails: Record } From bd57bc5bb6afa4cf2c7afb707d967e0ca04bb138 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 14:48:10 +0200 Subject: [PATCH 17/21] put isHardHatProject in api --- .../remix-ui/solidity-compiler/src/lib/compiler-container.tsx | 4 ++-- libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx | 4 ++-- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) 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 6e59535a4a..916b547cf4 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -18,7 +18,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { api, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, isHardHatProject, configurationSettings } = props // eslint-disable-line + const { api, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, configurationSettings } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -574,7 +574,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
{ - isHardHatProject && + api.isHardHatProject &&
diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index 13e0ac9352..ec0d7354a5 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, isHardHatProject, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, setHardHatCompilation, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -79,7 +79,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>
- +
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 3987e3a0c3..3fb4098041 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -4,7 +4,6 @@ export interface SolidityCompilerProps { file: string } | Record compileErrors: any, - isHardHatProject: boolean, compileTabLogic: any, contractsDetails: Record, contentImport: any, @@ -26,7 +25,6 @@ export interface CompilerContainerProps { compiledFileName: string, setHardHatCompilation: (value: boolean) => void, updateCurrentVersion: any, - isHardHatProject: boolean, configurationSettings: ConfigurationSettings } export interface ContractSelectionProps { From 8f952134b1345ce16bc9901c9fd4249417f0009e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 14:49:45 +0200 Subject: [PATCH 18/21] setHardHatCompilation in api --- .../remix-ui/solidity-compiler/src/lib/compiler-container.tsx | 4 ++-- libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx | 4 ++-- libs/remix-ui/solidity-compiler/src/lib/types/index.ts | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) 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 916b547cf4..91498d8894 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -18,7 +18,7 @@ declare global { const _paq = window._paq = window._paq || [] //eslint-disable-line export const CompilerContainer = (props: CompilerContainerProps) => { - const { api, compileTabLogic, tooltip, modal, compiledFileName, setHardHatCompilation, updateCurrentVersion, configurationSettings } = props // eslint-disable-line + const { api, compileTabLogic, tooltip, modal, compiledFileName, updateCurrentVersion, configurationSettings } = props // eslint-disable-line const [state, setState] = useState({ hideWarnings: false, autoCompile: false, @@ -483,7 +483,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const checked = event.target.checked sethhCompilation(checked) - setHardHatCompilation(checked) + api.setHardHatCompilation(checked) } /* diff --git a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx index ec0d7354a5..46c032d582 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx @@ -9,7 +9,7 @@ import { Renderer } from '@remix-ui/renderer' // eslint-disable-line import './css/style.css' export const SolidityCompiler = (props: SolidityCompilerProps) => { - const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, setHardHatCompilation, configurationSettings } } = props + const { plugin, plugin: { compileTabLogic, contractsDetails, contractMap, compileErrors, configurationSettings } } = props const [state, setState] = useState({ contractsDetails: {}, eventHandlers: {}, @@ -79,7 +79,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => { return ( <>
- +
diff --git a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts index 3fb4098041..a2106e2205 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/types/index.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/types/index.ts @@ -9,7 +9,6 @@ export interface SolidityCompilerProps { contentImport: any, call: (...args) => void on: (...args) => void, - setHardHatCompilation: (value: boolean) => void, setSelectedVersion: (value: string) => void, configurationSettings: ConfigurationSettings, getConfiguration: (value: string) => string, @@ -23,7 +22,6 @@ export interface CompilerContainerProps { tooltip: (message: string | JSX.Element) => void, modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, compiledFileName: string, - setHardHatCompilation: (value: boolean) => void, updateCurrentVersion: any, configurationSettings: ConfigurationSettings } From 971f780d5832df714a1e1cc3bce0f9013b68ad9a Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 15:46:36 +0200 Subject: [PATCH 19/21] linting --- apps/remix-ide/src/app/tabs/compile-tab.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index 5ed189813f..14ca4ae30e 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -290,10 +290,6 @@ class CompileTab extends ViewPlugin { this.config.set(name, value) } - readFile (fileName) { - return this.call('fileManager', 'readFile', fileName) - } - fileProviderOf (fileName) { return this.fileManager.fileProviderOf(fileName) } From c14483081edcd34bbcc7cc620ce27e8e5f7b61d9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 17 Aug 2021 17:17:32 +0200 Subject: [PATCH 20/21] fix listening on edirot event --- libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts | 6 +++--- .../solidity-compiler/src/lib/compiler-container.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts index 359e6269f7..e0e2a46498 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts @@ -26,8 +26,8 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch) => { }) } -export const listenToEvents = (compileTabLogic) => (dispatch: React.Dispatch) => { - compileTabLogic.on('editor', 'sessionSwitched', () => { +export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatch) => { + api.on('editor', 'sessionSwitched', () => { dispatch(setEditorMode('sessionSwitched')) }) @@ -39,7 +39,7 @@ export const listenToEvents = (compileTabLogic) => (dispatch: React.Dispatch { + api.on('editor', 'contentChanged', () => { dispatch(setEditorMode('contentChanged')) }) 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 91498d8894..104a515a39 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -59,7 +59,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const currentFileName = api.getConfiguration('currentFile') currentFile(currentFileName) - listenToEvents(compileTabLogic)(dispatch) + listenToEvents(compileTabLogic, api)(dispatch) }, []) useEffect(() => { From d041cfa759c187f093f5ebb335c6a040ffe34594 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 18 Aug 2021 12:07:22 +0200 Subject: [PATCH 21/21] check if onListeners are set --- apps/debugger/src/app/debugger-api.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/debugger/src/app/debugger-api.ts b/apps/debugger/src/app/debugger-api.ts index 8528759d14..2b5a149d16 100644 --- a/apps/debugger/src/app/debugger-api.ts +++ b/apps/debugger/src/app/debugger-api.ts @@ -119,17 +119,17 @@ export const DebuggerApiMixin = (Base) => class extends Base { debug (hash) { this.debugHash = hash - this.onDebugRequestedListener(hash) + if (this.onDebugRequestedListener) this.onDebugRequestedListener(hash) } onActivation () { - this.on('editor', 'breakpointCleared', (fileName, row) => this.onBreakpointClearedListener(fileName, row)) - this.on('editor', 'breakpointAdded', (fileName, row) => this.onBreakpointAddedListener(fileName, row)) - this.on('editor', 'contentChanged', () => this.onEditorContentChangedListener()) + this.on('editor', 'breakpointCleared', (fileName, row) => { if (this.onBreakpointClearedListener) this.onBreakpointClearedListener(fileName, row) }) + this.on('editor', 'breakpointAdded', (fileName, row) => { if (this.onBreakpointAddedListener) this.onBreakpointAddedListener(fileName, row) }) + this.on('editor', 'contentChanged', () => { if (this.onEditorContentChangedListener) this.onEditorContentChangedListener() }) } onDeactivation () { - this.onRemoveHighlightsListener() + if (this.onRemoveHighlightsListener) this.onRemoveHighlightsListener() this.off('editor', 'breakpointCleared') this.off('editor', 'breakpointAdded') this.off('editor', 'contentChanged')