-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix: flatten nested arrays in parseAbiParameters #232
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Can you add a test based on #231? You can use the provided playground as the base for the test. That way if there is a unforseen regression that test catches it. |
Sure! I noticed the type tests are failing. I need to fix that as well when I find time. Any help/guidance is welcomed |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #232 +/- ##
==========================================
+ Coverage 99.83% 99.85% +0.01%
==========================================
Files 26 26
Lines 6082 6105 +23
Branches 195 195
==========================================
+ Hits 6072 6096 +24
Misses 8 8
+ Partials 2 1 -1 ☔ View full report in Codecov by Sentry. |
@xenoliss since depth flatten returns a arraylist now you need to check if it's length is 0 instead of checking if the list member is undefined which was the previous implementation so that it shows as never for the parameters. Something like this should work. But feel free to take any other approach ? Filter<Mapped, never> extends readonly [...infer Content]
? Content['length'] extends 0
? never
: DeepFlatten<Content>
: never
: never |
Hey thank you @Raiden1411, I added your fix and it seems to work fine. I also added the playground test. Let me know how that looks to you. |
I think that the only thing that is missing is the changeset otherwise it looks good |
I added the changeset @Raiden1411 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! s/o @Raiden1411 for reviewing.
.changeset/cool-buttons-rush.md
Outdated
"abitype": patch | ||
--- | ||
|
||
Fix type detection when using an array in (encode|parse)AbiParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix type detection when using an array in (encode|parse)AbiParameters | |
Fixed type detection when using an array in `ParseAbiParameters` |
Description
Hopefully fix #231
Additional Information
Introduce a
DeepFlatten
and use it inParseAbiParameters
instead of assuming thatFilter<Mapped, never>
has always only one element.NOTE: I had to update
parseAbiParameters
toreturn abiParameters as unknown as ParseAbiParameters<TParams>
for the compiler to be happy but waiting for feedback.Before submitting this issue, please make sure you do the following.
PR-Codex overview
This PR focuses on fixing type detection in
ParseAbiParameters
when using an array.Detailed summary
ParseAbiParameters
DeepFlatten
type for flattening arraysDeepFlatten
AbiParameter
objects