-
-
Notifications
You must be signed in to change notification settings - Fork 44
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: add custom struct type matching to Register
via structTypeMatches
#251
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 5c026b4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks for the discussion and PR! Haven't had a chance to review or consider this yet, but figured I would provide some quick comments.
What's an example of how this would look in Viem/Wagmi?
You should be able to add the register tests in |
This PR allows users and library authors to inject custom types that match their custom solidity structs. The use case is narrow, but allows library authors to create more expressive tools that interact with viem and wagmi. I have created a discussion that this PR references: #250
I've added a new test in
register.test-d.ts
which unfortunately can only be run locally since it relies on declaration merging to test. Hopefully the test shows the kind of problem I'm trying to solve with this PR, which is that without theinternalType
it is impossible to differentiate between structs with different names but matching types after the ABI has been broken down into primitives.This PR is somewhat outside the scope of what
abitype
is, so I can understand if this isn't something you would like to add to the project, however it is useful for me and may be useful for others, so I've opened the PR in case that is true.Thanks for taking a look!
PR-Codex overview
This PR introduces
structTypeMatches
toRegister
inabitype
, allowing custom struct types to be matched against structs before processing.Detailed summary
structTypeMatches
toRegister
inabitype
ResolvedStructMatchesMap
andResolvedStructMatchesUnion
AbiParameterToPrimitiveType
inutils.ts
to handle user-defined struct matches