From 1e4eaa5fb6331f3ad85d96cd352646df528163a6 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Fri, 11 Jan 2019 10:54:00 +0000 Subject: [PATCH] fix: allow to debug instanceOf contracts --- embark-ui/src/containers/EditorContainer.js | 7 ++++--- embark-ui/src/reducers/selectors.js | 2 +- src/lib/modules/contracts_manager/index.js | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/embark-ui/src/containers/EditorContainer.js b/embark-ui/src/containers/EditorContainer.js index 1b084e94a..7cbd04ff4 100644 --- a/embark-ui/src/containers/EditorContainer.js +++ b/embark-ui/src/containers/EditorContainer.js @@ -35,6 +35,7 @@ class EditorContainer extends React.Component { this.state = { currentAsideTab: {}, + debuggingContract: null, showHiddenFiles: false, currentFile: this.props.currentFile, editorHeight: this.DEFAULT_HEIGHT, @@ -78,11 +79,11 @@ class EditorContainer extends React.Component { this.setState({currentFile: this.props.currentFile}); } - if(this.props.contracts && this.props.transaction !== prevProps.transaction && this.props.transaction) { + if(this.props.contracts.length && this.props.transaction) { const debuggingContract = this.props.contracts.find(contract => contract.address === this.props.transaction.to) - if (debuggingContract) { + if (this.state.debuggingContract !== debuggingContract) { const editorWidth = this.getNewEditorWidth(OPERATIONS.LESS) - this.setState({currentAsideTab: TextEditorToolbarTabs.Debugger, editorWidth}) + this.setState({currentAsideTab: TextEditorToolbarTabs.Debugger, editorWidth, debuggingContract}) this.props.fetchFile({path: debuggingContract.path}); } } diff --git a/embark-ui/src/reducers/selectors.js b/embark-ui/src/reducers/selectors.js index 69b2aae66..c9921b1ef 100644 --- a/embark-ui/src/reducers/selectors.js +++ b/embark-ui/src/reducers/selectors.js @@ -234,7 +234,7 @@ export function getDebuggerInfo(state) { } export function getDebuggerLine(state) { - if (!state.debuggerInfo.sources) return; + if (!state.debuggerInfo.sources || !state.debuggerInfo.sources.lineColumnPos[0]) return; return state.debuggerInfo.sources.lineColumnPos[0].start.line + 1; } diff --git a/src/lib/modules/contracts_manager/index.js b/src/lib/modules/contracts_manager/index.js index 639e65c5d..d2f1fa275 100644 --- a/src/lib/modules/contracts_manager/index.js +++ b/src/lib/modules/contracts_manager/index.js @@ -423,6 +423,9 @@ class ContractsManager { })); } + contract.path = parentContract.path; + contract.originalFilename = parentContract.originalFilename; + contract.filename = parentContract.filename; contract.code = parentContract.code; contract.runtimeBytecode = parentContract.runtimeBytecode; contract.realRuntimeBytecode = (parentContract.realRuntimeBytecode || parentContract.runtimeBytecode);