Skip to content

Commit

Permalink
Merge pull request #367 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare for release v1.2.0
  • Loading branch information
unclezoro authored Dec 6, 2023
2 parents 2a8e68a + 3e7d502 commit 0855e09
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## V1.2.0
This release introduce the Manchurian upgrade to the testnet.

Chores:
* [#365](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/365) chore: add xml marshal for Int type
* [#364](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/364) chore: add xml marshal for UInt type

## v1.1.1
This release introduces the Pampas upgrade to the mainnet.

Expand Down
15 changes: 15 additions & 0 deletions math/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package math
import (
"encoding"
"encoding/json"
"encoding/xml"
"fmt"
"math/big"
"strings"
Expand Down Expand Up @@ -327,6 +328,20 @@ func (i Int) String() string {
return i.i.String()
}

// MarshalXML defines custom encoding for xml Marshaler
func (i Int) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(i.String(), start)
}

// UnmarshalXML defines custom decoding for xml Marshaler
func (i *Int) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
if err := d.DecodeElement(&s, &start); err != nil {
return err
}
return i.Unmarshal([]byte(s))
}

// MarshalJSON defines custom encoding scheme
func (i Int) MarshalJSON() ([]byte, error) {
if i.i == nil { // Necessary since default Uint initialization has i.i as nil
Expand Down
9 changes: 9 additions & 0 deletions math/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package math_test

import (
"encoding/json"
"encoding/xml"
"fmt"
"math/big"
"math/rand"
Expand Down Expand Up @@ -396,6 +397,14 @@ func (s *intTestSuite) TestIntEq() {
s.Require().False(resp)
}

func (s *intTestSuite) TestIntXmlMarshalRoundTrip() {
u1 := math.NewInt(256)
marshalResult, _ := xml.Marshal(u1)
u2 := math.Int{}
xml.Unmarshal(marshalResult, &u2)
s.Require().Equal(u1, u2)
}

func TestRoundTripMarshalToInt(t *testing.T) {
values := []int64{
0,
Expand Down
16 changes: 16 additions & 0 deletions math/uint.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package math

import (
"encoding/xml"
"errors"
"fmt"
"math/big"
Expand Down Expand Up @@ -137,6 +138,21 @@ func MaxUint(u1, u2 Uint) Uint { return NewUintFromBigInt(max(u1.i, u2.i)) }
// Human readable string
func (u Uint) String() string { return u.i.String() }

// MarshalXML defines custom encoding for xml Marshaler
func (u Uint) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(u.String(), start)
}

// UnmarshalXML defines custom decoding for xml Marshaler
func (u *Uint) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
if err := d.DecodeElement(&s, &start); err != nil {
return err
}
*u = NewUintFromString(s)
return nil
}

// MarshalJSON defines custom encoding scheme
func (u Uint) MarshalJSON() ([]byte, error) {
if u.i == nil { // Necessary since default Uint initialization has i.i as nil
Expand Down
9 changes: 9 additions & 0 deletions math/uint_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package math_test

import (
"encoding/xml"
"fmt"
"math"
"math/big"
Expand Down Expand Up @@ -377,3 +378,11 @@ func (s *uintTestSuite) TestUintBigEndian() {
s.Require().Equal(u1, u2)

}

func (s *uintTestSuite) TestUintXmlMarshalRoundTrip() {
u1 := sdkmath.NewUint(256)
marshalResult, _ := xml.Marshal(u1)
u2 := sdkmath.Uint{}
xml.Unmarshal(marshalResult, &u2)
s.Require().Equal(u1, u2)
}
4 changes: 2 additions & 2 deletions types/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ const (
// Pampas is the upgrade name for Pampas upgrade
Pampas = "Pampas"

// Eddystone is the upgrade name for Eddystone upgrade
Eddystone = "Eddystone"
// Manchurian is the upgrade name for Manchurian upgrade
Manchurian = "Manchurian"
)
4 changes: 2 additions & 2 deletions x/upgrade/types/upgrade_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const (
// Pampas is the upgrade name for Pampas upgrade
Pampas = types.Pampas

// Eddystone is the upgrade name for Eddystone upgrade
Eddystone = types.Eddystone
// Manchurian is the upgrade name for Manchurian upgrade
Manchurian = types.Manchurian
)

// The default upgrade config for networks
Expand Down

0 comments on commit 0855e09

Please sign in to comment.