From 836c232a1c7c2b95fa7ef0cda812a9a29761148b Mon Sep 17 00:00:00 2001 From: botond <105208209+notbot00@users.noreply.github.com> Date: Wed, 6 Jul 2022 16:53:35 +0100 Subject: [PATCH 1/3] Feat/675: Git info (#683) * feat: add network-switcher lib * feat: add env variables for some deployed app urls * feat: add network processing to environment hoook * refactor: network handling * refactor: remove dialog from provider and add env setter * feat: add network switcher dialog to the trading app * refactor: add network redirect to dialog connect callback * fix: lint * feat: add network configuration files to static app * feat: update environments to use config file instead of static node url * refactor: split out network switcher utils * refactor: split up environment hook * fix: jsonify env variable for possible networks * fix: add formatter file * feat: add network loader component * feat: add network loader to the trading app * fix: assign correct global state to network swicther * feat: add status modal * feat: add network-switcher lib * feat: add env variables for some deployed app urls * feat: add network processing to environment hoook * refactor: network handling * refactor: remove dialog from provider and add env setter * feat: add network switcher dialog to the trading app * refactor: add network redirect to dialog connect callback * fix: lint * fix: jsonify env variable for possible networks * fix: add formatter file * fix: assign correct global state to network swicther * fix: failing tests from UI changes * feat: add environment validation * feat: add runtime validation for network configs * fix: readd node urls to envs to avoid breaking the apps for now * chore: rename network swicther lib to environmnet * fix: lint * feat: add tests for config hook * feat: add environment hook tests * fix: lint * fix: lint * feat: add environment hook tests * feat: add storage tests * fix: formet * feat: improve loading states * fix: format * fix: use router instead of window location * fix: rearrange network loader props and components * fix: remove FC type * fix: env validation * fix: untangle returns in network loader * fix: add teardown for env and localstorage * fix: add custom to env networks * fix: lint * fix: format * fix: lint * fix: remove env provider from simple trading app * fix: remove failing promise hacks * fix: some leftover format files * fix: remove network switcher from tsconf * fix: move Networks to libs/environment * fix: add defaults for ether env vars * feat: add tests for default ether env vars * fix: remove chain id env var from web3 container * fix: remove chain id from the environment * fix: format * fix: lint token * fix: lint env * fix: add comment to callout hack * fix: lint token again * fix: remove skip * fix: move addresses to token app * fix: improve schema validation errors and fix token app * fix: lint * fix: format * fix: format * fix: add network loaders to apps * fix: format * fix: remove logs * fix: cypress process errors * fix: change network loader hierarchy in token * fix: remove stray console.log * fix: revert test changes in simple trading app * fix: prefix env vars with NX Co-authored-by: Dexter Edwards * fix: improve schema validation errors and fix token app * fix: format * fix: disable lint rules for catch block any types * fix: format again * fix: remove redundant process.platform injections * fix: format * feat: add explorer footer * fix: format * feat: add custom executor for next * feat: adjust footer links and add custom executors * fix: lint and format * fix: format again * fix: add explicit github feedback url * fix: create footer lib * feat: add footer to token app * fix: add compiled file to ignore * fix: make lozenge styling more flexible when no variant specified * fix: remove schema duplication for third party executors * fix: add missing intent variant for the lozenge * fix: move commit hash in footer down two positions * fix: revert breaking schema removals * fix: format * chore: rename footer to network-info * fix: format Co-authored-by: Joe Co-authored-by: Matthew Russell Co-authored-by: Dexter Edwards --- .gitignore | 1 + apps/explorer/.env | 1 + apps/explorer/.env.capsule | 1 + apps/explorer/.env.devnet | 1 + apps/explorer/.env.mainnet | 1 + apps/explorer/.env.stagnet1 | 1 + apps/explorer/.env.stagnet2 | 1 + apps/explorer/.env.testnet | 1 + apps/explorer/.env.vegacapsule | 1 + apps/explorer/project.json | 4 +- apps/explorer/src/app/app.tsx | 4 + .../src/app/components/txs/tx-order-type.tsx | 4 +- apps/explorer/webpack.config.js | 18 +- apps/simple-trading-app/project.json | 4 +- apps/static/project.json | 4 +- apps/stats/project.json | 4 +- apps/token/.env | 1 + apps/token/.env.capsule | 1 + apps/token/.env.devnet | 1 + apps/token/.env.mainnet | 1 + apps/token/.env.stagnet1 | 1 + apps/token/.env.stagnet2 | 1 + apps/token/.env.testnet | 1 + apps/token/project.json | 4 +- apps/token/src/app.tsx | 6 +- .../src/components/app-footer/app-footer.tsx | 28 -- apps/token/src/components/app-footer/index.ts | 1 - .../components/token-input/token-input.tsx | 5 +- apps/trading/README.md | 6 + .../web3-container/web3-container.spec.tsx | 10 +- apps/trading/project.json | 4 +- .../src/hooks/use-environment.spec.tsx | 9 + .../src/utils/compile-environment.ts | 8 + .../src/utils/validate-environment.ts | 4 + libs/network-info/.babelrc | 12 + libs/network-info/.eslintrc.json | 18 + libs/network-info/README.md | 21 + libs/network-info/jest.config.js | 9 + libs/network-info/package.json | 4 + libs/network-info/project.json | 43 +++ libs/network-info/src/index.ts | 1 + libs/network-info/src/network-info.tsx | 87 +++++ libs/network-info/tsconfig.json | 25 ++ libs/network-info/tsconfig.lib.json | 22 ++ libs/network-info/tsconfig.spec.json | 19 + libs/smart-contracts/package.json | 3 +- .../components/lozenge/lozenge.stories.tsx | 5 + .../src/components/lozenge/lozenge.tsx | 10 +- libs/ui-toolkit/src/utils/intent.tsx | 2 +- tools/executors/next/build/impl.ts | 18 + tools/executors/next/build/schema.json | 50 +++ tools/executors/next/executor.json | 14 + tools/executors/{serve => next}/package.json | 0 tools/executors/next/serve/impl.ts | 18 + tools/executors/next/serve/schema.json | 54 +++ tools/executors/{serve => next}/tsconfig.json | 2 +- tools/executors/serve/executor.json | 9 - tools/executors/webpack/build/impl.ts | 19 + tools/executors/webpack/build/schema.json | 359 ++++++++++++++++++ tools/executors/webpack/executor.json | 14 + tools/executors/webpack/package.json | 3 + tools/executors/webpack/serve/impl.ts | 19 + .../executors/{ => webpack}/serve/schema.json | 0 tools/executors/webpack/tsconfig.json | 13 + .../impl.ts => utils/setup-environment.ts} | 53 +-- tsconfig.base.json | 1 + workspace.json | 1 + 67 files changed, 979 insertions(+), 92 deletions(-) delete mode 100644 apps/token/src/components/app-footer/app-footer.tsx delete mode 100644 apps/token/src/components/app-footer/index.ts create mode 100644 libs/network-info/.babelrc create mode 100644 libs/network-info/.eslintrc.json create mode 100644 libs/network-info/README.md create mode 100644 libs/network-info/jest.config.js create mode 100644 libs/network-info/package.json create mode 100644 libs/network-info/project.json create mode 100644 libs/network-info/src/index.ts create mode 100644 libs/network-info/src/network-info.tsx create mode 100644 libs/network-info/tsconfig.json create mode 100644 libs/network-info/tsconfig.lib.json create mode 100644 libs/network-info/tsconfig.spec.json create mode 100644 tools/executors/next/build/impl.ts create mode 100644 tools/executors/next/build/schema.json create mode 100644 tools/executors/next/executor.json rename tools/executors/{serve => next}/package.json (100%) create mode 100644 tools/executors/next/serve/impl.ts create mode 100644 tools/executors/next/serve/schema.json rename tools/executors/{serve => next}/tsconfig.json (83%) delete mode 100644 tools/executors/serve/executor.json create mode 100644 tools/executors/webpack/build/impl.ts create mode 100644 tools/executors/webpack/build/schema.json create mode 100644 tools/executors/webpack/executor.json create mode 100644 tools/executors/webpack/package.json create mode 100644 tools/executors/webpack/serve/impl.ts rename tools/executors/{ => webpack}/serve/schema.json (100%) create mode 100644 tools/executors/webpack/tsconfig.json rename tools/{executors/serve/impl.ts => utils/setup-environment.ts} (65%) diff --git a/.gitignore b/.gitignore index bcd8b0059..6f14d09b0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /tmp /out-tsc /tools/executors/**/*.js +/tools/utils/*.js # dependencies /node_modules diff --git a/apps/explorer/.env b/apps/explorer/.env index a978e7639..b6b59b054 100644 --- a/apps/explorer/.env +++ b/apps/explorer/.env @@ -13,6 +13,7 @@ NX_VEGA_ENV=TESTNET NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' CYPRESS_VEGA_TENDERMINT_URL=https://lb.testnet.vega.xyz/tm +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions # App flags NX_EXPLORER_ASSETS=1 diff --git a/apps/explorer/.env.capsule b/apps/explorer/.env.capsule index e9cd02f8c..e603825a6 100644 --- a/apps/explorer/.env.capsule +++ b/apps/explorer/.env.capsule @@ -6,6 +6,7 @@ NX_VEGA_URL=http://localhost:3028/query NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' NX_VEGA_ENV=CUSTOM NX_VEGA_REST=http://localhost:3029 +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions # App flags NX_EXPLORER_ASSETS=1 diff --git a/apps/explorer/.env.devnet b/apps/explorer/.env.devnet index c5c245622..738e500ad 100644 --- a/apps/explorer/.env.devnet +++ b/apps/explorer/.env.devnet @@ -7,3 +7,4 @@ NX_VEGA_URL=https://n04.d.vega.xyz/query NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' NX_VEGA_ENV=DEVNET NX_VEGA_REST=https://n04.d.vega.xyz/datanode/rest +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/.env.mainnet b/apps/explorer/.env.mainnet index 721af8681..bdfcded65 100644 --- a/apps/explorer/.env.mainnet +++ b/apps/explorer/.env.mainnet @@ -7,3 +7,4 @@ NX_VEGA_URL=https://api.token.vega.xyz/query NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' NX_VEGA_ENV=MAINNET NX_VEGA_REST=https://api.token.vega.xyz/ +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/.env.stagnet1 b/apps/explorer/.env.stagnet1 index 7a7359f9d..164257d9c 100644 --- a/apps/explorer/.env.stagnet1 +++ b/apps/explorer/.env.stagnet1 @@ -7,3 +7,4 @@ NX_VEGA_URL=https://n03.s.vega.xyz/query NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' NX_VEGA_ENV=STAGNET NX_VEGA_REST=https://n03.s.vega.xyz/datanode/rest +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/.env.stagnet2 b/apps/explorer/.env.stagnet2 index 38baff594..a55708673 100644 --- a/apps/explorer/.env.stagnet2 +++ b/apps/explorer/.env.stagnet2 @@ -7,3 +7,4 @@ NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' NX_VEGA_ENV=STAGNET2 NX_VEGA_REST=https://n01.stagnet2.vega.xyz/datanode/rest +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/.env.testnet b/apps/explorer/.env.testnet index 750098142..68a985352 100644 --- a/apps/explorer/.env.testnet +++ b/apps/explorer/.env.testnet @@ -7,3 +7,4 @@ NX_VEGA_URL=https://lb.testnet.vega.xyz/query NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' NX_VEGA_ENV=TESTNET NX_VEGA_REST=https://lb.testnet.vega.xyz/datanode/rest +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/.env.vegacapsule b/apps/explorer/.env.vegacapsule index b15ae01ae..348f7604d 100644 --- a/apps/explorer/.env.vegacapsule +++ b/apps/explorer/.env.vegacapsule @@ -5,3 +5,4 @@ NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26607/websocket NX_VEGA_URL=http://localhost:3003/query NX_VEGA_ENV=CUSTOM NX_VEGA_REST=http://localhost:3029/rest +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/project.json b/apps/explorer/project.json index a97dc0c4d..62df33978 100644 --- a/apps/explorer/project.json +++ b/apps/explorer/project.json @@ -4,7 +4,7 @@ "projectType": "application", "targets": { "build": { - "executor": "@nrwl/web:webpack", + "executor": "./tools/executors/webpack:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "options": { @@ -38,7 +38,7 @@ } }, "serve": { - "executor": "./tools/executors/serve:serve", + "executor": "./tools/executors/webpack:serve", "options": { "port": 3000, "buildTarget": "explorer:build", diff --git a/apps/explorer/src/app/app.tsx b/apps/explorer/src/app/app.tsx index 088ae5594..da2cd690c 100644 --- a/apps/explorer/src/app/app.tsx +++ b/apps/explorer/src/app/app.tsx @@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'; import { useLocation } from 'react-router-dom'; import { ThemeContext, useThemeSwitcher } from '@vegaprotocol/react-helpers'; import { EnvironmentProvider, NetworkLoader } from '@vegaprotocol/environment'; +import { NetworkInfo } from '@vegaprotocol/network-info'; import { createClient } from './lib/apollo-client'; import { Nav } from './components/nav'; import { Header } from './components/header'; @@ -36,6 +37,9 @@ function App() { />