Enable Cosmos endpoints on rest-server command (#162)
This commit is contained in:
parent
a4d88188bc
commit
b98685c46b
@ -60,8 +60,7 @@ func main() {
|
|||||||
client.ConfigCmd(emintapp.DefaultCLIHome),
|
client.ConfigCmd(emintapp.DefaultCLIHome),
|
||||||
queryCmd(cdc),
|
queryCmd(cdc),
|
||||||
txCmd(cdc),
|
txCmd(cdc),
|
||||||
// TODO: Set up rest routes (if included, different from web3 api)
|
rpc.EmintServeCmd(cdc),
|
||||||
rpc.Web3RpcCmd(cdc),
|
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
keyCommands(),
|
keyCommands(),
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
|
@ -5,11 +5,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/client/input"
|
"github.com/cosmos/cosmos-sdk/client/input"
|
||||||
emintkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
emintkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/client/lcd"
|
"github.com/cosmos/cosmos-sdk/client/lcd"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||||
|
"github.com/cosmos/ethermint/app"
|
||||||
emintcrypto "github.com/cosmos/ethermint/crypto"
|
emintcrypto "github.com/cosmos/ethermint/crypto"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
|
||||||
@ -36,8 +39,9 @@ type Config struct {
|
|||||||
RPCVHosts []string
|
RPCVHosts []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Web3RpcCmd creates a CLI command to start RPC server
|
// EmintServeCmd creates a CLI command to start Cosmos LCD server with web3 RPC API and
|
||||||
func Web3RpcCmd(cdc *codec.Codec) *cobra.Command {
|
// Cosmos rest-server endpoints
|
||||||
|
func EmintServeCmd(cdc *codec.Codec) *cobra.Command {
|
||||||
cmd := lcd.ServeCommand(cdc, registerRoutes)
|
cmd := lcd.ServeCommand(cdc, registerRoutes)
|
||||||
cmd.Flags().String(flagUnlockKey, "", "Select a key to unlock on the RPC server")
|
cmd.Flags().String(flagUnlockKey, "", "Select a key to unlock on the RPC server")
|
||||||
cmd.Flags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
|
cmd.Flags().StringP(flags.FlagBroadcastMode, "b", flags.BroadcastSync, "Transaction broadcasting mode (sync|async|block)")
|
||||||
@ -86,7 +90,13 @@ func registerRoutes(rs *lcd.RestServer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Web3 RPC API route
|
||||||
rs.Mux.HandleFunc("/", s.ServeHTTP).Methods("POST", "OPTIONS")
|
rs.Mux.HandleFunc("/", s.ServeHTTP).Methods("POST", "OPTIONS")
|
||||||
|
|
||||||
|
// Register all other Cosmos routes
|
||||||
|
client.RegisterRoutes(rs.CliCtx, rs.Mux)
|
||||||
|
authrest.RegisterTxRoutes(rs.CliCtx, rs.Mux)
|
||||||
|
app.ModuleBasics.RegisterRESTRoutes(rs.CliCtx, rs.Mux)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unlockKeyFromNameAndPassphrase(accountName, passphrase string) (emintKey emintcrypto.PrivKeySecp256k1, err error) {
|
func unlockKeyFromNameAndPassphrase(accountName, passphrase string) (emintKey emintcrypto.PrivKeySecp256k1, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user