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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Vyper contract compilation via sys.path modules #5479

Open
pcaversaccio opened this issue Jul 3, 2024 · 0 comments
Open

Support Vyper contract compilation via sys.path modules #5479

pcaversaccio opened this issue Jul 3, 2024 · 0 comments
Assignees

Comments

@pcaversaccio
Copy link
Contributor

pcaversaccio commented Jul 3, 2024

Describe the feature

When using the Vyper CLI, the search path defaults to the current working directory and the Python sys.path since the 0.4.0 release.

How does this look like in practice: Let's do a typical workflow using 馃悕 snekmate contracts:

~$ mkdir test && cd test
~$ python -m venv && source venv/bin/activate
~$ pip install vyper snekmate
~$ mkdir src && cd src && vi token.vy # here you put the example I paste below
~$ cd .. && vyper src/token.vy
# pragma version ~=0.4.0
from ethereum.ercs import IERC20
from ethereum.ercs import IERC20Detailed
from snekmate.auth import ownable
from snekmate.tokens import erc20


initializes: ownable
initializes: erc20[ownable := ownable]
exports: (
    erc20.owner,
    erc20.IERC20,
    erc20.IERC20Detailed,
    erc20.mint,
    erc20.set_minter,
)


@deploy
def __init__():
    ownable.__init__()
    erc20.__init__("Vyper", "VY", 18, "Vyper", "1")

As a result, all imported 馃悕 snekmate contracts (e.g. from snekmate.tokens import erc20) are seamlessly located during compilation.

I have tested this workflow with the latest hardhat-vyper version and unfortunately it fails:

Error: Command failed: <path-to-compiler> --evm-version paris --optimize gas -f combined_json <some-path>/vyper-sandbox/contracts/vyper/Foo.vy
vyper.exceptions.ModuleNotFound: snekmate.auth.ownable

  contract "<some-path>/vyper-sandbox/contracts/vyper/Foo.vy:4", line 4:0
       3 from ethereum.ercs import IERC20Detailed
  ---> 4 from snekmate.auth import ownable
  -------^
       5 from snekmate.tokens import erc20

[32916] Failed to execute script 'vyper_compile' due to unhandled exception!

Can you guys consider adding this in the near future since it will boost Vyper devex a lot IMHO.

Search terms

vyper, syspath, modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants