diff --git a/nodes/server/cmd/routes.go b/nodes/server/cmd/routes.go index fd3ca537..8ff3347d 100644 --- a/nodes/server/cmd/routes.go +++ b/nodes/server/cmd/routes.go @@ -3,6 +3,7 @@ package cmd import ( "bytes" "encoding/json" + "fmt" "io/ioutil" "log" "net/http" @@ -31,17 +32,13 @@ func (es *extendedServer) pingGethRoute(w http.ResponseWriter, req *http.Request http.Error(w, http.StatusText(500), http.StatusInternalServerError) return } - var IPC_PATH string - if es.blockchain == "ethereum" { - IPC_PATH = settings.MOONSTREAM_NODE_ETHEREUM_IPC_PATH - } else if es.blockchain == "polygon" { - IPC_PATH = settings.MOONSTREAM_NODE_POLYGON_IPC_PATH - } else { + if es.blockchain != "ethereum" && es.blockchain != "polygon" { log.Printf("Unaccepted blockchain type: %s", es.blockchain) http.Error(w, http.StatusText(400), http.StatusBadRequest) return } - gethResponse, err := http.Post(IPC_PATH, "application/json", + MOONSTREAM_WEB3_PROVIDER_URI := fmt.Sprintf("http://%s:8545", settings.LOCAL_IPV4) + gethResponse, err := http.Post(MOONSTREAM_WEB3_PROVIDER_URI, "application/json", bytes.NewBuffer(postBody)) if err != nil { log.Printf("Unable to request geth, error: %s", err) diff --git a/nodes/server/configs/settings.go b/nodes/server/configs/settings.go index 9d8c0672..6cecec96 100644 --- a/nodes/server/configs/settings.go +++ b/nodes/server/configs/settings.go @@ -1,19 +1,10 @@ package settings import ( - "fmt" "os" ) -// Geth configs -var MOONSTREAM_NODE_ETHEREUM_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_ETHEREUM_IPC_ADDR") -var MOONSTREAM_NODE_ETHEREUM_IPC_PORT = os.Getenv("MOONSTREAM_NODE_ETHEREUM_IPC_PORT") -var MOONSTREAM_NODE_ETHEREUM_IPC_PATH = fmt.Sprintf("http://%s:%s", MOONSTREAM_NODE_ETHEREUM_IPC_ADDR, MOONSTREAM_NODE_ETHEREUM_IPC_PORT) - -// Bor configs -var MOONSTREAM_NODE_POLYGON_IPC_ADDR = os.Getenv("MOONSTREAM_NODE_POLYGON_IPC_ADDR") -var MOONSTREAM_NODE_POLYGON_IPC_PORT = os.Getenv("MOONSTREAM_NODE_POLYGON_IPC_PORT") -var MOONSTREAM_NODE_POLYGON_IPC_PATH = fmt.Sprintf("http://%s:%s", MOONSTREAM_NODE_POLYGON_IPC_ADDR, MOONSTREAM_NODE_POLYGON_IPC_PORT) +var LOCAL_IPV4 = os.Getenv("AWS_LOCAL_IPV4") // CORS var MOONSTREAM_CORS_ALLOWED_ORIGINS = os.Getenv("MOONSTREAM_CORS_ALLOWED_ORIGINS") diff --git a/nodes/server/sample.env b/nodes/server/sample.env index e0d7211a..ca876a99 100644 --- a/nodes/server/sample.env +++ b/nodes/server/sample.env @@ -1,5 +1,2 @@ -export MOONSTREAM_NODE_ETHEREUM_IPC_ADDR="127.0.0.1" -export MOONSTREAM_NODE_ETHEREUM_IPC_PORT="8545" -export MOONSTREAM_NODE_POLYGON_IPC_ADDR="127.0.0.1" -export MOONSTREAM_NODE_POLYGON_IPC_PORT="8545" +export AWS_LOCAL_IPV4="" export MOONSTREAM_CORS_ALLOWED_ORIGINS="http://localhost:3000,https://moonstream.to,https://www.moonstream.to,https://alpha.moonstream.to"