Field | Description |
---|---|
zip | ZIP: MoonBaZe-0001 |
title | convert big.Int to string on RPC responses |
author | @MoonBaZe |
status | Draft |
type | Implementation ZIP |
acceptance | upon usage by the community |
activation | upon usage by the community |
created | 2023-05-03 |
license | GPL v3.0 |
url | go-zenon-big-int-string-repository |
Motivation
As the network evolves and increases its interoperability, there is a natural need to support tokens with a number of decimals that would overflow uint64. This requirement was also pointed out by Mr. Kaine.
Implementation
Each struct that contains a big.Int
field and is returned by RPC now has two additional methods: MarshalJSON
and UnmarshalJSON
. These methods override the default behavior in json-rpc
when marshaling a struct to create an RPC response. The object will now be returned as before, but the big.Int
field is returned as a string.
In every test, the changes include wrapping each big.Int
inside " ". For getDepositedQsr and getQsrRegistrationCost, a new variable was included because the newly returned type is a string. In pillar_test, a few extra expects were added. Each test runs smoothly.
These changes do not affect consensus or the way nodes communicate or synchronize and can be considered a soft fork. However, it is considered a hard fork for every application (such as Syrius or web apps) that is using an older version of the SDK
which does not contain these changes. SDK
developers would need to update them, and all apps should be recompiled using the new SDK
.