foundry-rs / compilers

Utilities for working with native solc and compiling projects.
Apache License 2.0
58 stars 34 forks source link

fix: update vyper path resolution logic #127

Closed klkvr closed 1 month ago

klkvr commented 1 month ago

Current Vyper path resolution does not correctly handle relative paths (from . import X, from .. import X).

This PR fixes this and changes parser to parse into VyperImport which tracks final_part (X at from ... import X expression).

Currently vyper allows doing imports like from Contract import Contract which is equivalent to import Contract as Contract and only requires Contract.vy to be present. However, such format is only supported when invoking vyper from command like, and for standard JSON input it does not work, which is why we can't compile snekmate right away without small import fixes.

I believe in the future Vyper versions that will be fixed and thus VyperImport tracks final_part additionaly.

Also added more tests for path resolution