Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: abi method factory#260

Open
bout3fiddy wants to merge 5 commits into
vyperlang:masterfrom
bout3fiddy:feat/ABIMethodFactory
Open

feat: abi method factory#260
bout3fiddy wants to merge 5 commits into
vyperlang:masterfrom
bout3fiddy:feat/ABIMethodFactory

Conversation

@bout3fiddy
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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