github.com/InjectiveLabs/sdk-go@v1.53.0/chain/types/int.go (about)

     1  package types
     2  
     3  import "math/big"
     4  
     5  // MarshalBigInt marshals big int into text string for consistent encoding
     6  func MarshalBigInt(i *big.Int) (string, error) {
     7  	bz, err := i.MarshalText()
     8  	if err != nil {
     9  		return "", err
    10  	}
    11  	return string(bz), nil
    12  }
    13  
    14  // UnmarshalBigInt unmarshals string from *big.Int
    15  func UnmarshalBigInt(s string) (*big.Int, error) {
    16  	ret := new(big.Int)
    17  	err := ret.UnmarshalText([]byte(s))
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  	return ret, nil
    22  }