Merge pull request #132 from vegaprotocol/feat/127-generalised-stats-page
frontend-monorepo-127 Generalize stats page to work for all environments
@ -2,6 +2,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Testnet'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
NX_EXPLORER_GENESIS = 1
|
||||
|
@ -3,6 +3,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://n04.d.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n04.d.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Devnet'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
|
@ -3,6 +3,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://mainnet-observer-proxy01.ops.vega.xyz/"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://mainnet-observer-proxy01.ops.vega.xyz/websocket"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Mainnet'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
|
@ -3,6 +3,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://n03.s.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.s.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Stagnet 1'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
|
@ -3,6 +3,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://n03.stagnet2.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.stagnet2.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Stagnet 2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
|
@ -3,6 +3,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Testnet'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
|
@ -3,3 +3,5 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://n04.d.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n04.d.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n04.d.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Devnet'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
||||
|
@ -3,6 +3,8 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Testnet'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
|
||||
# App flags
|
||||
NX_EXPLORER_ASSETS = 1
|
||||
|
@ -3,3 +3,5 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://mainnet-observer-proxy01.ops.vega.xyz/"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://mainnet-observer-proxy01.ops.vega.xyz/websocket"
|
||||
NX_VEGA_URL = "https://api.token.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Mainnet'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
||||
|
@ -3,3 +3,5 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://n03.s.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.s.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.s.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Stagnet 1'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
||||
|
@ -3,3 +3,5 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://n03.stagnet2.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://n03.stagnet2.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://n03.stagnet2.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Stagnet 2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
||||
|
@ -3,3 +3,5 @@ NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-
|
||||
NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm"
|
||||
NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket"
|
||||
NX_VEGA_URL = "https://lb.testnet.vega.xyz/query"
|
||||
NX_VEGA_ENV = 'Testnet'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
||||
|
@ -3,4 +3,6 @@ export const DATA_SOURCES = {
|
||||
tendermintUrl: process.env['NX_TENDERMINT_URL'] as string,
|
||||
tendermintWebsocketUrl: process.env['NX_TENDERMINT_WEBSOCKET_URL'] as string,
|
||||
dataNodeUrl: process.env['NX_VEGA_URL'] as string,
|
||||
envName: process.env['NX_VEGA_ENV'] as string,
|
||||
restEndpoint: process.env['NX_VEGA_REST'] as string,
|
||||
};
|
||||
|
@ -1,9 +1,20 @@
|
||||
import { StatsManager } from '@vegaprotocol/mainnet-stats-manager';
|
||||
import { DATA_SOURCES } from '../../config';
|
||||
import { StatsManager } from '@vegaprotocol/network-stats';
|
||||
|
||||
const envName = DATA_SOURCES.envName;
|
||||
const restEndpoint = DATA_SOURCES.restEndpoint;
|
||||
const statsEndpoint = `${restEndpoint}/statistics`;
|
||||
const nodesEndpoint = `${restEndpoint}/nodes-data`;
|
||||
|
||||
const Home = () => {
|
||||
return (
|
||||
<section>
|
||||
<StatsManager className="mt-12 grid grid-cols-1 lg:grid-cols-2 lg:gap-16" />
|
||||
<StatsManager
|
||||
envName={envName}
|
||||
statsEndpoint={statsEndpoint}
|
||||
nodesEndpoint={nodesEndpoint}
|
||||
className="mt-12 grid grid-cols-1 lg:grid-cols-2 lg:gap-16"
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
4
apps/stats-e2e/.env
Normal file
@ -0,0 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
CYPRESS_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
4
apps/stats-e2e/.env.devnet
Normal file
@ -0,0 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
CYPRESS_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
4
apps/stats-e2e/.env.mainnet
Normal file
@ -0,0 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
CYPRESS_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
4
apps/stats-e2e/.env.stagnet1
Normal file
@ -0,0 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET 1'
|
||||
CYPRESS_VEGA_ENV = 'STAGNET 1'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
4
apps/stats-e2e/.env.stagnet2
Normal file
@ -0,0 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET 2'
|
||||
CYPRESS_VEGA_ENV = 'STAGNET 2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
4
apps/stats-e2e/.env.testnet
Normal file
@ -0,0 +1,4 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
CYPRESS_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
@ -8,7 +8,7 @@
|
||||
"supportFile": "./src/support/index.ts",
|
||||
"pluginsFile": false,
|
||||
"video": true,
|
||||
"videosFolder": "../../dist/cypress/apps/stats-mainnet-e2e/videos",
|
||||
"screenshotsFolder": "../../dist/cypress/apps/stats-mainnet-e2e/screenshots",
|
||||
"videosFolder": "../../dist/cypress/apps/stats-e2e/videos",
|
||||
"screenshotsFolder": "../../dist/cypress/apps/stats-e2e/screenshots",
|
||||
"chromeWebSecurity": false
|
||||
}
|
28
apps/stats-e2e/project.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"root": "apps/stats-e2e",
|
||||
"sourceRoot": "apps/stats-e2e/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"executor": "@nrwl/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/stats-e2e/cypress.json",
|
||||
"devServerTarget": "stats:serve"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "stats:serve:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/stats-e2e/**/*.{js,ts}"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [],
|
||||
"implicitDependencies": ["stats"]
|
||||
}
|
9
apps/stats-e2e/src/integration/app.spec.ts
Normal file
@ -0,0 +1,9 @@
|
||||
const textToCheck = Cypress.env('VEGA_ENV');
|
||||
|
||||
describe('stats', () => {
|
||||
beforeEach(() => cy.visit('/'));
|
||||
|
||||
it('should display header based on environment name', () => {
|
||||
cy.get('h3').should('have.text', `/ ${textToCheck}`);
|
||||
});
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"root": "apps/stats-mainnet-e2e",
|
||||
"sourceRoot": "apps/stats-mainnet-e2e/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"executor": "@nrwl/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/stats-mainnet-e2e/cypress.json",
|
||||
"devServerTarget": "stats-mainnet:serve"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "stats-mainnet:serve:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/stats-mainnet-e2e/**/*.{js,ts}"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [],
|
||||
"implicitDependencies": ["stats-mainnet"]
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
describe('stats-mainnet', () => {
|
||||
beforeEach(() => cy.visit('/'));
|
||||
|
||||
it('should display header', () => {
|
||||
cy.get('h3').should('have.text', '/ Mainnet');
|
||||
});
|
||||
});
|
3
apps/stats/.env.devnet
Normal file
@ -0,0 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'DEVNET'
|
||||
NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest'
|
3
apps/stats/.env.mainnet
Normal file
@ -0,0 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'MAINNET'
|
||||
NX_VEGA_REST = 'https://api.token.vega.xyz/'
|
3
apps/stats/.env.stagnet1
Normal file
@ -0,0 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET 1'
|
||||
NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest'
|
3
apps/stats/.env.stagnet2
Normal file
@ -0,0 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'STAGNET 2'
|
||||
NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest'
|
3
apps/stats/.env.testnet
Normal file
@ -0,0 +1,3 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_ENV = 'TESTNET'
|
||||
NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest'
|
@ -1,11 +1,11 @@
|
||||
module.exports = {
|
||||
displayName: 'stats-mainnet',
|
||||
displayName: 'stats',
|
||||
preset: '../../jest.preset.js',
|
||||
transform: {
|
||||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
|
||||
'^.+\\.[tj]sx?$': 'babel-jest',
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
||||
coverageDirectory: '../../coverage/apps/stats-mainnet',
|
||||
coverageDirectory: '../../coverage/apps/stats',
|
||||
setupFilesAfterEnv: ['./src/setup-tests.ts'],
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"root": "apps/stats-mainnet",
|
||||
"sourceRoot": "apps/stats-mainnet/src",
|
||||
"root": "apps/stats",
|
||||
"sourceRoot": "apps/stats/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"build": {
|
||||
@ -9,17 +9,17 @@
|
||||
"defaultConfiguration": "production",
|
||||
"options": {
|
||||
"compiler": "babel",
|
||||
"outputPath": "dist/apps/stats-mainnet",
|
||||
"index": "apps/stats-mainnet/src/index.html",
|
||||
"outputPath": "dist/apps/stats",
|
||||
"index": "apps/stats/src/index.html",
|
||||
"baseHref": "/",
|
||||
"main": "apps/stats-mainnet/src/main.tsx",
|
||||
"polyfills": "apps/stats-mainnet/src/polyfills.ts",
|
||||
"tsConfig": "apps/stats-mainnet/tsconfig.app.json",
|
||||
"main": "apps/stats/src/main.tsx",
|
||||
"polyfills": "apps/stats/src/polyfills.ts",
|
||||
"tsConfig": "apps/stats/tsconfig.app.json",
|
||||
"assets": [
|
||||
"apps/stats-mainnet/src/assets/favicon.ico",
|
||||
"apps/stats-mainnet/src/assets"
|
||||
"apps/stats/src/assets/favicon.ico",
|
||||
"apps/stats/src/assets"
|
||||
],
|
||||
"styles": ["apps/stats-mainnet/src/styles/styles.css"],
|
||||
"styles": ["apps/stats/src/styles/styles.css"],
|
||||
"scripts": [],
|
||||
"webpackConfig": "@nrwl/react/plugins/webpack"
|
||||
},
|
||||
@ -27,8 +27,8 @@
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "apps/stats-mainnet/src/environments/environment.ts",
|
||||
"with": "apps/stats-mainnet/src/environments/environment.prod.ts"
|
||||
"replace": "apps/stats/src/environments/environment.ts",
|
||||
"with": "apps/stats/src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
@ -44,12 +44,12 @@
|
||||
"executor": "@nrwl/web:dev-server",
|
||||
"options": {
|
||||
"port": 3010,
|
||||
"buildTarget": "stats-mainnet:build",
|
||||
"buildTarget": "stats:build",
|
||||
"hmr": true
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "stats-mainnet:build:production",
|
||||
"buildTarget": "stats:build:production",
|
||||
"hmr": false
|
||||
}
|
||||
}
|
||||
@ -58,14 +58,14 @@
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/stats-mainnet/**/*.{ts,tsx,js,jsx}"]
|
||||
"lintFilePatterns": ["apps/stats/**/*.{ts,tsx,js,jsx}"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/apps/stats-mainnet"],
|
||||
"outputs": ["coverage/apps/stats"],
|
||||
"options": {
|
||||
"jestConfig": "apps/stats-mainnet/jest.config.js",
|
||||
"jestConfig": "apps/stats/jest.config.js",
|
||||
"passWithNoTests": true
|
||||
}
|
||||
}
|
@ -1,6 +1,12 @@
|
||||
import React, { useState } from 'react';
|
||||
import { DATA_SOURCES } from './config';
|
||||
import { Header } from './components/header';
|
||||
import { StatsManager } from '@vegaprotocol/mainnet-stats-manager';
|
||||
import { StatsManager } from '@vegaprotocol/network-stats';
|
||||
|
||||
const envName = DATA_SOURCES.envName;
|
||||
const restEndpoint = DATA_SOURCES.restEndpoint;
|
||||
const statsEndpoint = `${restEndpoint}/statistics`;
|
||||
const nodesEndpoint = `${restEndpoint}/nodes-data`;
|
||||
|
||||
function App() {
|
||||
const [darkMode, setDarkMode] = useState<boolean>(
|
||||
@ -15,7 +21,12 @@ function App() {
|
||||
>
|
||||
<div className="layout-grid w-screen justify-self-center">
|
||||
<Header darkMode={darkMode} setDarkMode={setDarkMode} />
|
||||
<StatsManager className="max-w-3xl px-24" />
|
||||
<StatsManager
|
||||
envName={envName}
|
||||
statsEndpoint={statsEndpoint}
|
||||
nodesEndpoint={nodesEndpoint}
|
||||
className="max-w-3xl px-24"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 547 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
4
apps/stats/src/config/index.tsx
Normal file
@ -0,0 +1,4 @@
|
||||
export const DATA_SOURCES = {
|
||||
envName: process.env['NX_VEGA_ENV'] as string,
|
||||
restEndpoint: process.env['NX_VEGA_REST'] as string,
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
# mainnet-stats-manager
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `nx test mainnet-stats-manager` to execute the unit tests via [Jest](https://jestjs.io).
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"name": "@vegaprotocol/mainnet-stats-manager",
|
||||
"version": "0.0.1"
|
||||
}
|
7
libs/network-stats/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# network-stats
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `nx test network-stats` to execute the unit tests via [Jest](https://jestjs.io).
|
@ -1,9 +1,9 @@
|
||||
module.exports = {
|
||||
displayName: 'mainnet-stats-manager',
|
||||
displayName: 'network-stats',
|
||||
preset: '../../jest.preset.js',
|
||||
transform: {
|
||||
'^.+\\.[tj]sx?$': 'babel-jest',
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
||||
coverageDirectory: '../../coverage/libs/mainnet-stats-manager',
|
||||
coverageDirectory: '../../coverage/libs/network-stats',
|
||||
};
|
4
libs/network-stats/package.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "@vegaprotocol/network-stats",
|
||||
"version": "0.0.1"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"root": "libs/mainnet-stats-manager",
|
||||
"sourceRoot": "libs/mainnet-stats-manager/src",
|
||||
"root": "libs/network-stats",
|
||||
"sourceRoot": "libs/network-stats/src",
|
||||
"projectType": "library",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
@ -8,16 +8,16 @@
|
||||
"executor": "@nrwl/web:rollup",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/libs/mainnet-stats-manager",
|
||||
"tsConfig": "libs/mainnet-stats-manager/tsconfig.lib.json",
|
||||
"project": "libs/mainnet-stats-manager/package.json",
|
||||
"entryFile": "libs/mainnet-stats-manager/src/index.ts",
|
||||
"outputPath": "dist/libs/network-stats",
|
||||
"tsConfig": "libs/network-stats/tsconfig.lib.json",
|
||||
"project": "libs/network-stats/package.json",
|
||||
"entryFile": "libs/network-stats/src/index.ts",
|
||||
"external": ["react/jsx-runtime"],
|
||||
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
|
||||
"compiler": "babel",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "libs/mainnet-stats-manager/README.md",
|
||||
"glob": "libs/network-stats/README.md",
|
||||
"input": ".",
|
||||
"output": "."
|
||||
}
|
||||
@ -28,14 +28,14 @@
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["libs/mainnet-stats-manager/**/*.{ts,tsx,js,jsx}"]
|
||||
"lintFilePatterns": ["libs/network-stats/**/*.{ts,tsx,js,jsx}"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["coverage/libs/mainnet-stats-manager"],
|
||||
"outputs": ["coverage/libs/network-stats"],
|
||||
"options": {
|
||||
"jestConfig": "libs/mainnet-stats-manager/jest.config.js",
|
||||
"jestConfig": "libs/network-stats/jest.config.js",
|
||||
"passWithNoTests": true
|
||||
}
|
||||
}
|
@ -10,11 +10,19 @@ import { TableRow } from '../table-row';
|
||||
import { PromotedStats } from '../promoted-stats';
|
||||
import { PromotedStatsItem } from '../promoted-stats-item';
|
||||
|
||||
interface statsManagerProps {
|
||||
interface StatsManagerProps {
|
||||
envName: string;
|
||||
statsEndpoint: string;
|
||||
nodesEndpoint: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const StatsManager = ({ className }: statsManagerProps) => {
|
||||
export const StatsManager = ({
|
||||
envName,
|
||||
statsEndpoint,
|
||||
nodesEndpoint,
|
||||
className,
|
||||
}: StatsManagerProps) => {
|
||||
const [data, setData] = useState<IStructuredStats | null>(null);
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
|
||||
@ -22,8 +30,8 @@ export const StatsManager = ({ className }: statsManagerProps) => {
|
||||
async function getStats() {
|
||||
try {
|
||||
const [res1, res2] = await Promise.all([
|
||||
fetch('https://api.token.vega.xyz/statistics'),
|
||||
fetch('https://api.token.vega.xyz/nodes-data'),
|
||||
fetch(statsEndpoint),
|
||||
fetch(nodesEndpoint),
|
||||
]);
|
||||
const [{ statistics }, { nodeData }] = await Promise.all([
|
||||
res1.json(),
|
||||
@ -69,7 +77,7 @@ export const StatsManager = ({ className }: statsManagerProps) => {
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, []);
|
||||
}, [nodesEndpoint, statsEndpoint]);
|
||||
|
||||
const classes = classnames(
|
||||
className,
|
||||
@ -79,7 +87,7 @@ export const StatsManager = ({ className }: statsManagerProps) => {
|
||||
return (
|
||||
<div className={classes}>
|
||||
<h3 className="font-alpha uppercase text-h3 pb-16 col-span-full">
|
||||
{(error && `/ ${error}`) || (data ? '/ Mainnet' : '/ Connecting...')}
|
||||
{(error && `/ ${error}`) || (data ? `/ ${envName}` : '/ Connecting...')}
|
||||
</h3>
|
||||
|
||||
{data?.promoted ? (
|
@ -17,10 +17,8 @@
|
||||
"paths": {
|
||||
"@vegaprotocol/deal-ticket": ["libs/deal-ticket/src/index.ts"],
|
||||
"@vegaprotocol/graphql": ["libs/graphql/src/index.ts"],
|
||||
"@vegaprotocol/mainnet-stats-manager": [
|
||||
"libs/mainnet-stats-manager/src/index.ts"
|
||||
],
|
||||
"@vegaprotocol/market-list": ["libs/market-list/src/index.ts"],
|
||||
"@vegaprotocol/network-stats": ["libs/network-stats/src/index.ts"],
|
||||
"@vegaprotocol/order-list": ["libs/order-list/src/index.ts"],
|
||||
"@vegaprotocol/react-helpers": ["libs/react-helpers/src/index.ts"],
|
||||
"@vegaprotocol/tailwindcss-config": [
|
||||
|
@ -5,12 +5,12 @@
|
||||
"explorer": "apps/explorer",
|
||||
"explorer-e2e": "apps/explorer-e2e",
|
||||
"graphql": "libs/graphql",
|
||||
"mainnet-stats-manager": "libs/mainnet-stats-manager",
|
||||
"market-list": "libs/market-list",
|
||||
"network-stats": "libs/network-stats",
|
||||
"order-list": "libs/order-list",
|
||||
"react-helpers": "libs/react-helpers",
|
||||
"stats-mainnet": "apps/stats-mainnet",
|
||||
"stats-mainnet-e2e": "apps/stats-mainnet-e2e",
|
||||
"stats": "apps/stats",
|
||||
"stats-e2e": "apps/stats-e2e",
|
||||
"tailwindcss-config": "libs/tailwindcss-config",
|
||||
"trading": "apps/trading",
|
||||
"trading-e2e": "apps/trading-e2e",
|
||||
|