Skip to content

Commit

Permalink
Merge branch 'main' into snyk-upgrade-abd8049c82d7386edf156cd6eed051ad
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Le Ponner <[email protected]>
  • Loading branch information
ericleponner authored Jan 3, 2024
2 parents 32695c0 + 6761e85 commit ac94592
Show file tree
Hide file tree
Showing 161 changed files with 8,604 additions and 3,177 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ coverage

/dist

# local env files
# local env and configuration files
.env.local
.env.*.local
networks-config.json

# Editor directories and files
.vscode
Expand Down
66 changes: 46 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Visual Explorer for the Hedera Hashgraph DLT.
npm install
```

## Build

### Compile and hot-reload for development

```shell
Expand All @@ -28,6 +30,8 @@ npm run build
npm run lint
```

## Test

### Run unit tests (based on Jest)

```shell
Expand All @@ -43,12 +47,46 @@ npm run test:e2e:dev
npm run test:e2e
```

### Run the Explorer in Docker
## Run local sourcify instance (for smart contract verification)

This set-up uses an nginx reverse proxy in front of the 3 sourcify services (ui, server, repository) in order to
support HTTPS. The SSL set-up is based on a self-signed certificate obtained per the instructions at:
https://letsencrypt.org/docs/certificates-for-localhost/

The design of the repository (itself based on an nginx reverse proxy) is such that it requires to be on a distinct host,
so it cannot be accessed by localhost like ui and server. To this effect you need to define a hostname locally (see below)

```shell
# Define the domain repository.local` used by the repository
bash -c 'echo "127.0.0.1 repository.local" >> /etc/hosts'

# Start sourcify services
# in sourcify-setup directory do:
docker-compose up -d

# Invoke the server API once to make sure your browser accepts the self-signed certificate
open https://localhost/server/chains

# To open the sourcify UI
open https://localhost

# To open the sourcify repository UI
open https://repository.local

# Stop sourcify services
# in sourcify-setup directory do:
docker-compose down
```

## Run in Docker

```shell
# Build the Docker image locally
npm run docker:build

# Copy and adjust configuration of Hedera networks as needed
cp networks-config-example.json networks-config.json

# Start the Docker container
# (if not built locally, this will fetch a pre-built image from Google Container Registry)
npm run docker:start
Expand All @@ -60,7 +98,7 @@ npm run docker:stop
# then open http://localhost:8080 in your web browser
```

### Run in Kubernetes
## Run in Kubernetes

To run in [Kubernetes](https://kubernetes.io) the hedera-explorer [Helm](https://helm.sh) chart can be used. First,
obtain access to a Kubernetes cluster running version 1.23 or greater. [Minikube](https://minikube.sigs.k8s.io/docs/)
Expand All @@ -69,7 +107,8 @@ can be used for a local Kubernetes cluster.
```shell
helm upgrade --install hedera-explorer chart/
```
#### Specify custom network (can also be used for development)

### Configure custom networks (can also be used for development)

By default the hedera explorer has support for MAINNET, PREVIEWNET and TESTNET. If you want to add or remove more networks
you can specify it using the `customNetworkConfig` in the `values.yaml` file
Expand Down Expand Up @@ -105,22 +144,9 @@ An example:
]
```

### Configure the Explorer

#### FOR DEVELOPMENT PURPOSES: Docker configuration

When running the explorer in Docker, for instance with a Local Node, it is possible
to add a network to the list of available networks configured at build time -- see below.
This is achieved by defining the variable `DOCKER_LOCAL_MIRROR_NODE_URL`
(and optionally `DOCKER_LOCAL_MIRROR_NODE_MENU_NAME`) in the `.env.docker` file,
which will be taken into account at start time by Docker. For instance:

```shell
DOCKER_LOCAL_MIRROR_NODE_MENU_NAME=LOCAL NODE # Optional, defaults to 'DEVNET'
DOCKER_LOCAL_MIRROR_NODE_URL=http://localhost:5551
```
## Configuration

#### Customize the available networks
### Customize the available networks

The list of networks available in the network selector (top navigation bar)
can be configured in the file `/public/networks-config.json`.
Expand Down Expand Up @@ -152,7 +178,7 @@ Note:
- The `ledgerID` is required to process the ID checksums shown in the UI.
- The maximum number of networks taken into account is 15. The rest will be ignored.

#### Customize the UI
### Customize the UI

A few aspects of the Explorer UI, such as the product name displayed at the bottom of the pages,
are controlled by environment variables defined in the `.env` file. These will be taken into
Expand All @@ -170,7 +196,7 @@ To enable the Staking page and menu item, set the following variable to *true* i
VITE_APP_ENABLE_STAKING=true
```

### Customize configuration
### Customize the look and feel

#### Branding

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ services:
restart: "always"
ports:
- "8080:8080"
volumes:
- ./networks-config.json:/app/networks-config.json
54 changes: 54 additions & 0 deletions networks-config-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "mainnet",
"displayName": "MAINNET",
"url": "https://mainnet-public.mirrornode.hedera.com/",
"ledgerID": "00",
"sourcifySetup": {
"activate": true,
"repoURL": "http://localhost:10000/contracts/",
"serverURL": "http://localhost:5002/",
"verifierURL": "http://localhost:3000/#/",
"chainID": 295
}
},
{
"name": "testnet",
"displayName": "TESTNET",
"url": "https://testnet.mirrornode.hedera.com/",
"ledgerID": "01",
"sourcifySetup": {
"activate": true,
"repoURL": "http://localhost:10000/contracts/",
"serverURL": "http://localhost:5002/",
"verifierURL": "http://localhost:3000/#/",
"chainID": 296
}
},
{
"name": "previewnet",
"displayName": "PREVIEWNET",
"url": "https://previewnet.mirrornode.hedera.com/",
"ledgerID": "02",
"sourcifySetup": {
"activate": true,
"repoURL": "http://localhost:10000/contracts/",
"serverURL": "http://localhost:5002/",
"verifierURL": "http://localhost:3000/#/",
"chainID": 297
}
},
{
"name": "localnode",
"displayName": "LOCAL NODE",
"url": "http://127.0.0.1:5551",
"ledgerID": "FF",
"sourcifySetup": {
"activate": true,
"repoURL": "http://localhost:10000/contracts/",
"serverURL": "http://localhost:5002/",
"verifierURL": "http://localhost:3000/#/",
"chainID": 298
}
}
]
54 changes: 54 additions & 0 deletions networks-config-https-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"name": "mainnet",
"displayName": "MAINNET",
"url": "https://mainnet-public.mirrornode.hedera.com/",
"ledgerID": "00",
"sourcifySetup": {
"activate": true,
"repoURL": "https://repository.local/contracts/",
"serverURL": "https://localhost/server/",
"verifierURL": "https://localhost/#/",
"chainID": 295
}
},
{
"name": "testnet",
"displayName": "TESTNET",
"url": "https://testnet.mirrornode.hedera.com/",
"ledgerID": "01",
"sourcifySetup": {
"activate": true,
"repoURL": "https://repository.local/contracts/",
"serverURL": "https://localhost/server/",
"verifierURL": "https://localhost/#/",
"chainID": 296
}
},
{
"name": "previewnet",
"displayName": "PREVIEWNET",
"url": "https://previewnet.mirrornode.hedera.com/",
"ledgerID": "02",
"sourcifySetup": {
"activate": true,
"repoURL": "https://repository.local/contracts/",
"serverURL": "https://localhost/server/",
"verifierURL": "https://localhost/#/",
"chainID": 297
}
},
{
"name": "localnode",
"displayName": "LOCAL NODE",
"url": "http://127.0.0.1:5551",
"ledgerID": "FF",
"sourcifySetup": {
"activate": true,
"repoURL": "https://repository.local/contracts/",
"serverURL": "https://localhost/server/",
"verifierURL": "https://localhost/#/",
"chainID": 298
}
}
]
48 changes: 48 additions & 0 deletions nossl.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pluginRewriteAll from 'vite-plugin-rewrite-all'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import * as child from "child_process"

const commitHash = child.execSync("git rev-parse --short HEAD").toString() //i.e., 706e821
const tagAndCommitHash = child.execSync("git describe --always --tags").toString() //i.e., v23.5.0-1-g706e821
const buildDate = new Date().toUTCString()

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
pluginRewriteAll(), // See vite issue: https://github.com/vitejs/vite/issues/2190
nodePolyfills({ // hashgraph/proto needs NodeJS buffers
exclude: [
'fs', // Excludes the polyfill for `fs` and `node:fs`.
],
globals: {
Buffer: true,
global: false,
process: false,
},
protocolImports: false,
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
commonjsOptions: {
transformMixedEsModules: true, // else hashconnect crashes because require() is undefined :(
},
},
define: {
'import.meta.env.VITE_BUILD_SHORTCOMMITHASH': JSON.stringify(commitHash),
'import.meta.env.VITE_BUILD_RELEASE': JSON.stringify(tagAndCommitHash),
'import.meta.env.VITE_BUILD_TIME_UTC': JSON.stringify(buildDate),
},
worker: {
format: "es",
}
})
Loading

0 comments on commit ac94592

Please sign in to comment.