Allow to have fixed-width integer types in the autogenerator #1459

Open
opened 2025-12-28 17:16:31 +00:00 by sami · 1 comment
Owner

Originally created by @fyfyrchik on GitHub (Dec 19, 2024).

Sometimes I want to use uint32 instead of big.Int in the auto-generated wrappers.
Currently, I need to add another struct.

Describe the solution you'd like

pkg/rpcclient/unwrap has a beautiful unwrapper
nspcc-dev/neo-go@6d20772714/pkg/rpcclient/unwrap/unwrap.go (L98)

Allow to use it from inside the autogenerator.
A possible value to use for a type in rpcbinding configuration is Integer:int64. Another option is base: Integer; Name: int64.
We may also have other types (e.g. uint32), the details can be discussed. E.g. have LimitedInt[T interface { ~int* }] and LimitedUint[T interface{ ~uint* }] in unwrap and reuse them.

Describe alternatives you've considered

Provide custom type/unmarshaler defined outside the generated code. With it, we can have SDK types reused in the autogenerated code for contracts.

Originally created by @fyfyrchik on GitHub (Dec 19, 2024). ## Is your feature request related to a problem? Please describe. Sometimes I want to use `uint32` instead of `big.Int` in the auto-generated wrappers. Currently, I need to add another struct. ## Describe the solution you'd like `pkg/rpcclient/unwrap` has a beautiful unwrapper https://github.com/nspcc-dev/neo-go/blob/6d2077271499733ff847ab47306a97c9233ee599/pkg/rpcclient/unwrap/unwrap.go#L98 Allow to use it from inside the autogenerator. A possible value to use for a type in rpcbinding configuration is `Integer:int64`. Another option is `base: Integer; Name: int64`. We may also have other types (e.g. uint32), the details can be discussed. E.g. have `LimitedInt[T interface { ~int* }]` and `LimitedUint[T interface{ ~uint* }]` in `unwrap` and reuse them. ## Describe alternatives you've considered Provide custom type/unmarshaler _defined_ outside the generated code. With it, we can have SDK types reused in the autogenerated code for contracts.
Author
Owner

@roman-khimov commented on GitHub (Dec 19, 2024):

This will be possible with NEP-25 implementation, it has a notion of type width.

@roman-khimov commented on GitHub (Dec 19, 2024): This will be possible with NEP-25 implementation, it has a notion of type width.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#1459
No description provided.