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
@@ -7,6 +7,7 @@ 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"
@@ -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)
+4 -3
View File
@@ -1,7 +1,8 @@
package tx
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
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"
@@ -21,7 +22,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 +61,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)
}
+3 -1
View File
@@ -1,6 +1,8 @@
package tx
import (
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"github.com/cosmos/cosmos-sdk/codec/types"
)
@@ -8,7 +10,7 @@ import (
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)
+3 -1
View File
@@ -3,6 +3,8 @@ 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"
)
@@ -53,7 +55,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)
+5 -4
View File
@@ -3,7 +3,8 @@ package signing
import (
"fmt"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)
@@ -86,10 +87,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 +102,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))
}
+6 -6
View File
@@ -3,13 +3,13 @@ package tx
import (
"errors"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"google.golang.org/protobuf/reflect/protoreflect"
"cosmossdk.io/core/registry"
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"
@@ -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))
}