Skip to content

Commit

Permalink
Merge branch 'main' into alex/sims2_v2_dev_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 authored Jan 10, 2025
2 parents 71c45a7 + a6b0924 commit c29ec4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
27 changes: 8 additions & 19 deletions x/auth/tx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,15 @@ func NewTxConfigWithOptions(protoCodec codec.Codec, configOptions ConfigOptions)
}
}

txConfig.txDecoder, err = txdecode.NewDecoder(txdecode.Options{
SigningContext: configOptions.SigningContext,
ProtoCodec: protoCodec,
})
if err != nil {
return nil, err
}
if configOptions.ProtoDecoder == nil {
dec, err := txdecode.NewDecoder(txdecode.Options{
SigningContext: configOptions.SigningContext,
ProtoCodec: protoCodec,
})
if err != nil {
return nil, err
}
txConfig.decoder = txV2toInterface(configOptions.SigningOptions.AddressCodec, protoCodec, dec)
txConfig.txDecoder = dec
txConfig.decoder = DefaultTxDecoder(configOptions.SigningOptions.AddressCodec, protoCodec, txConfig.txDecoder)
}
if configOptions.ProtoEncoder == nil {
txConfig.encoder = DefaultTxEncoder()
Expand Down Expand Up @@ -262,13 +261,3 @@ func (g config) TxJSONDecoder() sdk.TxDecoder {
func (g config) SigningContext() *txsigning.Context {
return g.signingContext
}

func txV2toInterface(addrCodec address.Codec, cdc codec.BinaryCodec, decoder *txdecode.Decoder) func([]byte) (sdk.Tx, error) {
return func(txBytes []byte) (sdk.Tx, error) {
decodedTx, err := decoder.Decode(txBytes)
if err != nil {
return nil, err
}
return newWrapperFromDecodedTx(addrCodec, cdc, decodedTx)
}
}
11 changes: 11 additions & 0 deletions x/auth/tx/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx"
)

// DefaultTxDecoder returns a default protobuf TxDecoder.
func DefaultTxDecoder(addrCodec address.Codec, cdc codec.BinaryCodec, decoder *decode.Decoder) func([]byte) (sdk.Tx, error) {
return func(txBytes []byte) (sdk.Tx, error) {
decodedTx, err := decoder.Decode(txBytes)
if err != nil {
return nil, err
}
return newWrapperFromDecodedTx(addrCodec, cdc, decodedTx)
}
}

// DefaultJSONTxDecoder returns a default protobuf JSON TxDecoder using the provided Marshaler.
func DefaultJSONTxDecoder(addrCodec address.Codec, cdc codec.Codec, decoder *decode.Decoder) sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, error) {
Expand Down

0 comments on commit c29ec4d

Please sign in to comment.