diff --git a/cmd/exchaincli/main.go b/cmd/exchaincli/main.go index ec9b107a77..f97d6e4d81 100644 --- a/cmd/exchaincli/main.go +++ b/cmd/exchaincli/main.go @@ -1,18 +1,14 @@ package main import ( - "encoding/hex" "fmt" - "strings" - "github.com/cosmos/cosmos-sdk/client/context" + sdkcodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/okex/exchain/x/dex" evmtypes "github.com/okex/exchain/x/evm/types" "github.com/okex/exchain/x/order" "github.com/spf13/cobra" - "github.com/spf13/viper" - tmamino "github.com/tendermint/tendermint/crypto/encoding/amino" "github.com/tendermint/tendermint/crypto/multisig" "github.com/tendermint/tendermint/libs/cli" @@ -21,7 +17,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" clientkeys "github.com/cosmos/cosmos-sdk/client/keys" clientrpc "github.com/cosmos/cosmos-sdk/client/rpc" - sdkcodec "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -66,6 +61,7 @@ func main() { // Add --chain-id to persistent flags and mark it required rootCmd.PersistentFlags().String(flags.FlagChainID, "", "Chain ID of tendermint node") rootCmd.PersistentPreRunE = func(_ *cobra.Command, _ []string) error { + utils.SetParseAppTx(parseMsgEthereumTx) return client.InitConfig(rootCmd) } @@ -105,7 +101,7 @@ func queryCmd(cdc *sdkcodec.Codec) *cobra.Command { authcmd.GetAccountCmd(cdc), flags.LineBreak, authcmd.QueryTxsByEventsCmd(cdc), - queryTxCmd(cdc), + authcmd.QueryTxCmd(cdc), flags.LineBreak, ) @@ -153,43 +149,11 @@ func txCmd(cdc *sdkcodec.Codec) *cobra.Command { return txCmd } -// queryTxCmd implements the default command for a tx query. -func queryTxCmd(cdc *sdkcodec.Codec) *cobra.Command { - cmd := &cobra.Command{ - Use: "tx [hash]", - Short: "Query for a transaction by hash in a committed block", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx := context.NewCLIContext().WithCodec(cdc) - - output, err := utils.QueryTx(cliCtx, args[0]) - if err != nil { - ss := strings.Split(output.TxHash, "/") - if len(ss) != 2 { - return err - } - txBytes, err := hex.DecodeString(ss[1]) - var tx evmtypes.MsgEthereumTx - err = cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx) - if err != nil { - return err - } - output.TxHash = ss[0] - output.Tx = tx - } - - if output.Empty() { - return fmt.Errorf("no transaction found with hash %s", args[0]) - } - - return cliCtx.PrintOutput(output) - }, +func parseMsgEthereumTx(cdc *sdkcodec.Codec, txBytes []byte) (sdk.Tx, error) { + var tx evmtypes.MsgEthereumTx + err := cdc.UnmarshalBinaryLengthPrefixed(txBytes, &tx) + if err != nil { + return nil, err } - - cmd.Flags().StringP(flags.FlagNode, "n", "tcp://localhost:26657", "Node to connect to") - viper.BindPFlag(flags.FlagNode, cmd.Flags().Lookup(flags.FlagNode)) - cmd.Flags().Bool(flags.FlagTrustNode, false, "Trust connected full node (don't verify proofs for responses)") - viper.BindPFlag(flags.FlagTrustNode, cmd.Flags().Lookup(flags.FlagTrustNode)) - - return cmd + return tx, nil } diff --git a/go.mod b/go.mod index 62f72c7b47..e8b621de5d 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/okex/cosmos-sdk v0.39.2-exchain7 + github.com/cosmos/cosmos-sdk => github.com/okex/cosmos-sdk v0.39.2-exchain8 github.com/tendermint/iavl => github.com/okex/iavl v0.14.3-exchain github.com/tendermint/tendermint => github.com/okex/tendermint v0.33.9-exchain5 ) diff --git a/go.sum b/go.sum index 983501d980..e80c9ce12a 100644 --- a/go.sum +++ b/go.sum @@ -499,8 +499,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/okex/cosmos-sdk v0.39.2-exchain7 h1:ySr9r+EErCK31LakC+fkV6TsOYf6rG64PQlwhEqFOrs= -github.com/okex/cosmos-sdk v0.39.2-exchain7/go.mod h1:IvlniaZoJAtzILHgcmnfaJ5S125TYJWfJvGqY9zSXb4= +github.com/okex/cosmos-sdk v0.39.2-exchain8 h1:kyhTZQF9RIWR63s6cCRaWfvUnOX59QB2LJd/ylp2jso= +github.com/okex/cosmos-sdk v0.39.2-exchain8/go.mod h1:IvlniaZoJAtzILHgcmnfaJ5S125TYJWfJvGqY9zSXb4= github.com/okex/iavl v0.14.3-exchain h1:kwRIwpFD6B8mDDqoaxeUN3Pg2GW0Vr+sA+b86renWcA= github.com/okex/iavl v0.14.3-exchain/go.mod h1:vHLYxU/zuxBmxxr1v+5Vnd/JzcIsyK17n9P9RDubPVU= github.com/okex/tendermint v0.33.9-exchain5 h1:8nSeDVzcO+g2bFUMcT34Wkv0x/yEPD/eAFoSVExicQk=