Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph generation fails #190

Closed
spaceh3ad opened this issue Oct 27, 2023 · 9 comments
Closed

Graph generation fails #190

spaceh3ad opened this issue Oct 27, 2023 · 9 comments

Comments

@spaceh3ad
Copy link

As mentioned in #137 there is an issue generating graphs for contracts that has mappings declared. Using SolidityAuditor extension I was able to generate graph for file without mappings however using cmd not.
surya grap Test.sol | dot -Tpng > Test.png output produces empty Test.png file.

I am using MacOS.
Surya version: 0.4.8
Graphviz: 9.0.0

@GNSPS
Copy link
Collaborator

GNSPS commented Oct 27, 2023

Can you post the test Solidity file here so I can test locally, please? 🙏

@spaceh3ad
Copy link
Author

now suddenly I got logs from the surya grap PositionManager.sol | dot -Tpng > Test.png

TypeError: Cannot read properties of undefined (reading 'undefined')
    at Object.UsingForDeclaration (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/lib/graph.js:210:44)
    at visit (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/node_modules/@solidity-parser/parser/dist/index.cjs.js:37156:30)
    at /Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/node_modules/@solidity-parser/parser/dist/index.cjs.js:37150:29
    at Array.forEach (<anonymous>)
    at visit (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/node_modules/@solidity-parser/parser/dist/index.cjs.js:37150:10)
    at Object.visit (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/node_modules/@solidity-parser/parser/dist/index.cjs.js:37162:7)
    at _loop (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/lib/graph.js:107:12)
    at graph (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/lib/graph.js:226:18)
    at Object.handler (/Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/bin/surya:65:19)
    at /Users/jan-k/.nvm/versions/node/v16.20.2/lib/node_modules/surya/node_modules/yargs/build/index.cjs:1:8993

@GNSPS I tired to write minimal test for this case but it apparently worked with mapping now. I have trouble providing the minimal sample of when code fails, so I can provide link to my repo. From where the surya grap PositionManager.sol | dot -Tpng > Test.png is failing with error above.

@GNSPS
Copy link
Collaborator

GNSPS commented Oct 27, 2023

From the error logs, I suspect the bug might be with the using for declaration and not with mappings. But I'll take a look, thanks! 🙏

@GNSPS
Copy link
Collaborator

GNSPS commented Oct 27, 2023

Ahhh LOL, figured out quickly. I am not allowing using for declarations outside of contracts! 🙈 Back then it was not permitted in the grammar. I'll fix this.

@GNSPS
Copy link
Collaborator

GNSPS commented Oct 27, 2023

Done! 😄 👍 Thank you for reporting it!

@GNSPS GNSPS closed this as completed Oct 27, 2023
@GNSPS
Copy link
Collaborator

GNSPS commented Oct 27, 2023

You can try v0.4.9

@spaceh3ad
Copy link
Author

Thank you so much! 🎉

@DutchBBS
Copy link

DutchBBS commented Nov 4, 2023

I am still not able to generate graphs on contracts with named mappings. I tried all the solutions on different threads but nothing seems to work. Back to manual graphs i guess

@GNSPS
Copy link
Collaborator

GNSPS commented Nov 6, 2023

Can you post here a Solidity snippet that fails? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants