fix(x/auth): properly populate tx config options and deprecate ProtoCodecMarshaler (backport #17946) (#17952)

This commit is contained in:
mergify[bot]
2023-10-04 23:49:07 +02:00
committed by GitHub
parent 31e603ac8d
commit 3da9f9c9ec
10 changed files with 31 additions and 23 deletions
+8 -3
View File
@@ -289,10 +289,10 @@ func (f Factory) WithExtensionOptions(extOpts ...*codectypes.Any) Factory {
func (f Factory) BuildUnsignedTx(msgs ...sdk.Msg) (client.TxBuilder, error) {
if f.offline && f.generateOnly {
if f.chainID != "" {
return nil, fmt.Errorf("chain ID cannot be used when offline and generate-only flags are set")
return nil, errors.New("chain ID cannot be used when offline and generate-only flags are set")
}
} else if f.chainID == "" {
return nil, fmt.Errorf("chain ID required but not specified")
return nil, errors.New("chain ID required but not specified")
}
fees := f.fees
@@ -370,7 +370,12 @@ func (f Factory) PrintUnsignedTx(clientCtx client.Context, msgs ...sdk.Msg) erro
return err
}
json, err := clientCtx.TxConfig.TxJSONEncoder()(unsignedTx.GetTx())
encoder := f.txConfig.TxJSONEncoder()
if encoder == nil {
return errors.New("cannot print unsigned tx: tx json encoder is nil")
}
json, err := encoder(unsignedTx.GetTx())
if err != nil {
return err
}
+6 -1
View File
@@ -100,7 +100,12 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
}
if !clientCtx.SkipConfirm {
txBytes, err := clientCtx.TxConfig.TxJSONEncoder()(tx.GetTx())
encoder := txf.txConfig.TxJSONEncoder()
if encoder == nil {
return errors.New("failed to encode transaction: tx json encoder is nil")
}
txBytes, err := encoder(tx.GetTx())
if err != nil {
return err
}