Clean Any interface (#8167)
* Clean Any interface + removed Any.Pack method. This method is not needed, because we have specialized functions for createing new Any values. It could be used inappropriately with existing Any objects. * removed deprecated PackAny function * fix linter issue * update nil handling * NewAnyWithValue returns error on nil instead of panic * NewMsgCreateValidator: handle nil pubkey * Remove AsAny and tx builder workarounds * fix linter issue * Add AsAny methods to TxBuilder and StdTxConfig, but keep intoAny interface private * remove tx.PubKeyToAny * cosmetic updates * fix method interface * move ProtoTxProvider to x/auth/tx
This commit is contained in:
+3
-10
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/input"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -21,6 +20,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
)
|
||||
|
||||
// GenerateOrBroadcastTxCLI will either generate and print and unsigned transaction
|
||||
@@ -263,22 +263,15 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
|
||||
},
|
||||
Sequence: txf.Sequence(),
|
||||
}
|
||||
|
||||
if err := txb.SetSignatures(sig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
any, ok := txb.(codectypes.IntoAny)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot simulate tx that cannot be wrapped into any")
|
||||
}
|
||||
cached := any.AsAny().GetCachedValue()
|
||||
protoTx, ok := cached.(*tx.Tx)
|
||||
protoProvider, ok := txb.(authtx.ProtoTxProvider)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot simulate amino tx")
|
||||
}
|
||||
|
||||
simReq := tx.SimulateRequest{Tx: protoTx}
|
||||
simReq := tx.SimulateRequest{Tx: protoProvider.GetProtoTx()}
|
||||
|
||||
return simReq.Marshal()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user