diff --git a/packages/truffle-debugger/lib/ast/sagas/index.js b/packages/truffle-debugger/lib/ast/sagas/index.js index 480166cf4ff..08bb7bba4ca 100644 --- a/packages/truffle-debugger/lib/ast/sagas/index.js +++ b/packages/truffle-debugger/lib/ast/sagas/index.js @@ -47,6 +47,11 @@ function *handleEnter(sourceId, node, pointer, parentId) { debug("%s recording variable %o", pointer, node); yield *data.declare(node); break; + case "ContractDefinition": + case "StructDefinition": + case "EnumDefinition": + yield *data.defineType(node); + break; } } diff --git a/packages/truffle-debugger/lib/data/actions/index.js b/packages/truffle-debugger/lib/data/actions/index.js index 2b1398a195e..44a98a51be0 100644 --- a/packages/truffle-debugger/lib/data/actions/index.js +++ b/packages/truffle-debugger/lib/data/actions/index.js @@ -56,3 +56,11 @@ export function learnAddress(dummyAddress, address) { address }; } + +export const DEFINE_TYPE = "DEFINE_TYPE"; +export function defineType(node) { + return { + type: DEFINE_TYPE, + node + }; +} diff --git a/packages/truffle-debugger/lib/data/reducers.js b/packages/truffle-debugger/lib/data/reducers.js index d543edd7c36..8c402e11b07 100644 --- a/packages/truffle-debugger/lib/data/reducers.js +++ b/packages/truffle-debugger/lib/data/reducers.js @@ -5,8 +5,6 @@ import { combineReducers } from "redux"; import { stableKeccak256 } from "lib/helpers"; -import { Allocation } from "truffle-decode-utils"; - import * as actions from "./actions"; const DEFAULT_SCOPES = { @@ -70,16 +68,8 @@ function scopes(state = DEFAULT_SCOPES, action) { function userDefinedTypes(state = [], action) { switch (action.type) { - case actions.DECLARE: - const userDefinedNodeTypes = - ["StructDefinition","NodeDefinition","ContractDefinition"]; - //note that interfaces and libraries are also ContractDefinition - if(userDefinedNodeTypes.includes(action.node.nodeType)) { - return [...state, action.node.id]; - } - else { - return state; - } + case actions.DEFINE_TYPE: + return [...state, action.node.id]; default: return state; } diff --git a/packages/truffle-debugger/lib/data/sagas/index.js b/packages/truffle-debugger/lib/data/sagas/index.js index fae39495d25..fc12103116b 100644 --- a/packages/truffle-debugger/lib/data/sagas/index.js +++ b/packages/truffle-debugger/lib/data/sagas/index.js @@ -92,6 +92,7 @@ function* tickSaga() { let allocation = allocations[node.id]; debug("Contract definition case"); + debug("allocations %O", allocations); debug("allocation %O", allocation); assignments = { byId: {} }; for (let id in allocation.children) { @@ -222,6 +223,10 @@ export function* reset() { yield put(actions.reset()); } +export function* defineType(node) { + yield put(actions.defineType(node)); +} + export function* learnAddressSaga(dummyAddress, address) { debug("about to learn an address"); yield put(actions.learnAddress(dummyAddress, address)); diff --git a/packages/truffle-debugger/lib/data/selectors/index.js b/packages/truffle-debugger/lib/data/selectors/index.js index 9f71f75f52f..b5dc4932113 100644 --- a/packages/truffle-debugger/lib/data/selectors/index.js +++ b/packages/truffle-debugger/lib/data/selectors/index.js @@ -270,10 +270,13 @@ const data = createSelectorTree({ _: createLeaf(["../userDefinedTypes/containers/ordered", "/views/scopes/inlined"], (types, scopes) => { let allocations = {}; - for(id of types) { + debug("types %o", types); + for(let id of types) { + debug("in the allocation loop"); + debug("id %d", id); let variables = scopes[id].variables; - let allocation = Allocation.allocateDeclarations(variables, scopes, - allocations); + let allocation = TruffleDecodeUtils.Allocation.allocateDeclarations( + variables, scopes, allocations); allocations[id] = allocation; } return allocations;