diff --git a/init.sh b/init.sh index 1a6972b1..0c871f60 100755 --- a/init.sh +++ b/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 diff --git a/x/faucet/client/cli/tx.go b/x/faucet/client/cli/tx.go index 2ad3464b..42dfe94a 100644 --- a/x/faucet/client/cli/tx.go +++ b/x/faucet/client/cli/tx.go @@ -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()) diff --git a/x/faucet/client/rest/tx.go b/x/faucet/client/rest/tx.go index 6d26b015..50cc91a1 100644 --- a/x/faucet/client/rest/tx.go +++ b/x/faucet/client/rest/tx.go @@ -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