Use abi param names with key remapping for functions with fully named inputs #369
-
I'm sure this has been debated before but is there a reason why functions with fully named inputs do not use typescript key remapping to generate an object type instead of an unnamed tuple? I see that there are already utils for handling this case, but they are not used for AbiParameters. Hence, I'm curious... Why not sth. like this? type AbiParametersToPrimitiveTypes<TAbiParameters extends readonly AbiParameter[], TAbiParameterKind extends AbiParameterKind = AbiParameterKind> = _HasUnnamedAbiParameter<TAbiParameters> extends true ? readonly [
...{
[K in keyof TAbiParameters]: AbiParameterToPrimitiveType<TAbiParameters[K], TAbiParameterKind>;
}
] : {
[K in TAbiParameters[number] as K extends {
name: string
} ? K['name'] : never]: AbiParameterToPrimitiveType<K, TAbiParameterKind>;
}; |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
The same could be done for outputs of course (if all outputs are named). I'm sure I'm missing sth. here :-) |
Beta Was this translation helpful? Give feedback.
-
Is this discussion along the lines of what you mean? pancakeswap/pancake-frontend#6558 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
Ok that makes sense. And dynamically named tuples would be dope indeed. Thanks for clarifying. |
Beta Was this translation helpful? Give feedback.
-
I feel like this would be a great candidate for a FAQ :-P. Seems like that question comes up frequently. |
Beta Was this translation helpful? Give feedback.
-
Is there any update for this feature? @tmm |
Beta Was this translation helpful? Give feedback.
Is this discussion along the lines of what you mean? pancakeswap/pancake-frontend#6558 (reply in thread)