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: ability to get conversion classes by name #2497

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Feb 7, 2025

What I did

This helps me access the ENS conversion class, which makes more sense than any of these, but is still helpful.

This is what I have to do in the meantime to get access to ENS in the ape-ens tests:


@pytest.fixture(scope="session")
def converter(chain):
    # TODO: Replace with https://github.com/ApeWorX/ape/pull/2497
    #   (requires ape 0.8.26).
    converters = chain.conversion_manager._converters[AddressType]
    for converter in converters:
        if isinstance(converter, ENSConversions):
            return converter

    pytest.fail("Failed to find ENS converter registered in Ape.")

Ape should be good about testing stuff like ape-ens

How I did it

How to verify it

Checklist

  • All changes are completed
  • Change is covered in tests
  • Documentation is complete

@@ -45,3 +45,14 @@ def convert(self, value: Any) -> ConvertedType:
# '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'

"""

@property
def name(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

I think in some of the other plugins I used package name (minus ape-)

Copy link
Member Author

Choose a reason for hiding this comment

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

that may not work the best here, as ape-ethereum includes the WeiConversions etc.

@antazoey antazoey merged commit 5455d4a into ApeWorX:main Feb 11, 2025
19 checks passed
@antazoey antazoey deleted the feat/converter-access branch February 11, 2025 00:09
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.

2 participants