iamdefinitelyahuman / py-solc-ast

A tool for exploring the solc abstract syntax tree
MIT License
36 stars 10 forks source link

AttributeError: 'dict' object has no attribute 'exportedSymbols' #25

Open HasaTan opened 1 year ago

HasaTan commented 1 year ago

Environment information

What was wrong?

Please include information like:

when i run the code : source = dict()

  source["sources"] = solcx.compile_files([filename], output_values=['ast'])

  file = filename + ".json"
  with open(file, 'w') as file_obj:
      json.dump(source, file_obj)

  contrasts_units = solcast.from_standard_output(source)

the log shows that:

Traceback (most recent call last): File "D:\Project\Python\cfg_builder\main.py", line 27, in contrasts_units = solcast.from_standard_output(source) File "D:\Project\Python\cfg_builder\venv\lib\site-packages\solcast\main.py", line 33, in from_standard_output source_nodes = set_dependencies(source_nodes) File "D:\Project\Python\cfg_builder\venv\lib\site-packages\solcast\dependencies.py", line 12, in set_dependencies symbol_map = get_symbol_map(source_nodes) File "D:\Project\Python\cfg_builder\venv\lib\site-packages\solcast\dependencies.py", line 98, in get_symbol_map for key, value in ((k, x) for k, v in node.exportedSymbols.items() for x in v): AttributeError: 'dict' object has no attribute 'exportedSymbols'

How can it be fixed?

Fill this in if you know how the bug could be fixed.

antazoey commented 1 year ago

I think if you use from_standard_output, you have to use the standard output approach for compiling, and not compile_files().

try:

from solcx.main import _compile_combined_json

output = _compile_combined_json(source_files=[filename], output_values=["ast"])
antazoey commented 1 year ago

also i think we are inheriting this package over here: https://github.com/ApeWorX/py-solc-ast

HasaTan commented 1 year ago

另外,我认为我们在这里继承了这个包:https://github.com/ApeWorX/py-solc-ast

thks,i use the sol that sloditity version 0.5.4,then i change it to version ^0.8.0, then i success .

antazoey commented 1 year ago

i realized i imported the wrong method in my example, but the words are still right ,have to use standard input compile.