fix(client/v2): *big.Int unmarshal (cherry-pick #21853) (#24361)

This commit is contained in:
julienrbrt 2025-04-03 16:02:26 +02:00 committed by GitHub
parent 167f3f12e2
commit df07789843
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 62 additions and 7 deletions

View File

@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* (cli) [#24330](https://github.com/cosmos/cosmos-sdk/pull/24330) Use the gogoproto merge registry as a file resolver instead of the interface registry.
* [#21853](https://github.com/cosmos/cosmos-sdk/pull/21853) Fix `*big.Int` unmarshalling in txs.
## [v2.0.0-beta.8] - 2025-01-29
@ -66,10 +67,14 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements
* [#21712](https://github.com/cosmos/cosmos-sdk/pull/21712) Marshal `type` field as proto message url in queries instead of amino name.
* [#21936](https://github.com/cosmos/cosmos-sdk/pull/21936) Print possible enum values in error message after an invalid input was provided.
## [v2.0.0-beta.4] - 2024-07-16
### Improvements
* [#21712](https://github.com/cosmos/cosmos-sdk/pull/21712) Marshal `type` field as proto message url in queries instead of amino name.
### Bug Fixes
* [#20964](https://github.com/cosmos/cosmos-sdk/pull/20964) Fix `GetNodeHomeDirectory` helper in `client/v2/helpers` to respect the `(PREFIX)_HOME` environment variable.

View File

@ -28,6 +28,7 @@ const (
ValidatorAddressStringScalarType = "cosmos.ValidatorAddressString"
ConsensusAddressStringScalarType = "cosmos.ConsensusAddressString"
PubkeyScalarType = "cosmos.Pubkey"
DecScalarType = "cosmos.Dec"
)
// Builder manages options for building pflag flags for protobuf messages.
@ -70,6 +71,7 @@ func (b *Builder) init() {
b.scalarFlagTypes[ValidatorAddressStringScalarType] = validatorAddressStringType{}
b.scalarFlagTypes[ConsensusAddressStringScalarType] = consensusAddressStringType{}
b.scalarFlagTypes[PubkeyScalarType] = pubkeyType{}
b.scalarFlagTypes[DecScalarType] = decType{}
}
}

View File

@ -0,0 +1,48 @@
package flag
import (
"context"
"google.golang.org/protobuf/reflect/protoreflect"
"cosmossdk.io/math"
)
type decType struct{}
func (a decType) NewValue(_ *context.Context, _ *Builder) Value {
return &decValue{}
}
func (a decType) DefaultValue() string {
return "0"
}
type decValue struct {
value string
}
func (a decValue) Get(protoreflect.Value) (protoreflect.Value, error) {
return protoreflect.ValueOf(a.value), nil
}
func (a decValue) String() string {
return a.value
}
func (a *decValue) Set(s string) error {
dec, err := math.LegacyNewDecFromStr(s)
if err != nil {
return err
}
// we need to convert from float representation to non-float representation using default precision
// 0.5 -> 500000000000000000
a.value = dec.BigInt().String()
return nil
}
func (a decValue) Type() string {
return "cosmos.Dec"
}

View File

@ -21,7 +21,7 @@ require (
github.com/cometbft/cometbft v0.38.17
github.com/cosmos/cosmos-db v1.1.1
// this version is not used as it is always replaced by the latest Cosmos SDK version
github.com/cosmos/cosmos-sdk v0.53.0-rc.1
github.com/cosmos/cosmos-sdk v0.53.0-rc.2
github.com/cosmos/gogoproto v1.7.0
github.com/spf13/cast v1.7.1
github.com/spf13/cobra v1.9.1
@ -218,6 +218,8 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)
replace cosmossdk.io/client/v2 => ../client/v2
// Here are the short-lived replace from the SimApp
// Replace here are pending PRs, or version to be tagged
// replace (

View File

@ -616,8 +616,6 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT
cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw=
cosmossdk.io/api v0.9.0 h1:QYs9APeSlDNGbsBOBFjp3jXgGd4hnEPnnku3+W3tT4Y=
cosmossdk.io/api v0.9.0/go.mod h1:pLkU/NSqYHWxyN7XftVt8iD7oldKJzqMZgzeiOmT2nk=
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e h1:NqQEVIjRqSdsAfTI9uDRZ1oU/cQuCoAbUuIkndQM+Bo=
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
cosmossdk.io/collections v1.2.0 h1:IesfVG8G/+FYCMVMP01frS/Cw99Omk5vBh3cHbO01Gg=
cosmossdk.io/collections v1.2.0/go.mod h1:4NkMoYw6qRA8fnSH/yn1D/MOutr8qyQnwsO50Mz9ItU=
cosmossdk.io/core v0.11.3 h1:mei+MVDJOwIjIniaKelE3jPDqShCc/F4LkNNHh+4yfo=
@ -726,8 +724,8 @@ github.com/bits-and-blooms/bitset v1.22.0 h1:Tquv9S8+SGaS3EhyA+up3FXzmkhxPGjQQCk
github.com/bits-and-blooms/bitset v1.22.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c=
github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE=
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=

View File

@ -20,7 +20,7 @@ require (
github.com/cosmos/cosmos-db v1.1.1
github.com/cosmos/cosmos-proto v1.0.0-beta.5
// this version is not used as it is always replaced by the latest Cosmos SDK version
github.com/cosmos/cosmos-sdk v0.53.0-rc.1
github.com/cosmos/cosmos-sdk v0.53.0-rc.2
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.7.0
github.com/spf13/cobra v1.9.1