Skip to content
This repository has been archived by the owner on Feb 27, 2021. It is now read-only.

Commit

Permalink
fix: eth rpc configuration
Browse files Browse the repository at this point in the history
fixes #51
  • Loading branch information
shanejonas committed Sep 3, 2019
1 parent 26bd157 commit 18fce91
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Jade Explorer

A block explorer for EVM-based blockchains.
A block explorer for EVM-based blockchains.

Jade Explorer is a minimal block explorer that uses Jade Service Runner for managing background services (Multi-Geth), OpenRPC for underlying functionality, and Pristine. It does not use a database, and be configured to point at any remote RPC node for any EVM-based network. The goal of Jade Explorer is to provide a resource for network information and block exploration.
Jade Explorer is a minimal block explorer that uses Jade Service Runner for managing background services (Multi-Geth), OpenRPC for underlying functionality, and Pristine. It does not use a database, and be configured to point at any remote RPC node for any EVM-based network. The goal of Jade Explorer is to provide a resource for network information and block exploration.

Explorer Features:
- Display chain id
Expand Down Expand Up @@ -32,13 +32,17 @@ git clone https://github.com/etclabscore/jade-explorer.git && cd jade-explorer &
## Usage



### Service Runner
If you dont have a [service-runner](https://github.com/etclabscore/jade-service-runner) running you can use the one in the package.json via: (or see the configuration section below to provide your own ethereum rpc URL):

```bash
npm run service-runner
```

Jade Service Runner will run at http://localhost:8002/.

Start the explorer.
## Start the explorer.

```bash
npm start
Expand All @@ -65,6 +69,22 @@ By default, multi-geth service will run ETC mainnet. Jade Service runner conveni
└── keystore
```

### Configure default urls via environment variables

Override eth url

```
REACT_APP_ETH_RPC_URL=https://services.jade.builders/multi-geth/mainnet/1.9.2 npm start
```

**OR**

Override service runner url

```
REACT_APP_SERVICE_RUNNER_URL=https://services.jade.builders/ npm start
```

## Resources

- [Ethereum JSON RPC Specification](https://github.com/etclabscore/ethereum-json-rpc-specification)
Expand Down
8 changes: 5 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AppBar, CssBaseline, Theme, Toolbar, Typography, IconButton, Grid } fro
import { makeStyles, ThemeProvider } from "@material-ui/styles";
import Link from "@material-ui/core/Link";
import { Link as RouterLink } from "react-router-dom";
import * as React from "react";
import React, { Dispatch } from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import useDarkMode from "use-dark-mode";
import "./App.css";
Expand Down Expand Up @@ -32,12 +32,14 @@ function App(props: any) {
const theme = darkMode.value ? darkTheme : lightTheme;

const [, , setServiceRunnerUrl] = useServiceRunnerStore();
const [erpc]: [EthereumJSONRPC] = useMultiGethStore();
const [erpc, setMultiGethUrlOverride]: [EthereumJSONRPC, Dispatch<string>] = useMultiGethStore();

const classes = useStyles(theme);
const handleConfigurationChange = (type: string, url: string) => {
if (type === "service-runner") {
setServiceRunnerUrl(url);
} else if (type === "ethereum-rpc") {
setMultiGethUrlOverride(url);
}
};

Expand All @@ -55,7 +57,7 @@ function App(props: any) {
}, 100, true);

return (
<Router>
<Router >
<ThemeProvider theme={theme}>
<CssBaseline />
<AppBar color="default" elevation={0}>
Expand Down
11 changes: 6 additions & 5 deletions src/hooks/useMultiGeth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ERPC from "@etclabscore/ethereum-json-rpc";
import JadeServiceRunner from "@etclabscore/jade-service-runner-client";
import * as React from "react";
import React, { useState, Dispatch } from "react";

const serviceName = "multi-geth";

Expand All @@ -9,8 +9,9 @@ function useMultiGeth(
serviceRunnerUrl: string,
version: string,
env: string,
): [ERPC] {
): [ERPC, Dispatch<string>] {
const [erpc, setErpc] = React.useState();
const [urlOverride, setUrlOverride] = useState(process.env.REACT_APP_ETH_RPC_URL);
React.useEffect(() => {
if (!serviceRunner) {
return;
Expand All @@ -23,7 +24,7 @@ function useMultiGeth(
await serviceRunner.startService(serviceName, version, env);
let parsedUrl;
try {
parsedUrl = new URL(`${serviceRunnerUrl}/${serviceName}/${env}/${version}`);
parsedUrl = new URL(urlOverride || `${serviceRunnerUrl}/${serviceName}/${env}/${version}`);
} catch (e) {
return;
}
Expand All @@ -48,8 +49,8 @@ function useMultiGeth(
}
};
runAsync();
}, [serviceRunner, serviceRunnerUrl, version, env]);
return [erpc];
}, [serviceRunner, serviceRunnerUrl, version, env, urlOverride]);
return [erpc, setUrlOverride];
}

export default useMultiGeth;
4 changes: 2 additions & 2 deletions src/hooks/useServiceRunner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import JadeServiceRunner from "@etclabscore/jade-service-runner-client";
import * as React from "react";
import React, { Dispatch } from "react";

function useServiceRunner(defaultUrl: string): [JadeServiceRunner | undefined, string, any] {
function useServiceRunner(defaultUrl: string): [JadeServiceRunner | undefined, string, Dispatch<string>] {
const [url, setUrl] = React.useState(defaultUrl);
const [serviceRunner, setServiceRunner] = React.useState<JadeServiceRunner | undefined>();
React.useEffect(() => {
Expand Down

0 comments on commit 18fce91

Please sign in to comment.