Skip to content

Commit

Permalink
IBC Fraction for trust level changed to uints (#7892)
Browse files Browse the repository at this point in the history
* fraction uses uint now

* Update proto/ibc/lightclients/tendermint/v1/tendermint.proto

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
colin-axner and fedekunze authored Nov 11, 2020
1 parent e564d7f commit 76ffdcc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions proto/ibc/lightclients/tendermint/v1/tendermint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ message Header {
.tendermint.types.ValidatorSet trusted_validators = 4 [(gogoproto.moretags) = "yaml:\"trusted_validators\""];
}

// Fraction defines the protobuf message type for tmmath.Fraction
// Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values.
message Fraction {
int64 numerator = 1;
int64 denominator = 2;
uint64 numerator = 1;
uint64 denominator = 2;
}
4 changes: 2 additions & 2 deletions x/ibc/light-clients/07-tendermint/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ func parseFraction(fraction string) (types.Fraction, error) {
return types.Fraction{}, fmt.Errorf("fraction must have format 'numerator/denominator' got %s", fraction)
}

numerator, err := strconv.ParseInt(fr[0], 10, 64)
numerator, err := strconv.ParseUint(fr[0], 10, 64)
if err != nil {
return types.Fraction{}, fmt.Errorf("invalid trust-level numerator: %w", err)
}

denominator, err := strconv.ParseInt(fr[1], 10, 64)
denominator, err := strconv.ParseUint(fr[1], 10, 64)
if err != nil {
return types.Fraction{}, fmt.Errorf("invalid trust-level denominator: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions x/ibc/light-clients/07-tendermint/types/fraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ var DefaultTrustLevel = NewFractionFromTm(light.DefaultTrustLevel)
// NewFractionFromTm returns a new Fraction instance from a tmmath.Fraction
func NewFractionFromTm(f tmmath.Fraction) Fraction {
return Fraction{
Numerator: f.Numerator,
Denominator: f.Denominator,
Numerator: uint64(f.Numerator),
Denominator: uint64(f.Denominator),
}
}

// ToTendermint converts Fraction to tmmath.Fraction
func (f Fraction) ToTendermint() tmmath.Fraction {
return tmmath.Fraction{
Numerator: f.Numerator,
Denominator: f.Denominator,
Numerator: int64(f.Numerator),
Denominator: int64(f.Denominator),
}
}
18 changes: 9 additions & 9 deletions x/ibc/light-clients/07-tendermint/types/tendermint.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76ffdcc

Please sign in to comment.