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 032d9254b..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 { 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 (
- +
); }; diff --git a/apps/stats-e2e/.env b/apps/stats-e2e/.env new file mode 100644 index 000000000..2ffc8e07a --- /dev/null +++ b/apps/stats-e2e/.env @@ -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' diff --git a/apps/stats-e2e/.env.devnet b/apps/stats-e2e/.env.devnet new file mode 100644 index 000000000..d07477535 --- /dev/null +++ b/apps/stats-e2e/.env.devnet @@ -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' diff --git a/apps/stats-e2e/.env.mainnet b/apps/stats-e2e/.env.mainnet new file mode 100644 index 000000000..6269ea3e4 --- /dev/null +++ b/apps/stats-e2e/.env.mainnet @@ -0,0 +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 new file mode 100644 index 000000000..f382a1675 --- /dev/null +++ b/apps/stats-e2e/.env.stagnet1 @@ -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' diff --git a/apps/stats-e2e/.env.stagnet2 b/apps/stats-e2e/.env.stagnet2 new file mode 100644 index 000000000..96d28ba03 --- /dev/null +++ b/apps/stats-e2e/.env.stagnet2 @@ -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' diff --git a/apps/stats-e2e/.env.testnet b/apps/stats-e2e/.env.testnet new file mode 100644 index 000000000..2ffc8e07a --- /dev/null +++ b/apps/stats-e2e/.env.testnet @@ -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' 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..6ae926aed --- /dev/null +++ b/apps/stats-e2e/src/integration/app.spec.ts @@ -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}`); + }); +}); 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/.env.devnet b/apps/stats/.env.devnet new file mode 100644 index 000000000..b4b50b8a9 --- /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..55d4d65ea --- /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..a9ec115d3 --- /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..e19fe0891 --- /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..6c20d35dd --- /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-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 75% rename from apps/stats-mainnet/jest.config.js rename to apps/stats/jest.config.js index 9d114d295..f9632ad16 100644 --- a/apps/stats-mainnet/jest.config.js +++ b/apps/stats/jest.config.js @@ -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'], }; 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 55% rename from apps/stats-mainnet/src/app.tsx rename to apps/stats/src/app.tsx index 42aa79564..3f01d7596 100644 --- a/apps/stats-mainnet/src/app.tsx +++ b/apps/stats/src/app.tsx @@ -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( @@ -15,7 +21,12 @@ function App() { >
- +
); 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/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/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 100% rename from apps/stats-mainnet/src/main.tsx rename to apps/stats/src/main.tsx 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/report-web-vitals.ts b/apps/stats/src/report-web-vitals.ts similarity index 100% rename from apps/stats-mainnet/src/report-web-vitals.ts rename to apps/stats/src/report-web-vitals.ts diff --git a/apps/stats-mainnet/src/setup-tests.ts b/apps/stats/src/setup-tests.ts similarity index 100% rename from apps/stats-mainnet/src/setup-tests.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 88% 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..c7b3a1e40 100644 --- a/libs/mainnet-stats-manager/src/components/stats-manager/stats-manager.tsx +++ b/libs/network-stats/src/components/stats-manager/stats-manager.tsx @@ -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(null); const [error, setError] = useState(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 (

- {(error && `/ ${error}`) || (data ? '/ Mainnet' : '/ Connecting...')} + {(error && `/ ${error}`) || (data ? `/ ${envName}` : '/ 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 100% rename from libs/mainnet-stats-manager/src/config/types.ts rename to libs/network-stats/src/config/types.ts 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 55dd28414..9ca955a42 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/order-list": ["libs/order-list/src/index.ts"], "@vegaprotocol/react-helpers": ["libs/react-helpers/src/index.ts"], "@vegaprotocol/tailwindcss-config": [ diff --git a/workspace.json b/workspace.json index 9ae846565..271efd4cf 100644 --- a/workspace.json +++ b/workspace.json @@ -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",