From 9fe74ba603013ba4586d3a15f6cf555a0eb10922 Mon Sep 17 00:00:00 2001 From: Facundo Date: Fri, 21 Jun 2024 17:32:14 +0200 Subject: [PATCH 1/8] add test --- client/keys/output_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/client/keys/output_test.go b/client/keys/output_test.go index c88f93b8752a..b56a30c7a083 100644 --- a/client/keys/output_test.go +++ b/client/keys/output_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -15,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func generatePubKeys(n int) []types.PubKey { @@ -100,3 +102,24 @@ func TestProtoMarshalJSON(t *testing.T) { require.Equal(ko.Address, expectedOutput) require.Equal(ko.PubKey, string(bz)) } + +func TestNestedMultisigOutput(t *testing.T) { + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec + + sk := secp256k1.PrivKey{Key: []byte{154, 49, 3, 117, 55, 232, 249, 20, 205, 216, 102, 7, 136, 72, 177, 2, 131, 202, 234, 81, 31, 208, 46, 244, 179, 192, 167, 163, 142, 117, 246, 13}} + tmpKey := sk.PubKey() + multisigPk := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey}) + multisigPk2 := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey, multisigPk}) + + kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cdc) + require.NoError(t, err) + + _, err = kb.SaveMultisig("multisig", multisigPk2) + require.NoError(t, err) + + k, err := kb.Key("multisig") + require.NoError(t, err) + + _, err = MkAccKeyOutput(k, addresscodec.NewBech32Codec("cosmos")) + require.NoError(t, err) +} From 59d8c51970f21036dab5d9173e6f389cf004443f Mon Sep 17 00:00:00 2001 From: Facundo Date: Fri, 21 Jun 2024 17:33:31 +0200 Subject: [PATCH 2/8] remove UnpackInterfacesMessage --- client/grpc/cmtservice/service.go | 9 +-- client/grpc_query.go | 3 +- codec/amino.go | 10 +-- codec/codec.go | 3 +- codec/json.go | 3 +- codec/proto_codec.go | 5 +- codec/types/interface_registry.go | 77 ++++++++++++------------ crypto/keyring/legacy_info.go | 6 +- crypto/keyring/record.go | 3 +- crypto/keys/multisig/multisig.go | 7 ++- testutil/testdata/animal.go | 15 +++-- testutil/testdata/grpc_query.go | 12 ++-- types/result.go | 9 +-- types/tx/direct_aux.go | 6 +- types/tx/ext.go | 3 +- types/tx/msgs.go | 3 +- types/tx/signing/signature.go | 8 +-- types/tx/types.go | 12 ++-- x/auth/migrations/legacytx/stdsign.go | 6 +- x/auth/migrations/legacytx/stdsignmsg.go | 8 +-- x/auth/migrations/legacytx/stdtx.go | 14 ++--- x/auth/types/account.go | 16 ++--- x/auth/types/genesis.go | 14 ++--- x/auth/types/query.go | 6 +- x/staking/types/genesis.go | 4 +- x/staking/types/msg.go | 32 +++++----- x/staking/types/validator.go | 8 +-- 27 files changed, 156 insertions(+), 146 deletions(-) diff --git a/client/grpc/cmtservice/service.go b/client/grpc/cmtservice/service.go index ad307984c0e5..7c08b5ec655c 100644 --- a/client/grpc/cmtservice/service.go +++ b/client/grpc/cmtservice/service.go @@ -17,11 +17,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" qtypes "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/version" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) type ( @@ -112,7 +113,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa return ValidatorsOutput(ctx, s.clientCtx, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) @@ -171,7 +172,7 @@ func ValidatorsOutput(ctx context.Context, clientCtx client.Context, height *int if err != nil { return nil, err } - anyPub, err := codectypes.NewAnyWithValue(pk) + anyPub, err := gogoprotoany.NewAnyWithCacheWithValue(pk) if err != nil { return nil, err } diff --git a/client/grpc_query.go b/client/grpc_query.go index 45f60e48d2de..8687492571d8 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -19,6 +19,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" "github.com/cosmos/cosmos-sdk/types/tx" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var _ gogogrpc.ClientConn = Context{} @@ -115,7 +116,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i } if ctx.InterfaceRegistry != nil { - return types.UnpackInterfaces(reply, ctx.InterfaceRegistry) + return gogoprotoany.UnpackInterfaces(reply, ctx.InterfaceRegistry) } return nil diff --git a/codec/amino.go b/codec/amino.go index 7dcdb844d518..4f3e9fc7648d 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -11,8 +11,8 @@ import ( "github.com/tendermint/go-amino" "cosmossdk.io/core/legacy" - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // LegacyAmino defines a wrapper for an Amino codec that properly @@ -65,19 +65,19 @@ func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte { } func (cdc *LegacyAmino) marshalAnys(o interface{}) error { - return types.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino}) + return gogoprotoany.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) unmarshalAnys(o interface{}) error { - return types.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino}) + return gogoprotoany.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) jsonMarshalAnys(o interface{}) error { - return types.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino}) + return gogoprotoany.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) jsonUnmarshalAnys(o interface{}) error { - return types.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino}) + return gogoprotoany.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error) { diff --git a/codec/codec.go b/codec/codec.go index c8c5844ac04b..7f8060f88a8e 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -6,6 +6,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type ( @@ -76,7 +77,7 @@ type ( // is not registered in codec, or is not compatible with the serialized data UnmarshalInterface(bz []byte, ptr interface{}) error - types.AnyUnpacker + gogoprotoany.AnyUnpacker } JSONCodec interface { diff --git a/codec/json.go b/codec/json.go index 2e913bfd11d8..7532ba556e22 100644 --- a/codec/json.go +++ b/codec/json.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var defaultJM = &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: nil} @@ -20,7 +21,7 @@ func ProtoMarshalJSON(msg proto.Message, resolver jsonpb.AnyResolver) ([]byte, e if resolver != nil { jm = &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: resolver} } - err := types.UnpackInterfaces(msg, types.ProtoJSONPacker{JSONPBMarshaler: jm}) + err := gogoprotoany.UnpackInterfaces(msg, types.ProtoJSONPacker{JSONPBMarshaler: jm}) if err != nil { return nil, err } diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 2c0c081896b1..6008f96e4cd0 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-proto/anyutil" "github.com/cosmos/gogoproto/jsonpb" gogoproto "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/grpc/encoding" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" @@ -98,7 +99,7 @@ func (pc *ProtoCodec) Unmarshal(bz []byte, ptr gogoproto.Message) error { if err != nil { return err } - err = types.UnpackInterfaces(ptr, pc.interfaceRegistry) + err = gogoprotoany.UnpackInterfaces(ptr, pc.interfaceRegistry) if err != nil { return err } @@ -207,7 +208,7 @@ func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr gogoproto.Message) error { return err } - return types.UnpackInterfaces(ptr, pc.interfaceRegistry) + return gogoprotoany.UnpackInterfaces(ptr, pc.interfaceRegistry) } // MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index ca1d1e61e60b..60f209710baf 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoiface" @@ -17,56 +18,56 @@ import ( // AnyUnpacker is an interface which allows safely unpacking types packed // in Any's against a whitelist of registered types -type AnyUnpacker interface { - // UnpackAny unpacks the value in any to the interface pointer passed in as - // iface. Note that the type in any must have been registered in the - // underlying whitelist registry as a concrete type for that interface - // Ex: - // var msg sdk.Msg - // err := cdc.UnpackAny(any, &msg) - // ... - UnpackAny(any *Any, iface interface{}) error -} +// type AnyUnpacker interface { +// // UnpackAny unpacks the value in any to the interface pointer passed in as +// // iface. Note that the type in any must have been registered in the +// // underlying whitelist registry as a concrete type for that interface +// // Ex: +// // var msg sdk.Msg +// // err := cdc.UnpackAny(any, &msg) +// // ... +// UnpackAny(any *Any, iface interface{}) error +// } // UnpackInterfacesMessage is meant to extend protobuf types (which implement // proto.Message) to support a post-deserialization phase which unpacks // types packed within Any's using the whitelist provided by AnyUnpacker -type UnpackInterfacesMessage interface { - // UnpackInterfaces is implemented in order to unpack values packed within - // Any's using the AnyUnpacker. It should generally be implemented as - // follows: - // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { - // var x AnyInterface - // // where X is an Any field on MyStruct - // err := unpacker.UnpackAny(s.X, &x) - // if err != nil { - // return nil - // } - // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself - // err = s.Y.UnpackInterfaces(unpacker) - // if err != nil { - // return nil - // } - // return nil - // } - UnpackInterfaces(unpacker AnyUnpacker) error -} +// type UnpackInterfacesMessage interface { +// // UnpackInterfaces is implemented in order to unpack values packed within +// // Any's using the AnyUnpacker. It should generally be implemented as +// // follows: +// // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { +// // var x AnyInterface +// // // where X is an Any field on MyStruct +// // err := unpacker.UnpackAny(s.X, &x) +// // if err != nil { +// // return nil +// // } +// // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself +// // err = s.Y.UnpackInterfaces(unpacker) +// // if err != nil { +// // return nil +// // } +// // return nil +// // } +// UnpackInterfaces(unpacker AnyUnpacker) error +// } // UnpackInterfaces is a convenience function that calls UnpackInterfaces // on x if x implements UnpackInterfacesMessage -func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { - if msg, ok := x.(UnpackInterfacesMessage); ok { - return msg.UnpackInterfaces(unpacker) - } - return nil -} +// func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { +// if msg, ok := x.(UnpackInterfacesMessage); ok { +// return msg.UnpackInterfaces(unpacker) +// } +// return nil +// } var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem() // InterfaceRegistry provides a mechanism for registering interfaces and // implementations that can be safely unpacked from Any type InterfaceRegistry interface { - AnyUnpacker + gogoprotoany.AnyUnpacker jsonpb.AnyResolver registry.InterfaceRegistrar @@ -314,7 +315,7 @@ func (registry *interfaceRegistry) UnpackAny(any *Any, iface interface{}) error return err } - err = UnpackInterfaces(msg, registry) + err = gogoprotoany.UnpackInterfaces(msg, registry) if err != nil { return err } diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 47cbe3e9a920..ff842db7901a 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -5,11 +5,11 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/codec/legacy" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Deprecated: LegacyInfo is the publicly exposed information about a keypair @@ -218,10 +218,10 @@ func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (i LegacyMultiInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { multiPK := i.PubKey.(*multisig.LegacyAminoPubKey) - return codectypes.UnpackInterfaces(multiPK, unpacker) + return gogoprotoany.UnpackInterfaces(multiPK, unpacker) } // MarshalInfo encoding info diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index 96141e4c906e..fb7ddeee06a7 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( @@ -103,7 +104,7 @@ func (k Record) GetType() KeyType { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (k *Record) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (k *Record) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey if err := unpacker.UnpackAny(k.PubKey, &pk); err != nil { return err diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 623f25516164..3a56763cfc2c 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -9,11 +9,12 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" multisigtypes "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ multisigtypes.PubKey = &LegacyAminoPubKey{} - _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} + _ multisigtypes.PubKey = &LegacyAminoPubKey{} + _ gogoprotoany.UnpackInterfacesMessage = &LegacyAminoPubKey{} ) // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. @@ -149,7 +150,7 @@ func (m *LegacyAminoPubKey) Type() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range m.PubKeys { var pk cryptotypes.PubKey err := unpacker.UnpackAny(any, &pk) diff --git a/testutil/testdata/animal.go b/testutil/testdata/animal.go index 7d5afa615280..327b8851e1ea 100644 --- a/testutil/testdata/animal.go +++ b/testutil/testdata/animal.go @@ -4,8 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" - - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type Animal interface { @@ -32,9 +31,9 @@ func (d Dog) Greet() string { return fmt.Sprintf("Roof, my name is %s", d.Name) } -var _ types.UnpackInterfacesMessage = HasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasAnimal{} -func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal Animal return unpacker.UnpackAny(m.Animal, &animal) } @@ -59,9 +58,9 @@ func (m HasHasAnimal) TheHasAnimal() HasAnimalI { return m.HasAnimal.GetCachedValue().(HasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasAnimal{} -func (m HasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasAnimalI return unpacker.UnpackAny(m.HasAnimal, &animal) } @@ -76,9 +75,9 @@ func (m HasHasHasAnimal) TheHasHasAnimal() HasHasAnimalI { return m.HasHasAnimal.GetCachedValue().(HasHasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasHasAnimal{} -func (m HasHasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasHasAnimalI return unpacker.UnpackAny(m.HasHasAnimal, &animal) } diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index 1078f60b8b81..f9d3b36ae464 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -11,8 +11,8 @@ import ( "google.golang.org/grpc" "gotest.tools/v3/assert" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // iterCount defines the number of iterations to run on each query to test @@ -29,7 +29,7 @@ func (e QueryImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAny return nil, fmt.Errorf("expected Animal") } - any, err := types.NewAnyWithValue(animal.(proto.Message)) + any, err := gogoprotoany.NewAnyWithCacheWithValue(animal.(proto.Message)) if err != nil { return nil, err } @@ -49,16 +49,16 @@ func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHe return &SayHelloResponse{Greeting: greeting}, nil } -var _ types.UnpackInterfacesMessage = &TestAnyRequest{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyRequest{} -func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyRequest) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal test.Animal return unpacker.UnpackAny(m.AnyAnimal, &animal) } -var _ types.UnpackInterfacesMessage = &TestAnyResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyResponse{} -func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return m.HasAnimal.UnpackInterfaces(unpacker) } diff --git a/types/result.go b/types/result.go index 148847eecf2b..75dd671eedc5 100644 --- a/types/result.go +++ b/types/result.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) func (gi GasInfo) String() string { @@ -159,15 +160,15 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) { return res, err } -var _, _ codectypes.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} +var _, _ gogoprotoany.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces // // types.UnpackInterfaces needs to be called for each nested Tx because // there are generally interfaces to unpack in Tx's -func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s SearchTxsResult) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, tx := range s.Txs { - err := codectypes.UnpackInterfaces(tx, unpacker) + err := gogoprotoany.UnpackInterfaces(tx, unpacker) if err != nil { return err } @@ -176,7 +177,7 @@ func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (r TxResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (r TxResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if r.Tx != nil { var tx HasMsgs return unpacker.UnpackAny(r.Tx, &tx) diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 52c9fc214a8e..92183b904c55 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -1,10 +1,10 @@ package tx import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // ValidateBasic performs stateless validation of the sign doc. @@ -21,7 +21,7 @@ func (s *SignDocDirectAux) ValidateBasic() error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (s *SignDocDirectAux) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s *SignDocDirectAux) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(s.PublicKey, new(cryptotypes.PubKey)) } @@ -60,6 +60,6 @@ func (a *AuxSignerData) GetSignatureV2() (signing.SignatureV2, error) { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (a *AuxSignerData) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (a *AuxSignerData) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return a.GetSignDoc().UnpackInterfaces(unpacker) } diff --git a/types/tx/ext.go b/types/tx/ext.go index fb2e1ed448bc..94038f65d849 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -2,13 +2,14 @@ package tx import ( "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // TxExtensionOptionI defines the interface for tx extension options type TxExtensionOptionI interface{} // unpackTxExtensionOptionsI unpacks Any's to TxExtensionOptionI's. -func unpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { +func unpackTxExtensionOptionsI(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var opt TxExtensionOptionI err := unpacker.UnpackAny(any, &opt) diff --git a/types/tx/msgs.go b/types/tx/msgs.go index 2f2f9a80f912..1e8476809f60 100644 --- a/types/tx/msgs.go +++ b/types/tx/msgs.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( @@ -53,7 +54,7 @@ func GetMsgs(anys []*types.Any, name string) ([]sdk.Msg, error) { } // UnpackInterfaces unpacks Any's to sdk.Msg's. -func UnpackInterfaces(unpacker types.AnyUnpacker, anys []*types.Any) error { +func UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var msg sdk.Msg err := unpacker.UnpackAny(any, &msg) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index a9549bab9a12..7860637b8415 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,8 +3,8 @@ package signing import ( "fmt" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // SignatureV2 is a convenience type that is easier to use in application logic @@ -86,10 +86,10 @@ func SignatureDataFromProto(descData *SignatureDescriptor_Data) SignatureData { } } -var _, _ codectypes.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} +var _, _ gogoprotoany.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sds *SignatureDescriptors) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, sig := range sds.Signatures { err := sig.UnpackInterfaces(unpacker) if err != nil { @@ -101,6 +101,6 @@ func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacke } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sd *SignatureDescriptor) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sd *SignatureDescriptor) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(sd.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx/types.go b/types/tx/types.go index c5a2e91ef37e..2917cd86b5ea 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -9,10 +9,10 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // MaxGasWanted defines the max gas allowed. @@ -20,7 +20,7 @@ const MaxGasWanted = uint64((1 << 63) - 1) // Interface implementation checks. var ( - _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} + _, _, _, _ gogoprotoany.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} ) // GetMsgs implements the GetMsgs method on sdk.Tx. @@ -177,7 +177,7 @@ func (t *Tx) FeeGranter(cdc codec.Codec) []byte { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (t *Tx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if t.Body != nil { if err := t.Body.UnpackInterfaces(unpacker); err != nil { return err @@ -192,7 +192,7 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *TxBody) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if err := UnpackInterfaces(unpacker, m.Messages); err != nil { return err } @@ -209,7 +209,7 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *AuthInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, signerInfo := range m.SignerInfos { err := signerInfo.UnpackInterfaces(unpacker) if err != nil { @@ -220,7 +220,7 @@ func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *SignerInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *SignerInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(m.PublicKey, new(cryptotypes.PubKey)) } diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index e8d00f67594c..d28a2fd8f8fd 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -10,11 +10,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // LegacyMsg defines the old interface a message must fulfill, @@ -129,8 +129,8 @@ func (ss StdSignature) MarshalYAML() (interface{}, error) { return string(bz), err } -func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return codectypes.UnpackInterfaces(ss.PubKey, unpacker) +func (ss StdSignature) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { + return gogoprotoany.UnpackInterfaces(ss.PubKey, unpacker) } // StdSignatureToSignatureV2 converts a StdSignature to a SignatureV2 diff --git a/x/auth/migrations/legacytx/stdsignmsg.go b/x/auth/migrations/legacytx/stdsignmsg.go index 561a64463f50..aac1d6d55c45 100644 --- a/x/auth/migrations/legacytx/stdsignmsg.go +++ b/x/auth/migrations/legacytx/stdsignmsg.go @@ -1,11 +1,11 @@ package legacytx import ( - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = StdSignMsg{} +var _ gogoprotoany.UnpackInterfacesMessage = StdSignMsg{} // StdSignMsg is a convenience structure for passing along a Msg with the other // requirements for a StdSignDoc before it is signed. For use in the CLI. @@ -19,9 +19,9 @@ type StdSignMsg struct { Memo string `json:"memo" yaml:"memo"` } -func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg StdSignMsg) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range msg.Msgs { - err := types.UnpackInterfaces(m, unpacker) + err := gogoprotoany.UnpackInterfaces(m, unpacker) if err != nil { return err } diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index dc5dba098860..c8ffaa34a828 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -5,17 +5,17 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec/legacy" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Interface implementation checks var ( - _ codectypes.UnpackInterfacesMessage = (*StdTx)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdTx)(nil) - _ codectypes.UnpackInterfacesMessage = (*StdSignature)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdSignature)(nil) ) // StdFee includes the amount of coins paid in fees and the maximum @@ -104,8 +104,8 @@ func (tx StdTx) GetMsgs() []sdk.Msg { return tx.Msgs } // Deprecated: AsAny implements intoAny. It doesn't work for protobuf serialization, // so it can't be saved into protobuf configured storage. We are using it only for API // compatibility. -func (tx *StdTx) AsAny() *codectypes.Any { - return codectypes.UnsafePackAny(tx) +func (tx *StdTx) AsAny() *gogoprotoany.Any { + return gogoprotoany.UnsafePackAnyWithCache(tx) } // GetMemo returns the memo @@ -169,9 +169,9 @@ func (tx StdTx) FeeGranter() sdk.AccAddress { return nil } -func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (tx StdTx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range tx.Msgs { - err := codectypes.UnpackInterfaces(m, unpacker) + err := gogoprotoany.UnpackInterfaces(m, unpacker) if err != nil { return err } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 791803174b5c..9b2ad65bc25e 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,18 +7,18 @@ import ( "fmt" "strings" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ sdk.AccountI = (*BaseAccount)(nil) - _ GenesisAccount = (*BaseAccount)(nil) - _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) - _ GenesisAccount = (*ModuleAccount)(nil) - _ sdk.ModuleAccountI = (*ModuleAccount)(nil) + _ sdk.AccountI = (*BaseAccount)(nil) + _ GenesisAccount = (*BaseAccount)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*BaseAccount)(nil) + _ GenesisAccount = (*ModuleAccount)(nil) + _ sdk.ModuleAccountI = (*ModuleAccount)(nil) ) // NewBaseAccount creates a new BaseAccount object. @@ -84,7 +84,7 @@ func (acc *BaseAccount) SetPubKey(pubKey cryptotypes.PubKey) error { acc.PubKey = nil return nil } - any, err := codectypes.NewAnyWithValue(pubKey) + any, err := gogoprotoany.NewAnyWithCacheWithValue(pubKey) if err == nil { acc.PubKey = any } @@ -132,7 +132,7 @@ func (acc BaseAccount) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (acc BaseAccount) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if acc.PubKey == nil { return nil } diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index b31c686bc43f..2d419b3c2bc0 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -9,12 +9,12 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // RandomGenesisAccountsFn defines the function required to generate custom account types type RandomGenesisAccountsFn func(simState *module.SimulationState) GenesisAccounts @@ -32,7 +32,7 @@ func NewGenesisState(params Params, accounts GenesisAccounts) *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range g.Accounts { var account GenesisAccount err := unpacker.UnpackAny(any, &account) @@ -164,14 +164,14 @@ func (GenesisAccountIterator) IterateGenesisAccounts( } // PackAccounts converts GenesisAccounts to Any slice -func PackAccounts(accounts GenesisAccounts) ([]*types.Any, error) { - accountsAny := make([]*types.Any, len(accounts)) +func PackAccounts(accounts GenesisAccounts) ([]*gogoprotoany.Any, error) { + accountsAny := make([]*gogoprotoany.Any, len(accounts)) for i, acc := range accounts { msg, ok := acc.(proto.Message) if !ok { return nil, fmt.Errorf("cannot proto marshal %T", acc) } - any, err := types.NewAnyWithValue(msg) + any, err := gogoprotoany.NewAnyWithCacheWithValue(msg) if err != nil { return nil, err } @@ -182,7 +182,7 @@ func PackAccounts(accounts GenesisAccounts) ([]*types.Any, error) { } // UnpackAccounts converts Any slice to GenesisAccounts -func UnpackAccounts(accountsAny []*types.Any) (GenesisAccounts, error) { +func UnpackAccounts(accountsAny []*gogoprotoany.Any) (GenesisAccounts, error) { accounts := make(GenesisAccounts, len(accountsAny)) for i, any := range accountsAny { acc, ok := any.GetCachedValue().(GenesisAccount) diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 8ab9df38f9f0..67b708837047 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,13 +1,13 @@ package types import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *QueryAccountResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } -var _ codectypes.UnpackInterfacesMessage = &QueryAccountResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &QueryAccountResponse{} diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index e144661afe55..673d251caa23 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates a new GenesisState instance @@ -36,7 +36,7 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range g.Validators { if err := g.Validators[i].UnpackInterfaces(c); err != nil { return err diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 3effad961f14..e9c13d9fc230 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -6,21 +6,21 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ coretransaction.Msg = &MsgCreateValidator{} - _ codectypes.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) - _ coretransaction.Msg = &MsgEditValidator{} - _ coretransaction.Msg = &MsgDelegate{} - _ coretransaction.Msg = &MsgUndelegate{} - _ coretransaction.Msg = &MsgBeginRedelegate{} - _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} - _ coretransaction.Msg = &MsgUpdateParams{} + _ coretransaction.Msg = &MsgCreateValidator{} + _ gogoprotoany.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) + _ coretransaction.Msg = &MsgEditValidator{} + _ coretransaction.Msg = &MsgDelegate{} + _ coretransaction.Msg = &MsgUndelegate{} + _ coretransaction.Msg = &MsgBeginRedelegate{} + _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} + _ coretransaction.Msg = &MsgUpdateParams{} ) // NewMsgCreateValidator creates a new MsgCreateValidator instance. @@ -29,10 +29,10 @@ func NewMsgCreateValidator( valAddr string, pubKey cryptotypes.PubKey, selfDelegation sdk.Coin, description Description, commission CommissionRates, minSelfDelegation math.Int, ) (*MsgCreateValidator, error) { - var pkAny *codectypes.Any + var pkAny *gogoprotoany.Any if pubKey != nil { var err error - if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil { + if pkAny, err = gogoprotoany.NewAnyWithCacheWithValue(pubKey); err != nil { return nil, err } } @@ -89,7 +89,7 @@ func (msg MsgCreateValidator) Validate(ac address.Codec) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgCreateValidator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.Pubkey, &pubKey) } @@ -146,10 +146,10 @@ func NewMsgCancelUnbondingDelegation(delAddr, valAddr string, creationHeight int // NewMsgRotateConsPubKey creates a new MsgRotateConsPubKey instance. func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRotateConsPubKey, error) { - var pkAny *codectypes.Any + var pkAny *gogoprotoany.Any if pubKey != nil { var err error - if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil { + if pkAny, err = gogoprotoany.NewAnyWithCacheWithValue(pubKey); err != nil { return nil, err } } @@ -160,13 +160,13 @@ func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRota } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.NewPubkey, &pubKey) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var oldPubKey cryptotypes.PubKey err := unpacker.UnpackAny(hi.OldConsPubkey, &oldPubKey) if err != nil { diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 9906bc2b8009..3b7b38bf02c2 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -13,10 +13,10 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( @@ -39,7 +39,7 @@ var _ sdk.ValidatorI = Validator{} // NewValidator constructs a new Validator func NewValidator(operator string, pubKey cryptotypes.PubKey, description Description) (Validator, error) { - pkAny, err := codectypes.NewAnyWithValue(pubKey) + pkAny, err := gogoprotoany.NewAnyWithCacheWithValue(pubKey) if err != nil { return Validator{}, err } @@ -138,7 +138,7 @@ func (valz ValidatorsByVotingPower) Swap(i, j int) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validators) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (v Validators) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range v.Validators { if err := v.Validators[i].UnpackInterfaces(c); err != nil { return err @@ -494,7 +494,7 @@ func (v Validator) GetMinSelfDelegation() math.Int { return v.MinSelfDelegat func (v Validator) GetDelegatorShares() math.LegacyDec { return v.DelegatorShares } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (v Validator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey return unpacker.UnpackAny(v.ConsensusPubkey, &pk) } From 94a3c7a5ea05c78b244e1af735d259f505472d2e Mon Sep 17 00:00:00 2001 From: Facundo Date: Thu, 18 Jul 2024 10:58:13 +0200 Subject: [PATCH 3/8] Revert "remove UnpackInterfacesMessage" This reverts commit 59d8c51970f21036dab5d9173e6f389cf004443f. --- client/grpc/cmtservice/service.go | 9 ++- client/grpc_query.go | 3 +- codec/amino.go | 10 +-- codec/codec.go | 3 +- codec/json.go | 3 +- codec/proto_codec.go | 5 +- codec/types/interface_registry.go | 77 ++++++++++++------------ crypto/keyring/legacy_info.go | 6 +- crypto/keyring/record.go | 3 +- crypto/keys/multisig/multisig.go | 7 +-- testutil/testdata/animal.go | 15 ++--- testutil/testdata/grpc_query.go | 12 ++-- types/result.go | 9 ++- types/tx/direct_aux.go | 6 +- types/tx/ext.go | 3 +- types/tx/msgs.go | 3 +- types/tx/signing/signature.go | 8 +-- types/tx/types.go | 12 ++-- x/auth/migrations/legacytx/stdsign.go | 6 +- x/auth/migrations/legacytx/stdsignmsg.go | 8 +-- x/auth/migrations/legacytx/stdtx.go | 14 ++--- x/auth/types/account.go | 16 ++--- x/auth/types/genesis.go | 14 ++--- x/auth/types/query.go | 6 +- x/staking/types/genesis.go | 4 +- x/staking/types/msg.go | 32 +++++----- x/staking/types/validator.go | 8 +-- 27 files changed, 146 insertions(+), 156 deletions(-) diff --git a/client/grpc/cmtservice/service.go b/client/grpc/cmtservice/service.go index 7c08b5ec655c..ad307984c0e5 100644 --- a/client/grpc/cmtservice/service.go +++ b/client/grpc/cmtservice/service.go @@ -17,12 +17,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" qtypes "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/version" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ ServiceServer = queryServer{} - _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) type ( @@ -113,7 +112,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa return ValidatorsOutput(ctx, s.clientCtx, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) @@ -172,7 +171,7 @@ func ValidatorsOutput(ctx context.Context, clientCtx client.Context, height *int if err != nil { return nil, err } - anyPub, err := gogoprotoany.NewAnyWithCacheWithValue(pk) + anyPub, err := codectypes.NewAnyWithValue(pk) if err != nil { return nil, err } diff --git a/client/grpc_query.go b/client/grpc_query.go index 8687492571d8..45f60e48d2de 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -19,7 +19,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" "github.com/cosmos/cosmos-sdk/types/tx" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var _ gogogrpc.ClientConn = Context{} @@ -116,7 +115,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i } if ctx.InterfaceRegistry != nil { - return gogoprotoany.UnpackInterfaces(reply, ctx.InterfaceRegistry) + return types.UnpackInterfaces(reply, ctx.InterfaceRegistry) } return nil diff --git a/codec/amino.go b/codec/amino.go index 4f3e9fc7648d..7dcdb844d518 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -11,8 +11,8 @@ import ( "github.com/tendermint/go-amino" "cosmossdk.io/core/legacy" + "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // LegacyAmino defines a wrapper for an Amino codec that properly @@ -65,19 +65,19 @@ func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte { } func (cdc *LegacyAmino) marshalAnys(o interface{}) error { - return gogoprotoany.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino}) + return types.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) unmarshalAnys(o interface{}) error { - return gogoprotoany.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino}) + return types.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) jsonMarshalAnys(o interface{}) error { - return gogoprotoany.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino}) + return types.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) jsonUnmarshalAnys(o interface{}) error { - return gogoprotoany.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino}) + return types.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino}) } func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error) { diff --git a/codec/codec.go b/codec/codec.go index 7f8060f88a8e..c8c5844ac04b 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -6,7 +6,6 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type ( @@ -77,7 +76,7 @@ type ( // is not registered in codec, or is not compatible with the serialized data UnmarshalInterface(bz []byte, ptr interface{}) error - gogoprotoany.AnyUnpacker + types.AnyUnpacker } JSONCodec interface { diff --git a/codec/json.go b/codec/json.go index 7532ba556e22..2e913bfd11d8 100644 --- a/codec/json.go +++ b/codec/json.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var defaultJM = &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: nil} @@ -21,7 +20,7 @@ func ProtoMarshalJSON(msg proto.Message, resolver jsonpb.AnyResolver) ([]byte, e if resolver != nil { jm = &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: resolver} } - err := gogoprotoany.UnpackInterfaces(msg, types.ProtoJSONPacker{JSONPBMarshaler: jm}) + err := types.UnpackInterfaces(msg, types.ProtoJSONPacker{JSONPBMarshaler: jm}) if err != nil { return nil, err } diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 6008f96e4cd0..2c0c081896b1 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-proto/anyutil" "github.com/cosmos/gogoproto/jsonpb" gogoproto "github.com/cosmos/gogoproto/proto" - gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/grpc/encoding" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" @@ -99,7 +98,7 @@ func (pc *ProtoCodec) Unmarshal(bz []byte, ptr gogoproto.Message) error { if err != nil { return err } - err = gogoprotoany.UnpackInterfaces(ptr, pc.interfaceRegistry) + err = types.UnpackInterfaces(ptr, pc.interfaceRegistry) if err != nil { return err } @@ -208,7 +207,7 @@ func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr gogoproto.Message) error { return err } - return gogoprotoany.UnpackInterfaces(ptr, pc.interfaceRegistry) + return types.UnpackInterfaces(ptr, pc.interfaceRegistry) } // MustUnmarshalJSON implements JSONCodec.MustUnmarshalJSON method, diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index 60f209710baf..ca1d1e61e60b 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" - gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoiface" @@ -18,56 +17,56 @@ import ( // AnyUnpacker is an interface which allows safely unpacking types packed // in Any's against a whitelist of registered types -// type AnyUnpacker interface { -// // UnpackAny unpacks the value in any to the interface pointer passed in as -// // iface. Note that the type in any must have been registered in the -// // underlying whitelist registry as a concrete type for that interface -// // Ex: -// // var msg sdk.Msg -// // err := cdc.UnpackAny(any, &msg) -// // ... -// UnpackAny(any *Any, iface interface{}) error -// } +type AnyUnpacker interface { + // UnpackAny unpacks the value in any to the interface pointer passed in as + // iface. Note that the type in any must have been registered in the + // underlying whitelist registry as a concrete type for that interface + // Ex: + // var msg sdk.Msg + // err := cdc.UnpackAny(any, &msg) + // ... + UnpackAny(any *Any, iface interface{}) error +} // UnpackInterfacesMessage is meant to extend protobuf types (which implement // proto.Message) to support a post-deserialization phase which unpacks // types packed within Any's using the whitelist provided by AnyUnpacker -// type UnpackInterfacesMessage interface { -// // UnpackInterfaces is implemented in order to unpack values packed within -// // Any's using the AnyUnpacker. It should generally be implemented as -// // follows: -// // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { -// // var x AnyInterface -// // // where X is an Any field on MyStruct -// // err := unpacker.UnpackAny(s.X, &x) -// // if err != nil { -// // return nil -// // } -// // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself -// // err = s.Y.UnpackInterfaces(unpacker) -// // if err != nil { -// // return nil -// // } -// // return nil -// // } -// UnpackInterfaces(unpacker AnyUnpacker) error -// } +type UnpackInterfacesMessage interface { + // UnpackInterfaces is implemented in order to unpack values packed within + // Any's using the AnyUnpacker. It should generally be implemented as + // follows: + // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { + // var x AnyInterface + // // where X is an Any field on MyStruct + // err := unpacker.UnpackAny(s.X, &x) + // if err != nil { + // return nil + // } + // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself + // err = s.Y.UnpackInterfaces(unpacker) + // if err != nil { + // return nil + // } + // return nil + // } + UnpackInterfaces(unpacker AnyUnpacker) error +} // UnpackInterfaces is a convenience function that calls UnpackInterfaces // on x if x implements UnpackInterfacesMessage -// func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { -// if msg, ok := x.(UnpackInterfacesMessage); ok { -// return msg.UnpackInterfaces(unpacker) -// } -// return nil -// } +func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { + if msg, ok := x.(UnpackInterfacesMessage); ok { + return msg.UnpackInterfaces(unpacker) + } + return nil +} var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem() // InterfaceRegistry provides a mechanism for registering interfaces and // implementations that can be safely unpacked from Any type InterfaceRegistry interface { - gogoprotoany.AnyUnpacker + AnyUnpacker jsonpb.AnyResolver registry.InterfaceRegistrar @@ -315,7 +314,7 @@ func (registry *interfaceRegistry) UnpackAny(any *Any, iface interface{}) error return err } - err = gogoprotoany.UnpackInterfaces(msg, registry) + err = UnpackInterfaces(msg, registry) if err != nil { return err } diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index ff842db7901a..47cbe3e9a920 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -5,11 +5,11 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/codec/legacy" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Deprecated: LegacyInfo is the publicly exposed information about a keypair @@ -218,10 +218,10 @@ func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (i LegacyMultiInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { multiPK := i.PubKey.(*multisig.LegacyAminoPubKey) - return gogoprotoany.UnpackInterfaces(multiPK, unpacker) + return codectypes.UnpackInterfaces(multiPK, unpacker) } // MarshalInfo encoding info diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index fb7ddeee06a7..96141e4c906e 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( @@ -104,7 +103,7 @@ func (k Record) GetType() KeyType { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (k *Record) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (k *Record) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var pk cryptotypes.PubKey if err := unpacker.UnpackAny(k.PubKey, &pk); err != nil { return err diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 3a56763cfc2c..623f25516164 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -9,12 +9,11 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" multisigtypes "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ multisigtypes.PubKey = &LegacyAminoPubKey{} - _ gogoprotoany.UnpackInterfacesMessage = &LegacyAminoPubKey{} + _ multisigtypes.PubKey = &LegacyAminoPubKey{} + _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} ) // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. @@ -150,7 +149,7 @@ func (m *LegacyAminoPubKey) Type() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { for _, any := range m.PubKeys { var pk cryptotypes.PubKey err := unpacker.UnpackAny(any, &pk) diff --git a/testutil/testdata/animal.go b/testutil/testdata/animal.go index 327b8851e1ea..7d5afa615280 100644 --- a/testutil/testdata/animal.go +++ b/testutil/testdata/animal.go @@ -4,7 +4,8 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" - gogoprotoany "github.com/cosmos/gogoproto/types/any" + + "github.com/cosmos/cosmos-sdk/codec/types" ) type Animal interface { @@ -31,9 +32,9 @@ func (d Dog) Greet() string { return fmt.Sprintf("Roof, my name is %s", d.Name) } -var _ gogoprotoany.UnpackInterfacesMessage = HasAnimal{} +var _ types.UnpackInterfacesMessage = HasAnimal{} -func (m HasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { var animal Animal return unpacker.UnpackAny(m.Animal, &animal) } @@ -58,9 +59,9 @@ func (m HasHasAnimal) TheHasAnimal() HasAnimalI { return m.HasAnimal.GetCachedValue().(HasAnimalI) } -var _ gogoprotoany.UnpackInterfacesMessage = HasHasAnimal{} +var _ types.UnpackInterfacesMessage = HasHasAnimal{} -func (m HasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m HasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { var animal HasAnimalI return unpacker.UnpackAny(m.HasAnimal, &animal) } @@ -75,9 +76,9 @@ func (m HasHasHasAnimal) TheHasHasAnimal() HasHasAnimalI { return m.HasHasAnimal.GetCachedValue().(HasHasAnimalI) } -var _ gogoprotoany.UnpackInterfacesMessage = HasHasHasAnimal{} +var _ types.UnpackInterfacesMessage = HasHasHasAnimal{} -func (m HasHasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m HasHasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { var animal HasHasAnimalI return unpacker.UnpackAny(m.HasHasAnimal, &animal) } diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index f9d3b36ae464..1078f60b8b81 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -11,8 +11,8 @@ import ( "google.golang.org/grpc" "gotest.tools/v3/assert" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // iterCount defines the number of iterations to run on each query to test @@ -29,7 +29,7 @@ func (e QueryImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAny return nil, fmt.Errorf("expected Animal") } - any, err := gogoprotoany.NewAnyWithCacheWithValue(animal.(proto.Message)) + any, err := types.NewAnyWithValue(animal.(proto.Message)) if err != nil { return nil, err } @@ -49,16 +49,16 @@ func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHe return &SayHelloResponse{Greeting: greeting}, nil } -var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyRequest{} +var _ types.UnpackInterfacesMessage = &TestAnyRequest{} -func (m *TestAnyRequest) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { var animal test.Animal return unpacker.UnpackAny(m.AnyAnimal, &animal) } -var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyResponse{} +var _ types.UnpackInterfacesMessage = &TestAnyResponse{} -func (m *TestAnyResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { return m.HasAnimal.UnpackInterfaces(unpacker) } diff --git a/types/result.go b/types/result.go index 75dd671eedc5..148847eecf2b 100644 --- a/types/result.go +++ b/types/result.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) func (gi GasInfo) String() string { @@ -160,15 +159,15 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) { return res, err } -var _, _ gogoprotoany.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} +var _, _ codectypes.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces // // types.UnpackInterfaces needs to be called for each nested Tx because // there are generally interfaces to unpack in Tx's -func (s SearchTxsResult) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, tx := range s.Txs { - err := gogoprotoany.UnpackInterfaces(tx, unpacker) + err := codectypes.UnpackInterfaces(tx, unpacker) if err != nil { return err } @@ -177,7 +176,7 @@ func (s SearchTxsResult) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) err } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (r TxResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (r TxResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if r.Tx != nil { var tx HasMsgs return unpacker.UnpackAny(r.Tx, &tx) diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 92183b904c55..52c9fc214a8e 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -1,10 +1,10 @@ package tx import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // ValidateBasic performs stateless validation of the sign doc. @@ -21,7 +21,7 @@ func (s *SignDocDirectAux) ValidateBasic() error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (s *SignDocDirectAux) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (s *SignDocDirectAux) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return unpacker.UnpackAny(s.PublicKey, new(cryptotypes.PubKey)) } @@ -60,6 +60,6 @@ func (a *AuxSignerData) GetSignatureV2() (signing.SignatureV2, error) { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (a *AuxSignerData) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (a *AuxSignerData) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return a.GetSignDoc().UnpackInterfaces(unpacker) } diff --git a/types/tx/ext.go b/types/tx/ext.go index 94038f65d849..fb2e1ed448bc 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -2,14 +2,13 @@ package tx import ( "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // TxExtensionOptionI defines the interface for tx extension options type TxExtensionOptionI interface{} // unpackTxExtensionOptionsI unpacks Any's to TxExtensionOptionI's. -func unpackTxExtensionOptionsI(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { +func unpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var opt TxExtensionOptionI err := unpacker.UnpackAny(any, &opt) diff --git a/types/tx/msgs.go b/types/tx/msgs.go index 1e8476809f60..2f2f9a80f912 100644 --- a/types/tx/msgs.go +++ b/types/tx/msgs.go @@ -5,7 +5,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( @@ -54,7 +53,7 @@ func GetMsgs(anys []*types.Any, name string) ([]sdk.Msg, error) { } // UnpackInterfaces unpacks Any's to sdk.Msg's. -func UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { +func UnpackInterfaces(unpacker types.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var msg sdk.Msg err := unpacker.UnpackAny(any, &msg) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index 7860637b8415..a9549bab9a12 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,8 +3,8 @@ package signing import ( "fmt" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // SignatureV2 is a convenience type that is easier to use in application logic @@ -86,10 +86,10 @@ func SignatureDataFromProto(descData *SignatureDescriptor_Data) SignatureData { } } -var _, _ gogoprotoany.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} +var _, _ codectypes.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sds *SignatureDescriptors) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, sig := range sds.Signatures { err := sig.UnpackInterfaces(unpacker) if err != nil { @@ -101,6 +101,6 @@ func (sds *SignatureDescriptors) UnpackInterfaces(unpacker gogoprotoany.AnyUnpac } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sd *SignatureDescriptor) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (sd *SignatureDescriptor) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return unpacker.UnpackAny(sd.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx/types.go b/types/tx/types.go index 2917cd86b5ea..c5a2e91ef37e 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -9,10 +9,10 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // MaxGasWanted defines the max gas allowed. @@ -20,7 +20,7 @@ const MaxGasWanted = uint64((1 << 63) - 1) // Interface implementation checks. var ( - _, _, _, _ gogoprotoany.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} + _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} ) // GetMsgs implements the GetMsgs method on sdk.Tx. @@ -177,7 +177,7 @@ func (t *Tx) FeeGranter(cdc codec.Codec) []byte { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (t *Tx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if t.Body != nil { if err := t.Body.UnpackInterfaces(unpacker); err != nil { return err @@ -192,7 +192,7 @@ func (t *Tx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *TxBody) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if err := UnpackInterfaces(unpacker, m.Messages); err != nil { return err } @@ -209,7 +209,7 @@ func (m *TxBody) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *AuthInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, signerInfo := range m.SignerInfos { err := signerInfo.UnpackInterfaces(unpacker) if err != nil { @@ -220,7 +220,7 @@ func (m *AuthInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *SignerInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *SignerInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return unpacker.UnpackAny(m.PublicKey, new(cryptotypes.PubKey)) } diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index d28a2fd8f8fd..e8d00f67594c 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -10,11 +10,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // LegacyMsg defines the old interface a message must fulfill, @@ -129,8 +129,8 @@ func (ss StdSignature) MarshalYAML() (interface{}, error) { return string(bz), err } -func (ss StdSignature) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { - return gogoprotoany.UnpackInterfaces(ss.PubKey, unpacker) +func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + return codectypes.UnpackInterfaces(ss.PubKey, unpacker) } // StdSignatureToSignatureV2 converts a StdSignature to a SignatureV2 diff --git a/x/auth/migrations/legacytx/stdsignmsg.go b/x/auth/migrations/legacytx/stdsignmsg.go index aac1d6d55c45..561a64463f50 100644 --- a/x/auth/migrations/legacytx/stdsignmsg.go +++ b/x/auth/migrations/legacytx/stdsignmsg.go @@ -1,11 +1,11 @@ package legacytx import ( + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ gogoprotoany.UnpackInterfacesMessage = StdSignMsg{} +var _ types.UnpackInterfacesMessage = StdSignMsg{} // StdSignMsg is a convenience structure for passing along a Msg with the other // requirements for a StdSignDoc before it is signed. For use in the CLI. @@ -19,9 +19,9 @@ type StdSignMsg struct { Memo string `json:"memo" yaml:"memo"` } -func (msg StdSignMsg) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error { for _, m := range msg.Msgs { - err := gogoprotoany.UnpackInterfaces(m, unpacker) + err := types.UnpackInterfaces(m, unpacker) if err != nil { return err } diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index c8ffaa34a828..dc5dba098860 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -5,17 +5,17 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec/legacy" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Interface implementation checks var ( - _ gogoprotoany.UnpackInterfacesMessage = (*StdTx)(nil) + _ codectypes.UnpackInterfacesMessage = (*StdTx)(nil) - _ gogoprotoany.UnpackInterfacesMessage = (*StdSignature)(nil) + _ codectypes.UnpackInterfacesMessage = (*StdSignature)(nil) ) // StdFee includes the amount of coins paid in fees and the maximum @@ -104,8 +104,8 @@ func (tx StdTx) GetMsgs() []sdk.Msg { return tx.Msgs } // Deprecated: AsAny implements intoAny. It doesn't work for protobuf serialization, // so it can't be saved into protobuf configured storage. We are using it only for API // compatibility. -func (tx *StdTx) AsAny() *gogoprotoany.Any { - return gogoprotoany.UnsafePackAnyWithCache(tx) +func (tx *StdTx) AsAny() *codectypes.Any { + return codectypes.UnsafePackAny(tx) } // GetMemo returns the memo @@ -169,9 +169,9 @@ func (tx StdTx) FeeGranter() sdk.AccAddress { return nil } -func (tx StdTx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, m := range tx.Msgs { - err := gogoprotoany.UnpackInterfaces(m, unpacker) + err := codectypes.UnpackInterfaces(m, unpacker) if err != nil { return err } diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 9b2ad65bc25e..791803174b5c 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,18 +7,18 @@ import ( "fmt" "strings" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ sdk.AccountI = (*BaseAccount)(nil) - _ GenesisAccount = (*BaseAccount)(nil) - _ gogoprotoany.UnpackInterfacesMessage = (*BaseAccount)(nil) - _ GenesisAccount = (*ModuleAccount)(nil) - _ sdk.ModuleAccountI = (*ModuleAccount)(nil) + _ sdk.AccountI = (*BaseAccount)(nil) + _ GenesisAccount = (*BaseAccount)(nil) + _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) + _ GenesisAccount = (*ModuleAccount)(nil) + _ sdk.ModuleAccountI = (*ModuleAccount)(nil) ) // NewBaseAccount creates a new BaseAccount object. @@ -84,7 +84,7 @@ func (acc *BaseAccount) SetPubKey(pubKey cryptotypes.PubKey) error { acc.PubKey = nil return nil } - any, err := gogoprotoany.NewAnyWithCacheWithValue(pubKey) + any, err := codectypes.NewAnyWithValue(pubKey) if err == nil { acc.PubKey = any } @@ -132,7 +132,7 @@ func (acc BaseAccount) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (acc BaseAccount) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if acc.PubKey == nil { return nil } diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index 2d419b3c2bc0..b31c686bc43f 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -9,12 +9,12 @@ import ( "github.com/cosmos/gogoproto/proto" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} +var _ types.UnpackInterfacesMessage = GenesisState{} // RandomGenesisAccountsFn defines the function required to generate custom account types type RandomGenesisAccountsFn func(simState *module.SimulationState) GenesisAccounts @@ -32,7 +32,7 @@ func NewGenesisState(params Params, accounts GenesisAccounts) *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { for _, any := range g.Accounts { var account GenesisAccount err := unpacker.UnpackAny(any, &account) @@ -164,14 +164,14 @@ func (GenesisAccountIterator) IterateGenesisAccounts( } // PackAccounts converts GenesisAccounts to Any slice -func PackAccounts(accounts GenesisAccounts) ([]*gogoprotoany.Any, error) { - accountsAny := make([]*gogoprotoany.Any, len(accounts)) +func PackAccounts(accounts GenesisAccounts) ([]*types.Any, error) { + accountsAny := make([]*types.Any, len(accounts)) for i, acc := range accounts { msg, ok := acc.(proto.Message) if !ok { return nil, fmt.Errorf("cannot proto marshal %T", acc) } - any, err := gogoprotoany.NewAnyWithCacheWithValue(msg) + any, err := types.NewAnyWithValue(msg) if err != nil { return nil, err } @@ -182,7 +182,7 @@ func PackAccounts(accounts GenesisAccounts) ([]*gogoprotoany.Any, error) { } // UnpackAccounts converts Any slice to GenesisAccounts -func UnpackAccounts(accountsAny []*gogoprotoany.Any) (GenesisAccounts, error) { +func UnpackAccounts(accountsAny []*types.Any) (GenesisAccounts, error) { accounts := make(GenesisAccounts, len(accountsAny)) for i, any := range accountsAny { acc, ok := any.GetCachedValue().(GenesisAccount) diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 67b708837047..8ab9df38f9f0 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,13 +1,13 @@ package types import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -func (m *QueryAccountResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } -var _ gogoprotoany.UnpackInterfacesMessage = &QueryAccountResponse{} +var _ codectypes.UnpackInterfacesMessage = &QueryAccountResponse{} diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index 673d251caa23..e144661afe55 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/cosmos/cosmos-sdk/codec" - gogoprotoany "github.com/cosmos/gogoproto/types/any" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new GenesisState instance @@ -36,7 +36,7 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(c codectypes.AnyUnpacker) error { for i := range g.Validators { if err := g.Validators[i].UnpackInterfaces(c); err != nil { return err diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index e9c13d9fc230..3effad961f14 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -6,21 +6,21 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ coretransaction.Msg = &MsgCreateValidator{} - _ gogoprotoany.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) - _ coretransaction.Msg = &MsgEditValidator{} - _ coretransaction.Msg = &MsgDelegate{} - _ coretransaction.Msg = &MsgUndelegate{} - _ coretransaction.Msg = &MsgBeginRedelegate{} - _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} - _ coretransaction.Msg = &MsgUpdateParams{} + _ coretransaction.Msg = &MsgCreateValidator{} + _ codectypes.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) + _ coretransaction.Msg = &MsgEditValidator{} + _ coretransaction.Msg = &MsgDelegate{} + _ coretransaction.Msg = &MsgUndelegate{} + _ coretransaction.Msg = &MsgBeginRedelegate{} + _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} + _ coretransaction.Msg = &MsgUpdateParams{} ) // NewMsgCreateValidator creates a new MsgCreateValidator instance. @@ -29,10 +29,10 @@ func NewMsgCreateValidator( valAddr string, pubKey cryptotypes.PubKey, selfDelegation sdk.Coin, description Description, commission CommissionRates, minSelfDelegation math.Int, ) (*MsgCreateValidator, error) { - var pkAny *gogoprotoany.Any + var pkAny *codectypes.Any if pubKey != nil { var err error - if pkAny, err = gogoprotoany.NewAnyWithCacheWithValue(pubKey); err != nil { + if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil { return nil, err } } @@ -89,7 +89,7 @@ func (msg MsgCreateValidator) Validate(ac address.Codec) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateValidator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.Pubkey, &pubKey) } @@ -146,10 +146,10 @@ func NewMsgCancelUnbondingDelegation(delAddr, valAddr string, creationHeight int // NewMsgRotateConsPubKey creates a new MsgRotateConsPubKey instance. func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRotateConsPubKey, error) { - var pkAny *gogoprotoany.Any + var pkAny *codectypes.Any if pubKey != nil { var err error - if pkAny, err = gogoprotoany.NewAnyWithCacheWithValue(pubKey); err != nil { + if pkAny, err = codectypes.NewAnyWithValue(pubKey); err != nil { return nil, err } } @@ -160,13 +160,13 @@ func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRota } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.NewPubkey, &pubKey) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var oldPubKey cryptotypes.PubKey err := unpacker.UnpackAny(hi.OldConsPubkey, &oldPubKey) if err != nil { diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 3b7b38bf02c2..9906bc2b8009 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -13,10 +13,10 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( @@ -39,7 +39,7 @@ var _ sdk.ValidatorI = Validator{} // NewValidator constructs a new Validator func NewValidator(operator string, pubKey cryptotypes.PubKey, description Description) (Validator, error) { - pkAny, err := gogoprotoany.NewAnyWithCacheWithValue(pubKey) + pkAny, err := codectypes.NewAnyWithValue(pubKey) if err != nil { return Validator{}, err } @@ -138,7 +138,7 @@ func (valz ValidatorsByVotingPower) Swap(i, j int) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validators) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { +func (v Validators) UnpackInterfaces(c codectypes.AnyUnpacker) error { for i := range v.Validators { if err := v.Validators[i].UnpackInterfaces(c); err != nil { return err @@ -494,7 +494,7 @@ func (v Validator) GetMinSelfDelegation() math.Int { return v.MinSelfDelegat func (v Validator) GetDelegatorShares() math.LegacyDec { return v.DelegatorShares } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { +func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { var pk cryptotypes.PubKey return unpacker.UnpackAny(v.ConsensusPubkey, &pk) } From ea1a51f03f26ea3a9ba455201196a2b71f59b1ae Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 22 Jul 2024 09:43:02 +0200 Subject: [PATCH 4/8] keep replacing --- client/grpc/cmtservice/service.go | 7 +-- codec/codec.go | 3 +- codec/types/interface_registry.go | 44 ++----------------- crypto/keyring/legacy_info.go | 3 +- crypto/keyring/record.go | 3 +- crypto/keys/multisig/multisig.go | 15 ++++--- .../client/grpc/cmtservice/service.go | 3 +- testutil/testdata/animal.go | 15 +++---- testutil/testdata/grpc_query.go | 9 ++-- types/result.go | 7 +-- types/tx/direct_aux.go | 6 +-- types/tx/ext.go | 3 +- types/tx/msgs.go | 3 +- types/tx/signing/signature.go | 8 ++-- types/tx/types.go | 12 ++--- x/auth/migrations/legacytx/stdsign.go | 3 +- x/auth/migrations/legacytx/stdsignmsg.go | 5 ++- x/auth/migrations/legacytx/stdtx.go | 7 +-- x/auth/types/account.go | 13 +++--- x/auth/types/genesis.go | 5 ++- x/auth/types/query.go | 6 +-- x/authz/authorization_grant.go | 9 ++-- x/authz/genesis.go | 8 ++-- x/authz/msgs.go | 11 ++--- x/authz/simulation/operations.go | 3 +- x/evidence/types/genesis.go | 6 ++- x/evidence/types/genesis_test.go | 3 +- x/evidence/types/msgs.go | 9 ++-- x/feegrant/filtered_fee.go | 7 +-- x/feegrant/genesis.go | 6 +-- x/feegrant/grant.go | 5 ++- x/feegrant/msgs.go | 7 +-- x/gov/types/v1/genesis.go | 7 ++- x/gov/types/v1/msgs.go | 9 ++-- x/gov/types/v1/proposal.go | 9 ++-- x/gov/types/v1beta1/genesis.go | 7 ++- x/gov/types/v1beta1/msgs.go | 5 ++- x/gov/types/v1beta1/proposal.go | 7 +-- x/group/genesis.go | 4 +- x/group/msgs.go | 15 ++++--- x/group/proposal.go | 4 +- x/group/simulation/operations.go | 3 +- x/group/types.go | 9 ++-- x/staking/types/genesis.go | 4 +- x/staking/types/msg.go | 23 +++++----- x/staking/types/validator.go | 5 ++- 46 files changed, 179 insertions(+), 186 deletions(-) diff --git a/client/grpc/cmtservice/service.go b/client/grpc/cmtservice/service.go index ad307984c0e5..05eeeb6ecc43 100644 --- a/client/grpc/cmtservice/service.go +++ b/client/grpc/cmtservice/service.go @@ -5,6 +5,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" gogogrpc "github.com/cosmos/gogoproto/grpc" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -20,8 +21,8 @@ import ( ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) type ( @@ -112,7 +113,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa return ValidatorsOutput(ctx, s.clientCtx, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) diff --git a/codec/codec.go b/codec/codec.go index c8c5844ac04b..7f8060f88a8e 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -6,6 +6,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type ( @@ -76,7 +77,7 @@ type ( // is not registered in codec, or is not compatible with the serialized data UnmarshalInterface(bz []byte, ptr interface{}) error - types.AnyUnpacker + gogoprotoany.AnyUnpacker } JSONCodec interface { diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index ca1d1e61e60b..ff0c23a9d14f 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoiface" @@ -15,47 +16,10 @@ import ( "cosmossdk.io/x/tx/signing" ) -// AnyUnpacker is an interface which allows safely unpacking types packed -// in Any's against a whitelist of registered types -type AnyUnpacker interface { - // UnpackAny unpacks the value in any to the interface pointer passed in as - // iface. Note that the type in any must have been registered in the - // underlying whitelist registry as a concrete type for that interface - // Ex: - // var msg sdk.Msg - // err := cdc.UnpackAny(any, &msg) - // ... - UnpackAny(any *Any, iface interface{}) error -} - -// UnpackInterfacesMessage is meant to extend protobuf types (which implement -// proto.Message) to support a post-deserialization phase which unpacks -// types packed within Any's using the whitelist provided by AnyUnpacker -type UnpackInterfacesMessage interface { - // UnpackInterfaces is implemented in order to unpack values packed within - // Any's using the AnyUnpacker. It should generally be implemented as - // follows: - // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { - // var x AnyInterface - // // where X is an Any field on MyStruct - // err := unpacker.UnpackAny(s.X, &x) - // if err != nil { - // return nil - // } - // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself - // err = s.Y.UnpackInterfaces(unpacker) - // if err != nil { - // return nil - // } - // return nil - // } - UnpackInterfaces(unpacker AnyUnpacker) error -} - // UnpackInterfaces is a convenience function that calls UnpackInterfaces // on x if x implements UnpackInterfacesMessage -func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { - if msg, ok := x.(UnpackInterfacesMessage); ok { +func UnpackInterfaces(x interface{}, unpacker gogoprotoany.AnyUnpacker) error { + if msg, ok := x.(gogoprotoany.UnpackInterfacesMessage); ok { return msg.UnpackInterfaces(unpacker) } return nil @@ -66,7 +30,7 @@ var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem() // InterfaceRegistry provides a mechanism for registering interfaces and // implementations that can be safely unpacked from Any type InterfaceRegistry interface { - AnyUnpacker + gogoprotoany.AnyUnpacker jsonpb.AnyResolver registry.InterfaceRegistrar diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 47cbe3e9a920..ca615809324a 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Deprecated: LegacyInfo is the publicly exposed information about a keypair @@ -218,7 +219,7 @@ func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (i LegacyMultiInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { multiPK := i.PubKey.(*multisig.LegacyAminoPubKey) return codectypes.UnpackInterfaces(multiPK, unpacker) diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index 96141e4c906e..fb7ddeee06a7 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( @@ -103,7 +104,7 @@ func (k Record) GetType() KeyType { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (k *Record) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (k *Record) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey if err := unpacker.UnpackAny(k.PubKey, &pk); err != nil { return err diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 623f25516164..3bf0cbe27409 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -9,11 +9,12 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" multisigtypes "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ multisigtypes.PubKey = &LegacyAminoPubKey{} - _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} + _ multisigtypes.PubKey = &LegacyAminoPubKey{} + _ gogoprotoany.UnpackInterfacesMessage = &LegacyAminoPubKey{} ) // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. @@ -149,7 +150,7 @@ func (m *LegacyAminoPubKey) Type() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range m.PubKeys { var pk cryptotypes.PubKey err := unpacker.UnpackAny(any, &pk) @@ -170,10 +171,10 @@ func packPubKeys(pubKeys []cryptotypes.PubKey) ([]*types.Any, error) { } anyPubKeys[i] = any - // sets the compat.aminoBz value - if err := anyPubKeys[i].UnmarshalAmino(pubKeys[i].Bytes()); err != nil { - return nil, err - } + // // sets the compat.aminoBz value + // if err := anyPubKeys[i].UnmarshalAmino(pubKeys[i].Bytes()); err != nil { + // return nil, err + // } } return anyPubKeys, nil } diff --git a/server/v2/cometbft/client/grpc/cmtservice/service.go b/server/v2/cometbft/client/grpc/cmtservice/service.go index 096889a5a2ae..1d0a0c42102e 100644 --- a/server/v2/cometbft/client/grpc/cmtservice/service.go +++ b/server/v2/cometbft/client/grpc/cmtservice/service.go @@ -8,6 +8,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" gogogrpc "github.com/cosmos/gogoproto/grpc" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -131,7 +132,7 @@ func (s queryServer) GetLatestValidatorSet( return ValidatorsOutput(ctx, s.client, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) diff --git a/testutil/testdata/animal.go b/testutil/testdata/animal.go index 7d5afa615280..327b8851e1ea 100644 --- a/testutil/testdata/animal.go +++ b/testutil/testdata/animal.go @@ -4,8 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" - - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type Animal interface { @@ -32,9 +31,9 @@ func (d Dog) Greet() string { return fmt.Sprintf("Roof, my name is %s", d.Name) } -var _ types.UnpackInterfacesMessage = HasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasAnimal{} -func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal Animal return unpacker.UnpackAny(m.Animal, &animal) } @@ -59,9 +58,9 @@ func (m HasHasAnimal) TheHasAnimal() HasAnimalI { return m.HasAnimal.GetCachedValue().(HasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasAnimal{} -func (m HasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasAnimalI return unpacker.UnpackAny(m.HasAnimal, &animal) } @@ -76,9 +75,9 @@ func (m HasHasHasAnimal) TheHasHasAnimal() HasHasAnimalI { return m.HasHasAnimal.GetCachedValue().(HasHasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasHasAnimal{} -func (m HasHasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasHasAnimalI return unpacker.UnpackAny(m.HasHasAnimal, &animal) } diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index 1078f60b8b81..d4ca6c73d888 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/gogoproto/types/any/test" "github.com/cosmos/gogoproto/proto" @@ -49,16 +50,16 @@ func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHe return &SayHelloResponse{Greeting: greeting}, nil } -var _ types.UnpackInterfacesMessage = &TestAnyRequest{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyRequest{} -func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyRequest) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal test.Animal return unpacker.UnpackAny(m.AnyAnimal, &animal) } -var _ types.UnpackInterfacesMessage = &TestAnyResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyResponse{} -func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return m.HasAnimal.UnpackInterfaces(unpacker) } diff --git a/types/result.go b/types/result.go index 148847eecf2b..02a18c59f6ce 100644 --- a/types/result.go +++ b/types/result.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) func (gi GasInfo) String() string { @@ -159,13 +160,13 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) { return res, err } -var _, _ codectypes.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} +var _, _ gogoprotoany.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces // // types.UnpackInterfaces needs to be called for each nested Tx because // there are generally interfaces to unpack in Tx's -func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s SearchTxsResult) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, tx := range s.Txs { err := codectypes.UnpackInterfaces(tx, unpacker) if err != nil { @@ -176,7 +177,7 @@ func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (r TxResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (r TxResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if r.Tx != nil { var tx HasMsgs return unpacker.UnpackAny(r.Tx, &tx) diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 52c9fc214a8e..92183b904c55 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -1,10 +1,10 @@ package tx import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // ValidateBasic performs stateless validation of the sign doc. @@ -21,7 +21,7 @@ func (s *SignDocDirectAux) ValidateBasic() error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (s *SignDocDirectAux) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s *SignDocDirectAux) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(s.PublicKey, new(cryptotypes.PubKey)) } @@ -60,6 +60,6 @@ func (a *AuxSignerData) GetSignatureV2() (signing.SignatureV2, error) { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (a *AuxSignerData) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (a *AuxSignerData) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return a.GetSignDoc().UnpackInterfaces(unpacker) } diff --git a/types/tx/ext.go b/types/tx/ext.go index fb2e1ed448bc..94038f65d849 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -2,13 +2,14 @@ package tx import ( "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // TxExtensionOptionI defines the interface for tx extension options type TxExtensionOptionI interface{} // unpackTxExtensionOptionsI unpacks Any's to TxExtensionOptionI's. -func unpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { +func unpackTxExtensionOptionsI(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var opt TxExtensionOptionI err := unpacker.UnpackAny(any, &opt) diff --git a/types/tx/msgs.go b/types/tx/msgs.go index 2f2f9a80f912..1e8476809f60 100644 --- a/types/tx/msgs.go +++ b/types/tx/msgs.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( @@ -53,7 +54,7 @@ func GetMsgs(anys []*types.Any, name string) ([]sdk.Msg, error) { } // UnpackInterfaces unpacks Any's to sdk.Msg's. -func UnpackInterfaces(unpacker types.AnyUnpacker, anys []*types.Any) error { +func UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var msg sdk.Msg err := unpacker.UnpackAny(any, &msg) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index a9549bab9a12..7860637b8415 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,8 +3,8 @@ package signing import ( "fmt" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // SignatureV2 is a convenience type that is easier to use in application logic @@ -86,10 +86,10 @@ func SignatureDataFromProto(descData *SignatureDescriptor_Data) SignatureData { } } -var _, _ codectypes.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} +var _, _ gogoprotoany.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sds *SignatureDescriptors) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, sig := range sds.Signatures { err := sig.UnpackInterfaces(unpacker) if err != nil { @@ -101,6 +101,6 @@ func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacke } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sd *SignatureDescriptor) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sd *SignatureDescriptor) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(sd.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx/types.go b/types/tx/types.go index c5a2e91ef37e..2917cd86b5ea 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -9,10 +9,10 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // MaxGasWanted defines the max gas allowed. @@ -20,7 +20,7 @@ const MaxGasWanted = uint64((1 << 63) - 1) // Interface implementation checks. var ( - _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} + _, _, _, _ gogoprotoany.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} ) // GetMsgs implements the GetMsgs method on sdk.Tx. @@ -177,7 +177,7 @@ func (t *Tx) FeeGranter(cdc codec.Codec) []byte { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (t *Tx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if t.Body != nil { if err := t.Body.UnpackInterfaces(unpacker); err != nil { return err @@ -192,7 +192,7 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *TxBody) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if err := UnpackInterfaces(unpacker, m.Messages); err != nil { return err } @@ -209,7 +209,7 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *AuthInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, signerInfo := range m.SignerInfos { err := signerInfo.UnpackInterfaces(unpacker) if err != nil { @@ -220,7 +220,7 @@ func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *SignerInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *SignerInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(m.PublicKey, new(cryptotypes.PubKey)) } diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index e8d00f67594c..2b8452520a3c 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // LegacyMsg defines the old interface a message must fulfill, @@ -129,7 +130,7 @@ func (ss StdSignature) MarshalYAML() (interface{}, error) { return string(bz), err } -func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (ss StdSignature) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return codectypes.UnpackInterfaces(ss.PubKey, unpacker) } diff --git a/x/auth/migrations/legacytx/stdsignmsg.go b/x/auth/migrations/legacytx/stdsignmsg.go index 561a64463f50..b4cb5242b228 100644 --- a/x/auth/migrations/legacytx/stdsignmsg.go +++ b/x/auth/migrations/legacytx/stdsignmsg.go @@ -3,9 +3,10 @@ package legacytx import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = StdSignMsg{} +var _ gogoprotoany.UnpackInterfacesMessage = StdSignMsg{} // StdSignMsg is a convenience structure for passing along a Msg with the other // requirements for a StdSignDoc before it is signed. For use in the CLI. @@ -19,7 +20,7 @@ type StdSignMsg struct { Memo string `json:"memo" yaml:"memo"` } -func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg StdSignMsg) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range msg.Msgs { err := types.UnpackInterfaces(m, unpacker) if err != nil { diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index dc5dba098860..aacece7e5ec6 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -9,13 +9,14 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Interface implementation checks var ( - _ codectypes.UnpackInterfacesMessage = (*StdTx)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdTx)(nil) - _ codectypes.UnpackInterfacesMessage = (*StdSignature)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdSignature)(nil) ) // StdFee includes the amount of coins paid in fees and the maximum @@ -169,7 +170,7 @@ func (tx StdTx) FeeGranter() sdk.AccAddress { return nil } -func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (tx StdTx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range tx.Msgs { err := codectypes.UnpackInterfaces(m, unpacker) if err != nil { diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 791803174b5c..4d889178ae29 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -11,14 +11,15 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( - _ sdk.AccountI = (*BaseAccount)(nil) - _ GenesisAccount = (*BaseAccount)(nil) - _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) - _ GenesisAccount = (*ModuleAccount)(nil) - _ sdk.ModuleAccountI = (*ModuleAccount)(nil) + _ sdk.AccountI = (*BaseAccount)(nil) + _ GenesisAccount = (*BaseAccount)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*BaseAccount)(nil) + _ GenesisAccount = (*ModuleAccount)(nil) + _ sdk.ModuleAccountI = (*ModuleAccount)(nil) ) // NewBaseAccount creates a new BaseAccount object. @@ -132,7 +133,7 @@ func (acc BaseAccount) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (acc BaseAccount) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if acc.PubKey == nil { return nil } diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index b31c686bc43f..d0b6db9dbefd 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -14,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // RandomGenesisAccountsFn defines the function required to generate custom account types type RandomGenesisAccountsFn func(simState *module.SimulationState) GenesisAccounts @@ -32,7 +33,7 @@ func NewGenesisState(params Params, accounts GenesisAccounts) *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range g.Accounts { var account GenesisAccount err := unpacker.UnpackAny(any, &account) diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 8ab9df38f9f0..67b708837047 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,13 +1,13 @@ package types import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *QueryAccountResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } -var _ codectypes.UnpackInterfacesMessage = &QueryAccountResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &QueryAccountResponse{} diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index 9dd8aced3791..4ea7ba1abf09 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -6,9 +6,8 @@ import ( "github.com/cosmos/gogoproto/proto" errorsmod "cosmossdk.io/errors" - - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGrant returns new Grant. Expiration is optional and noop if null. @@ -22,7 +21,7 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran if !ok { return Grant{}, sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", a) } - any, err := cdctypes.NewAnyWithValue(msg) + any, err := gogoprotoany.NewAnyWithCacheWithValue(msg) if err != nil { return Grant{}, err } @@ -32,10 +31,10 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran }, nil } -var _ cdctypes.UnpackInterfacesMessage = &Grant{} +var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (g Grant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var authorization Authorization return unpacker.UnpackAny(g.Authorization, &authorization) } diff --git a/x/authz/genesis.go b/x/authz/genesis.go index 2e7dde1b7260..f2afc47cad91 100644 --- a/x/authz/genesis.go +++ b/x/authz/genesis.go @@ -3,7 +3,7 @@ package authz import ( "fmt" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates new GenesisState object @@ -32,10 +32,10 @@ func DefaultGenesisState() *GenesisState { return &GenesisState{} } -var _ cdctypes.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, a := range data.Authorization { err := a.UnpackInterfaces(unpacker) if err != nil { @@ -46,7 +46,7 @@ func (data GenesisState) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg GrantAuthorization) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg GrantAuthorization) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var a Authorization return unpacker.UnpackAny(msg.Authorization, &a) } diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 0964f45cb34b..b7c7c6c9cd30 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -4,6 +4,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +16,8 @@ var ( _ sdk.Msg = &MsgRevoke{} _ sdk.Msg = &MsgExec{} - _ cdctypes.UnpackInterfacesMessage = &MsgGrant{} - _ cdctypes.UnpackInterfacesMessage = &MsgExec{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgGrant{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgExec{} ) // NewMsgGrant creates a new MsgGrant @@ -44,7 +45,7 @@ func (msg *MsgGrant) SetAuthorization(a Authorization) error { if !ok { return sdkerrors.ErrPackAny.Wrapf("can't proto marshal %T", m) } - any, err := cdctypes.NewAnyWithValue(m) + any, err := gogoprotoany.NewAnyWithCacheWithValue(m) if err != nil { return err } @@ -53,7 +54,7 @@ func (msg *MsgGrant) SetAuthorization(a Authorization) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgExec) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg MsgExec) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range msg.Msgs { var msgExecAuthorized sdk.Msg err := unpacker.UnpackAny(x, &msgExecAuthorized) @@ -66,7 +67,7 @@ func (msg MsgExec) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg MsgGrant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return msg.Grant.UnpackInterfaces(unpacker) } diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index ec62f5196b2f..7b3fcb38467e 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/keeper" banktype "cosmossdk.io/x/bank/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -260,7 +261,7 @@ func SimulateMsgExec( ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, - unpacker cdctypes.AnyUnpacker, + unpacker gogoprotoany.AnyUnpacker, ) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, diff --git a/x/evidence/types/genesis.go b/x/evidence/types/genesis.go index d9ccaefbe729..ea64940f0f4d 100644 --- a/x/evidence/types/genesis.go +++ b/x/evidence/types/genesis.go @@ -8,9 +8,11 @@ import ( "cosmossdk.io/x/evidence/exported" "github.com/cosmos/cosmos-sdk/codec/types" + + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // NewGenesisState creates a new genesis state for the evidence module. func NewGenesisState(e []exported.Evidence) *GenesisState { @@ -55,7 +57,7 @@ func (gs GenesisState) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (gs GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (gs GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range gs.Evidence { var evi exported.Evidence err := unpacker.UnpackAny(any, &evi) diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 20b5967ac2eb..829050108b49 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/x/evidence/exported" "cosmossdk.io/x/evidence/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -130,7 +131,7 @@ func TestUnpackInterfaces(t *testing.T) { testCases := []struct { msg string - unpacker codectypes.AnyUnpacker + unpacker gogoprotoany.AnyUnpacker expPass bool }{ { diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 92df414692a5..03e70b5ab7df 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/x/evidence/exported" @@ -12,9 +13,9 @@ import ( ) var ( - _ sdk.Msg = &MsgSubmitEvidence{} - _ types.UnpackInterfacesMessage = MsgSubmitEvidence{} - _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} + _ sdk.Msg = &MsgSubmitEvidence{} + _ gogoprotoany.UnpackInterfacesMessage = MsgSubmitEvidence{} + _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. @@ -51,7 +52,7 @@ func (m MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return accAddr } -func (m MsgSubmitEvidence) UnpackInterfaces(ctx types.AnyUnpacker) error { +func (m MsgSubmitEvidence) UnpackInterfaces(ctx gogoprotoany.AnyUnpacker) error { var evi exported.Evidence return ctx.UnpackAny(m.Evidence, &evi) } diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 6e001ef947e9..a6c0d537a3f6 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -6,6 +6,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" @@ -23,12 +24,12 @@ const ( ) var ( - _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) - _ types.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) + _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) ) // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index 83b29baeb85d..71ddf943a3e3 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -1,10 +1,10 @@ package feegrant import ( - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // NewGenesisState creates new GenesisState object func NewGenesisState(entries []Grant) *GenesisState { @@ -34,7 +34,7 @@ func DefaultGenesisState() *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, f := range data.Allowances { err := f.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/feegrant/grant.go b/x/feegrant/grant.go index 0fb85dd5a226..2be36fa526a6 100644 --- a/x/feegrant/grant.go +++ b/x/feegrant/grant.go @@ -7,9 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = &Grant{} +var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} // NewGrant creates a new FeeAllowanceGrant. func NewGrant(granter, grantee string, feeAllowance FeeAllowanceI) (Grant, error) { @@ -62,7 +63,7 @@ func (a Grant) GetGrant() (FeeAllowanceI, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a Grant) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (a Grant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } diff --git a/x/feegrant/msgs.go b/x/feegrant/msgs.go index c049c73d4f3f..e79c5ce39ab9 100644 --- a/x/feegrant/msgs.go +++ b/x/feegrant/msgs.go @@ -2,6 +2,7 @@ package feegrant import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" @@ -11,8 +12,8 @@ import ( ) var ( - _, _ sdk.Msg = &MsgGrantAllowance{}, &MsgRevokeAllowance{} - _ types.UnpackInterfacesMessage = &MsgGrantAllowance{} + _, _ sdk.Msg = &MsgGrantAllowance{}, &MsgRevokeAllowance{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgGrantAllowance{} ) // NewMsgGrantAllowance creates a new MsgGrantAllowance. @@ -44,7 +45,7 @@ func (msg MsgGrantAllowance) GetFeeAllowanceI() (FeeAllowanceI, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg MsgGrantAllowance) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(msg.Allowance, &allowance) } diff --git a/x/gov/types/v1/genesis.go b/x/gov/types/v1/genesis.go index 21721e4b024e..e4a8ae280509 100644 --- a/x/gov/types/v1/genesis.go +++ b/x/gov/types/v1/genesis.go @@ -4,11 +4,10 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "golang.org/x/sync/errgroup" "cosmossdk.io/core/address" - - "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new genesis state for the governance module @@ -107,10 +106,10 @@ func ValidateGenesis(ac address.Codec, data *GenesisState) error { return errGroup.Wait() } -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, p := range data.Proposals { err := p.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index d25a9ed33aad..d061b6bddbd0 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -5,6 +5,7 @@ import ( "fmt" "cosmossdk.io/x/gov/types/v1beta1" + gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -12,8 +13,8 @@ import ( ) var ( - _, _, _, _, _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}, &MsgExecLegacyContent{}, &MsgUpdateParams{}, &MsgCancelProposal{}, &MsgSubmitMultipleChoiceProposal{} - _, _ codectypes.UnpackInterfacesMessage = &MsgSubmitProposal{}, &MsgExecLegacyContent{} + _, _, _, _, _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}, &MsgExecLegacyContent{}, &MsgUpdateParams{}, &MsgCancelProposal{}, &MsgSubmitMultipleChoiceProposal{} + _, _ gogoprotoany.UnpackInterfacesMessage = &MsgSubmitProposal{}, &MsgExecLegacyContent{} ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. @@ -60,7 +61,7 @@ func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, m.Messages) } @@ -120,7 +121,7 @@ func (c MsgExecLegacyContent) ValidateBasic() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (c MsgExecLegacyContent) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (c MsgExecLegacyContent) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content v1beta1.Content return unpacker.UnpackAny(c.Content, &content) } diff --git a/x/gov/types/v1/proposal.go b/x/gov/types/v1/proposal.go index be5931c217ae..e9a901934c58 100644 --- a/x/gov/types/v1/proposal.go +++ b/x/gov/types/v1/proposal.go @@ -5,7 +5,8 @@ import ( "strings" "time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" sdktx "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -74,14 +75,14 @@ func (p Proposal) GetMinDepositFromParams(params Params) sdk.Coins { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, p.Messages) } // Proposals is an array of proposal type Proposals []*Proposal -var _ codectypes.UnpackInterfacesMessage = Proposals{} +var _ gogoprotoany.UnpackInterfacesMessage = Proposals{} // String implements stringer interface func (p Proposals) String() string { @@ -94,7 +95,7 @@ func (p Proposals) String() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposals) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposals) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range p { err := x.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1beta1/genesis.go b/x/gov/types/v1beta1/genesis.go index d71c008d8860..987a47cacf88 100644 --- a/x/gov/types/v1beta1/genesis.go +++ b/x/gov/types/v1beta1/genesis.go @@ -4,8 +4,7 @@ import ( "fmt" "cosmossdk.io/math" - - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates a new genesis state for the governance module @@ -66,10 +65,10 @@ func ValidateGenesis(data *GenesisState) error { return nil } -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, p := range data.Proposals { err := p.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index 298f26c592eb..984bed150093 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,7 +21,7 @@ const ( var ( _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{} - _ codectypes.UnpackInterfacesMessage = &MsgSubmitProposal{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgSubmitProposal{} ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. @@ -73,7 +74,7 @@ func (m *MsgSubmitProposal) SetContent(content Content) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content Content return unpacker.UnpackAny(m.Content, &content) } diff --git a/x/gov/types/v1beta1/proposal.go b/x/gov/types/v1beta1/proposal.go index b29753edb33b..814301406861 100644 --- a/x/gov/types/v1beta1/proposal.go +++ b/x/gov/types/v1beta1/proposal.go @@ -7,6 +7,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/gov/types" @@ -81,7 +82,7 @@ func (p Proposal) GetTitle() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content Content return unpacker.UnpackAny(p.Content, &content) } @@ -89,7 +90,7 @@ func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // Proposals is an array of proposal type Proposals []Proposal -var _ codectypes.UnpackInterfacesMessage = Proposals{} +var _ gogoprotoany.UnpackInterfacesMessage = Proposals{} // Equal returns true if two slices (order-dependant) of proposals are equal. func (p Proposals) Equal(other Proposals) bool { @@ -118,7 +119,7 @@ func (p Proposals) String() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposals) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposals) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range p { err := x.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/group/genesis.go b/x/group/genesis.go index eccf1f941e05..87df3bf52acc 100644 --- a/x/group/genesis.go +++ b/x/group/genesis.go @@ -5,8 +5,8 @@ import ( errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates a new genesis state with default values. @@ -83,7 +83,7 @@ func (s GenesisState) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (s GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (s GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, g := range s.GroupPolicies { err := g.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/group/msgs.go b/x/group/msgs.go index d9aad25d63b3..a9e36c207f48 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -2,6 +2,7 @@ package group import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,9 +28,9 @@ var ( _ sdk.Msg = &MsgSubmitProposal{} _ sdk.Msg = &MsgCreateGroupPolicy{} - _ types.UnpackInterfacesMessage = MsgCreateGroupPolicy{} - _ types.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} - _ types.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgCreateGroupPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} ) // GetGroupID gets the group id of the MsgUpdateGroupMetadata. @@ -83,7 +84,7 @@ func (m *MsgCreateGroupWithPolicy) SetDecisionPolicy(decisionPolicy DecisionPoli } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -126,7 +127,7 @@ func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() (DecisionPolicy } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -180,7 +181,7 @@ func (m *MsgCreateGroupPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -218,6 +219,6 @@ func (m MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, m.Messages) } diff --git a/x/group/proposal.go b/x/group/proposal.go index a47ee5115c3b..815d81d8ec98 100644 --- a/x/group/proposal.go +++ b/x/group/proposal.go @@ -1,9 +1,9 @@ package group import ( - "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // GetMsgs unpacks p.Messages Any's into sdk.Msg's @@ -22,6 +22,6 @@ func (p *Proposal) SetMsgs(msgs []sdk.Msg) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, p.Messages) } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 2a90842681dc..e9e33a4a1c05 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -20,6 +20,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const unsetGroupID = 100000000000000 @@ -104,7 +105,7 @@ func WeightedOperations( registry cdctypes.InterfaceRegistry, appParams simtypes.AppParams, cdc codec.JSONCodec, txGen client.TxConfig, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper, - appCdc cdctypes.AnyUnpacker, + appCdc gogoprotoany.AnyUnpacker, ) simulation.WeightedOperations { var ( weightMsgCreateGroup int diff --git a/x/group/types.go b/x/group/types.go index 4a8b2cd7d564..e8328a6e6470 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/x/group/errors" "cosmossdk.io/x/group/internal/math" "cosmossdk.io/x/group/internal/orm" + gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -286,7 +287,7 @@ func (g GroupPolicyInfo) GetDecisionPolicy() (DecisionPolicy, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GroupPolicyInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (g GroupPolicyInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(g.DecisionPolicy, &decisionPolicy) } @@ -458,16 +459,16 @@ func (v Vote) ValidateBasic() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (q QueryGroupPoliciesByGroupResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (q QueryGroupPoliciesByGroupResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpackGroupPolicies(unpacker, q.GroupPolicies) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (q QueryGroupPoliciesByAdminResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (q QueryGroupPoliciesByAdminResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpackGroupPolicies(unpacker, q.GroupPolicies) } -func unpackGroupPolicies(unpacker codectypes.AnyUnpacker, accs []*GroupPolicyInfo) error { +func unpackGroupPolicies(unpacker gogoprotoany.AnyUnpacker, accs []*GroupPolicyInfo) error { for _, g := range accs { err := g.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index e144661afe55..673d251caa23 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates a new GenesisState instance @@ -36,7 +36,7 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range g.Validators { if err := g.Validators[i].UnpackInterfaces(c); err != nil { return err diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 3effad961f14..5c70ceb4c353 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -5,6 +5,7 @@ import ( coretransaction "cosmossdk.io/core/transaction" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" + gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -13,14 +14,14 @@ import ( ) var ( - _ coretransaction.Msg = &MsgCreateValidator{} - _ codectypes.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) - _ coretransaction.Msg = &MsgEditValidator{} - _ coretransaction.Msg = &MsgDelegate{} - _ coretransaction.Msg = &MsgUndelegate{} - _ coretransaction.Msg = &MsgBeginRedelegate{} - _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} - _ coretransaction.Msg = &MsgUpdateParams{} + _ coretransaction.Msg = &MsgCreateValidator{} + _ gogoprotoany.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) + _ coretransaction.Msg = &MsgEditValidator{} + _ coretransaction.Msg = &MsgDelegate{} + _ coretransaction.Msg = &MsgUndelegate{} + _ coretransaction.Msg = &MsgBeginRedelegate{} + _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} + _ coretransaction.Msg = &MsgUpdateParams{} ) // NewMsgCreateValidator creates a new MsgCreateValidator instance. @@ -89,7 +90,7 @@ func (msg MsgCreateValidator) Validate(ac address.Codec) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgCreateValidator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.Pubkey, &pubKey) } @@ -160,13 +161,13 @@ func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRota } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.NewPubkey, &pubKey) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var oldPubKey cryptotypes.PubKey err := unpacker.UnpackAny(hi.OldConsPubkey, &oldPubKey) if err != nil { diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 9906bc2b8009..fc169e357d23 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -17,6 +17,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( @@ -138,7 +139,7 @@ func (valz ValidatorsByVotingPower) Swap(i, j int) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validators) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (v Validators) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range v.Validators { if err := v.Validators[i].UnpackInterfaces(c); err != nil { return err @@ -494,7 +495,7 @@ func (v Validator) GetMinSelfDelegation() math.Int { return v.MinSelfDelegat func (v Validator) GetDelegatorShares() math.LegacyDec { return v.DelegatorShares } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (v Validator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey return unpacker.UnpackAny(v.ConsensusPubkey, &pk) } From 5481b8199b4095652d41c941078c0388563646ea Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 22 Jul 2024 09:44:18 +0200 Subject: [PATCH 5/8] remove previous fix --- crypto/keys/multisig/multisig.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 3bf0cbe27409..c088ac2fd779 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -170,11 +170,6 @@ func packPubKeys(pubKeys []cryptotypes.PubKey) ([]*types.Any, error) { return nil, err } anyPubKeys[i] = any - - // // sets the compat.aminoBz value - // if err := anyPubKeys[i].UnmarshalAmino(pubKeys[i].Bytes()); err != nil { - // return nil, err - // } } return anyPubKeys, nil } From 62e896333b4b819d390b859ac326958ab1ad55af Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 22 Jul 2024 10:04:18 +0200 Subject: [PATCH 6/8] upgrading md --- UPGRADING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/UPGRADING.md b/UPGRADING.md index 64f8b56780d9..37d701b2e496 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -170,7 +170,9 @@ There is no longer a need for the Cosmos SDK to host these protos for itself and That package containing proto v2 generated code, but the SDK now uses [buf generated go SDK instead](https://buf.build/docs/bsr/generated-sdks/go). If you were depending on `cosmossdk.io/api/tendermint`, please use the buf generated go SDK instead, or ask CometBFT host the generated proto v2 code. -The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers can update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK. +The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers need to update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional, but recommended, as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK. + +Also, any usages of the interfaces `AnyUnpacker` and `UnpackInterfacesMessage` must be replaced with the interfaces of the same name in the `github.com/cosmos/gogoproto/types/any` package. ### Modules From eec42bac0e0f74bc5852527d9beb204cb272508b Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 22 Jul 2024 10:14:08 +0200 Subject: [PATCH 7/8] linf fix --- codec/codec.go | 2 +- crypto/keyring/legacy_info.go | 3 ++- crypto/keyring/record.go | 3 ++- crypto/keys/multisig/multisig.go | 2 +- types/result.go | 2 +- types/tx/direct_aux.go | 3 ++- types/tx/ext.go | 3 ++- types/tx/msgs.go | 3 ++- types/tx/signing/signature.go | 3 ++- types/tx/types.go | 2 +- x/auth/migrations/legacytx/stdsign.go | 2 +- x/auth/migrations/legacytx/stdsignmsg.go | 3 ++- x/auth/migrations/legacytx/stdtx.go | 3 ++- x/auth/types/account.go | 3 ++- x/auth/types/query.go | 3 ++- x/authz/authorization_grant.go | 3 ++- x/authz/simulation/operations.go | 3 ++- x/evidence/types/genesis.go | 3 +-- x/evidence/types/genesis_test.go | 2 +- x/feegrant/grant.go | 2 +- x/gov/types/v1/msgs.go | 3 ++- x/gov/types/v1beta1/genesis.go | 3 ++- x/group/genesis.go | 3 ++- x/group/proposal.go | 3 ++- x/group/simulation/operations.go | 3 ++- x/group/types.go | 2 +- x/staking/types/genesis.go | 3 ++- x/staking/types/msg.go | 3 ++- x/staking/types/validator.go | 3 ++- 29 files changed, 49 insertions(+), 30 deletions(-) diff --git a/codec/codec.go b/codec/codec.go index 7f8060f88a8e..3d9cfd771bc0 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -2,11 +2,11 @@ package codec import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/grpc/encoding" "google.golang.org/protobuf/reflect/protoreflect" "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type ( diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index ca615809324a..48e5d664f11f 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -4,13 +4,14 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Deprecated: LegacyInfo is the publicly exposed information about a keypair diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index fb7ddeee06a7..2e19c5b91576 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -3,13 +3,14 @@ package keyring import ( "errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index c088ac2fd779..1fc3f8e28098 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -4,12 +4,12 @@ import ( "fmt" cmtcrypto "github.com/cometbft/cometbft/crypto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" multisigtypes "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( diff --git a/types/result.go b/types/result.go index 02a18c59f6ce..b4724151e9da 100644 --- a/types/result.go +++ b/types/result.go @@ -7,10 +7,10 @@ import ( cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) func (gi GasInfo) String() string { diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 92183b904c55..d685a837ad29 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -1,10 +1,11 @@ package tx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // ValidateBasic performs stateless validation of the sign doc. diff --git a/types/tx/ext.go b/types/tx/ext.go index 94038f65d849..e51be337d5b1 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -1,8 +1,9 @@ package tx import ( - "github.com/cosmos/cosmos-sdk/codec/types" gogoprotoany "github.com/cosmos/gogoproto/types/any" + + "github.com/cosmos/cosmos-sdk/codec/types" ) // TxExtensionOptionI defines the interface for tx extension options diff --git a/types/tx/msgs.go b/types/tx/msgs.go index 1e8476809f60..036f9a2414c8 100644 --- a/types/tx/msgs.go +++ b/types/tx/msgs.go @@ -3,9 +3,10 @@ package tx import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index 7860637b8415..a27ea27b86eb 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,8 +3,9 @@ package signing import ( "fmt" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" gogoprotoany "github.com/cosmos/gogoproto/types/any" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) // SignatureV2 is a convenience type that is easier to use in application logic diff --git a/types/tx/types.go b/types/tx/types.go index 2917cd86b5ea..cc64047393cf 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -3,6 +3,7 @@ package tx import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protoreflect" "cosmossdk.io/core/registry" @@ -12,7 +13,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // MaxGasWanted defines the max gas allowed. diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index 2b8452520a3c..04e131768ac2 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "sigs.k8s.io/yaml" "cosmossdk.io/errors" @@ -15,7 +16,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // LegacyMsg defines the old interface a message must fulfill, diff --git a/x/auth/migrations/legacytx/stdsignmsg.go b/x/auth/migrations/legacytx/stdsignmsg.go index b4cb5242b228..1fd8c585015f 100644 --- a/x/auth/migrations/legacytx/stdsignmsg.go +++ b/x/auth/migrations/legacytx/stdsignmsg.go @@ -1,9 +1,10 @@ package legacytx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var _ gogoprotoany.UnpackInterfacesMessage = StdSignMsg{} diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index aacece7e5ec6..5e67518716d5 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -1,6 +1,8 @@ package legacytx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -9,7 +11,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // Interface implementation checks diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 4d889178ae29..f2147d75bd54 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,11 +7,12 @@ import ( "fmt" "strings" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var ( diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 67b708837047..96b089e18a74 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,8 +1,9 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" gogoprotoany "github.com/cosmos/gogoproto/types/any" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func (m *QueryAccountResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index 4ea7ba1abf09..c054eb081403 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -4,10 +4,11 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGrant returns new Grant. Expiration is optional and noop if null. diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 7b3fcb38467e..374a451cfc23 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -5,6 +5,8 @@ import ( "math/rand" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" @@ -13,7 +15,6 @@ import ( "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/keeper" banktype "cosmossdk.io/x/bank/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" diff --git a/x/evidence/types/genesis.go b/x/evidence/types/genesis.go index ea64940f0f4d..e5c683831663 100644 --- a/x/evidence/types/genesis.go +++ b/x/evidence/types/genesis.go @@ -4,12 +4,11 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/x/evidence/exported" "github.com/cosmos/cosmos-sdk/codec/types" - - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 829050108b49..786b2103f762 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -5,11 +5,11 @@ import ( "testing" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/stretchr/testify/require" "cosmossdk.io/x/evidence/exported" "cosmossdk.io/x/evidence/types" - gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/feegrant/grant.go b/x/feegrant/grant.go index 2be36fa526a6..a483475c6b41 100644 --- a/x/feegrant/grant.go +++ b/x/feegrant/grant.go @@ -2,12 +2,12 @@ package feegrant import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index d061b6bddbd0..70b4b90c5c73 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -4,9 +4,10 @@ import ( "errors" "fmt" - "cosmossdk.io/x/gov/types/v1beta1" gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/x/gov/types/v1beta1" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdktx "github.com/cosmos/cosmos-sdk/types/tx" diff --git a/x/gov/types/v1beta1/genesis.go b/x/gov/types/v1beta1/genesis.go index 987a47cacf88..d2c288574db6 100644 --- a/x/gov/types/v1beta1/genesis.go +++ b/x/gov/types/v1beta1/genesis.go @@ -3,8 +3,9 @@ package v1beta1 import ( "fmt" - "cosmossdk.io/math" gogoprotoany "github.com/cosmos/gogoproto/types/any" + + "cosmossdk.io/math" ) // NewGenesisState creates a new genesis state for the governance module diff --git a/x/group/genesis.go b/x/group/genesis.go index 87df3bf52acc..2a7e073890ba 100644 --- a/x/group/genesis.go +++ b/x/group/genesis.go @@ -3,10 +3,11 @@ package group import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates a new genesis state with default values. diff --git a/x/group/proposal.go b/x/group/proposal.go index 815d81d8ec98..642e8981a487 100644 --- a/x/group/proposal.go +++ b/x/group/proposal.go @@ -1,9 +1,10 @@ package group import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // GetMsgs unpacks p.Messages Any's into sdk.Msg's diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index e9e33a4a1c05..d0eb1b8f7989 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -8,6 +8,8 @@ import ( "sync/atomic" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/x/group" "cosmossdk.io/x/group/keeper" @@ -20,7 +22,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const unsetGroupID = 100000000000000 diff --git a/x/group/types.go b/x/group/types.go index e8328a6e6470..d91d4fd89704 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -5,13 +5,13 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/core/address" errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/group/errors" "cosmossdk.io/x/group/internal/math" "cosmossdk.io/x/group/internal/orm" - gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index 673d251caa23..e3534fc4ea58 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -3,8 +3,9 @@ package types import ( "encoding/json" - "github.com/cosmos/cosmos-sdk/codec" gogoprotoany "github.com/cosmos/gogoproto/types/any" + + "github.com/cosmos/cosmos-sdk/codec" ) // NewGenesisState creates a new GenesisState instance diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 5c70ceb4c353..782183ff0684 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -1,11 +1,12 @@ package types import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" coretransaction "cosmossdk.io/core/transaction" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index fc169e357d23..c2e442d4c55a 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -7,6 +7,8 @@ import ( "strings" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/errors" @@ -17,7 +19,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - gogoprotoany "github.com/cosmos/gogoproto/types/any" ) const ( From 6c3261a55f7d84ee8b299dc81bc3c1b258dbfdb5 Mon Sep 17 00:00:00 2001 From: Facundo Date: Mon, 22 Jul 2024 10:44:50 +0200 Subject: [PATCH 8/8] fix v --- server/v2/cometbft/client/grpc/cmtservice/service.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/v2/cometbft/client/grpc/cmtservice/service.go b/server/v2/cometbft/client/grpc/cmtservice/service.go index 1d0a0c42102e..05f65d4657be 100644 --- a/server/v2/cometbft/client/grpc/cmtservice/service.go +++ b/server/v2/cometbft/client/grpc/cmtservice/service.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "cosmossdk.io/server/v2/cometbft/client/rpc" abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" gogogrpc "github.com/cosmos/gogoproto/grpc" @@ -13,8 +14,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "cosmossdk.io/server/v2/cometbft/client/rpc" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -24,8 +23,8 @@ import ( ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) type (