Handle nil arrays in autogenerated RPC wrappers #1456

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

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

RPC binding generator doesn't expect nil when handling a slice nspcc-dev/neo-go@6d20772714/pkg/smartcontract/rpcbinding/binding.go (L700)

But, compiler emits NULL by default for slice fields in struct nspcc-dev/neo-go@6d20772714/pkg/compiler/codegen.go (L346)

This is inconsistent and prevents me from using autogenerated named types.
The problem may also not be immediately obvious, as it is hard to guess when sth in contract is Null and when an empty array.

Describe the solution you'd like

Allow to have nils in struct slice fields parsed with FromStackItem().

Describe alternatives you've considered

  1. Have a configuration option (nullable slice) for this.
  2. Change compiler to respect the declared ABI (may be done separately).
Originally created by @fyfyrchik on GitHub (Dec 18, 2024). ## Is your feature request related to a problem? Please describe. RPC binding generator doesn't expect nil when handling a slice https://github.com/nspcc-dev/neo-go/blob/6d2077271499733ff847ab47306a97c9233ee599/pkg/smartcontract/rpcbinding/binding.go#L700 But, compiler emits NULL by default for slice fields in struct https://github.com/nspcc-dev/neo-go/blob/6d2077271499733ff847ab47306a97c9233ee599/pkg/compiler/codegen.go#L346 This is inconsistent and prevents me from using autogenerated named types. The problem may also not be immediately obvious, as it is hard to guess when sth in contract is `Null` and when an empty array. ## Describe the solution you'd like Allow to have `nil`s in struct slice fields parsed with `FromStackItem()`. ## Describe alternatives you've considered 1. Have a configuration option (nullable slice) for this. 2. Change compiler to respect the declared ABI (may be done separately).
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#1456
No description provided.