`(encode|parse)AbiParameters` detects types correctly when passed as string but not array
Closed this issue · 4 comments
Describe the bug
This doesn't work:
encodeAbiParameters(parseAbiParameters(["(uint256 a)", "(uint256 b)"]), [
{ a: BigInt(1) },
{ b: BigInt(1) },
])
Error: Source has 2 element(s) but target allows only 1
This works:
encodeAbiParameters(parseAbiParameters(["(uint256 a),(uint256 b)"]), [
{ a: BigInt(1) },
{ b: BigInt(1) },
])
Sorry, in case there has been a misconception from my side :)
Cheers, Dennis
Link to Minimal Reproducible Example
No response
Steps To Reproduce
No response
Package Version
1.0.0 (installed by viem@2.7.20)
TypeScript Version
5.3.2
Anything else?
No response
Validations
- Checked there isn't already an issue that exists for the bug you encountered.
- Followed the Code of Conduct.
Just confirmed that this works at runtime, but not compile time. Attaching TypeScript Playground.
Great first issue for someone looking to dive into advanced TypeScript!
Want to give it a try! The issue seems to be in the Filter<Mapped, never>[0]
, which incorrectly assumes that there is only one element.
This issue has been locked since it has been closed for more than 14 days.
If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest ABIType version. If you have any other comments you can create a new discussion.