fix decode orphan struct definition

pull/1251/head^2
yann300 4 years ago committed by Liana Husikyan
parent 50e46e43e5
commit 0757c48a3a
  1. 23
      libs/remix-debug/src/solidity-decoder/astHelper.ts
  2. 8
      libs/remix-debug/src/solidity-decoder/decodeInfo.ts

@ -26,6 +26,27 @@ export function extractContractDefinitions (sourcesList) {
return ret
}
/**
* return nodes from an ast @arg sourcesList that are declared outside of a ContractDefinition @astList
*
* @param {Object} sourcesList - sources list (containing root AST node)
* @return {Object} - returns a list of node
*/
export function extractOrphanDefinitions (sourcesList) {
const ret = []
for (const k in sourcesList) {
const ast = sourcesList[k].ast
if (ast.nodes && ast.nodes.length) {
for (const node of ast.nodes) {
if (node.nodeType !== 'ContractDefinition') {
ret.push(node)
}
}
}
}
return ret
}
/**
* returns the linearized base contracts of the contract @arg id
*
@ -54,7 +75,7 @@ export function extractStateDefinitions (contractName, sourcesList, contracts) {
if (!node) {
return null
}
const stateItems = []
const stateItems = extractOrphanDefinitions(sourcesList)
const stateVar = []
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
baseContracts.reverse()

@ -233,11 +233,11 @@ function getEnum (type, stateDefinitions, contractName) {
* @return {Array} containing all members of the current struct type
*/
function getStructMembers (type, stateDefinitions, contractName, location) {
const split = type.split('.')
if (!split.length) {
if (type.indexOf('.') === -1) {
type = contractName + '.' + type
} else {
contractName = split[0]
}
if (!contractName) {
contractName = type.split('.')[0]
}
const state = stateDefinitions[contractName]
if (state) {

Loading…
Cancel
Save