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(abigen,abigen-plugin): force-load all generated contract wrapper classes on first access #44

Merged
merged 6 commits into from
Dec 27, 2023

Conversation

ArtificialPB
Copy link
Member

@ArtificialPB ArtificialPB commented Dec 23, 2023

Description

Generated contract wrappers self-register any custom errors that it contains in the companion object initializer, which is initialized on first class access. This creates an issue where only errors from contracts referenced in the code are automatically registered, and thus available to be decoded project-wide when any contract call fails.

This PR also contains optimization of ethers-abigen tests: all generated contract wrappers are now compiled by a single kotlin compile task, speeding up the tests. The wrappers are also now placed under build directory so the files can be inspected for errors.

Solution

This PR introduces a "hack" to force-load all generated contract wrappers within a module, generated by the same gradle abigen task, when first generated contract class is referenced in code.

Abigen gradle task collects all generated wrapper canonical names, which are then referenced inside the generated "loader" object. This loader object contains a dummy function which is called in all generated wrappers' companion object initializers.

@ArtificialPB
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@ArtificialPB ArtificialPB force-pushed the feat/improved-error-resolver branch from 56d5656 to ad4f24a Compare December 25, 2023 14:10
@ArtificialPB ArtificialPB merged commit a332aef into master Dec 27, 2023
1 check passed
@ArtificialPB ArtificialPB deleted the feat/improved-error-resolver branch December 27, 2023 22:59
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.

1 participant