Merge branch 'master' into remixd_terminal

pull/1342/head
David Zagi 3 years ago committed by GitHub
commit d14a404e97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      apps/debugger/src/app/debugger-api.ts
  2. 3
      apps/debugger/src/app/debugger.ts
  3. 2
      apps/remix-ide-e2e/src/tests/publishContract.test.ts
  4. 20
      libs/remix-debug/src/Ethdebugger.ts
  5. 51
      libs/remix-debug/src/debugger/debugger.ts
  6. 3
      libs/remix-debug/src/trace/traceManager.ts
  7. 58
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx
  8. 3
      libs/remix-ui/debugger-ui/src/lib/idebugger-api.ts
  9. 4
      libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx

@ -16,6 +16,7 @@ export const DebuggerApiMixin = (Base) => class extends Base {
}
}
this._web3 = new Web3(this.web3Provider)
remixDebug.init.extendWeb3(this._web3)
this.offsetToLineColumnConverter = {
async offsetToLineColumn (rawLocation, file, sources, asts) {

@ -23,6 +23,7 @@ export class DebuggerClientApi extends DebuggerApiMixin(PluginClient) {
fetchContractAndCompile: (address: string, currentReceipt: TransactionReceipt) => Promise<CompilerAbstract>
getFile: (path: string) => Promise<string>
setFile: (path: string, content: string) => Promise<void>
getDebugWeb3: () => any // returns an instance of web3.js
getDebugWeb3: () => any // returns an instance of web3.js, if applicable (mainet, goerli, ...) it returns a reference to a node from devops (so we are sure debug endpoint is available)
web3: () => any // returns an instance of web3.js
}

@ -32,6 +32,7 @@ module.exports = {
.click('[data-id="publishToStorage-modal-footer-ok-react"]')
},
/* Disableing the test untill refactoring and the new swarm usage
'Publish on Swarm': '' + function (browser: NightwatchBrowser) {
browser
.click('#publishOnSwarm')
@ -47,6 +48,7 @@ module.exports = {
})
.click('[data-id="publishToStorage-modal-footer-ok-react"]')
},
*/
'Should publish contract metadata to ipfs on deploy': function (browser: NightwatchBrowser) {
browser

@ -33,7 +33,6 @@ export class Ethdebugger {
storageResolver
callTree
breakpointManager
statusMessage
constructor (opts) {
this.compilationResult = opts.compilationResult || function (contractAddress) { return null }
@ -151,22 +150,19 @@ export class Ethdebugger {
this.event.trigger('traceUnloaded')
}
debug (tx) {
async debug (tx) {
if (this.traceManager.isLoading) {
return
}
tx.to = tx.to || contractCreationToken('0')
this.tx = tx
this.traceManager.resolveTrace(tx).then(async (result) => {
this.setCompilationResult(await this.compilationResult(tx.to))
this.event.trigger('newTraceLoaded', [this.traceManager.trace])
if (this.breakpointManager && this.breakpointManager.hasBreakpoint()) {
this.breakpointManager.jumpNextBreakpoint(false)
}
this.storageResolver = new StorageResolver({ web3: this.traceManager.web3 })
}).catch((error) => {
this.statusMessage = error ? error.message : 'Trace not loaded'
})
await this.traceManager.resolveTrace(tx)
this.setCompilationResult(await this.compilationResult(tx.to))
this.event.trigger('newTraceLoaded', [this.traceManager.trace])
if (this.breakpointManager && this.breakpointManager.hasBreakpoint()) {
this.breakpointManager.jumpNextBreakpoint(false)
}
this.storageResolver = new StorageResolver({ web3: this.traceManager.web3 })
}
}

@ -99,44 +99,31 @@ export class Debugger {
this.debugger.web3 = web3
}
debug (blockNumber, txNumber, tx, loadingCb): Promise<void> {
async debug (blockNumber, txNumber, tx, loadingCb) {
const web3 = this.debugger.web3
return new Promise((resolve, reject) => {
if (this.debugger.traceManager.isLoading) {
return resolve()
}
if (this.debugger.traceManager.isLoading) {
return
}
if (tx) {
if (!tx.to) {
tx.to = contractCreationToken('0')
}
this.debugTx(tx, loadingCb)
return resolve()
if (tx) {
if (!tx.to) {
tx.to = contractCreationToken('0')
}
return await this.debugTx(tx, loadingCb)
}
try {
if (txNumber.indexOf('0x') !== -1) {
return web3.eth.getTransaction(txNumber, (_error, tx) => {
if (_error) return reject(_error)
if (!tx) return reject(new Error('cannot find transaction ' + txNumber))
this.debugTx(tx, loadingCb)
return resolve()
})
}
web3.eth.getTransactionFromBlock(blockNumber, txNumber, (_error, tx) => {
if (_error) return reject(_error)
if (!tx) return reject(new Error('cannot find transaction ' + blockNumber + ' ' + txNumber))
this.debugTx(tx, loadingCb)
return resolve()
})
} catch (e) {
return reject(e.message)
}
})
if (txNumber.indexOf('0x') !== -1) {
tx = await web3.eth.getTransaction(txNumber)
if (!tx) throw new Error('cannot find transaction ' + txNumber)
} else {
tx = await web3.eth.getTransactionFromBlock(blockNumber, txNumber)
if (!tx) throw new Error('cannot find transaction ' + blockNumber + ' ' + txNumber)
}
return await this.debugTx(tx, loadingCb)
}
debugTx (tx, loadingCb) {
async debugTx (tx, loadingCb) {
this.step_manager = new DebuggerStepManager(this.debugger, this.debugger.traceManager)
this.debugger.codeManager.event.register('changed', this, (code, address, instIndex) => {
@ -162,7 +149,7 @@ export class Debugger {
})
loadingCb()
this.debugger.debug(tx)
await this.debugger.debug(tx)
}
unload () {

@ -30,9 +30,8 @@ export class TraceManager {
this.init()
if (!this.web3) throw new Error('web3 not loaded')
this.isLoading = true
const result = await this.getTrace(tx.hash)
try {
const result = await this.getTrace(tx.hash)
if (result['structLogs'].length > 0) {
this.trace = result['structLogs']

@ -15,7 +15,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
const debuggerModule = props.debuggerAPI
const [state, setState] = useState({
isActive: false,
statusMessage: '',
debugger: null,
currentReceipt: {
contractAddress: null,
@ -25,7 +24,8 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
txNumber: '',
debugging: false,
opt: {
debugWithGeneratedSources: false
debugWithGeneratedSources: false,
debugWithLocalNode: false
},
toastMessage: '',
validationError: '',
@ -132,7 +132,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return {
...prevState,
isActive: false,
statusMessage: '',
debugger: null,
currentReceipt: {
contractAddress: null,
@ -166,7 +165,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
return
}
const web3 = await debuggerModule.getDebugWeb3()
const web3 = state.opt.debugWithLocalNode ? await debuggerModule.web3() : await debuggerModule.getDebugWeb3()
try {
const networkId = await web3.eth.net.getId()
_paq.push(['trackEvent', 'debugger', 'startDebugging', networkId])
@ -211,33 +210,31 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
debugWithGeneratedSources: state.opt.debugWithGeneratedSources
})
debuggerInstance.debug(blockNumber, txNumber, tx, () => {
listenToEvents(debuggerInstance, currentReceipt)
setState(prevState => {
return {
...prevState,
blockNumber,
txNumber,
debugging: true,
currentReceipt,
debugger: debuggerInstance,
toastMessage: `debugging ${txNumber}`,
validationError: ''
}
})
}).catch((error) => {
if (JSON.stringify(error) !== '{}') {
let message = 'Error: ' + JSON.stringify(error)
message = message.split('\\"').join('\'')
try {
await debuggerInstance.debug(blockNumber, txNumber, tx, () => {
listenToEvents(debuggerInstance, currentReceipt)
setState(prevState => {
return {
...prevState,
validationError: message
blockNumber,
txNumber,
debugging: true,
currentReceipt,
debugger: debuggerInstance,
toastMessage: `debugging ${txNumber}`,
validationError: ''
}
})
}
})
} catch (error) {
unLoad()
})
setState(prevState => {
return {
...prevState,
validationError: error.message || error
}
})
}
}
const debug = (txHash) => {
@ -277,18 +274,25 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
<div className="mt-2 mb-2 debuggerConfig custom-control custom-checkbox">
<input className="custom-control-input" id="debugGeneratedSourcesInput" onChange={({ target: { checked } }) => {
setState(prevState => {
return { ...prevState, opt: { debugWithGeneratedSources: checked } }
return { ...prevState, opt: { ...prevState.opt, debugWithGeneratedSources: checked } }
})
}} type="checkbox" title="Debug with generated sources" />
<label data-id="debugGeneratedSourcesLabel" className="form-check-label custom-control-label" htmlFor="debugGeneratedSourcesInput">Use generated sources (from Solidity v0.7.2)</label>
</div>
<div className="mt-2 mb-2 debuggerConfig custom-control custom-checkbox">
<input className="custom-control-input" id="debugWithLocalNodeInput" onChange={({ target: { checked } }) => {
setState(prevState => {
return { ...prevState, opt: { ...prevState.opt, debugWithLocalNode: checked } }
})
}} type="checkbox" title="Force the debugger to use the current local node" />
<label data-id="debugLocaNodeLabel" className="form-check-label custom-control-label" htmlFor="debugWithLocalNodeInput">Force using local node</label>
</div>
{ state.validationError && <span className="w-100 py-1 text-danger validationError">{state.validationError}</span> }
</div>
<TxBrowser requestDebug={ requestDebug } unloadRequested={ unloadRequested } updateTxNumberFlag={ updateTxNumberFlag } transactionNumber={ state.txNumber } debugging={ state.debugging } />
{ state.debugging && <StepManager stepManager={ stepManager } /> }
{ state.debugging && <VmDebuggerHead vmDebugger={ vmDebugger } /> }
</div>
{ state.debugging && <div className="statusMessage">{ state.statusMessage }</div> }
{ state.debugging && <VmDebugger vmDebugger={ vmDebugger } /> }
</div>
)

@ -62,6 +62,7 @@ export interface IDebuggerApi {
fetchContractAndCompile: (address: string, currentReceipt: TransactionReceipt) => Promise<CompilationOutput>
getFile: (path: string) => Promise<string>
setFile: (path: string, content: string) => Promise<void>
getDebugWeb3: () => any // returns an instance of web3.js
getDebugWeb3: () => any // returns an instance of web3.js, if applicable (mainet, goerli, ...) it returns a reference to a node from devops (so we are sure debug endpoint is available)
web3: () => any // returns an instance of web3.js
showMessage (title: string, message: string): void
}

@ -203,10 +203,6 @@ export const ContractSelection = (props: ContractSelectionProps) => {
</select>
</div>
<article className="mt-2 pb-0">
<button id="publishOnSwarm" className="btn btn-secondary btn-block" title="Publish on Swarm" onClick={() => { handlePublishToStorage('swarm') }}>
<span>Publish on Swarm</span>
<img id="swarmLogo" className="remixui_storageLogo ml-2" src="assets/img/swarm.webp" />
</button>
<button id="publishOnIpfs" className="btn btn-secondary btn-block" title="Publish on Ipfs" onClick={() => { handlePublishToStorage('ipfs') }}>
<span>Publish on Ipfs</span>
<img id="ipfsLogo" className="remixui_storageLogo ml-2" src="assets/img/ipfs.webp" />

Loading…
Cancel
Save