indexer icon indicating copy to clipboard operation
indexer copied to clipboard

Zero addresses should be omitted from asset information instead of being serialized as a zero address.

Open AlterionX opened this issue 3 years ago • 1 comments

Problem

The serializer spits out a zero address instead of no address for optional fields. This behavior is mildly unexpected and also differs from the algod API.

For languages with well-known Optional values, it's mildly annoying (and potentially error prone) to need to check if the address is a zero value and swap it out with an "empty" value instead of just having the value be that well known optional value in the first place. (undefined for JS, None for Python, Option in Rust, std::optional in C++, Optional in Java. This doesn't really apply to golang, since golang uses zero values instead, but it's prevalent enough elsewhere to be a relatively widespread annoyance.)

It may also save on a not-insignificant chunk of bandwidth when considered in requests for large quantities of data.

For more information: manuelmauro/algonaut#142.

Solution

Make the serializer understand that it should skip a zero-valued address. (It's possible there are other places that are also marked optional in the Indexer REST API docs.)

Dependencies

Maintainers of the various deserialization libraries would need to tweak their implementation to properly react to this.

Urgency

Low. It's fairly simple to work around this problem.

Acceptance Criteria

  • Convert the optional fields to optional, rather than required in the spec.
  • Create tasks to update the SDKs.

AlterionX avatar Mar 19 '22 23:03 AlterionX

Related to #597

winder avatar May 07 '22 02:05 winder