MCPcopy Create free account
hub / github.com/PolymathNetwork/polymath-core / parseContract

Function parseContract

scripts/compareStorageLayout.js:74–102  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

72}
73
74function parseContract(input) {
75
76 const elements = [];
77 const AST = input;
78 traverseAST(AST, elements);
79 // console.log(elements);
80
81 // filter out all Contract Definitions
82 const contractDefinitions = _.filter(elements, (e, i) => e.name == "ContractDefinition");
83
84 // filter out all linearizedBaseContracts
85 // pick the last one as the last contract always has the full inheritance
86 const linearizedBaseContracts = _.last(_.map(contractDefinitions, e => e.attributes.linearizedBaseContracts));
87
88 // get all stateVariables
89 const stateVariables = _.filter(elements, e => e.attributes && e.attributes.stateVariable);
90
91 // group them by scope
92 const stateVariableMap = _.groupBy(stateVariables, e => e.attributes.scope);
93
94 orderedStateVariables = _.reduceRight(
95 linearizedBaseContracts,
96 (a, b) => {
97 return a.concat(stateVariableMap[b] || []);
98 },
99 []
100 );
101 return orderedStateVariables;
102}
103
104var walkSync = function(dir, filelist) {
105 files = fs.readdirSync(dir);

Callers 1

Calls 1

traverseASTFunction · 0.85

Tested by

no test coverage detected