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

feat[ux]: compile .vyi files #4290

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

sandbubbles
Copy link
Collaborator

What I did

Allowed compiling ".vyi" files with ast,annotated_ast,interface,external_interface,abi flags.
#4232

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@@ -254,7 +254,8 @@ def build_method_identifiers_output(compiler_data: CompilerData) -> dict:

def build_abi_output(compiler_data: CompilerData) -> list:
module_t = compiler_data.annotated_vyper_module._metadata["type"]
_ = compiler_data.ir_runtime # ensure _ir_info is generated
if compiler_data.contract_path.suffix != ".vyi":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should tag it on the ModuleT or Module node object somehow

Copy link
Collaborator Author

@sandbubbles sandbubbles Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it to slots in Module- not sure that that is the best.
The argument is_interface is added to parse_to_ast_with_setting instead of parse_to_ast because the _generate_ast calls the parse_to_ast_with_settings funciton directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it looks great

@charles-cooper charles-cooper changed the title feat[ux]: compile solely vyi feat[ux]: compile .vyi files Oct 15, 2024
@charles-cooper
Copy link
Member

looking good to me. @cyberthirst can you take a look?

@cyberthirst
Copy link
Collaborator

bit unrelated, but if an interface implements other interface and doesn't implement all the methods, we get the following exception:

vyper.exceptions.InterfaceViolation: Contract does not implement all interface functions: foobar()

Contract does not implement.. although it can be triggered via eg vyper -f abi i.vyi

@cyberthirst
Copy link
Collaborator

-f interface doesn't include Flags. is it intended?

@charles-cooper
Copy link
Member

-f interface doesn't include Flags. is it intended?

Not intended. May be the order in which we merged flag and -f interfave PRs

@cyberthirst
Copy link
Collaborator

shouldn't -f interface be basically an identity when called on interface files?

import ITest2

implements: ITest2

def bar() -> uint256:
    ...

def foo() -> uint8:
    ...


def foobar() -> uint8:
    ...

outputs:

# Functions

@external
def bar() -> uint256:
    ...


@external
def foo() -> uint8:
    ...


@external
def foobar() -> uint8:
    ...

ie implements is lost in the translation

@cyberthirst
Copy link
Collaborator

shouldn't -f interface be basically an identity when called on interface files?

import ITest2

implements: ITest2

def bar() -> uint256:
    ...

def foo() -> uint8:
    ...


def foobar() -> uint8:
    ...

outputs:

# Functions

@external
def bar() -> uint256:
    ...


@external
def foo() -> uint8:
    ...


@external
def foobar() -> uint8:
    ...

ie implements is lost in the translation

also, if ITest2.vyi contains a struct (or flag), then those don't propagate for -f interface - not sure whether that's intentional


"""
file = make_file("interface.vyi", interface)
compile_files([file], ["ast", "annotated_ast", "interface", "external_interface", "abi"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to use this here? https://github.com/vyperlang/vyper/pull/4290/files#diff-d428d4c971c9f7166899f6f2d3da5e17ca4478d8d371d803e735d6ee36b39d30R49

so we don't have to maintain the list on 2 places

@cyberthirst
Copy link
Collaborator

 vyper -f external_interface tests/custom/ITest.vyi

# External Interfaces
interface Itest:
    def bar() -> uint256: nonpayable
    def foo() -> uint8: nonpayable
    def foobar() -> uint8: nonpayable

name discrepancy - Itest vs ITest

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

Successfully merging this pull request may close these issues.

3 participants