Support calling args as object instead of tuples for contract functions #2534
Replies: 4 comments
-
Hi @jxom was wondering if you have any thoughts on this and is it something that can be supported? Thank you 🙏 |
Beta Was this translation helpful? Give feedback.
-
FYI this was discussed in discord recently (but no final conclusion yet on the approach) https://discord.com/channels/1156791276818157609/1268170772036325386 |
Beta Was this translation helpful? Give feedback.
-
Really cool, thank you for this! I used this to make a reversed version too. That for given function output array returns a named object
So here I have this
And the util gives me this back:
|
Beta Was this translation helpful? Give feedback.
-
I've written a gist that takes advantage of Please star if you like it :) |
Beta Was this translation helpful? Give feedback.
-
When supplying the args for calling a contract function, it is currently in arrays or strongly typed tuples. However, it is kinda hard to know the order and know which index is referring to which param. By using named object props mapping to the Abi function order, it makes code alot more readable. I've got a little helper below that converts the object to the typed tuple and finally pass it to the function call. However it's kinda repetitive, not having the ability to call it directly from a contract object.
Would be nice to do something like this:
rather than below workaround:
and below is snippet of
mapArgs
A single param is pretty straightforward, but when you have 3 or more params for a contract input, such as swapping a token, it can get confusing at times especially dealing with different DEX that has their own signatures.
Please note that I'm not asking if we can have a breaking change to replace existing signature, but also support it alongside of tuples.
Thank you for your considerations, and hope this can be implemented.
Beta Was this translation helpful? Give feedback.
All reactions