Skip to content

sdk.Int marshaling of empty instance is always 0 instead of "<nil>" #9629

Open
@fedekunze

Description

Summary of Bug

Marshaling of an empty sdk.Int always populates the big.Int value to zero. This is unexpected from applications as the encoding of a nil value for big.Int should be "<nil>".

// MarshalText implements the encoding.TextMarshaler interface.
func (x *Int) MarshalText() (text []byte, err error) {
	if x == nil {
		return []byte("<nil>"), nil
	}
	return x.abs.itoa(x.neg, 10), nil
}

Version

v0.43.0-rc0

Steps to Reproduce

  • create an empty sdk.Int instance and call Marshal

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions