forked from cerc-io/laconicd-deprecated
update fork
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
rpctypes "github.com/cerc-io/laconicd/rpc/ethereum/types"
|
||||
rpctypes "github.com/cerc-io/laconicd/rpc/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@@ -23,6 +23,7 @@ func GetQueryCmd() *cobra.Command {
|
||||
cmd.AddCommand(
|
||||
GetStorageCmd(),
|
||||
GetCodeCmd(),
|
||||
GetParamsCmd(),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
@@ -32,7 +33,7 @@ func GetStorageCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "storage [address] [key]",
|
||||
Short: "Gets storage for an account with a given key and height",
|
||||
Long: "Gets storage for an account with a given key and height. If the height is not provided, it will use the latest height from context.",
|
||||
Long: "Gets storage for an account with a given key and height. If the height is not provided, it will use the latest height from context.", //nolint:lll
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
@@ -103,3 +104,31 @@ func GetCodeCmd() *cobra.Command {
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetParamsCmd queries the fee market params
|
||||
func GetParamsCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "params",
|
||||
Short: "Get the evm params",
|
||||
Long: "Get the evm parameter values.",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
rpctypes "github.com/cerc-io/laconicd/rpc/ethereum/types"
|
||||
rpctypes "github.com/cerc-io/laconicd/rpc/types"
|
||||
"github.com/cerc-io/laconicd/x/evm/types"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package rest
|
||||
|
||||
// clientrest "github.com/cosmos/cosmos-sdk/client/rest"
|
||||
// "github.com/cosmos/cosmos-sdk/types/rest"
|
||||
// authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||
|
||||
// // RegisterTxRoutes - Central function to define routes that get registered by the main application
|
||||
// func RegisterTxRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
// r := testutil.GetRequestWithHeaders(rtr)
|
||||
// r.HandleFunc("/txs/{hash}", QueryTxRequestHandlerFn(clientCtx)).Methods("GET")
|
||||
// r.HandleFunc("/txs", testutil.QueryTxsRequestHandlerFn(clientCtx)).Methods("GET")
|
||||
// r.HandleFunc("/txs/decode", testutil.DecodeTxRequestHandlerFn(clientCtx)).Methods("POST")
|
||||
// }
|
||||
|
||||
// QueryTxRequestHandlerFn implements a REST handler that queries a transaction
|
||||
// by hash in a committed block.
|
||||
// func QueryTxRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
// return func(w http.ResponseWriter, r *http.Request) {
|
||||
// vars := mux.Vars(r)
|
||||
// hashHexStr := vars["hash"]
|
||||
|
||||
// clientCtx, ok := testutil.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r)
|
||||
// if !ok {
|
||||
// return
|
||||
// }
|
||||
|
||||
// ethHashPrefix := "0x"
|
||||
// // if !strings.HasPrefix(hashHexStr, ethHashPrefix) {
|
||||
// // authrest.QueryTxRequestHandlerFn(clientCtx)
|
||||
// // return
|
||||
// // }
|
||||
|
||||
// // eth Tx
|
||||
// ethHashPrefixLength := len(ethHashPrefix)
|
||||
// output, err := getEthTransactionByHash(clientCtx, hashHexStr[ethHashPrefixLength:])
|
||||
// if err != nil {
|
||||
// rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
// return
|
||||
// }
|
||||
|
||||
// rest.PostProcessResponseBare(w, clientCtx, output)
|
||||
// }
|
||||
// }
|
||||
|
||||
// // GetTransactionByHash returns the transaction identified by hash.
|
||||
// func getEthTransactionByHash(clientCtx client.Context, hashHex string) ([]byte, error) {
|
||||
// hash, err := hex.DecodeString(hashHex)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// node, err := clientCtx.GetNode()
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// tx, err := node.Tx(context.Background(), hash, false)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// // Can either cache or just leave this out if not necessary
|
||||
// block, err := node.Block(context.Background(), &tx.Height)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// client := feemarkettypes.NewQueryClient(clientCtx)
|
||||
// res, err := client.BaseFee(context.Background(), &feemarkettypes.QueryBaseFeeRequest{})
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// var baseFee *big.Int
|
||||
// if res.BaseFee != nil {
|
||||
// baseFee = res.BaseFee.BigInt()
|
||||
// }
|
||||
|
||||
// blockHash := common.BytesToHash(block.Block.Header.Hash())
|
||||
|
||||
// ethTxs, err := rpctypes.RawTxToEthTx(clientCtx, tx.Tx)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// height := uint64(tx.Height)
|
||||
|
||||
// for _, ethTx := range ethTxs {
|
||||
// if common.HexToHash(ethTx.Hash) == common.BytesToHash(hash) {
|
||||
// rpcTx, err := rpctypes.NewRPCTransaction(ethTx.AsTransaction(), blockHash, height, uint64(tx.Index), baseFee)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// return json.Marshal(rpcTx)
|
||||
// }
|
||||
// }
|
||||
|
||||
// return nil, errors.New("eth tx not found")
|
||||
// }
|
||||
Reference in New Issue
Block a user