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: abi method factory #260

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

Conversation

bout3fiddy
Copy link
Contributor

What I did

Enables:

fn = boa.loads_fn_sig("def balanceOf(a: address) -> uint256: view")
crv = fn.at("0xD533a949740bb3306d119CC777fa900bA034cd52")

This way, I don't need to store a long abi file, or write a complicated json dict and let vyper handle it for me underneath.

How I did it

Added method from_fn_sig to ABIContractFactory class, thus extending it's scope to beyond just providing a list of dict.

How to verify it

Run test: https://github.com/bout3fiddy/titanoboa/blob/ac38a8b79a2467b8c68bbe42b38fd21e072a1caa/tests/integration/fork/test_abi_contract.py#L43

Description for the changelog

Adds boa.loads_fn_sig("def foo() -> uint256: view") -> contract object.

Cute Animal Picture

image

@bout3fiddy bout3fiddy added the enhancement New feature or request label Jul 20, 2024
@charles-cooper
Copy link
Member

this seems like a bit of a niche use case. i think it might be more generally useful for users if the function were boa.from_sigs(list[str]) -> ABIContractFactory which takes a list of signatures instead of a single function, as it's a bit odd to think of a smart contract with a full interface as consisting of a single function.

@charles-cooper
Copy link
Member

also, ABIContractFactory.from_sigs() might be better, since it's a bit of a niche use case we don't need to pollute the global boa namespace.

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

Successfully merging this pull request may close these issues.

3 participants