From baa3fc843297c92c8a1b5126c34d4f8093b30476 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 22 Jun 2021 15:39:57 +0530 Subject: [PATCH 01/21] fix hardhat modal reappearing --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 037117fa85..88fe3b7c85 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -39,12 +39,17 @@ export default class HardhatProvider extends Plugin { sendAsync (data) { return new Promise((resolve, reject) => { - if (!this.provider) { + if (!this.provider || data.method === 'net_listening') { modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { this.provider = new Web3.providers.HttpProvider(target) this.sendAsyncInternal(data, resolve, reject) }, () => { - this.sendAsyncInternal(data, resolve, reject) + if (data.method === 'net_listening') resolve({ jsonrpc: '2.0', result: 'canceled', id: data.id }) + else { + this.blockchain.changeExecutionContext('vm') + this.provider = this.blockchain.getCurrentProvider() + reject(new Error('Connection canceled')) + } }) } else { this.sendAsyncInternal(data, resolve, reject) @@ -62,8 +67,7 @@ export default class HardhatProvider extends Plugin { resolve(message) }) } else { - const result = data.method === 'net_listening' ? 'canceled' : [] - resolve({ jsonrpc: '2.0', result: result, id: data.id }) + resolve({ jsonrpc: '2.0', result: [], id: data.id }) } } } From 94910717816b82024628ca28a981c8fe722118cc Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 22 Jun 2021 16:04:45 +0530 Subject: [PATCH 02/21] specific error on tooltip --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 88fe3b7c85..8c2cd0ae05 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -59,6 +59,9 @@ export default class HardhatProvider extends Plugin { sendAsyncInternal (data, resolve, reject) { if (this.provider) { + // 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.blockchain.getProvider() !== 'Hardhat Provider' && data.method !== 'net_listening') return reject(new Error('Environment Updated !!')) this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => { if (error) { this.provider = null From b1a0286707378f5efb50e1165919be9446570ae9 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 22 Jun 2021 19:02:01 +0530 Subject: [PATCH 03/21] comments --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 8c2cd0ae05..0676d199d3 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -39,13 +39,17 @@ export default class HardhatProvider extends Plugin { sendAsync (data) { return new Promise((resolve, reject) => { + // If provider is not set, allow to open modal only when provider is trying to connect if (!this.provider || data.method === 'net_listening') { modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { this.provider = new Web3.providers.HttpProvider(target) this.sendAsyncInternal(data, resolve, reject) }, () => { + // If 'cancel' is clicked while trying to connect, handle it in custom manner if (data.method === 'net_listening') resolve({ jsonrpc: '2.0', result: 'canceled', id: data.id }) else { + // When node is abruptly stopped, modal will appear + // On which clicking on 'Cancel' will set the Envrionment to VM this.blockchain.changeExecutionContext('vm') this.provider = this.blockchain.getCurrentProvider() reject(new Error('Connection canceled')) From 552324df22ef9fd31811f21a38c4117496f06365 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 22 Jun 2021 19:20:13 +0530 Subject: [PATCH 04/21] added info in modal --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 0676d199d3..ec43d72ffc 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -32,12 +32,16 @@ export default class HardhatProvider extends Plugin {
For more info, visit: Hardhat Documentation

+ Note: Click on 'Cancel' if node is stopped. +

Hardhat JSON-RPC Endpoint ` } sendAsync (data) { + console.log('data in sendAsync-->', data) + console.log('provider in sendAsync-->', this.provider) return new Promise((resolve, reject) => { // If provider is not set, allow to open modal only when provider is trying to connect if (!this.provider || data.method === 'net_listening') { From 47117eda63fbe2be7325086ce825fc0c8f89b1d3 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 22 Jun 2021 19:22:01 +0530 Subject: [PATCH 05/21] consoles removed --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index ec43d72ffc..43fc613624 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -40,8 +40,6 @@ export default class HardhatProvider extends Plugin { } sendAsync (data) { - console.log('data in sendAsync-->', data) - console.log('provider in sendAsync-->', this.provider) return new Promise((resolve, reject) => { // If provider is not set, allow to open modal only when provider is trying to connect if (!this.provider || data.method === 'net_listening') { From c24b7e5926653c3ca7542aab97ee5dc0007a40d4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 28 Jun 2021 16:29:16 +0200 Subject: [PATCH 06/21] temporarily block provider --- .../src/app/tabs/hardhat-provider.js | 22 +++++++++---------- apps/remix-ide/src/remixAppManager.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 43fc613624..fa99969d20 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -1,6 +1,7 @@ import * as packageJson from '../../../../../package.json' import { Plugin } from '@remixproject/engine' import Web3 from 'web3' +import toaster from '../ui/tooltip' const yo = require('yo-yo') const modalDialogCustom = require('../ui/modal-dialog-custom') @@ -17,11 +18,13 @@ export default class HardhatProvider extends Plugin { constructor (blockchain) { super(profile) this.provider = null + this.blocked = false // used to block any call when trying to recover after a failed connection. this.blockchain = blockchain } onDeactivation () { this.provider = null + this.blocked = false } hardhatProviderDialogBody () { @@ -41,21 +44,14 @@ export default class HardhatProvider extends Plugin { sendAsync (data) { return new Promise((resolve, reject) => { + if (this.blocked) return reject(new Error('provider temporarily blocked')) // If provider is not set, allow to open modal only when provider is trying to connect - if (!this.provider || data.method === 'net_listening') { + if (!this.provider) { modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { this.provider = new Web3.providers.HttpProvider(target) this.sendAsyncInternal(data, resolve, reject) }, () => { - // If 'cancel' is clicked while trying to connect, handle it in custom manner - if (data.method === 'net_listening') resolve({ jsonrpc: '2.0', result: 'canceled', id: data.id }) - else { - // When node is abruptly stopped, modal will appear - // On which clicking on 'Cancel' will set the Envrionment to VM - this.blockchain.changeExecutionContext('vm') - this.provider = this.blockchain.getCurrentProvider() - reject(new Error('Connection canceled')) - } + this.sendAsyncInternal(data, resolve, reject) }) } else { this.sendAsyncInternal(data, resolve, reject) @@ -68,9 +64,13 @@ export default class HardhatProvider extends Plugin { // 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.blockchain.getProvider() !== 'Hardhat Provider' && data.method !== 'net_listening') return reject(new Error('Environment Updated !!')) - this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => { + this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, async (error, message) => { if (error) { + this.blocked = true + modalDialogCustom.alert('Hardhat', `Error while connecting to the hardhat provider: ${error.message}`) + await this.call('udapp', 'setEnvironmentMode', 'vm') this.provider = null + setTimeout(_ => this.blocked = false, 1000) return reject(error) } resolve(message) diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 26f684e432..45bc5a7421 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -14,7 +14,7 @@ const requiredModules = [ // services + layout views + system views const dependentModules = ['git', 'hardhat'] // module which shouldn't be manually activated (e.g git is activated by remixd) export function isNative (name) { - const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity'] + const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'hardhat-provider'] return nativePlugins.includes(name) || requiredModules.includes(name) } From b4fde6a4364b86779449861de46c0d94357c52d9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 29 Jun 2021 15:47:21 +0200 Subject: [PATCH 07/21] linting --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index fa99969d20..afcd72276a 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -1,7 +1,6 @@ import * as packageJson from '../../../../../package.json' import { Plugin } from '@remixproject/engine' import Web3 from 'web3' -import toaster from '../ui/tooltip' const yo = require('yo-yo') const modalDialogCustom = require('../ui/modal-dialog-custom') @@ -70,7 +69,7 @@ export default class HardhatProvider extends Plugin { modalDialogCustom.alert('Hardhat', `Error while connecting to the hardhat provider: ${error.message}`) await this.call('udapp', 'setEnvironmentMode', 'vm') this.provider = null - setTimeout(_ => this.blocked = false, 1000) + setTimeout(_ => { this.blocked = false }, 1000) return reject(error) } resolve(message) From cc35bf1cbd46ffb14ad5ec40dc2bb6a68e777b9e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 29 Jun 2021 16:41:54 +0200 Subject: [PATCH 08/21] label & comment --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index afcd72276a..06d9459426 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -43,7 +43,7 @@ export default class HardhatProvider extends Plugin { sendAsync (data) { return new Promise((resolve, reject) => { - if (this.blocked) return reject(new Error('provider temporarily blocked')) + if (this.blocked) return reject(new Error('provider unable to connect')) // If provider is not set, allow to open modal only when provider is trying to connect if (!this.provider) { modalDialogCustom.prompt('Hardhat node request', this.hardhatProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { @@ -66,10 +66,10 @@ export default class HardhatProvider extends Plugin { this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, async (error, message) => { if (error) { this.blocked = true - modalDialogCustom.alert('Hardhat', `Error while connecting to the hardhat provider: ${error.message}`) + modalDialogCustom.alert('Hardhat Provider', `Error while connecting to the hardhat provider: ${error.message}`) await this.call('udapp', 'setEnvironmentMode', 'vm') this.provider = null - setTimeout(_ => { this.blocked = false }, 1000) + setTimeout(_ => { this.blocked = false }, 1000) // we wait 1 second for letting remix to switch to vm return reject(error) } resolve(message) From 5631491b63f7a103b1dc9c10c4a7f04faa6186be Mon Sep 17 00:00:00 2001 From: Aniket <30843294+Aniket-Engg@users.noreply.github.com> Date: Wed, 30 Jun 2021 12:03:24 +0530 Subject: [PATCH 09/21] Update hardhat-provider.js --- apps/remix-ide/src/app/tabs/hardhat-provider.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/hardhat-provider.js b/apps/remix-ide/src/app/tabs/hardhat-provider.js index 06d9459426..805bc37e08 100644 --- a/apps/remix-ide/src/app/tabs/hardhat-provider.js +++ b/apps/remix-ide/src/app/tabs/hardhat-provider.js @@ -34,8 +34,6 @@ export default class HardhatProvider extends Plugin {
For more info, visit: Hardhat Documentation

- Note: Click on 'Cancel' if node is stopped. -

Hardhat JSON-RPC Endpoint ` @@ -75,7 +73,8 @@ export default class HardhatProvider extends Plugin { resolve(message) }) } else { - resolve({ jsonrpc: '2.0', result: [], id: data.id }) + const result = data.method === 'net_listening' ? 'canceled' : [] + resolve({ jsonrpc: '2.0', result: result, id: data.id }) } } } From 444893180aeef64ac66d11881536dfcf4925248e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 22 Jun 2021 14:27:13 +0200 Subject: [PATCH 10/21] improve loading opcodes --- .../debugger-ui/src/reducers/assembly-items.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts index 4038cce2d9..35d428c667 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts @@ -20,6 +20,14 @@ export const initialState = { hasError: null } +const reducedOpcode = (opCodes) => { + const length = 50 + let bottom = opCodes.index - 10 + bottom = bottom < 0 ? 0 : bottom + const top = bottom + length + return { top, bottom, display: opCodes.code.slice(bottom, top) } +} + export const reducer = (state = initialState, action: Action) => { switch (action.type) { case 'FETCH_OPCODES_REQUEST': { @@ -34,16 +42,12 @@ export const reducer = (state = initialState, action: Action) => { const opCodes = action.payload.address === state.opCodes.address ? { ...state.opCodes, index: action.payload.index } : deepEqual(action.payload.code, state.opCodes.code) ? state.opCodes : action.payload - const top = opCodes.index - 3 > 0 ? opCodes.index - 3 : 0 - const bottom = opCodes.index + 4 < opCodes.code.length ? opCodes.index + 4 : opCodes.code.length - const display = opCodes.code.slice(top, bottom) + const reduced = reducedOpcode(opCodes) return { opCodes, - display, - index: display.findIndex(code => code === opCodes.code[opCodes.index]), - top, - bottom, + display: reduced.display, + index: reduced.display.findIndex(code => code === opCodes.code[opCodes.index]), isRequesting: false, isSuccessful: true, hasError: null From 84e0d3315f2066069099db5fa8c2745efddfb47a Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 23 Jun 2021 11:05:37 +0200 Subject: [PATCH 11/21] highlight the next opcode to be executed --- libs/remix-debug/src/code/codeManager.ts | 4 +- libs/remix-debug/src/debugger/VmDebugger.ts | 4 +- .../src/lib/vm-debugger/assembly-items.tsx | 56 ++++++++++++++++--- .../src/reducers/assembly-items.ts | 14 +++-- 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/libs/remix-debug/src/code/codeManager.ts b/libs/remix-debug/src/code/codeManager.ts index fff30cba15..b0f61a0a24 100644 --- a/libs/remix-debug/src/code/codeManager.ts +++ b/libs/remix-debug/src/code/codeManager.ts @@ -147,13 +147,15 @@ export class CodeManager { private retrieveIndexAndTrigger (codeMananger, address, step, code) { let result + let next try { result = codeMananger.getInstructionIndex(address, step) + next = codeMananger.getInstructionIndex(address, step + 1) } catch (error) { return console.log(error) } try { - codeMananger.event.trigger('changed', [code, address, result]) + codeMananger.event.trigger('changed', [code, address, result, next]) } catch (e) { console.log('dispatching event failed', e) } diff --git a/libs/remix-debug/src/debugger/VmDebugger.ts b/libs/remix-debug/src/debugger/VmDebugger.ts index 2a90d0ed2c..47ea75ea4b 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.ts +++ b/libs/remix-debug/src/debugger/VmDebugger.ts @@ -59,8 +59,8 @@ export class VmDebuggerLogic { } listenToCodeManagerEvents () { - this._codeManager.event.register('changed', (code, address, index) => { - this.event.trigger('codeManagerChanged', [code, address, index]) + this._codeManager.event.register('changed', (code, address, index, nextIndex) => { + this.event.trigger('codeManagerChanged', [code, address, index, nextIndex]) }) } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 67f9821960..debabf4ce1 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -4,24 +4,28 @@ import './styles/assembly-items.css' export const AssemblyItems = ({ registerEvent }) => { const [assemblyItems, dispatch] = useReducer(reducer, initialState) + const [absoluteSelectedIndex, setAbsoluteSelectedIndex] = useState(0) const [selectedItem, setSelectedItem] = useState(0) + const [nextSelectedItem, setNextSelectedItem] = useState(1) const refs = useRef({}) const asmItemsRef = useRef(null) useEffect(() => { - registerEvent && registerEvent('codeManagerChanged', (code, address, index) => { - dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index } }) + registerEvent && registerEvent('codeManagerChanged', (code, address, index, nextIndex) => { + dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index, nextIndex } }) }) }, []) useEffect(() => { - if (selectedItem !== assemblyItems.index) { + console.log('useEffect', assemblyItems.index) + if (absoluteSelectedIndex !== assemblyItems.index) { + clearItems() indexChanged(assemblyItems.index) + nextIndexChanged(assemblyItems.nextIndex) } - }, [assemblyItems.index]) + }, [assemblyItems.opCodes.index]) - const indexChanged = (index: number) => { - if (index < 0) return + const clearItems = () => { let currentItem = refs.current[selectedItem] ? refs.current[selectedItem] : null if (currentItem) { @@ -30,15 +34,49 @@ export const AssemblyItems = ({ registerEvent }) => { if (currentItem.firstChild) { currentItem.firstChild.removeAttribute('style') } - const codeView = asmItemsRef.current + } - currentItem = codeView.children[index] + currentItem = refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null + + if (currentItem) { + currentItem.removeAttribute('selected') + currentItem.removeAttribute('style') + if (currentItem.firstChild) { + currentItem.firstChild.removeAttribute('style') + } + } + } + + const indexChanged = (index: number) => { + console.log("index " + index) + if (index < 0) return + + const codeView = asmItemsRef.current + + const currentItem = codeView.children[index] + if (currentItem) { currentItem.style.setProperty('border-color', 'var(--primary)') currentItem.style.setProperty('border-style', 'solid') currentItem.setAttribute('selected', 'selected') codeView.scrollTop = currentItem.offsetTop - parseInt(codeView.offsetTop) - setSelectedItem(index) } + + setSelectedItem(index) + setAbsoluteSelectedIndex(assemblyItems.opCodes.index) + } + + const nextIndexChanged = (index: number) => { + if (index < 0) return + + const codeView = asmItemsRef.current + + const currentItem = codeView.children[index] + if (currentItem) { + currentItem.style.setProperty('border-color', 'var(--secondary)') + currentItem.style.setProperty('border-style', 'dotted') + currentItem.setAttribute('selected', 'selected') + } + setNextSelectedItem(index) } return ( diff --git a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts index 35d428c667..ff6fe23b40 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts @@ -13,6 +13,7 @@ export const initialState = { }, display: [], index: 0, + nextIndex: -1, top: 0, bottom: 0, isRequesting: false, @@ -21,11 +22,15 @@ export const initialState = { } const reducedOpcode = (opCodes) => { - const length = 50 + const length = 100 let bottom = opCodes.index - 10 bottom = bottom < 0 ? 0 : bottom const top = bottom + length - return { top, bottom, display: opCodes.code.slice(bottom, top) } + return { + index: opCodes.index - bottom, + nextIndex:opCodes.nextIndex - bottom, + display: opCodes.code.slice(bottom, top) + } } export const reducer = (state = initialState, action: Action) => { @@ -40,14 +45,15 @@ export const reducer = (state = initialState, action: Action) => { } case 'FETCH_OPCODES_SUCCESS': { const opCodes = action.payload.address === state.opCodes.address ? { - ...state.opCodes, index: action.payload.index + ...state.opCodes, index: action.payload.index, nextIndex: action.payload.nextIndex } : deepEqual(action.payload.code, state.opCodes.code) ? state.opCodes : action.payload const reduced = reducedOpcode(opCodes) return { opCodes, display: reduced.display, - index: reduced.display.findIndex(code => code === opCodes.code[opCodes.index]), + index: reduced.index, + nextIndex: reduced.nextIndex, isRequesting: false, isSuccessful: true, hasError: null From 3ef6c2a9b80ae8db7a5e8f382f59d24728544dbc Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 23 Jun 2021 11:13:26 +0200 Subject: [PATCH 12/21] linting --- .../debugger-ui/src/lib/vm-debugger/assembly-items.tsx | 10 +++++----- .../debugger-ui/src/reducers/assembly-items.ts | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index debabf4ce1..248e4be9cc 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -48,9 +48,9 @@ export const AssemblyItems = ({ registerEvent }) => { } const indexChanged = (index: number) => { - console.log("index " + index) + console.log('index ' + index) if (index < 0) return - + const codeView = asmItemsRef.current const currentItem = codeView.children[index] @@ -60,21 +60,21 @@ export const AssemblyItems = ({ registerEvent }) => { currentItem.setAttribute('selected', 'selected') codeView.scrollTop = currentItem.offsetTop - parseInt(codeView.offsetTop) } - + setSelectedItem(index) setAbsoluteSelectedIndex(assemblyItems.opCodes.index) } const nextIndexChanged = (index: number) => { if (index < 0) return - + const codeView = asmItemsRef.current const currentItem = codeView.children[index] if (currentItem) { currentItem.style.setProperty('border-color', 'var(--secondary)') currentItem.style.setProperty('border-style', 'dotted') - currentItem.setAttribute('selected', 'selected') + currentItem.setAttribute('selected', 'selected') } setNextSelectedItem(index) } diff --git a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts index ff6fe23b40..bc9ea96580 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts @@ -26,10 +26,10 @@ const reducedOpcode = (opCodes) => { let bottom = opCodes.index - 10 bottom = bottom < 0 ? 0 : bottom const top = bottom + length - return { + return { index: opCodes.index - bottom, - nextIndex:opCodes.nextIndex - bottom, - display: opCodes.code.slice(bottom, top) + nextIndex: opCodes.nextIndex - bottom, + display: opCodes.code.slice(bottom, top) } } From 59e8169a8abe24d935a903e587a59b024f8bb7c2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 23 Jun 2021 11:18:27 +0200 Subject: [PATCH 13/21] add css style --- libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 af3648aa90..7adc8a9312 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -274,7 +274,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {

Debugger Configuration

-
+
{ setState(prevState => { return { ...prevState, opt: { debugWithGeneratedSources: checked } } From 0fd5334f473f7afa545169b29916901fda71c05b Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 23 Jun 2021 23:11:37 +0200 Subject: [PATCH 14/21] keep track of stop/revert/return indexes and outofgad indexes --- libs/remix-debug/src/code/codeManager.ts | 30 ++++++-- libs/remix-debug/src/debugger/VmDebugger.ts | 4 +- libs/remix-debug/src/trace/traceAnalyser.ts | 11 +++ libs/remix-debug/src/trace/traceCache.ts | 14 +++- libs/remix-debug/src/trace/traceManager.ts | 8 +++ .../src/web3Provider/web3VmProvider.ts | 2 +- .../src/lib/vm-debugger/assembly-items.tsx | 69 ++++++++++++++++++- .../src/reducers/assembly-items.ts | 14 ++-- 8 files changed, 136 insertions(+), 16 deletions(-) diff --git a/libs/remix-debug/src/code/codeManager.ts b/libs/remix-debug/src/code/codeManager.ts index b0f61a0a24..fb04f64945 100644 --- a/libs/remix-debug/src/code/codeManager.ts +++ b/libs/remix-debug/src/code/codeManager.ts @@ -145,17 +145,37 @@ export class CodeManager { }) } - private retrieveIndexAndTrigger (codeMananger, address, step, code) { + private async retrieveIndexAndTrigger (codeMananger, address, step, code) { let result let next + let returnInstructionIndexes = [] + let outOfGasInstructionIndexes = [] + try { result = codeMananger.getInstructionIndex(address, step) next = codeMananger.getInstructionIndex(address, step + 1) - } catch (error) { - return console.log(error) - } + + let values = this.traceManager.getAllStopIndexes() + values = values.filter((value) => value.address === address) + if (values) { + for (const value of values) { + returnInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + } + } + + values = this.traceManager.getAllOutofGasIndexes() + values = values.filter((value) => value.address === address) + if (values) { + for (const value of values) { + outOfGasInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + } + } + + } catch (error) { + return console.log(error) + } try { - codeMananger.event.trigger('changed', [code, address, result, next]) + codeMananger.event.trigger('changed', [code, address, result, next, returnInstructionIndexes, outOfGasInstructionIndexes]) } catch (e) { console.log('dispatching event failed', e) } diff --git a/libs/remix-debug/src/debugger/VmDebugger.ts b/libs/remix-debug/src/debugger/VmDebugger.ts index 47ea75ea4b..72a131cfd6 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.ts +++ b/libs/remix-debug/src/debugger/VmDebugger.ts @@ -59,8 +59,8 @@ export class VmDebuggerLogic { } listenToCodeManagerEvents () { - this._codeManager.event.register('changed', (code, address, index, nextIndex) => { - this.event.trigger('codeManagerChanged', [code, address, index, nextIndex]) + this._codeManager.event.register('changed', (code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes) => { + this.event.trigger('codeManagerChanged', [code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes]) }) } diff --git a/libs/remix-debug/src/trace/traceAnalyser.ts b/libs/remix-debug/src/trace/traceAnalyser.ts index ae8957b5ac..ba66f2dbb1 100644 --- a/libs/remix-debug/src/trace/traceAnalyser.ts +++ b/libs/remix-debug/src/trace/traceAnalyser.ts @@ -49,6 +49,17 @@ export class TraceAnalyser { this.traceCache.pushReturnValue(index, returnParamsObj) } + if (traceHelper.isReturnInstruction(step) || traceHelper.isStopInstruction(step) || traceHelper.isRevertInstruction(step)) { + this.traceCache.pushStopIndex(index, this.traceCache.currentCall.call.address) + } + + try { + if (parseInt(step.gas) - parseInt(step.gasCost) <= 0 || step.error === 'OutOfGas') { + this.traceCache.pushOutOfGasIndex(index, this.traceCache.currentCall.call.address) + } + } catch (e) { + console.error(e) + } } buildCalldata (index, step, tx, newContext) { diff --git a/libs/remix-debug/src/trace/traceCache.ts b/libs/remix-debug/src/trace/traceCache.ts index 7c2d381ccc..411e8e617c 100644 --- a/libs/remix-debug/src/trace/traceCache.ts +++ b/libs/remix-debug/src/trace/traceCache.ts @@ -5,6 +5,8 @@ const { sha3_256 } = util export class TraceCache { returnValues + stopIndexes + outofgasIndexes currentCall callsTree callsData @@ -24,6 +26,8 @@ export class TraceCache { // ...Changes contains index in the vmtrace of the corresponding changes this.returnValues = {} + this.stopIndexes = [] + this.outofgasIndexes = [] this.currentCall = null this.callsTree = null this.callsData = {} @@ -59,7 +63,7 @@ export class TraceCache { this.currentCall.call.reverted = reverted } var parent = this.currentCall.parent - this.currentCall = parent ? { call: parent.call, parent: parent.parent } : null + if (parent) this.currentCall = { call: parent.call, parent: parent.parent } return } const call = { @@ -78,6 +82,14 @@ export class TraceCache { this.currentCall = { call: call, parent: this.currentCall } } + pushOutOfGasIndex (index, address) { + this.outofgasIndexes.push({ index, address }) + } + + pushStopIndex (index, address) { + this.stopIndexes.push({ index, address }) + } + pushReturnValue (step, value) { this.returnValues[step] = value } diff --git a/libs/remix-debug/src/trace/traceManager.ts b/libs/remix-debug/src/trace/traceManager.ts index 8e78782922..848b3c57aa 100644 --- a/libs/remix-debug/src/trace/traceManager.ts +++ b/libs/remix-debug/src/trace/traceManager.ts @@ -209,6 +209,14 @@ export class TraceManager { return this.trace[stepIndex].pc } + getAllStopIndexes () { + return this.traceCache.stopIndexes + } + + getAllOutofGasIndexes () { + return this.traceCache.outofgasIndexes + } + getReturnValue (stepIndex) { try { this.checkRequestedStep(stepIndex) diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.ts b/libs/remix-lib/src/web3Provider/web3VmProvider.ts index 59b0e7e909..b5d8ea4732 100644 --- a/libs/remix-lib/src/web3Provider/web3VmProvider.ts +++ b/libs/remix-lib/src/web3Provider/web3VmProvider.ts @@ -138,7 +138,7 @@ export class Web3VmProvider { async txProcessed (data) { const lastOp = this.vmTraces[this.processingHash].structLogs[this.processingIndex - 1] if (lastOp) { - lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'thisDESTRUCT' + lastOp.error = lastOp.op !== 'RETURN' && lastOp.op !== 'STOP' && lastOp.op !== 'DESTRUCT' } this.vmTraces[this.processingHash].gas = '0x' + data.gasUsed.toString(16) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 248e4be9cc..de9c37e1bc 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -7,12 +7,14 @@ export const AssemblyItems = ({ registerEvent }) => { const [absoluteSelectedIndex, setAbsoluteSelectedIndex] = useState(0) const [selectedItem, setSelectedItem] = useState(0) const [nextSelectedItem, setNextSelectedItem] = useState(1) + const [returnInstructionIndexes, setReturnInstructionIndexes] = useState([]) + const [outOfGasInstructionIndexes, setOutOfGasInstructionIndexes] = useState([]) const refs = useRef({}) const asmItemsRef = useRef(null) useEffect(() => { - registerEvent && registerEvent('codeManagerChanged', (code, address, index, nextIndex) => { - dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index, nextIndex } }) + registerEvent && registerEvent('codeManagerChanged', (code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes) => { + dispatch({ type: 'FETCH_OPCODES_SUCCESS', payload: { code, address, index, nextIndex, returnInstructionIndexes, outOfGasInstructionIndexes } }) }) }, []) @@ -22,6 +24,8 @@ export const AssemblyItems = ({ registerEvent }) => { clearItems() indexChanged(assemblyItems.index) nextIndexChanged(assemblyItems.nextIndex) + returnIndexes(assemblyItems.returnInstructionIndexes) + outOfGasIndexes(assemblyItems.outOfGasInstructionIndexes) } }, [assemblyItems.opCodes.index]) @@ -45,10 +49,37 @@ export const AssemblyItems = ({ registerEvent }) => { currentItem.firstChild.removeAttribute('style') } } + + returnInstructionIndexes.map((index) => { + if (index < 0) return + + currentItem = refs.current[index] ? refs.current[index] : null + + if (currentItem) { + currentItem.removeAttribute('selected') + currentItem.removeAttribute('style') + if (currentItem.firstChild) { + currentItem.firstChild.removeAttribute('style') + } + } + }) + + outOfGasInstructionIndexes.map((index) => { + if (index < 0) return + + currentItem = refs.current[index] ? refs.current[index] : null + + if (currentItem) { + currentItem.removeAttribute('selected') + currentItem.removeAttribute('style') + if (currentItem.firstChild) { + currentItem.firstChild.removeAttribute('style') + } + } + }) } const indexChanged = (index: number) => { - console.log('index ' + index) if (index < 0) return const codeView = asmItemsRef.current @@ -79,6 +110,38 @@ export const AssemblyItems = ({ registerEvent }) => { setNextSelectedItem(index) } + const returnIndexes = (indexes) => { + indexes.map((index) => { + if (index < 0) return + + const codeView = asmItemsRef.current + + const currentItem = codeView.children[index] + if (currentItem) { + currentItem.style.setProperty('border-color', 'var(--warning)') + currentItem.style.setProperty('border-style', 'dotted') + currentItem.setAttribute('selected', 'selected') + } + }) + setReturnInstructionIndexes(indexes) + } + + const outOfGasIndexes = (indexes) => { + indexes.map((index) => { + if (index < 0) return + + const codeView = asmItemsRef.current + + const currentItem = codeView.children[index] + if (currentItem) { + currentItem.style.setProperty('border-color', 'var(--danger)') + currentItem.style.setProperty('border-style', 'dotted') + currentItem.setAttribute('selected', 'selected') + } + }) + setOutOfGasInstructionIndexes(indexes) + } + return (
diff --git a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts index bc9ea96580..d5a936bc95 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts @@ -14,6 +14,8 @@ export const initialState = { display: [], index: 0, nextIndex: -1, + returnInstructionIndexes: [], + outOfGasInstructionIndexes: [], top: 0, bottom: 0, isRequesting: false, @@ -21,7 +23,7 @@ export const initialState = { hasError: null } -const reducedOpcode = (opCodes) => { +const reducedOpcode = (opCodes, payload) => { const length = 100 let bottom = opCodes.index - 10 bottom = bottom < 0 ? 0 : bottom @@ -29,7 +31,9 @@ const reducedOpcode = (opCodes) => { return { index: opCodes.index - bottom, nextIndex: opCodes.nextIndex - bottom, - display: opCodes.code.slice(bottom, top) + display: opCodes.code.slice(bottom, top), + returnInstructionIndexes: payload.returnInstructionIndexes.map((index) => index.instructionIndex - bottom ), + outOfGasInstructionIndexes: payload.outOfGasInstructionIndexes.map((index) => index.instructionIndex - bottom ) } } @@ -48,7 +52,7 @@ export const reducer = (state = initialState, action: Action) => { ...state.opCodes, index: action.payload.index, nextIndex: action.payload.nextIndex } : deepEqual(action.payload.code, state.opCodes.code) ? state.opCodes : action.payload - const reduced = reducedOpcode(opCodes) + const reduced = reducedOpcode(opCodes, action.payload) return { opCodes, display: reduced.display, @@ -56,7 +60,9 @@ export const reducer = (state = initialState, action: Action) => { nextIndex: reduced.nextIndex, isRequesting: false, isSuccessful: true, - hasError: null + hasError: null, + returnInstructionIndexes: reduced.returnInstructionIndexes, + outOfGasInstructionIndexes: reduced.outOfGasInstructionIndexes } } case 'FETCH_OPCODES_ERROR': { From c0bd3883050dc575cb7735df5dad6e057f9830e9 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 24 Jun 2021 09:01:55 +0200 Subject: [PATCH 15/21] linting --- libs/remix-debug/src/code/codeManager.ts | 11 +++++------ libs/remix-debug/src/trace/traceAnalyser.ts | 4 ++-- .../debugger-ui/src/reducers/assembly-items.ts | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libs/remix-debug/src/code/codeManager.ts b/libs/remix-debug/src/code/codeManager.ts index fb04f64945..207f3e0510 100644 --- a/libs/remix-debug/src/code/codeManager.ts +++ b/libs/remix-debug/src/code/codeManager.ts @@ -148,8 +148,8 @@ export class CodeManager { private async retrieveIndexAndTrigger (codeMananger, address, step, code) { let result let next - let returnInstructionIndexes = [] - let outOfGasInstructionIndexes = [] + const returnInstructionIndexes = [] + const outOfGasInstructionIndexes = [] try { result = codeMananger.getInstructionIndex(address, step) @@ -170,10 +170,9 @@ export class CodeManager { outOfGasInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) } } - - } catch (error) { - return console.log(error) - } + } catch (error) { + return console.log(error) + } try { codeMananger.event.trigger('changed', [code, address, result, next, returnInstructionIndexes, outOfGasInstructionIndexes]) } catch (e) { diff --git a/libs/remix-debug/src/trace/traceAnalyser.ts b/libs/remix-debug/src/trace/traceAnalyser.ts index ba66f2dbb1..74651b228d 100644 --- a/libs/remix-debug/src/trace/traceAnalyser.ts +++ b/libs/remix-debug/src/trace/traceAnalyser.ts @@ -52,14 +52,14 @@ export class TraceAnalyser { if (traceHelper.isReturnInstruction(step) || traceHelper.isStopInstruction(step) || traceHelper.isRevertInstruction(step)) { this.traceCache.pushStopIndex(index, this.traceCache.currentCall.call.address) } - + try { if (parseInt(step.gas) - parseInt(step.gasCost) <= 0 || step.error === 'OutOfGas') { this.traceCache.pushOutOfGasIndex(index, this.traceCache.currentCall.call.address) } } catch (e) { console.error(e) - } + } } buildCalldata (index, step, tx, newContext) { diff --git a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts index d5a936bc95..18622bfa68 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts @@ -32,8 +32,8 @@ const reducedOpcode = (opCodes, payload) => { index: opCodes.index - bottom, nextIndex: opCodes.nextIndex - bottom, display: opCodes.code.slice(bottom, top), - returnInstructionIndexes: payload.returnInstructionIndexes.map((index) => index.instructionIndex - bottom ), - outOfGasInstructionIndexes: payload.outOfGasInstructionIndexes.map((index) => index.instructionIndex - bottom ) + returnInstructionIndexes: payload.returnInstructionIndexes.map((index) => index.instructionIndex - bottom), + outOfGasInstructionIndexes: payload.outOfGasInstructionIndexes.map((index) => index.instructionIndex - bottom) } } From b78ff327ccbb83bf1d7f91a9bd8e3498318b9690 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 24 Jun 2021 14:37:50 +0200 Subject: [PATCH 16/21] remove unneeded loop --- libs/remix-debug/src/code/codeManager.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/remix-debug/src/code/codeManager.ts b/libs/remix-debug/src/code/codeManager.ts index 207f3e0510..390c988eed 100644 --- a/libs/remix-debug/src/code/codeManager.ts +++ b/libs/remix-debug/src/code/codeManager.ts @@ -156,18 +156,20 @@ export class CodeManager { next = codeMananger.getInstructionIndex(address, step + 1) let values = this.traceManager.getAllStopIndexes() - values = values.filter((value) => value.address === address) if (values) { for (const value of values) { - returnInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + if (value.address === address) { + returnInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + } } } values = this.traceManager.getAllOutofGasIndexes() - values = values.filter((value) => value.address === address) if (values) { for (const value of values) { - outOfGasInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + if (value.address === address) { + outOfGasInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + } } } } catch (error) { From f8989c663f95fb293a9b46e8ff95021162167a34 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 24 Jun 2021 14:38:25 +0200 Subject: [PATCH 17/21] remove console.log --- libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index de9c37e1bc..3f1a4c5235 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -19,7 +19,6 @@ export const AssemblyItems = ({ registerEvent }) => { }, []) useEffect(() => { - console.log('useEffect', assemblyItems.index) if (absoluteSelectedIndex !== assemblyItems.index) { clearItems() indexChanged(assemblyItems.index) From 3959e1bb5768be091cb59aafae0b815a28d6e3ee Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 24 Jun 2021 14:42:14 +0200 Subject: [PATCH 18/21] refactor --- .../src/lib/vm-debugger/assembly-items.tsx | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 3f1a4c5235..af6c061e6c 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -28,19 +28,7 @@ export const AssemblyItems = ({ registerEvent }) => { } }, [assemblyItems.opCodes.index]) - const clearItems = () => { - let currentItem = refs.current[selectedItem] ? refs.current[selectedItem] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - } - - currentItem = refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null - + let clearItem = (currentItem) => { if (currentItem) { currentItem.removeAttribute('selected') currentItem.removeAttribute('style') @@ -48,33 +36,20 @@ export const AssemblyItems = ({ registerEvent }) => { currentItem.firstChild.removeAttribute('style') } } + } + const clearItems = () => { + clearItem(refs.current[selectedItem] ? refs.current[selectedItem] : null) + clearItem(refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null) + returnInstructionIndexes.map((index) => { if (index < 0) return - - currentItem = refs.current[index] ? refs.current[index] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - } + clearItem(refs.current[index] ? refs.current[index] : null) }) outOfGasInstructionIndexes.map((index) => { if (index < 0) return - - currentItem = refs.current[index] ? refs.current[index] : null - - if (currentItem) { - currentItem.removeAttribute('selected') - currentItem.removeAttribute('style') - if (currentItem.firstChild) { - currentItem.firstChild.removeAttribute('style') - } - } + clearItem(refs.current[index] ? refs.current[index] : null) }) } From 5086d96cecc9d8dd03f36e3b5737cd94329938b1 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 29 Jun 2021 15:07:20 +0200 Subject: [PATCH 19/21] linting --- libs/remix-debug/src/code/codeManager.ts | 4 ++-- .../debugger-ui/src/lib/vm-debugger/assembly-items.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-debug/src/code/codeManager.ts b/libs/remix-debug/src/code/codeManager.ts index 390c988eed..f0b38ea3d9 100644 --- a/libs/remix-debug/src/code/codeManager.ts +++ b/libs/remix-debug/src/code/codeManager.ts @@ -159,7 +159,7 @@ export class CodeManager { if (values) { for (const value of values) { if (value.address === address) { - returnInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + returnInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) } } } @@ -168,7 +168,7 @@ export class CodeManager { if (values) { for (const value of values) { if (value.address === address) { - outOfGasInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) + outOfGasInstructionIndexes.push({ instructionIndex: this.getInstructionIndex(address, value.index), address }) } } } diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index af6c061e6c..8b0ed07d9c 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -28,7 +28,7 @@ export const AssemblyItems = ({ registerEvent }) => { } }, [assemblyItems.opCodes.index]) - let clearItem = (currentItem) => { + const clearItem = (currentItem) => { if (currentItem) { currentItem.removeAttribute('selected') currentItem.removeAttribute('style') @@ -41,7 +41,7 @@ export const AssemblyItems = ({ registerEvent }) => { const clearItems = () => { clearItem(refs.current[selectedItem] ? refs.current[selectedItem] : null) clearItem(refs.current[nextSelectedItem] ? refs.current[nextSelectedItem] : null) - + returnInstructionIndexes.map((index) => { if (index < 0) return clearItem(refs.current[index] ? refs.current[index] : null) From 857d47591878a97c01aa1a3ca655eb495a1ebb69 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 30 Jun 2021 16:52:09 +0200 Subject: [PATCH 20/21] change font style --- .../debugger-ui/src/lib/vm-debugger/assembly-items.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 8b0ed07d9c..1606ce8491 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -60,8 +60,8 @@ export const AssemblyItems = ({ registerEvent }) => { const currentItem = codeView.children[index] if (currentItem) { - currentItem.style.setProperty('border-color', 'var(--primary)') - currentItem.style.setProperty('border-style', 'solid') + currentItem.style.setProperty('background-color', 'var(--primary)') + currentItem.style.setProperty('color', 'var(--light)') currentItem.setAttribute('selected', 'selected') codeView.scrollTop = currentItem.offsetTop - parseInt(codeView.offsetTop) } From dcefec4a7deb02ef07d05677aa7a778159dc4b7d Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 30 Jun 2021 21:38:46 +0200 Subject: [PATCH 21/21] fix e2e --- apps/remix-ide-e2e/src/tests/pluginManager.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/pluginManager.spec.ts b/apps/remix-ide-e2e/src/tests/pluginManager.spec.ts index bd2884e4e5..f87bf1269e 100644 --- a/apps/remix-ide-e2e/src/tests/pluginManager.spec.ts +++ b/apps/remix-ide-e2e/src/tests/pluginManager.spec.ts @@ -5,7 +5,7 @@ import init from '../helpers/init' const testData = { pluginName: 'remixIde', pluginDisplayName: 'Remix IDE', - pluginUrl: 'https://zokrates-remix-plugin.netlify.app/' + pluginUrl: 'https://zokrates.github.io/zokrates-remix-plugin/' } module.exports = {