From 5d6147ec7e57be2fbfe5b20021373da03b21580d Mon Sep 17 00:00:00 2001 From: sam-keen Date: Thu, 24 Mar 2022 12:04:01 +0000 Subject: [PATCH 1/4] frontend-monorepo-127 Generalize stats page to work for all environments --- apps/explorer/src/app/routes/home/index.tsx | 2 +- .../.eslintrc.json | 0 .../cypress.json | 4 +- apps/stats-e2e/project.json | 28 +++++++ .../src/fixtures/example.json | 0 apps/stats-e2e/src/integration/app.spec.ts | 37 +++++++++ .../src/support/commands.ts | 0 .../src/support/index.ts | 0 .../tsconfig.json | 0 apps/stats-mainnet-e2e/project.json | 28 ------- .../src/integration/app.spec.ts | 7 -- apps/{stats-mainnet => stats}/.babelrc | 0 apps/{stats-mainnet => stats}/.browserslistrc | 0 apps/{stats-mainnet => stats}/.eslintrc.json | 0 apps/{stats-mainnet => stats}/jest.config.js | 4 +- .../postcss.config.js | 0 apps/{stats-mainnet => stats}/project.json | 34 ++++---- apps/{stats-mainnet => stats}/src/app.tsx | 2 +- .../src/assets/apple-touch-icon.png | Bin .../src/assets/favicon.ico | Bin .../src/assets/logo.png | Bin .../src/assets/logo192.png | Bin .../src/assets/manifest.json | 0 .../src/assets/robots.txt | 0 .../src/components/header/header.tsx | 0 .../src/components/header/index.ts | 0 .../components/images/dark-mode-toggle.tsx | 0 .../src/components/images/index.ts | 0 .../components/images/light-mode-toggle.tsx | 0 .../src/components/videos/index.ts | 0 .../videos/vega-background-video.tsx | 0 .../src/config/types.ts | 0 apps/{stats-mainnet => stats}/src/index.html | 0 apps/{stats-mainnet => stats}/src/main.tsx | 2 +- .../{stats-mainnet => stats}/src/polyfills.ts | 0 .../src/react-app-env.d.ts | 0 .../src/report-web-vitals.ts} | 0 .../src/setup-tests.ts} | 0 .../src/styles/AlphaLyrae-Medium.woff | Bin .../src/styles/styles.css | 0 .../tailwind.config.js | 0 .../tsconfig.app.json | 0 apps/{stats-mainnet => stats}/tsconfig.json | 0 .../tsconfig.spec.json | 0 libs/mainnet-stats-manager/README.md | 7 -- libs/mainnet-stats-manager/package.json | 4 - .../.babelrc | 0 .../.eslintrc.json | 0 libs/network-stats/README.md | 7 ++ .../jest.config.js | 4 +- libs/network-stats/package.json | 4 + .../project.json | 20 ++--- .../good-threshold-indicator.tsx | 0 .../good-threshold-indicator/index.ts | 0 .../components/promoted-stats-item/index.ts | 0 .../promoted-stats-item.tsx | 0 .../src/components/promoted-stats/index.ts | 0 .../promoted-stats/promoted-stats.tsx | 0 .../src/components/stats-manager/index.ts | 0 .../stats-manager/stats-manager.tsx | 74 +++++++++++++++++- .../src/components/table-row/index.ts | 0 .../src/components/table-row/table-row.tsx | 0 .../src/components/table/index.ts | 0 .../src/components/table/table.tsx | 0 .../src/components/tooltip/index.ts | 0 .../src/components/tooltip/tooltip.tsx | 0 .../src/config/stats-fields.ts | 0 .../src/config/types.ts | 1 + .../src/index.ts | 0 .../tsconfig.json | 0 .../tsconfig.lib.json | 0 .../tsconfig.spec.json | 0 tsconfig.base.json | 4 +- workspace.json | 6 +- 74 files changed, 187 insertions(+), 92 deletions(-) rename apps/{stats-mainnet-e2e => stats-e2e}/.eslintrc.json (100%) rename apps/{stats-mainnet-e2e => stats-e2e}/cypress.json (68%) create mode 100644 apps/stats-e2e/project.json rename apps/{stats-mainnet-e2e => stats-e2e}/src/fixtures/example.json (100%) create mode 100644 apps/stats-e2e/src/integration/app.spec.ts rename apps/{stats-mainnet-e2e => stats-e2e}/src/support/commands.ts (100%) rename apps/{stats-mainnet-e2e => stats-e2e}/src/support/index.ts (100%) rename apps/{stats-mainnet-e2e => stats-e2e}/tsconfig.json (100%) delete mode 100644 apps/stats-mainnet-e2e/project.json delete mode 100644 apps/stats-mainnet-e2e/src/integration/app.spec.ts rename apps/{stats-mainnet => stats}/.babelrc (100%) rename apps/{stats-mainnet => stats}/.browserslistrc (100%) rename apps/{stats-mainnet => stats}/.eslintrc.json (100%) rename apps/{stats-mainnet => stats}/jest.config.js (72%) rename apps/{stats-mainnet => stats}/postcss.config.js (100%) rename apps/{stats-mainnet => stats}/project.json (56%) rename apps/{stats-mainnet => stats}/src/app.tsx (90%) rename apps/{stats-mainnet => stats}/src/assets/apple-touch-icon.png (100%) rename apps/{stats-mainnet => stats}/src/assets/favicon.ico (100%) rename apps/{stats-mainnet => stats}/src/assets/logo.png (100%) rename apps/{stats-mainnet => stats}/src/assets/logo192.png (100%) rename apps/{stats-mainnet => stats}/src/assets/manifest.json (100%) rename apps/{stats-mainnet => stats}/src/assets/robots.txt (100%) rename apps/{stats-mainnet => stats}/src/components/header/header.tsx (100%) rename apps/{stats-mainnet => stats}/src/components/header/index.ts (100%) rename apps/{stats-mainnet => stats}/src/components/images/dark-mode-toggle.tsx (100%) rename apps/{stats-mainnet => stats}/src/components/images/index.ts (100%) rename apps/{stats-mainnet => stats}/src/components/images/light-mode-toggle.tsx (100%) rename apps/{stats-mainnet => stats}/src/components/videos/index.ts (100%) rename apps/{stats-mainnet => stats}/src/components/videos/vega-background-video.tsx (100%) rename apps/{stats-mainnet => stats}/src/config/types.ts (100%) rename apps/{stats-mainnet => stats}/src/index.html (100%) rename apps/{stats-mainnet => stats}/src/main.tsx (90%) rename apps/{stats-mainnet => stats}/src/polyfills.ts (100%) rename apps/{stats-mainnet => stats}/src/react-app-env.d.ts (100%) rename apps/{stats-mainnet/src/reportWebVitals.ts => stats/src/report-web-vitals.ts} (100%) rename apps/{stats-mainnet/src/setupTests.ts => stats/src/setup-tests.ts} (100%) rename apps/{stats-mainnet => stats}/src/styles/AlphaLyrae-Medium.woff (100%) rename apps/{stats-mainnet => stats}/src/styles/styles.css (100%) rename apps/{stats-mainnet => stats}/tailwind.config.js (100%) rename apps/{stats-mainnet => stats}/tsconfig.app.json (100%) rename apps/{stats-mainnet => stats}/tsconfig.json (100%) rename apps/{stats-mainnet => stats}/tsconfig.spec.json (100%) delete mode 100644 libs/mainnet-stats-manager/README.md delete mode 100644 libs/mainnet-stats-manager/package.json rename libs/{mainnet-stats-manager => network-stats}/.babelrc (100%) rename libs/{mainnet-stats-manager => network-stats}/.eslintrc.json (100%) create mode 100644 libs/network-stats/README.md rename libs/{mainnet-stats-manager => network-stats}/jest.config.js (60%) create mode 100644 libs/network-stats/package.json rename libs/{mainnet-stats-manager => network-stats}/project.json (52%) rename libs/{mainnet-stats-manager => network-stats}/src/components/good-threshold-indicator/good-threshold-indicator.tsx (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/good-threshold-indicator/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/promoted-stats-item/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/promoted-stats-item/promoted-stats-item.tsx (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/promoted-stats/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/promoted-stats/promoted-stats.tsx (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/stats-manager/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/stats-manager/stats-manager.tsx (63%) rename libs/{mainnet-stats-manager => network-stats}/src/components/table-row/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/table-row/table-row.tsx (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/table/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/table/table.tsx (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/tooltip/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/components/tooltip/tooltip.tsx (100%) rename libs/{mainnet-stats-manager => network-stats}/src/config/stats-fields.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/src/config/types.ts (90%) rename libs/{mainnet-stats-manager => network-stats}/src/index.ts (100%) rename libs/{mainnet-stats-manager => network-stats}/tsconfig.json (100%) rename libs/{mainnet-stats-manager => network-stats}/tsconfig.lib.json (100%) rename libs/{mainnet-stats-manager => network-stats}/tsconfig.spec.json (100%) diff --git a/apps/explorer/src/app/routes/home/index.tsx b/apps/explorer/src/app/routes/home/index.tsx index 032d9254b..fe02a45ba 100644 --- a/apps/explorer/src/app/routes/home/index.tsx +++ b/apps/explorer/src/app/routes/home/index.tsx @@ -1,4 +1,4 @@ -import { StatsManager } from '@vegaprotocol/mainnet-stats-manager'; +import { StatsManager } from '@vegaprotocol/network-stats'; const Home = () => { return ( diff --git a/apps/stats-mainnet-e2e/.eslintrc.json b/apps/stats-e2e/.eslintrc.json similarity index 100% rename from apps/stats-mainnet-e2e/.eslintrc.json rename to apps/stats-e2e/.eslintrc.json diff --git a/apps/stats-mainnet-e2e/cypress.json b/apps/stats-e2e/cypress.json similarity index 68% rename from apps/stats-mainnet-e2e/cypress.json rename to apps/stats-e2e/cypress.json index 51e27859e..146fd9bd2 100644 --- a/apps/stats-mainnet-e2e/cypress.json +++ b/apps/stats-e2e/cypress.json @@ -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 } diff --git a/apps/stats-e2e/project.json b/apps/stats-e2e/project.json new file mode 100644 index 000000000..fcaa00685 --- /dev/null +++ b/apps/stats-e2e/project.json @@ -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"] +} diff --git a/apps/stats-mainnet-e2e/src/fixtures/example.json b/apps/stats-e2e/src/fixtures/example.json similarity index 100% rename from apps/stats-mainnet-e2e/src/fixtures/example.json rename to apps/stats-e2e/src/fixtures/example.json diff --git a/apps/stats-e2e/src/integration/app.spec.ts b/apps/stats-e2e/src/integration/app.spec.ts new file mode 100644 index 000000000..1c6b1c020 --- /dev/null +++ b/apps/stats-e2e/src/integration/app.spec.ts @@ -0,0 +1,37 @@ +describe('stats', () => { + beforeEach(() => cy.visit('/')); + + let textToCheck = ''; + + const dataNodeUrl = process.env['NX_VEGA_URL']; + + if (dataNodeUrl) { + if (dataNodeUrl.includes('api')) { + textToCheck = 'Mainnet'; + } + + if (dataNodeUrl.includes('testnet')) { + textToCheck = 'Testnet'; + } + + if (dataNodeUrl.includes('n04.d')) { + textToCheck = 'Devnet'; + } + + if (dataNodeUrl.includes('n03.s.vega')) { + textToCheck = 'Stagnet 1'; + } + + if (dataNodeUrl.includes('stagnet2')) { + textToCheck = 'Stagnet 2'; + } + } else { + // Network-stats falls back to showing Mainnet stats if no + // environment variables have been set + textToCheck = 'Mainnet'; + } + + it('should display header based on environment', () => { + cy.get('h3').should('have.text', `/ ${textToCheck}`); + }); +}); diff --git a/apps/stats-mainnet-e2e/src/support/commands.ts b/apps/stats-e2e/src/support/commands.ts similarity index 100% rename from apps/stats-mainnet-e2e/src/support/commands.ts rename to apps/stats-e2e/src/support/commands.ts diff --git a/apps/stats-mainnet-e2e/src/support/index.ts b/apps/stats-e2e/src/support/index.ts similarity index 100% rename from apps/stats-mainnet-e2e/src/support/index.ts rename to apps/stats-e2e/src/support/index.ts diff --git a/apps/stats-mainnet-e2e/tsconfig.json b/apps/stats-e2e/tsconfig.json similarity index 100% rename from apps/stats-mainnet-e2e/tsconfig.json rename to apps/stats-e2e/tsconfig.json diff --git a/apps/stats-mainnet-e2e/project.json b/apps/stats-mainnet-e2e/project.json deleted file mode 100644 index bdf7accfc..000000000 --- a/apps/stats-mainnet-e2e/project.json +++ /dev/null @@ -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"] -} diff --git a/apps/stats-mainnet-e2e/src/integration/app.spec.ts b/apps/stats-mainnet-e2e/src/integration/app.spec.ts deleted file mode 100644 index 77a688f7c..000000000 --- a/apps/stats-mainnet-e2e/src/integration/app.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -describe('stats-mainnet', () => { - beforeEach(() => cy.visit('/')); - - it('should display header', () => { - cy.get('h3').should('have.text', '/ Mainnet'); - }); -}); diff --git a/apps/stats-mainnet/.babelrc b/apps/stats/.babelrc similarity index 100% rename from apps/stats-mainnet/.babelrc rename to apps/stats/.babelrc diff --git a/apps/stats-mainnet/.browserslistrc b/apps/stats/.browserslistrc similarity index 100% rename from apps/stats-mainnet/.browserslistrc rename to apps/stats/.browserslistrc diff --git a/apps/stats-mainnet/.eslintrc.json b/apps/stats/.eslintrc.json similarity index 100% rename from apps/stats-mainnet/.eslintrc.json rename to apps/stats/.eslintrc.json diff --git a/apps/stats-mainnet/jest.config.js b/apps/stats/jest.config.js similarity index 72% rename from apps/stats-mainnet/jest.config.js rename to apps/stats/jest.config.js index d4328090a..986df82c2 100644 --- a/apps/stats-mainnet/jest.config.js +++ b/apps/stats/jest.config.js @@ -1,10 +1,10 @@ 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', }; diff --git a/apps/stats-mainnet/postcss.config.js b/apps/stats/postcss.config.js similarity index 100% rename from apps/stats-mainnet/postcss.config.js rename to apps/stats/postcss.config.js diff --git a/apps/stats-mainnet/project.json b/apps/stats/project.json similarity index 56% rename from apps/stats-mainnet/project.json rename to apps/stats/project.json index e66aa17c6..00ed1918a 100644 --- a/apps/stats-mainnet/project.json +++ b/apps/stats/project.json @@ -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 } } diff --git a/apps/stats-mainnet/src/app.tsx b/apps/stats/src/app.tsx similarity index 90% rename from apps/stats-mainnet/src/app.tsx rename to apps/stats/src/app.tsx index 42aa79564..6ca239e4b 100644 --- a/apps/stats-mainnet/src/app.tsx +++ b/apps/stats/src/app.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { Header } from './components/header'; -import { StatsManager } from '@vegaprotocol/mainnet-stats-manager'; +import { StatsManager } from '@vegaprotocol/network-stats'; function App() { const [darkMode, setDarkMode] = useState( diff --git a/apps/stats-mainnet/src/assets/apple-touch-icon.png b/apps/stats/src/assets/apple-touch-icon.png similarity index 100% rename from apps/stats-mainnet/src/assets/apple-touch-icon.png rename to apps/stats/src/assets/apple-touch-icon.png diff --git a/apps/stats-mainnet/src/assets/favicon.ico b/apps/stats/src/assets/favicon.ico similarity index 100% rename from apps/stats-mainnet/src/assets/favicon.ico rename to apps/stats/src/assets/favicon.ico diff --git a/apps/stats-mainnet/src/assets/logo.png b/apps/stats/src/assets/logo.png similarity index 100% rename from apps/stats-mainnet/src/assets/logo.png rename to apps/stats/src/assets/logo.png diff --git a/apps/stats-mainnet/src/assets/logo192.png b/apps/stats/src/assets/logo192.png similarity index 100% rename from apps/stats-mainnet/src/assets/logo192.png rename to apps/stats/src/assets/logo192.png diff --git a/apps/stats-mainnet/src/assets/manifest.json b/apps/stats/src/assets/manifest.json similarity index 100% rename from apps/stats-mainnet/src/assets/manifest.json rename to apps/stats/src/assets/manifest.json diff --git a/apps/stats-mainnet/src/assets/robots.txt b/apps/stats/src/assets/robots.txt similarity index 100% rename from apps/stats-mainnet/src/assets/robots.txt rename to apps/stats/src/assets/robots.txt diff --git a/apps/stats-mainnet/src/components/header/header.tsx b/apps/stats/src/components/header/header.tsx similarity index 100% rename from apps/stats-mainnet/src/components/header/header.tsx rename to apps/stats/src/components/header/header.tsx diff --git a/apps/stats-mainnet/src/components/header/index.ts b/apps/stats/src/components/header/index.ts similarity index 100% rename from apps/stats-mainnet/src/components/header/index.ts rename to apps/stats/src/components/header/index.ts diff --git a/apps/stats-mainnet/src/components/images/dark-mode-toggle.tsx b/apps/stats/src/components/images/dark-mode-toggle.tsx similarity index 100% rename from apps/stats-mainnet/src/components/images/dark-mode-toggle.tsx rename to apps/stats/src/components/images/dark-mode-toggle.tsx diff --git a/apps/stats-mainnet/src/components/images/index.ts b/apps/stats/src/components/images/index.ts similarity index 100% rename from apps/stats-mainnet/src/components/images/index.ts rename to apps/stats/src/components/images/index.ts diff --git a/apps/stats-mainnet/src/components/images/light-mode-toggle.tsx b/apps/stats/src/components/images/light-mode-toggle.tsx similarity index 100% rename from apps/stats-mainnet/src/components/images/light-mode-toggle.tsx rename to apps/stats/src/components/images/light-mode-toggle.tsx diff --git a/apps/stats-mainnet/src/components/videos/index.ts b/apps/stats/src/components/videos/index.ts similarity index 100% rename from apps/stats-mainnet/src/components/videos/index.ts rename to apps/stats/src/components/videos/index.ts diff --git a/apps/stats-mainnet/src/components/videos/vega-background-video.tsx b/apps/stats/src/components/videos/vega-background-video.tsx similarity index 100% rename from apps/stats-mainnet/src/components/videos/vega-background-video.tsx rename to apps/stats/src/components/videos/vega-background-video.tsx diff --git a/apps/stats-mainnet/src/config/types.ts b/apps/stats/src/config/types.ts similarity index 100% rename from apps/stats-mainnet/src/config/types.ts rename to apps/stats/src/config/types.ts diff --git a/apps/stats-mainnet/src/index.html b/apps/stats/src/index.html similarity index 100% rename from apps/stats-mainnet/src/index.html rename to apps/stats/src/index.html diff --git a/apps/stats-mainnet/src/main.tsx b/apps/stats/src/main.tsx similarity index 90% rename from apps/stats-mainnet/src/main.tsx rename to apps/stats/src/main.tsx index 9ad023d26..08e66f713 100644 --- a/apps/stats-mainnet/src/main.tsx +++ b/apps/stats/src/main.tsx @@ -2,7 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './styles/styles.css'; import App from './app'; -import reportWebVitals from './reportWebVitals'; +import reportWebVitals from './report-web-vitals'; ReactDOM.render( diff --git a/apps/stats-mainnet/src/polyfills.ts b/apps/stats/src/polyfills.ts similarity index 100% rename from apps/stats-mainnet/src/polyfills.ts rename to apps/stats/src/polyfills.ts diff --git a/apps/stats-mainnet/src/react-app-env.d.ts b/apps/stats/src/react-app-env.d.ts similarity index 100% rename from apps/stats-mainnet/src/react-app-env.d.ts rename to apps/stats/src/react-app-env.d.ts diff --git a/apps/stats-mainnet/src/reportWebVitals.ts b/apps/stats/src/report-web-vitals.ts similarity index 100% rename from apps/stats-mainnet/src/reportWebVitals.ts rename to apps/stats/src/report-web-vitals.ts diff --git a/apps/stats-mainnet/src/setupTests.ts b/apps/stats/src/setup-tests.ts similarity index 100% rename from apps/stats-mainnet/src/setupTests.ts rename to apps/stats/src/setup-tests.ts diff --git a/apps/stats-mainnet/src/styles/AlphaLyrae-Medium.woff b/apps/stats/src/styles/AlphaLyrae-Medium.woff similarity index 100% rename from apps/stats-mainnet/src/styles/AlphaLyrae-Medium.woff rename to apps/stats/src/styles/AlphaLyrae-Medium.woff diff --git a/apps/stats-mainnet/src/styles/styles.css b/apps/stats/src/styles/styles.css similarity index 100% rename from apps/stats-mainnet/src/styles/styles.css rename to apps/stats/src/styles/styles.css diff --git a/apps/stats-mainnet/tailwind.config.js b/apps/stats/tailwind.config.js similarity index 100% rename from apps/stats-mainnet/tailwind.config.js rename to apps/stats/tailwind.config.js diff --git a/apps/stats-mainnet/tsconfig.app.json b/apps/stats/tsconfig.app.json similarity index 100% rename from apps/stats-mainnet/tsconfig.app.json rename to apps/stats/tsconfig.app.json diff --git a/apps/stats-mainnet/tsconfig.json b/apps/stats/tsconfig.json similarity index 100% rename from apps/stats-mainnet/tsconfig.json rename to apps/stats/tsconfig.json diff --git a/apps/stats-mainnet/tsconfig.spec.json b/apps/stats/tsconfig.spec.json similarity index 100% rename from apps/stats-mainnet/tsconfig.spec.json rename to apps/stats/tsconfig.spec.json diff --git a/libs/mainnet-stats-manager/README.md b/libs/mainnet-stats-manager/README.md deleted file mode 100644 index 160242035..000000000 --- a/libs/mainnet-stats-manager/README.md +++ /dev/null @@ -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). diff --git a/libs/mainnet-stats-manager/package.json b/libs/mainnet-stats-manager/package.json deleted file mode 100644 index 6eed0f1da..000000000 --- a/libs/mainnet-stats-manager/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@vegaprotocol/mainnet-stats-manager", - "version": "0.0.1" -} diff --git a/libs/mainnet-stats-manager/.babelrc b/libs/network-stats/.babelrc similarity index 100% rename from libs/mainnet-stats-manager/.babelrc rename to libs/network-stats/.babelrc diff --git a/libs/mainnet-stats-manager/.eslintrc.json b/libs/network-stats/.eslintrc.json similarity index 100% rename from libs/mainnet-stats-manager/.eslintrc.json rename to libs/network-stats/.eslintrc.json diff --git a/libs/network-stats/README.md b/libs/network-stats/README.md new file mode 100644 index 000000000..3c86bee7c --- /dev/null +++ b/libs/network-stats/README.md @@ -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). diff --git a/libs/mainnet-stats-manager/jest.config.js b/libs/network-stats/jest.config.js similarity index 60% rename from libs/mainnet-stats-manager/jest.config.js rename to libs/network-stats/jest.config.js index de9ee9926..eaa3fa569 100644 --- a/libs/mainnet-stats-manager/jest.config.js +++ b/libs/network-stats/jest.config.js @@ -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', }; diff --git a/libs/network-stats/package.json b/libs/network-stats/package.json new file mode 100644 index 000000000..b3a1c0e45 --- /dev/null +++ b/libs/network-stats/package.json @@ -0,0 +1,4 @@ +{ + "name": "@vegaprotocol/network-stats", + "version": "0.0.1" +} diff --git a/libs/mainnet-stats-manager/project.json b/libs/network-stats/project.json similarity index 52% rename from libs/mainnet-stats-manager/project.json rename to libs/network-stats/project.json index 2b9cb03a1..97d7836a5 100644 --- a/libs/mainnet-stats-manager/project.json +++ b/libs/network-stats/project.json @@ -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 } } diff --git a/libs/mainnet-stats-manager/src/components/good-threshold-indicator/good-threshold-indicator.tsx b/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx similarity index 100% rename from libs/mainnet-stats-manager/src/components/good-threshold-indicator/good-threshold-indicator.tsx rename to libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx diff --git a/libs/mainnet-stats-manager/src/components/good-threshold-indicator/index.ts b/libs/network-stats/src/components/good-threshold-indicator/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/good-threshold-indicator/index.ts rename to libs/network-stats/src/components/good-threshold-indicator/index.ts diff --git a/libs/mainnet-stats-manager/src/components/promoted-stats-item/index.ts b/libs/network-stats/src/components/promoted-stats-item/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/promoted-stats-item/index.ts rename to libs/network-stats/src/components/promoted-stats-item/index.ts diff --git a/libs/mainnet-stats-manager/src/components/promoted-stats-item/promoted-stats-item.tsx b/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx similarity index 100% rename from libs/mainnet-stats-manager/src/components/promoted-stats-item/promoted-stats-item.tsx rename to libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx diff --git a/libs/mainnet-stats-manager/src/components/promoted-stats/index.ts b/libs/network-stats/src/components/promoted-stats/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/promoted-stats/index.ts rename to libs/network-stats/src/components/promoted-stats/index.ts diff --git a/libs/mainnet-stats-manager/src/components/promoted-stats/promoted-stats.tsx b/libs/network-stats/src/components/promoted-stats/promoted-stats.tsx similarity index 100% rename from libs/mainnet-stats-manager/src/components/promoted-stats/promoted-stats.tsx rename to libs/network-stats/src/components/promoted-stats/promoted-stats.tsx diff --git a/libs/mainnet-stats-manager/src/components/stats-manager/index.ts b/libs/network-stats/src/components/stats-manager/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/stats-manager/index.ts rename to libs/network-stats/src/components/stats-manager/index.ts diff --git a/libs/mainnet-stats-manager/src/components/stats-manager/stats-manager.tsx b/libs/network-stats/src/components/stats-manager/stats-manager.tsx similarity index 63% rename from libs/mainnet-stats-manager/src/components/stats-manager/stats-manager.tsx rename to libs/network-stats/src/components/stats-manager/stats-manager.tsx index 8f01bbae2..fada84816 100644 --- a/libs/mainnet-stats-manager/src/components/stats-manager/stats-manager.tsx +++ b/libs/network-stats/src/components/stats-manager/stats-manager.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useState, useRef } from 'react'; import classnames from 'classnames'; import { statsFields } from '../../config/stats-fields'; import { @@ -14,16 +14,81 @@ interface statsManagerProps { className?: string; } +interface dataSourceProps { + title: string; + stats: string; + nodes: string; +} + +const dataSources = { + mainnet: { + title: 'Mainnet', + stats: 'https://api.token.vega.xyz/statistics', + nodes: 'https://api.token.vega.xyz/nodes-data', + }, + testnet: { + title: 'Testnet', + stats: 'https://lb.testnet.vega.xyz/statistics', + nodes: 'https://lb.testnet.vega.xyz/datanode/rest/nodes-data', + }, + devnet: { + title: 'Devnet', + stats: 'https://n04.d.vega.xyz/datanode/rest/statistics', + nodes: 'https://n04.d.vega.xyz/datanode/rest/nodes-data', + }, + stagnet1: { + title: 'Stagnet 1', + stats: 'https://n03.s.vega.xyz/datanode/rest/statistics', + nodes: 'https://n03.s.vega.xyz/datanode/rest/nodes-data', + }, + stagnet2: { + title: 'Stagnet 2', + stats: 'https://n01.stagnet2.vega.xyz/datanode/rest/statistics', + nodes: 'https://n01.stagnet2.vega.xyz/datanode/rest/nodes-data', + }, +}; + +const getDataSource = () => { + const dataNodeUrl = process.env['NX_VEGA_URL']; + + if (dataNodeUrl) { + if (dataNodeUrl.includes('api')) { + return dataSources.mainnet; + } + + if (dataNodeUrl.includes('testnet')) { + return dataSources.testnet; + } + + if (dataNodeUrl.includes('n04.d')) { + return dataSources.devnet; + } + + if (dataNodeUrl.includes('n03.s.vega')) { + return dataSources.stagnet1; + } + + if (dataNodeUrl.includes('stagnet2')) { + return dataSources.stagnet2; + } + } + + return dataSources.mainnet; +}; + export const StatsManager = ({ className }: statsManagerProps) => { + const dataSource = useRef(getDataSource()); const [data, setData] = useState(null); const [error, setError] = useState(null); useEffect(() => { + getDataSource(); + 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(dataSource.current.stats), + fetch(dataSource.current.nodes), ]); const [{ statistics }, { nodeData }] = await Promise.all([ res1.json(), @@ -79,7 +144,8 @@ export const StatsManager = ({ className }: statsManagerProps) => { return (

- {(error && `/ ${error}`) || (data ? '/ Mainnet' : '/ Connecting...')} + {(error && `/ ${error}`) || + (data ? `/ ${dataSource.current.title}` : '/ Connecting...')}

{data?.promoted ? ( diff --git a/libs/mainnet-stats-manager/src/components/table-row/index.ts b/libs/network-stats/src/components/table-row/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/table-row/index.ts rename to libs/network-stats/src/components/table-row/index.ts diff --git a/libs/mainnet-stats-manager/src/components/table-row/table-row.tsx b/libs/network-stats/src/components/table-row/table-row.tsx similarity index 100% rename from libs/mainnet-stats-manager/src/components/table-row/table-row.tsx rename to libs/network-stats/src/components/table-row/table-row.tsx diff --git a/libs/mainnet-stats-manager/src/components/table/index.ts b/libs/network-stats/src/components/table/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/table/index.ts rename to libs/network-stats/src/components/table/index.ts diff --git a/libs/mainnet-stats-manager/src/components/table/table.tsx b/libs/network-stats/src/components/table/table.tsx similarity index 100% rename from libs/mainnet-stats-manager/src/components/table/table.tsx rename to libs/network-stats/src/components/table/table.tsx diff --git a/libs/mainnet-stats-manager/src/components/tooltip/index.ts b/libs/network-stats/src/components/tooltip/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/components/tooltip/index.ts rename to libs/network-stats/src/components/tooltip/index.ts diff --git a/libs/mainnet-stats-manager/src/components/tooltip/tooltip.tsx b/libs/network-stats/src/components/tooltip/tooltip.tsx similarity index 100% rename from libs/mainnet-stats-manager/src/components/tooltip/tooltip.tsx rename to libs/network-stats/src/components/tooltip/tooltip.tsx diff --git a/libs/mainnet-stats-manager/src/config/stats-fields.ts b/libs/network-stats/src/config/stats-fields.ts similarity index 100% rename from libs/mainnet-stats-manager/src/config/stats-fields.ts rename to libs/network-stats/src/config/stats-fields.ts diff --git a/libs/mainnet-stats-manager/src/config/types.ts b/libs/network-stats/src/config/types.ts similarity index 90% rename from libs/mainnet-stats-manager/src/config/types.ts rename to libs/network-stats/src/config/types.ts index 9a81b709e..95b35052e 100644 --- a/libs/mainnet-stats-manager/src/config/types.ts +++ b/libs/network-stats/src/config/types.ts @@ -18,6 +18,7 @@ export interface Stats { chainId: string; } +// @ts-ignore investigate why series of 'ors' didn't work instead of this 'any' export type value = any; export type goodThreshold = (...args: value[]) => boolean; diff --git a/libs/mainnet-stats-manager/src/index.ts b/libs/network-stats/src/index.ts similarity index 100% rename from libs/mainnet-stats-manager/src/index.ts rename to libs/network-stats/src/index.ts diff --git a/libs/mainnet-stats-manager/tsconfig.json b/libs/network-stats/tsconfig.json similarity index 100% rename from libs/mainnet-stats-manager/tsconfig.json rename to libs/network-stats/tsconfig.json diff --git a/libs/mainnet-stats-manager/tsconfig.lib.json b/libs/network-stats/tsconfig.lib.json similarity index 100% rename from libs/mainnet-stats-manager/tsconfig.lib.json rename to libs/network-stats/tsconfig.lib.json diff --git a/libs/mainnet-stats-manager/tsconfig.spec.json b/libs/network-stats/tsconfig.spec.json similarity index 100% rename from libs/mainnet-stats-manager/tsconfig.spec.json rename to libs/network-stats/tsconfig.spec.json diff --git a/tsconfig.base.json b/tsconfig.base.json index 3315e4bb9..b3bff5ab5 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -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/react-helpers": ["libs/react-helpers/src/index.ts"], "@vegaprotocol/tailwindcss-config": [ "libs/tailwindcss-config/src/index.js" diff --git a/workspace.json b/workspace.json index 4d72aaf7a..578356545 100644 --- a/workspace.json +++ b/workspace.json @@ -5,11 +5,11 @@ "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", "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", From e2a61d26adbb6ab472c549843f176cf7bc0eedd6 Mon Sep 17 00:00:00 2001 From: sam-keen Date: Thu, 24 Mar 2022 14:58:24 +0000 Subject: [PATCH 2/4] Proper way to get environment variables, and hoisted obtaining the env vars to the consumer of the stats manager --- apps/explorer-e2e/.env | 2 + apps/explorer-e2e/.env.devent | 2 + apps/explorer-e2e/.env.mainnet | 2 + apps/explorer-e2e/.env.stagnet1 | 2 + apps/explorer-e2e/.env.stagnet2 | 2 + apps/explorer-e2e/.env.testnet | 2 + apps/explorer/.env.devent | 2 + apps/explorer/.env.local | 2 + apps/explorer/.env.mainnet | 2 + apps/explorer/.env.stagnet1 | 2 + apps/explorer/.env.stagnet2 | 2 + apps/explorer/.env.testnet | 2 + apps/explorer/src/app/config/index.tsx | 2 + apps/explorer/src/app/routes/home/index.tsx | 13 ++- apps/stats-e2e/.env | 3 + apps/stats-e2e/.env.devnet | 3 + apps/stats-e2e/.env.mainnet | 3 + apps/stats-e2e/.env.stagnet1 | 3 + apps/stats-e2e/.env.stagnet2 | 3 + apps/stats-e2e/.env.testnet | 3 + apps/stats-e2e/src/integration/app.spec.ts | 34 +------ apps/stats/.env.devnet | 3 + apps/stats/.env.mainnet | 3 + apps/stats/.env.stagnet1 | 3 + apps/stats/.env.stagnet2 | 3 + apps/stats/.env.testnet | 3 + apps/stats/src/app.tsx | 13 ++- apps/stats/src/config/index.tsx | 4 + .../stats-manager/stats-manager.tsx | 88 ++++--------------- 29 files changed, 105 insertions(+), 106 deletions(-) create mode 100644 apps/stats-e2e/.env create mode 100644 apps/stats-e2e/.env.devnet create mode 100644 apps/stats-e2e/.env.mainnet create mode 100644 apps/stats-e2e/.env.stagnet1 create mode 100644 apps/stats-e2e/.env.stagnet2 create mode 100644 apps/stats-e2e/.env.testnet create mode 100644 apps/stats/.env.devnet create mode 100644 apps/stats/.env.mainnet create mode 100644 apps/stats/.env.stagnet1 create mode 100644 apps/stats/.env.stagnet2 create mode 100644 apps/stats/.env.testnet create mode 100644 apps/stats/src/config/index.tsx diff --git a/apps/explorer-e2e/.env b/apps/explorer-e2e/.env index bf9d3dbbc..ef2059492 100644 --- a/apps/explorer-e2e/.env +++ b/apps/explorer-e2e/.env @@ -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 diff --git a/apps/explorer-e2e/.env.devent b/apps/explorer-e2e/.env.devent index 996011a8e..932a90ac2 100644 --- a/apps/explorer-e2e/.env.devent +++ b/apps/explorer-e2e/.env.devent @@ -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 diff --git a/apps/explorer-e2e/.env.mainnet b/apps/explorer-e2e/.env.mainnet index 13b74ef15..d097f3aa0 100644 --- a/apps/explorer-e2e/.env.mainnet +++ b/apps/explorer-e2e/.env.mainnet @@ -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 diff --git a/apps/explorer-e2e/.env.stagnet1 b/apps/explorer-e2e/.env.stagnet1 index 871afdc6d..1e191685c 100644 --- a/apps/explorer-e2e/.env.stagnet1 +++ b/apps/explorer-e2e/.env.stagnet1 @@ -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 diff --git a/apps/explorer-e2e/.env.stagnet2 b/apps/explorer-e2e/.env.stagnet2 index e4cbaab0d..4d959a05a 100644 --- a/apps/explorer-e2e/.env.stagnet2 +++ b/apps/explorer-e2e/.env.stagnet2 @@ -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 diff --git a/apps/explorer-e2e/.env.testnet b/apps/explorer-e2e/.env.testnet index 5b296d196..95e4b1e16 100644 --- a/apps/explorer-e2e/.env.testnet +++ b/apps/explorer-e2e/.env.testnet @@ -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 diff --git a/apps/explorer/.env.devent b/apps/explorer/.env.devent index 3af139aa8..e90da3e6b 100644 --- a/apps/explorer/.env.devent +++ b/apps/explorer/.env.devent @@ -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' diff --git a/apps/explorer/.env.local b/apps/explorer/.env.local index 5b296d196..95e4b1e16 100644 --- a/apps/explorer/.env.local +++ b/apps/explorer/.env.local @@ -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 diff --git a/apps/explorer/.env.mainnet b/apps/explorer/.env.mainnet index ad8c0ef9d..4bdd55411 100644 --- a/apps/explorer/.env.mainnet +++ b/apps/explorer/.env.mainnet @@ -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/' diff --git a/apps/explorer/.env.stagnet1 b/apps/explorer/.env.stagnet1 index 83cda47ac..e042ac19d 100644 --- a/apps/explorer/.env.stagnet1 +++ b/apps/explorer/.env.stagnet1 @@ -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' diff --git a/apps/explorer/.env.stagnet2 b/apps/explorer/.env.stagnet2 index 05b15b546..c6fd590fe 100644 --- a/apps/explorer/.env.stagnet2 +++ b/apps/explorer/.env.stagnet2 @@ -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' diff --git a/apps/explorer/.env.testnet b/apps/explorer/.env.testnet index 5218200b8..dd89127e2 100644 --- a/apps/explorer/.env.testnet +++ b/apps/explorer/.env.testnet @@ -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' diff --git a/apps/explorer/src/app/config/index.tsx b/apps/explorer/src/app/config/index.tsx index a8e193ed3..0e1833f63 100644 --- a/apps/explorer/src/app/config/index.tsx +++ b/apps/explorer/src/app/config/index.tsx @@ -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, }; diff --git a/apps/explorer/src/app/routes/home/index.tsx b/apps/explorer/src/app/routes/home/index.tsx index fe02a45ba..aba729439 100644 --- a/apps/explorer/src/app/routes/home/index.tsx +++ b/apps/explorer/src/app/routes/home/index.tsx @@ -1,9 +1,20 @@ +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 (
- +
); }; diff --git a/apps/stats-e2e/.env b/apps/stats-e2e/.env new file mode 100644 index 000000000..8cee97c89 --- /dev/null +++ b/apps/stats-e2e/.env @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Testnet' +NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.devnet b/apps/stats-e2e/.env.devnet new file mode 100644 index 000000000..4d9a3fcbe --- /dev/null +++ b/apps/stats-e2e/.env.devnet @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Devnet' +NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.mainnet b/apps/stats-e2e/.env.mainnet new file mode 100644 index 000000000..791b64252 --- /dev/null +++ b/apps/stats-e2e/.env.mainnet @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Mainnet' +NX_VEGA_REST = 'https://api.token.vega.xyz/' diff --git a/apps/stats-e2e/.env.stagnet1 b/apps/stats-e2e/.env.stagnet1 new file mode 100644 index 000000000..259a3fbed --- /dev/null +++ b/apps/stats-e2e/.env.stagnet1 @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Stagnet 1' +NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.stagnet2 b/apps/stats-e2e/.env.stagnet2 new file mode 100644 index 000000000..76a344730 --- /dev/null +++ b/apps/stats-e2e/.env.stagnet2 @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Stagnet 2' +NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.testnet b/apps/stats-e2e/.env.testnet new file mode 100644 index 000000000..8cee97c89 --- /dev/null +++ b/apps/stats-e2e/.env.testnet @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Testnet' +NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/src/integration/app.spec.ts b/apps/stats-e2e/src/integration/app.spec.ts index 1c6b1c020..7ae0dc040 100644 --- a/apps/stats-e2e/src/integration/app.spec.ts +++ b/apps/stats-e2e/src/integration/app.spec.ts @@ -1,37 +1,9 @@ +const textToCheck = process.env['NX_VEGA_ENV']; + describe('stats', () => { beforeEach(() => cy.visit('/')); - let textToCheck = ''; - - const dataNodeUrl = process.env['NX_VEGA_URL']; - - if (dataNodeUrl) { - if (dataNodeUrl.includes('api')) { - textToCheck = 'Mainnet'; - } - - if (dataNodeUrl.includes('testnet')) { - textToCheck = 'Testnet'; - } - - if (dataNodeUrl.includes('n04.d')) { - textToCheck = 'Devnet'; - } - - if (dataNodeUrl.includes('n03.s.vega')) { - textToCheck = 'Stagnet 1'; - } - - if (dataNodeUrl.includes('stagnet2')) { - textToCheck = 'Stagnet 2'; - } - } else { - // Network-stats falls back to showing Mainnet stats if no - // environment variables have been set - textToCheck = 'Mainnet'; - } - - it('should display header based on environment', () => { + it('should display header based on environment name', () => { cy.get('h3').should('have.text', `/ ${textToCheck}`); }); }); diff --git a/apps/stats/.env.devnet b/apps/stats/.env.devnet new file mode 100644 index 000000000..4d9a3fcbe --- /dev/null +++ b/apps/stats/.env.devnet @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Devnet' +NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.mainnet b/apps/stats/.env.mainnet new file mode 100644 index 000000000..791b64252 --- /dev/null +++ b/apps/stats/.env.mainnet @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Mainnet' +NX_VEGA_REST = 'https://api.token.vega.xyz/' diff --git a/apps/stats/.env.stagnet1 b/apps/stats/.env.stagnet1 new file mode 100644 index 000000000..259a3fbed --- /dev/null +++ b/apps/stats/.env.stagnet1 @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Stagnet 1' +NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.stagnet2 b/apps/stats/.env.stagnet2 new file mode 100644 index 000000000..76a344730 --- /dev/null +++ b/apps/stats/.env.stagnet2 @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Stagnet 2' +NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.testnet b/apps/stats/.env.testnet new file mode 100644 index 000000000..8cee97c89 --- /dev/null +++ b/apps/stats/.env.testnet @@ -0,0 +1,3 @@ +# App configuration variables +NX_VEGA_ENV = 'Testnet' +NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats/src/app.tsx b/apps/stats/src/app.tsx index 6ca239e4b..3f01d7596 100644 --- a/apps/stats/src/app.tsx +++ b/apps/stats/src/app.tsx @@ -1,7 +1,13 @@ import React, { useState } from 'react'; +import { DATA_SOURCES } from './config'; import { Header } from './components/header'; 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( document.documentElement.classList.contains('dark-mode-preferred') @@ -15,7 +21,12 @@ function App() { >
- +
); diff --git a/apps/stats/src/config/index.tsx b/apps/stats/src/config/index.tsx new file mode 100644 index 000000000..7aaf89475 --- /dev/null +++ b/apps/stats/src/config/index.tsx @@ -0,0 +1,4 @@ +export const DATA_SOURCES = { + envName: process.env['NX_VEGA_ENV'] as string, + restEndpoint: process.env['NX_VEGA_REST'] as string, +}; diff --git a/libs/network-stats/src/components/stats-manager/stats-manager.tsx b/libs/network-stats/src/components/stats-manager/stats-manager.tsx index fada84816..c7b3a1e40 100644 --- a/libs/network-stats/src/components/stats-manager/stats-manager.tsx +++ b/libs/network-stats/src/components/stats-manager/stats-manager.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState, useRef } from 'react'; +import { useEffect, useState } from 'react'; import classnames from 'classnames'; import { statsFields } from '../../config/stats-fields'; import { @@ -10,85 +10,28 @@ 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; } -interface dataSourceProps { - title: string; - stats: string; - nodes: string; -} - -const dataSources = { - mainnet: { - title: 'Mainnet', - stats: 'https://api.token.vega.xyz/statistics', - nodes: 'https://api.token.vega.xyz/nodes-data', - }, - testnet: { - title: 'Testnet', - stats: 'https://lb.testnet.vega.xyz/statistics', - nodes: 'https://lb.testnet.vega.xyz/datanode/rest/nodes-data', - }, - devnet: { - title: 'Devnet', - stats: 'https://n04.d.vega.xyz/datanode/rest/statistics', - nodes: 'https://n04.d.vega.xyz/datanode/rest/nodes-data', - }, - stagnet1: { - title: 'Stagnet 1', - stats: 'https://n03.s.vega.xyz/datanode/rest/statistics', - nodes: 'https://n03.s.vega.xyz/datanode/rest/nodes-data', - }, - stagnet2: { - title: 'Stagnet 2', - stats: 'https://n01.stagnet2.vega.xyz/datanode/rest/statistics', - nodes: 'https://n01.stagnet2.vega.xyz/datanode/rest/nodes-data', - }, -}; - -const getDataSource = () => { - const dataNodeUrl = process.env['NX_VEGA_URL']; - - if (dataNodeUrl) { - if (dataNodeUrl.includes('api')) { - return dataSources.mainnet; - } - - if (dataNodeUrl.includes('testnet')) { - return dataSources.testnet; - } - - if (dataNodeUrl.includes('n04.d')) { - return dataSources.devnet; - } - - if (dataNodeUrl.includes('n03.s.vega')) { - return dataSources.stagnet1; - } - - if (dataNodeUrl.includes('stagnet2')) { - return dataSources.stagnet2; - } - } - - return dataSources.mainnet; -}; - -export const StatsManager = ({ className }: statsManagerProps) => { - const dataSource = useRef(getDataSource()); +export const StatsManager = ({ + envName, + statsEndpoint, + nodesEndpoint, + className, +}: StatsManagerProps) => { const [data, setData] = useState(null); const [error, setError] = useState(null); useEffect(() => { - getDataSource(); - async function getStats() { try { const [res1, res2] = await Promise.all([ - fetch(dataSource.current.stats), - fetch(dataSource.current.nodes), + fetch(statsEndpoint), + fetch(nodesEndpoint), ]); const [{ statistics }, { nodeData }] = await Promise.all([ res1.json(), @@ -134,7 +77,7 @@ export const StatsManager = ({ className }: statsManagerProps) => { return () => { clearInterval(interval); }; - }, []); + }, [nodesEndpoint, statsEndpoint]); const classes = classnames( className, @@ -144,8 +87,7 @@ export const StatsManager = ({ className }: statsManagerProps) => { return (

- {(error && `/ ${error}`) || - (data ? `/ ${dataSource.current.title}` : '/ Connecting...')} + {(error && `/ ${error}`) || (data ? `/ ${envName}` : '/ Connecting...')}

{data?.promoted ? ( From 13387e4ed49fcf24a4434b40327dfca020ca95ea Mon Sep 17 00:00:00 2001 From: sam-keen Date: Fri, 25 Mar 2022 10:37:16 +0000 Subject: [PATCH 3/4] Uppercase env names in env vars --- apps/stats-e2e/.env | 2 +- apps/stats-e2e/.env.devnet | 2 +- apps/stats-e2e/.env.mainnet | 2 +- apps/stats-e2e/.env.stagnet1 | 2 +- apps/stats-e2e/.env.stagnet2 | 2 +- apps/stats-e2e/.env.testnet | 2 +- apps/stats/.env.devnet | 2 +- apps/stats/.env.mainnet | 2 +- apps/stats/.env.stagnet1 | 2 +- apps/stats/.env.stagnet2 | 2 +- apps/stats/.env.testnet | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/stats-e2e/.env b/apps/stats-e2e/.env index 8cee97c89..6c20d35dd 100644 --- a/apps/stats-e2e/.env +++ b/apps/stats-e2e/.env @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Testnet' +NX_VEGA_ENV = 'TESTNET' NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.devnet b/apps/stats-e2e/.env.devnet index 4d9a3fcbe..b4b50b8a9 100644 --- a/apps/stats-e2e/.env.devnet +++ b/apps/stats-e2e/.env.devnet @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Devnet' +NX_VEGA_ENV = 'DEVNET' NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.mainnet b/apps/stats-e2e/.env.mainnet index 791b64252..55d4d65ea 100644 --- a/apps/stats-e2e/.env.mainnet +++ b/apps/stats-e2e/.env.mainnet @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Mainnet' +NX_VEGA_ENV = 'MAINNET' NX_VEGA_REST = 'https://api.token.vega.xyz/' diff --git a/apps/stats-e2e/.env.stagnet1 b/apps/stats-e2e/.env.stagnet1 index 259a3fbed..a9ec115d3 100644 --- a/apps/stats-e2e/.env.stagnet1 +++ b/apps/stats-e2e/.env.stagnet1 @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Stagnet 1' +NX_VEGA_ENV = 'STAGNET 1' NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.stagnet2 b/apps/stats-e2e/.env.stagnet2 index 76a344730..e19fe0891 100644 --- a/apps/stats-e2e/.env.stagnet2 +++ b/apps/stats-e2e/.env.stagnet2 @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Stagnet 2' +NX_VEGA_ENV = 'STAGNET 2' NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.testnet b/apps/stats-e2e/.env.testnet index 8cee97c89..6c20d35dd 100644 --- a/apps/stats-e2e/.env.testnet +++ b/apps/stats-e2e/.env.testnet @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Testnet' +NX_VEGA_ENV = 'TESTNET' NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.devnet b/apps/stats/.env.devnet index 4d9a3fcbe..b4b50b8a9 100644 --- a/apps/stats/.env.devnet +++ b/apps/stats/.env.devnet @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Devnet' +NX_VEGA_ENV = 'DEVNET' NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.mainnet b/apps/stats/.env.mainnet index 791b64252..55d4d65ea 100644 --- a/apps/stats/.env.mainnet +++ b/apps/stats/.env.mainnet @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Mainnet' +NX_VEGA_ENV = 'MAINNET' NX_VEGA_REST = 'https://api.token.vega.xyz/' diff --git a/apps/stats/.env.stagnet1 b/apps/stats/.env.stagnet1 index 259a3fbed..a9ec115d3 100644 --- a/apps/stats/.env.stagnet1 +++ b/apps/stats/.env.stagnet1 @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Stagnet 1' +NX_VEGA_ENV = 'STAGNET 1' NX_VEGA_REST = 'https://n03.s.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.stagnet2 b/apps/stats/.env.stagnet2 index 76a344730..e19fe0891 100644 --- a/apps/stats/.env.stagnet2 +++ b/apps/stats/.env.stagnet2 @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Stagnet 2' +NX_VEGA_ENV = 'STAGNET 2' NX_VEGA_REST = 'https://n01.stagnet2.vega.xyz/datanode/rest' diff --git a/apps/stats/.env.testnet b/apps/stats/.env.testnet index 8cee97c89..6c20d35dd 100644 --- a/apps/stats/.env.testnet +++ b/apps/stats/.env.testnet @@ -1,3 +1,3 @@ # App configuration variables -NX_VEGA_ENV = 'Testnet' +NX_VEGA_ENV = 'TESTNET' NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' From 4862b0a1c39cf18f8af76e43e2092344e2a5fa2f Mon Sep 17 00:00:00 2001 From: sam-keen Date: Fri, 25 Mar 2022 10:42:40 +0000 Subject: [PATCH 4/4] Added cypress env name var for tests --- apps/stats-e2e/.env | 1 + apps/stats-e2e/.env.devnet | 1 + apps/stats-e2e/.env.mainnet | 1 + apps/stats-e2e/.env.stagnet1 | 1 + apps/stats-e2e/.env.stagnet2 | 1 + apps/stats-e2e/.env.testnet | 1 + apps/stats-e2e/src/integration/app.spec.ts | 2 +- 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/stats-e2e/.env b/apps/stats-e2e/.env index 6c20d35dd..2ffc8e07a 100644 --- a/apps/stats-e2e/.env +++ b/apps/stats-e2e/.env @@ -1,3 +1,4 @@ # App configuration variables NX_VEGA_ENV = 'TESTNET' +CYPRESS_VEGA_ENV = 'TESTNET' NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.devnet b/apps/stats-e2e/.env.devnet index b4b50b8a9..d07477535 100644 --- a/apps/stats-e2e/.env.devnet +++ b/apps/stats-e2e/.env.devnet @@ -1,3 +1,4 @@ # App configuration variables NX_VEGA_ENV = 'DEVNET' +CYPRESS_VEGA_ENV = 'DEVNET' NX_VEGA_REST = 'https://n04.d.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/.env.mainnet b/apps/stats-e2e/.env.mainnet index 55d4d65ea..6269ea3e4 100644 --- a/apps/stats-e2e/.env.mainnet +++ b/apps/stats-e2e/.env.mainnet @@ -1,3 +1,4 @@ # App configuration variables NX_VEGA_ENV = 'MAINNET' +CYPRESS_VEGA_ENV = 'MAINNET' NX_VEGA_REST = 'https://api.token.vega.xyz/' diff --git a/apps/stats-e2e/.env.stagnet1 b/apps/stats-e2e/.env.stagnet1 index a9ec115d3..f382a1675 100644 --- a/apps/stats-e2e/.env.stagnet1 +++ b/apps/stats-e2e/.env.stagnet1 @@ -1,3 +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' diff --git a/apps/stats-e2e/.env.stagnet2 b/apps/stats-e2e/.env.stagnet2 index e19fe0891..96d28ba03 100644 --- a/apps/stats-e2e/.env.stagnet2 +++ b/apps/stats-e2e/.env.stagnet2 @@ -1,3 +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' diff --git a/apps/stats-e2e/.env.testnet b/apps/stats-e2e/.env.testnet index 6c20d35dd..2ffc8e07a 100644 --- a/apps/stats-e2e/.env.testnet +++ b/apps/stats-e2e/.env.testnet @@ -1,3 +1,4 @@ # App configuration variables NX_VEGA_ENV = 'TESTNET' +CYPRESS_VEGA_ENV = 'TESTNET' NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' diff --git a/apps/stats-e2e/src/integration/app.spec.ts b/apps/stats-e2e/src/integration/app.spec.ts index 7ae0dc040..6ae926aed 100644 --- a/apps/stats-e2e/src/integration/app.spec.ts +++ b/apps/stats-e2e/src/integration/app.spec.ts @@ -1,4 +1,4 @@ -const textToCheck = process.env['NX_VEGA_ENV']; +const textToCheck = Cypress.env('VEGA_ENV'); describe('stats', () => { beforeEach(() => cy.visit('/'));