fix(x/auth): properly populate tx config options and deprecate ProtoCodecMarshaler (backport #17946) (#17952)
This commit is contained in:
+8
-4
@@ -22,7 +22,7 @@ type config struct {
|
||||
encoder sdk.TxEncoder
|
||||
jsonDecoder sdk.TxDecoder
|
||||
jsonEncoder sdk.TxEncoder
|
||||
protoCodec codec.ProtoCodecMarshaler
|
||||
protoCodec codec.Codec
|
||||
signingContext *txsigning.Context
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ var DefaultSignModes = []signingtypes.SignMode{
|
||||
// We prefer to use depinject to provide client.TxConfig, but we permit this constructor usage. Within the SDK,
|
||||
// this constructor is primarily used in tests, but also sees usage in app chains like:
|
||||
// https://github.com/evmos/evmos/blob/719363fbb92ff3ea9649694bd088e4c6fe9c195f/encoding/config.go#L37
|
||||
func NewTxConfig(protoCodec codec.ProtoCodecMarshaler, enabledSignModes []signingtypes.SignMode,
|
||||
func NewTxConfig(protoCodec codec.Codec, enabledSignModes []signingtypes.SignMode,
|
||||
customSignModes ...txsigning.SignModeHandler,
|
||||
) client.TxConfig {
|
||||
txConfig, err := NewTxConfigWithOptions(protoCodec, ConfigOptions{
|
||||
@@ -165,9 +165,13 @@ func NewSigningHandlerMap(configOptions ConfigOptions) (*txsigning.HandlerMap, e
|
||||
|
||||
// NewTxConfigWithOptions returns a new protobuf TxConfig using the provided ProtoCodec, ConfigOptions and
|
||||
// custom sign mode handlers. If ConfigOptions is an empty struct then default values will be used.
|
||||
func NewTxConfigWithOptions(protoCodec codec.ProtoCodecMarshaler, configOptions ConfigOptions) (client.TxConfig, error) {
|
||||
func NewTxConfigWithOptions(protoCodec codec.Codec, configOptions ConfigOptions) (client.TxConfig, error) {
|
||||
txConfig := &config{
|
||||
protoCodec: protoCodec,
|
||||
protoCodec: protoCodec,
|
||||
decoder: configOptions.ProtoDecoder,
|
||||
encoder: configOptions.ProtoEncoder,
|
||||
jsonDecoder: configOptions.JSONDecoder,
|
||||
jsonEncoder: configOptions.JSONEncoder,
|
||||
}
|
||||
if configOptions.ProtoDecoder == nil {
|
||||
txConfig.decoder = DefaultTxDecoder(protoCodec)
|
||||
|
||||
@@ -43,7 +43,7 @@ type ModuleInputs struct {
|
||||
Config *txconfigv1.Config
|
||||
AddressCodec address.Codec
|
||||
ValidatorAddressCodec runtime.ValidatorAddressCodec
|
||||
ProtoCodecMarshaler codec.ProtoCodecMarshaler
|
||||
Codec codec.Codec
|
||||
ProtoFileResolver txsigning.ProtoFileResolver
|
||||
// BankKeeper is the expected bank keeper to be passed to AnteHandlers
|
||||
BankKeeper authtypes.BankKeeper `optional:"true"`
|
||||
@@ -87,7 +87,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
txConfigOptions.TextualCoinMetadataQueryFn = NewBankKeeperCoinMetadataQueryFn(in.MetadataBankKeeper)
|
||||
}
|
||||
|
||||
txConfig, err := tx.NewTxConfigWithOptions(in.ProtoCodecMarshaler, txConfigOptions)
|
||||
txConfig, err := tx.NewTxConfigWithOptions(in.Codec, txConfigOptions)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
// DefaultTxDecoder returns a default protobuf TxDecoder using the provided Marshaler.
|
||||
func DefaultTxDecoder(cdc codec.ProtoCodecMarshaler) sdk.TxDecoder {
|
||||
func DefaultTxDecoder(cdc codec.Codec) sdk.TxDecoder {
|
||||
return func(txBytes []byte) (sdk.Tx, error) {
|
||||
// Make sure txBytes follow ADR-027.
|
||||
err := rejectNonADR027TxRaw(txBytes)
|
||||
@@ -79,7 +79,7 @@ func DefaultTxDecoder(cdc codec.ProtoCodecMarshaler) sdk.TxDecoder {
|
||||
}
|
||||
|
||||
// DefaultJSONTxDecoder returns a default protobuf JSON TxDecoder using the provided Marshaler.
|
||||
func DefaultJSONTxDecoder(cdc codec.ProtoCodecMarshaler) sdk.TxDecoder {
|
||||
func DefaultJSONTxDecoder(cdc codec.Codec) sdk.TxDecoder {
|
||||
return func(txBytes []byte) (sdk.Tx, error) {
|
||||
var theTx tx.Tx
|
||||
err := cdc.UnmarshalJSON(txBytes, &theTx)
|
||||
|
||||
@@ -29,7 +29,7 @@ func DefaultTxEncoder() sdk.TxEncoder {
|
||||
}
|
||||
|
||||
// DefaultJSONTxEncoder returns a default protobuf JSON TxEncoder using the provided Marshaler.
|
||||
func DefaultJSONTxEncoder(cdc codec.ProtoCodecMarshaler) sdk.TxEncoder {
|
||||
func DefaultJSONTxEncoder(cdc codec.Codec) sdk.TxEncoder {
|
||||
return func(tx sdk.Tx) ([]byte, error) {
|
||||
txWrapper, ok := tx.(*wrapper)
|
||||
if ok {
|
||||
|
||||
Reference in New Issue
Block a user