inconsistent args type #651
Replies: 5 comments 2 replies
-
I realize now that a name-less argument cannot be used in a key/value mapping because it has no keys. However, perhaps it's an idea to construct the object regardless using the known keys, and add a special property that lists the unknown values. One could suggest to just remove the name-less argument from the inputs array alltogether to get the desired result, however I'm not sure if that were to alter the function selector and thus no events would be picked up. Any ideas how we could bypass this? |
Beta Was this translation helpful? Give feedback.
-
Could perhaps make the unnamed argument's key a number of the position it is in, ie:
Think this would work as numbers aren't a valid solidity argument. What do you think? |
Beta Was this translation helpful? Give feedback.
-
Going to move this to discussions as this is more of a feature request than a bug, but definitely want to address this soon! |
Beta Was this translation helpful? Give feedback.
-
After some thought I think the best course of action would be to:
What do you think? |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Package Version
0.3.41
Current Behavior
Consider the following code snippet:
where the PairCreated event in UNISWAP_V2_FACTORY has the following inputs:
log.args
will yield a tuple of results for both the actual response and the inferred types, typed as follows:readonly [`0x${string}`, `0x${string}`, `0x${string}`, bigint] | readonly [`0x${string}`, `0x${string}`, `0x${string}`] | readonly [`0x${string}`, `0x${string}`] | readonly [`0x${string}`]
This is slightly indesirable as opposed to returning a key/value pairing. However, if we were to remove the last argument of the inputs array - as shown below - args will no longer yield a tuple, but instead the desired object.
The output will be of type:
It appears the issue emerges due to name-less input arguments. It being the last argument in the inputs array is merely coincidence. Moving it to a different position produces the same issue.
Expected Behavior
The output isn't consistent, nor is it desirable for many. I'd expect it to return a key/value pairing at all times.
Steps To Reproduce
The example I've shared above uses the
watchContractEvent
function. However it happens to all other functions that make use of the Log[] return type.Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)
https://viem.sh/docs/actions/public/getLogs.html#returns
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions