Change ics20 packet data to use standard json library for marshaling #3915
Labels
20-transfer
help wanted
Issues for which we would appreciate help/support from the community
type: code hygiene
Clean up code but without changing functionality or interfaces
Summary
Change ICS 20 packet data
FungibileTokenPacketData
functionGetBytes
to use "encoding/json" library, rather than the sdk proto codec functionMustMarshalJSON
Problem Definition
The ibc spec states that the ics20 packet data should be JSON marshaled, it does not state it should be proto3 json marshaled. To avoid accidental non-conformance when adding additional fields to the existing packet data we should switch from the proto codec
MustMarshalJSON
(which uses proto3 json) to the standard libraryjson.Marshal
.The change would not be breaking because proto3 json maps strings to json strings (all fungible token packet data fields are strings)
In addition, this would remove the dependency on
sdk.MustSortJSON
which is being deprecated. The sorting of the json could be removed regardless since sorting of keys does not affect the ability of the counterparty to unmarshal the packet dataThis also removes the maintenance burden of the modified
MustMarshalJSON
function. The standard library handles not emitting empty defaults via theomitempty
json tag which is included by default on our.pb.go
(we should ensure this doesn't change)Proposal
Change
FungibleTokenPacketData.GetBytes()
to usejson.Marshal()
. Add documentation to the function to explain the usage ofomitempty
In addition, when cosmos/ibc#987 is addressed, our marshal should link to the encoding spec
For Admin Use
The text was updated successfully, but these errors were encountered: