parent
50ddf9ae73
commit
5d15be6adb
30
init.sh
30
init.sh
@ -2,27 +2,27 @@
|
||||
|
||||
KEY="mykey"
|
||||
CHAINID=8
|
||||
MONIKER="mymoniker"
|
||||
MONIKER="localtestnet"
|
||||
|
||||
# remove existing chain environment, data and
|
||||
# remove existing daemon and client
|
||||
rm -rf ~/.emint*
|
||||
|
||||
make install
|
||||
|
||||
emintcli config keyring-backend test
|
||||
|
||||
# if mykey exists it should be deleted
|
||||
emintcli keys add $KEY
|
||||
|
||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||
emintd init $MONIKER --chain-id $CHAINID
|
||||
|
||||
# Set up config for CLI
|
||||
emintcli config chain-id $CHAINID
|
||||
emintcli config output json
|
||||
emintcli config indent true
|
||||
emintcli config trust-node true
|
||||
|
||||
# if $KEY exists it should be deleted
|
||||
emintcli keys add $KEY
|
||||
|
||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||
emintd init $MONIKER --chain-id $CHAINID
|
||||
|
||||
# Allocate genesis accounts (cosmos formatted addresses)
|
||||
emintd add-genesis-account $(emintcli keys show $KEY -a) 1000000000000000000photon,1000000000000000000stake
|
||||
|
||||
@ -32,13 +32,21 @@ emintd gentx --name $KEY --keyring-backend test
|
||||
# Collect genesis tx
|
||||
emintd collect-gentxs
|
||||
|
||||
# Enable faucet
|
||||
cat $HOME/.emintd/config/genesis.json | jq '.app_state["faucet"]["enable_faucet"]=true' > $HOME/.emintd/config/tmp_genesis.json && mv $HOME/.emintd/config/tmp_genesis.json $HOME/.emintd/config/genesis.json
|
||||
|
||||
echo -e '\n\ntestnet faucet enabled'
|
||||
echo -e 'to transfer tokens to your account address use:'
|
||||
echo -e "emintcli tx faucet request 100photon --from $KEY\n"
|
||||
|
||||
|
||||
# Run this to ensure everything worked and that the genesis file is setup correctly
|
||||
emintd validate-genesis
|
||||
|
||||
# Command to run the rest server in a different terminal/window
|
||||
echo -e '\n\nRun this rest-server command in a different terminal/window:'
|
||||
echo -e "emintcli rest-server --laddr \"tcp://localhost:8545\" --unlock-key $KEY --chain-id $CHAINID\n\n"
|
||||
echo -e '\nrun the following command in a different terminal/window to run the REST server and JSON-RPC:'
|
||||
echo -e "emintcli rest-server --laddr \"tcp://localhost:8545\" --unlock-key $KEY --chain-id $CHAINID --trace\n"
|
||||
|
||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||
emintd start --pruning=nothing --rpc.unsafe --log_level "main:info,state:info,mempool:info"
|
||||
emintd start --pruning=nothing --rpc.unsafe --log_level "main:info,state:info,mempool:info" --trace
|
||||
|
||||
|
@ -27,17 +27,17 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command {
|
||||
}
|
||||
|
||||
faucetTxCmd.AddCommand(flags.PostCommands(
|
||||
GetCmdFund(cdc),
|
||||
GetCmdRequest(cdc),
|
||||
)...)
|
||||
|
||||
return faucetTxCmd
|
||||
}
|
||||
|
||||
// GetCmdFund is the CLI command to fund an address with the requested coins
|
||||
func GetCmdFund(cdc *codec.Codec) *cobra.Command {
|
||||
// GetCmdRequest is the CLI command to fund an address with the requested coins
|
||||
func GetCmdRequest(cdc *codec.Codec) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "fund [amount] [other-recipient (optional)]",
|
||||
Short: "fund an address with the requested coins",
|
||||
Use: "request [amount] [other-recipient (optional)]",
|
||||
Short: "request an address with the requested coins",
|
||||
Args: cobra.RangeArgs(1, 2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||
|
@ -16,20 +16,20 @@ import (
|
||||
|
||||
// RegisterRoutes register REST endpoints for the faucet module
|
||||
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
||||
r.HandleFunc(fmt.Sprintf("/%s/fund", types.ModuleName), fundHandlerFn(cliCtx)).Methods("POST")
|
||||
r.HandleFunc(fmt.Sprintf("/%s/request", types.ModuleName), requestHandler(cliCtx)).Methods("POST")
|
||||
r.HandleFunc(fmt.Sprintf("/%s/funded", types.ModuleName), fundedHandlerFn(cliCtx)).Methods("GET")
|
||||
}
|
||||
|
||||
// PostFundRequest defines fund request's body.
|
||||
type PostFundRequest struct {
|
||||
// PostRequestBody defines fund request's body.
|
||||
type PostRequestBody struct {
|
||||
BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"`
|
||||
Amount sdk.Coins `json:"amount" yaml:"amount"`
|
||||
Recipient string `json:"receipient" yaml:"receipient"`
|
||||
}
|
||||
|
||||
func fundHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
func requestHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req PostFundRequest
|
||||
var req PostRequestBody
|
||||
if !rest.ReadRESTReq(w, r, cliCtx.Codec, &req) {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request")
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user