chore(all)!: use gogoproto/any instead of codec/types/any (#21013)

This commit is contained in:
Facundo Medica
2024-07-22 11:23:51 +00:00
committed by GitHub
parent 71d14f9370
commit 9ab162de6d
48 changed files with 222 additions and 191 deletions
+4 -3
View File
@@ -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)
+23
View File
@@ -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)
}