Migrate {x/auth, x/gov, x/staking} missing CLI queries to proto (#6994)
* Fix error code * Fix decoder * Fix typo * Fix decode * refactor * Migrate SearchTxsResult to proto * fix MarkEventsToIndex * lint++ * Fix output * Add QueryTxCmd cli test * Add fmt * Put txBuilder in types/tx * Add GetAnyTx in TxBuilder * Add new IsAnyTx * Rename to IntoAny * Fix bug * fmt Co-authored-by: Marie <marie.gauthier63@gmail.com> * Fix ibc CLI to use proto * Fix any MarshalJSON * Fix test * Make tx.Tx implement sdk.Tx * Register sdk.Tx * Fix lint * Allow DefaultJSONTxEncoder to take tx.Tx * refactor * Rename variable * remove fmt Co-authored-by: Anil Kumar Kammari <anil@vitwit.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Marie <marie.gauthier63@gmail.com>
This commit is contained in:
co-authored by
Marie
Anil Kumar Kammari
Alexander Bezobchuk
Aleksandr Bezobchuk
Amaury Martiny
parent
d84296a5fc
commit
b2348180b8
@@ -11,10 +11,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@@ -98,9 +100,14 @@ func (s IntegrationTestSuite) TestSimulateService() {
|
||||
)
|
||||
txBuilder.SetSignatures(sigV2)
|
||||
|
||||
any, ok := txBuilder.(codectypes.IntoAny)
|
||||
s.Require().True(ok)
|
||||
cached := any.AsAny().GetCachedValue()
|
||||
txTx, ok := cached.(*txtypes.Tx)
|
||||
s.Require().True(ok)
|
||||
res, err := s.queryClient.Simulate(
|
||||
context.Background(),
|
||||
&simulate.SimulateRequest{Tx: txBuilder.GetProtoTx()},
|
||||
&simulate.SimulateRequest{Tx: txTx},
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
// ConvertTxToStdTx converts a transaction to the legacy StdTx format
|
||||
func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (types.StdTx, error) {
|
||||
|
||||
if stdTx, ok := tx.(types.StdTx); ok {
|
||||
return stdTx, nil
|
||||
}
|
||||
|
||||
@@ -3,26 +3,21 @@ package tx_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
tx2 "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
types3 "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
types3 "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
types2 "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
|
||||
+13
-1
@@ -14,9 +14,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
sim "github.com/cosmos/cosmos-sdk/client/grpc/simulate"
|
||||
"github.com/cosmos/cosmos-sdk/client/input"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
)
|
||||
@@ -265,7 +267,17 @@ func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
simReq := sim.SimulateRequest{Tx: txb.GetProtoTx()}
|
||||
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)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot simulate amino tx")
|
||||
}
|
||||
|
||||
simReq := sim.SimulateRequest{Tx: protoTx}
|
||||
|
||||
return simReq.Marshal()
|
||||
}
|
||||
|
||||
@@ -15,13 +15,12 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
func NewTestTxConfig() client.TxConfig {
|
||||
_, cdc := simapp.MakeCodecs()
|
||||
return types.StdTxConfig{Cdc: cdc}
|
||||
cfg := simapp.MakeEncodingConfig()
|
||||
return cfg.TxConfig
|
||||
}
|
||||
|
||||
func TestCalculateGas(t *testing.T) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package client
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
)
|
||||
@@ -36,8 +35,6 @@ type (
|
||||
// also know how to encode itself.
|
||||
TxBuilder interface {
|
||||
GetTx() signing.Tx
|
||||
// GetProtoTx returns the tx as a proto.Message.
|
||||
GetProtoTx() *tx.Tx
|
||||
|
||||
SetMsgs(msgs ...sdk.Msg) error
|
||||
SetSignatures(signatures ...signingtypes.SignatureV2) error
|
||||
|
||||
Reference in New Issue
Block a user