Merge branch 'fsfallback' of https://github.com/ethereum/remix-project into fsfallback

pull/2113/head
filip mertens 3 years ago
commit 40b9b41f85
  1. 5
      apps/remix-ide-e2e/src/commands/goToVMTraceStep.ts
  2. 3
      apps/remix-ide/src/app/files/fileManager.ts
  3. 1
      apps/remix-ide/src/app/files/workspaceFileProvider.js
  4. 4
      libs/remix-debug/src/debugger/stepManager.ts
  5. 8
      libs/remix-debug/src/solidity-decoder/decodeInfo.ts
  6. 12
      libs/remix-debug/src/solidity-decoder/types/FunctionType.ts
  7. 33
      libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx

@ -12,7 +12,10 @@ class GoToVmTraceStep extends EventEmitter {
function goToVMtraceStep (browser: NightwatchBrowser, step: number, incr: number, done: VoidFunction) { function goToVMtraceStep (browser: NightwatchBrowser, step: number, incr: number, done: VoidFunction) {
browser.execute(function (step) { (document.getElementById('slider') as HTMLInputElement).value = (step - 1).toString() }, [step]) browser.execute(function (step) { (document.getElementById('slider') as HTMLInputElement).value = (step - 1).toString() }, [step])
.setValue('*[data-id="slider"]', new Array(1).fill(browser.Keys.RIGHT_ARROW)) .setValue('*[data-id="slider"]', new Array(1).fill(browser.Keys.RIGHT_ARROW))
.pause(1000) .execute((step) => {
(document.querySelector('*[data-id="slider"]') as any).internal_onmouseup({ target: { value: step }})
}, [step])
.pause(10000)
.perform(() => { .perform(() => {
done() done()
}) })

@ -608,9 +608,10 @@ class FileManager extends Plugin {
this.events.emit('noFileSelected') this.events.emit('noFileSelected')
} else { } else {
file = this.normalize(file) file = this.normalize(file)
await this.saveCurrentFile()
const resolved = this.getPathFromUrl(file) const resolved = this.getPathFromUrl(file)
file = resolved.file file = resolved.file
await this.saveCurrentFile()
if (this.currentFile() === file) return
const provider = resolved.provider const provider = resolved.provider
this._deps.config.set('currentFile', file) this._deps.config.set('currentFile', file)
this.openedFiles[file] = file this.openedFiles[file] = file

@ -32,6 +32,7 @@ class WorkspaceFileProvider extends FileProvider {
removePrefix (path) { removePrefix (path) {
path = path.replace(/^\/|\/$/g, '') // remove first and last slash path = path.replace(/^\/|\/$/g, '') // remove first and last slash
path = path.replace(/^\.\/+/, '') // remove ./ from start of string
if (path.startsWith(this.workspacesPath + '/' + this.workspace)) return path if (path.startsWith(this.workspacesPath + '/' + this.workspace)) return path
const splitPath = path.split('/') const splitPath = path.split('/')

@ -121,6 +121,7 @@ export class DebuggerStepManager {
if (solidityMode) { if (solidityMode) {
step = this.resolveToReducedTrace(step, -1) step = this.resolveToReducedTrace(step, -1)
} }
if (this.currentStepIndex === step) return
this.currentStepIndex = step this.currentStepIndex = step
this.triggerStepChanged(step) this.triggerStepChanged(step)
} }
@ -136,6 +137,7 @@ export class DebuggerStepManager {
if (solidityMode) { if (solidityMode) {
step = this.resolveToReducedTrace(step, 1) step = this.resolveToReducedTrace(step, 1)
} }
if (this.currentStepIndex === step) return
this.currentStepIndex = step this.currentStepIndex = step
this.triggerStepChanged(step) this.triggerStepChanged(step)
} }
@ -146,12 +148,14 @@ export class DebuggerStepManager {
if (solidityMode) { if (solidityMode) {
step = this.resolveToReducedTrace(step, 0) step = this.resolveToReducedTrace(step, 0)
} }
if (this.currentStepIndex === step) return
this.currentStepIndex = step this.currentStepIndex = step
this.triggerStepChanged(step) this.triggerStepChanged(step)
} }
jumpTo (step) { jumpTo (step) {
if (!this.traceManager.inRange(step)) return if (!this.traceManager.inRange(step)) return
if (this.currentStepIndex === step) return
this.currentStepIndex = step this.currentStepIndex = step
this.triggerStepChanged(step) this.triggerStepChanged(step)
} }

@ -11,6 +11,7 @@ import { Struct as StructType } from './types/Struct'
import { Int as IntType } from './types/Int' import { Int as IntType } from './types/Int'
import { Uint as UintType } from './types/Uint' import { Uint as UintType } from './types/Uint'
import { Mapping as MappingType } from './types/Mapping' import { Mapping as MappingType } from './types/Mapping'
import { FunctionType } from './types/FunctionType'
import { extractLocation, removeLocation } from './types/util' import { extractLocation, removeLocation } from './types/util'
/** /**
@ -78,6 +79,10 @@ function bool (type) {
return new BoolType() return new BoolType()
} }
function functionType (type, stateDefinitions, contractName, location) {
return new FunctionType(type, stateDefinitions, contractName, location)
}
/** /**
* DynamicByteArray decode the given @arg type * DynamicByteArray decode the given @arg type
* *
@ -300,7 +305,8 @@ function parseType (type, stateDefinitions, contractName, location) {
struct: struct, struct: struct,
int: int, int: int,
uint: uint, uint: uint,
mapping: mapping mapping: mapping,
function: functionType
} }
const currentType = typeClass(type) const currentType = typeClass(type)
if (currentType === null) { if (currentType === null) {

@ -0,0 +1,12 @@
'use strict'
import { ValueType } from './ValueType'
export class FunctionType extends ValueType {
constructor (type, stateDefinitions, contractName, location) {
super(1, 8, 'function')
}
decodeValue (value) {
return 'at program counter ' + value
}
}

@ -1,47 +1,42 @@
import React, { useState, useEffect, useRef } from 'react' // eslint-disable-line import React, { useState, useEffect, useRef } from 'react' // eslint-disable-line
export const Slider = ({ jumpTo, sliderValue, traceLength }) => { export const Slider = ({ jumpTo, sliderValue, traceLength }) => {
const [state, setState] = useState({
currentValue: 0
})
const onChangeId = useRef(null) const onChangeId = useRef(null)
const slider = useRef(null)
useEffect(() => { useEffect(() => {
setValue(sliderValue) setValue(sliderValue)
}, [sliderValue]) }, [sliderValue])
const setValue = (value) => { const setValue = (value) => {
if (value === state.currentValue) return if (value === slider.current.value) return
setState(prevState => { slider.current.value = value
return { ...prevState, currentValue: value }
})
jumpTo && jumpTo(value)
}
const handleChange = (e) => {
if (onChangeId.current) { if (onChangeId.current) {
window.clearTimeout(onChangeId.current) clearTimeout(onChangeId.current)
} }
((value) => { ((value) => {
onChangeId.current = setTimeout(() => { onChangeId.current = setTimeout(() => {
console.log(value) jumpTo && jumpTo(value)
value = parseInt(value)
setValue(value)
}, 100) }, 100)
})(e.target.value) })(value)
} }
const handleChange = (e) => {
setValue(parseInt(e.target.value))
}
if (slider.current) slider.current.internal_onmouseup = handleChange
return ( return (
<div> <div>
<input id='slider' <input id='slider'
data-id="slider" data-id="slider"
className='w-100 my-0' className='w-100 my-0'
ref={slider}
type='range' type='range'
min={0} min={0}
max={traceLength ? traceLength - 1 : 0} max={traceLength ? traceLength - 1 : 0}
value={state.currentValue} onMouseUp={handleChange}
onChange={handleChange}
disabled={traceLength ? traceLength === 0 : true} disabled={traceLength ? traceLength === 0 : true}
/> />
</div> </div>

Loading…
Cancel
Save