Merge branch 'master' of github.com:vegaprotocol/frontend-monorepo into chore/657-move-all-order-hooks-into-order-list-lib-refactor-the-lib-and-handle-unsubscribe

This commit is contained in:
madalinaraicu
2022-07-06 23:08:19 +03:00
73 changed files with 1060 additions and 120 deletions
+1
View File
@@ -5,6 +5,7 @@
/tmp
/out-tsc
/tools/executors/**/*.js
/tools/utils/*.js
# dependencies
/node_modules
+1
View File
@@ -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
+1
View File
@@ -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
+1
View File
@@ -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
+1
View File
@@ -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
+1
View File
@@ -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
+1
View File
@@ -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
+1
View File
@@ -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
+1
View File
@@ -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
+2 -2
View File
@@ -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",
+4
View File
@@ -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() {
/>
<Nav menuOpen={menuOpen} />
<Main />
<footer className="grid grid-rows-2 grid-cols-[1fr_auto] md:flex md:col-span-2 p-16 gap-12 border-t-1">
<NetworkInfo />
</footer>
</div>
</div>
</NetworkLoader>
@@ -1,4 +1,4 @@
import { Lozenge } from '@vegaprotocol/ui-toolkit';
import { Lozenge, Intent } from '@vegaprotocol/ui-toolkit';
interface TxOrderTypeProps {
orderType: string;
@@ -36,7 +36,7 @@ const displayString: StringMap = {
export const TxOrderType = ({ orderType, className }: TxOrderTypeProps) => {
return (
<Lozenge data-testid="tx-type" className={className}>
<Lozenge data-testid="tx-type" variant={Intent.None} className={className}>
{displayString[orderType] || orderType}
</Lozenge>
);
+17 -1
View File
@@ -1,5 +1,13 @@
const { execSync } = require('child_process');
const webpack = require('webpack');
const SentryPlugin = require('@sentry/webpack-plugin');
const gitCommitHash = execSync('git rev-parse HEAD').toString();
const gitOriginUrl = execSync('git remote get-url origin')
.toString()
.replace('ssh://git@github.com', 'https://github.com')
.replace('.git', '');
module.exports = (config, context) => {
const additionalPlugins = process.env.SENTRY_AUTH_TOKEN
? [
@@ -9,8 +17,16 @@ module.exports = (config, context) => {
}),
]
: [];
return {
...config,
plugins: [...additionalPlugins, ...config.plugins],
plugins: [
...additionalPlugins,
...config.plugins,
new webpack.DefinePlugin({
'process.env.GIT_COMMIT_HASH': JSON.stringify(gitCommitHash),
'process.env.GIT_ORIGIN_URL': JSON.stringify(gitOriginUrl),
}),
],
};
};
+2 -2
View File
@@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"executor": "./tools/executors/webpack:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
@@ -41,7 +41,7 @@
}
},
"serve": {
"executor": "./tools/executors/serve:serve",
"executor": "./tools/executors/webpack:serve",
"options": {
"buildTarget": "simple-trading-app:build",
"hmr": true,
+2 -2
View File
@@ -5,7 +5,7 @@
"tags": [],
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"executor": "./tools/executors/webpack:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
@@ -36,7 +36,7 @@
}
},
"serve": {
"executor": "./tools/executors/serve:serve",
"executor": "./tools/executors/webpack:serve",
"options": {
"buildTarget": "static:build"
},
+72 -25
View File
@@ -1,4 +1,15 @@
[
{
"tranche_id": 37,
"tranche_start": "2023-12-01T00:00:00.000Z",
"tranche_end": "2024-06-01T00:00:00.000Z",
"total_added": "0",
"total_removed": "0",
"locked_amount": "0",
"deposits": [],
"withdrawals": [],
"users": []
},
{
"tranche_id": 34,
"tranche_start": "2023-02-01T00:00:00.000Z",
@@ -38,7 +49,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45",
"total_removed": "0",
"locked_amount": "122525.88191307405523764",
"locked_amount": "122466.80073900039814872",
"deposits": [
{
"amount": "129999.45",
@@ -488,7 +499,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "97499.58",
"total_removed": "0",
"locked_amount": "63408.677977456246568808",
"locked_amount": "63350.724849350300362722",
"deposits": [
{
"amount": "97499.58",
@@ -521,7 +532,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "135173.4239508",
"total_removed": "0",
"locked_amount": "86668.7157436153793667123126",
"locked_amount": "86589.50382268472509769865816",
"deposits": [
{
"amount": "135173.4239508",
@@ -554,7 +565,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "32499.86",
"total_removed": "0",
"locked_amount": "26674.935815817434593716",
"locked_amount": "26650.55593562025863175",
"deposits": [
{
"amount": "32499.86",
@@ -587,7 +598,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "10833.29",
"total_removed": "0",
"locked_amount": "8682.432760598448293026",
"locked_amount": "8674.497346171023969862",
"deposits": [
{
"amount": "10833.29",
@@ -675,7 +686,7 @@
"tranche_end": "2022-11-01T00:00:00.000Z",
"total_added": "22500",
"total_removed": "0",
"locked_amount": "14367.70550271739275",
"locked_amount": "14337.2509057971",
"deposits": [
{
"amount": "15000",
@@ -761,7 +772,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38",
"total_removed": "179856.049568108351",
"locked_amount": "1756543.510335156074478674",
"locked_amount": "1755219.836474145062276528",
"deposits": [
{
"amount": "1852091.69",
@@ -1813,7 +1824,7 @@
"tranche_end": "2022-09-30T00:00:00.000Z",
"total_added": "60916.66666633337",
"total_removed": "18705.279504739679372649",
"locked_amount": "13354.1677201311160318987416746646",
"locked_amount": "13315.2668169578522600229503068401",
"deposits": [
{
"amount": "2833.333333",
@@ -5318,7 +5329,7 @@
"tranche_end": "2022-09-03T00:00:00.000Z",
"total_added": "20311.000000000000000003",
"total_removed": "5187.51372516574",
"locked_amount": "3255.09666114916259006048078824200913238",
"locked_amount": "3241.23783003551563746047874124809741258",
"deposits": [
{
"amount": "75",
@@ -14553,7 +14564,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671",
"total_removed": "74162.9780761646031",
"locked_amount": "2723697.13661887299132612574",
"locked_amount": "2721663.11074879027293132555",
"deposits": [
{
"amount": "1998.95815",
@@ -15266,7 +15277,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15788853.065470999700000001",
"total_removed": "11195.65691145297525",
"locked_amount": "14881164.0837155619830244285340222114922952",
"locked_amount": "14873988.4843081453633432078837374189997296",
"deposits": [
{
"amount": "16249.93",
@@ -17461,7 +17472,7 @@
"tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999",
"total_removed": "2162841.750437521949647427",
"locked_amount": "8087447.37813225081972067489407",
"locked_amount": "8080788.82097691197493835968265707",
"deposits": [
{
"amount": "129284.449",
@@ -21707,7 +21718,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "5778205.3912159303",
"total_removed": "1421861.163897427556121727",
"locked_amount": "2878495.96803438305018477854769064",
"locked_amount": "2875865.131831691205593016179856649",
"deposits": [
{
"amount": "552496.6455",
@@ -22873,8 +22884,8 @@
"tranche_start": "2022-06-05T00:00:00.000Z",
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996",
"total_removed": "140.729826224",
"locked_amount": "431585.3806138542538319180517504",
"total_removed": "175.452149916",
"locked_amount": "431263.077587752090875320573313",
"deposits": [
{
"amount": "3000",
@@ -29522,6 +29533,11 @@
"amount": "34.361998984",
"user": "0xd2033db9c5370aC76ABD80823b5c5adC097E2FBF",
"tx": "0x70c8e4da3ecd0547daf42a0493a12429e973ded0ae1ae730fe71fe60be654996"
},
{
"amount": "34.722323692",
"user": "0x4eD2b3c68BB4fda084ce1591a210F4aC8b71234A",
"tx": "0x5de09bdb9cd98c5ca24bff1c625a68bb038613e0041103b4a637528a2eda5d5c"
}
],
"users": [
@@ -41227,10 +41243,17 @@
"tx": "0x716a7be06da5a7a3d8038907974887a31805ea8eeab5d130cba528e4d2094d9f"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "34.722323692",
"user": "0x4eD2b3c68BB4fda084ce1591a210F4aC8b71234A",
"tranche_id": 5,
"tx": "0x5de09bdb9cd98c5ca24bff1c625a68bb038613e0041103b4a637528a2eda5d5c"
}
],
"total_tokens": "400",
"withdrawn_tokens": "0",
"remaining_tokens": "400"
"withdrawn_tokens": "34.722323692",
"remaining_tokens": "365.277676308"
},
{
"address": "0x5c90765F50629570738fEe7b7FA82ae118f81Ed1",
@@ -48600,7 +48623,7 @@
"tranche_start": "2021-12-05T00:00:00.000Z",
"tranche_end": "2022-06-05T00:00:00.000Z",
"total_added": "171288.42",
"total_removed": "33318.5750837656377",
"total_removed": "33607.5750837656377",
"locked_amount": "0",
"deposits": [
{
@@ -52960,6 +52983,16 @@
"user": "0xEE525a275D1f54C22CCCf1a3314F13C712D7F3a8",
"tx": "0x2c76c34c8f292a704fcd454994f2f0aed24b411a3a447bd31676a25583513f58"
},
{
"amount": "200",
"user": "0x435B4D14fFaC8FCB4c1E2AF8c46Dd074a69766b7",
"tx": "0xa592d9280fc83d773e5f9c409c6d8f20d0605b1b3d8ff936530016ebfdc494af"
},
{
"amount": "89",
"user": "0xeB7A9ab2b001254f9Af59E433BBA04f420D8123C",
"tx": "0xf15500ca615c0b7acaf7810ac1b64ebb3728ba4c692c159419ed1753fbb662d7"
},
{
"amount": "183.6335597275",
"user": "0x690Fc36d52eD3f198F0eBDea1557333a1766f786",
@@ -60860,10 +60893,17 @@
"tx": "0x96a22c369645e8945b4047374a05332f4054b50a492c43092e8bb8e974a006b9"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "89",
"user": "0xeB7A9ab2b001254f9Af59E433BBA04f420D8123C",
"tranche_id": 6,
"tx": "0xf15500ca615c0b7acaf7810ac1b64ebb3728ba4c692c159419ed1753fbb662d7"
}
],
"total_tokens": "89",
"withdrawn_tokens": "0",
"remaining_tokens": "89"
"withdrawn_tokens": "89",
"remaining_tokens": "0"
},
{
"address": "0x98Bee53140E3f45CD38aED787588DD95b8198d20",
@@ -67059,10 +67099,17 @@
"tx": "0xb59405747c8088945a412703637a7b422f3639439ec2ee15e180c0a2a0d71ee4"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "200",
"user": "0x435B4D14fFaC8FCB4c1E2AF8c46Dd074a69766b7",
"tranche_id": 6,
"tx": "0xa592d9280fc83d773e5f9c409c6d8f20d0605b1b3d8ff936530016ebfdc494af"
}
],
"total_tokens": "200",
"withdrawn_tokens": "0",
"remaining_tokens": "200"
"withdrawn_tokens": "200",
"remaining_tokens": "0"
},
{
"address": "0x3DB21955A90F83AafD568ecAf55b7CEe52F88BcE",
@@ -38,7 +38,7 @@
"tranche_end": "2022-11-26T13:48:10.000Z",
"total_added": "100",
"total_removed": "0",
"locked_amount": "39.19756468797565",
"locked_amount": "39.12932838660579",
"deposits": [
{
"amount": "100",
@@ -242,7 +242,7 @@
"tranche_end": "2022-10-12T00:53:20.000Z",
"total_added": "1100",
"total_removed": "673.04388635",
"locked_amount": "293.93516615930995",
"locked_amount": "293.18456684424149",
"deposits": [
{
"amount": "1000",
+1 -1
View File
@@ -69,7 +69,7 @@
"tranche_end": "2022-10-12T00:53:20.000Z",
"total_added": "1010.000000000000000001",
"total_removed": "668.4622323651",
"locked_amount": "269.8859252917300450002672137874175545",
"locked_amount": "269.1967706747843790002665314561136479",
"deposits": [
{
"amount": "1000",
+2 -2
View File
@@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"executor": "./tools/executors/webpack:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
@@ -37,7 +37,7 @@
}
},
"serve": {
"executor": "./tools/executors/serve:serve",
"executor": "./tools/executors/webpack:serve",
"options": {
"port": 3010,
"buildTarget": "stats:build",
+1
View File
@@ -7,6 +7,7 @@ NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_FAIRGROUND=false
NX_IS_NEW_BRIDGE_CONTRACT=true
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
#Test configuration variables
CYPRESS_FAIRGROUND=false
+1
View File
@@ -5,6 +5,7 @@ NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_FAIRGROUND=false
NX_IS_NEW_BRIDGE_CONTRACT=true
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_VEGA_URL=http://localhost:3028/query
NX_VEGA_REST=http://localhost:3029
+1
View File
@@ -5,3 +5,4 @@ NX_VEGA_URL=https://n04.d.vega.xyz/query
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
+1
View File
@@ -5,3 +5,4 @@ NX_VEGA_URL=https://api.token.vega.xyz/query
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_ETHEREUM_PROVIDER_URL=https://mainnet.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
+1
View File
@@ -5,3 +5,4 @@ NX_VEGA_URL=https://n03.s.vega.xyz/query
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
+1
View File
@@ -5,3 +5,4 @@ NX_VEGA_URL=https://n03.stagnet2.vega.xyz/query
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
+1
View File
@@ -5,3 +5,4 @@ NX_VEGA_URL=https://lb.testnet.vega.xyz/query
NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET":"https://dev.token.vega.xyz","STAGNET2":"staging2.token.vega.xyz","TESTNET":"token.fairground.wtf","MAINNET":"token.vega.xyz"}'
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
+2 -2
View File
@@ -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": 4210,
"buildTarget": "token:build",
+4 -2
View File
@@ -4,7 +4,7 @@ import React, { useMemo } from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { AppLoader } from './app-loader';
import { AppBanner } from './components/app-banner';
import { AppFooter } from './components/app-footer';
import { NetworkInfo } from '@vegaprotocol/network-info';
import { BalanceManager } from './components/balance-manager';
import { EthWallet } from './components/eth-wallet';
import { TemplateSidebar } from './components/page-templates/template-sidebar';
@@ -54,7 +54,9 @@ const AppContainer = () => {
<TemplateSidebar sidebar={sideBar}>
<AppRouter />
</TemplateSidebar>
<AppFooter />
<footer className="grid grid-rows-2 grid-cols-[1fr_auto] md:flex md:col-span-2 p-16 gap-12 border-t-1">
<NetworkInfo />
</footer>
</div>
<VegaWalletDialogs />
<TransactionModal />
@@ -1,28 +0,0 @@
import { Link } from '@vegaprotocol/ui-toolkit';
import { Trans } from 'react-i18next';
import { Links } from '../../config';
import { ENV } from '../../config/env';
export const AppFooter = () => {
return (
<footer className="p-12 text-ui">
<p>Version: {ENV.commit || 'development'}</p>
<p>
<Trans
i18nKey="footerLinksText"
components={{
/* eslint-disable */
feedbackLink: (
<Link className="text-white underline" href={Links.FEEDBACK} />
),
githubLink: (
<Link className="text-white underline" href={Links.GITHUB} />
),
/* eslint-enable */
}}
/>
</p>
</footer>
);
};
@@ -1 +0,0 @@
export * from './app-footer';
@@ -49,7 +49,10 @@ export const AmountInput = ({
min={0}
step="any"
appendElement={
<Lozenge className="text-[10px] relative top-[-2px]">
<Lozenge
variant={Intent.None}
className="text-[10px] relative top-[-2px]"
>
{currency}
</Lozenge>
}
@@ -42,6 +42,7 @@ const Contracts = () => {
<Link
title={t('View address on Etherscan')}
href={`${ETHERSCAN_URL}/address/${contract.address}`}
target="_blank"
>
{contract.address}
</Link>
@@ -57,6 +58,7 @@ const Contracts = () => {
<Link
title={t('View address on Etherscan')}
href={`${ETHERSCAN_URL}/address/${value}`}
target="_blank"
>
{value}
</Link>
@@ -50,6 +50,7 @@ export const TokenDetails = ({
title={t('View on Etherscan (opens in a new tab)')}
className="font-mono text-white text-right"
href={`${ETHERSCAN_URL}/address/${token.address}`}
target="_blank"
>
{token.address}
</Link>
@@ -61,6 +62,7 @@ export const TokenDetails = ({
title={t('View on Etherscan (opens in a new tab)')}
className="font-mono text-white text-right"
href={`${ETHERSCAN_URL}/address/${config.token_vesting_contract.address}`}
target="_blank"
>
{config.token_vesting_contract.address}
</Link>
+6
View File
@@ -24,6 +24,12 @@ Example configurations are provided here:
- [Stagnet1](./.env.stagnet1)
- [Stagnet2](./.env.stagnet2)
For convenience, you can boot the app injecting one of the configurations above by running:
```bash
yarn nx run token:serve --env={env} # e.g. stagnet1
```
There are a few different configuration options offered for this app:
The network configuration for the app
@@ -41,6 +41,14 @@ const networkParamsQueryMock: MockedResponse<NetworkParamsQuery> = {
},
};
const mockEnvironment = {
VEGA_ENV: 'TESTNET',
VEGA_NETWORKS: JSON.stringify({}),
GIT_BRANCH: 'test',
GIT_COMMIT_HASH: 'abcdef',
GIT_ORIGIN_URL: 'https://github.com/test/repo',
};
jest.mock('@web3-react/core', () => {
const original = jest.requireActual('@web3-react/core');
return {
@@ -51,7 +59,7 @@ jest.mock('@web3-react/core', () => {
function setup(mock = networkParamsQueryMock) {
return render(
<EnvironmentProvider>
<EnvironmentProvider definitions={mockEnvironment}>
<MockedProvider mocks={[mock]}>
<Web3Container>
<div>
+2 -2
View File
@@ -4,7 +4,7 @@
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/next:build",
"executor": "./tools/executors/next:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
@@ -19,7 +19,7 @@
}
},
"serve": {
"executor": "@nrwl/next:server",
"executor": "./tools/executors/next:serve",
"options": {
"buildTarget": "trading:build",
"dev": true
@@ -40,6 +40,10 @@ const mockEnvironmentState: EnvironmentState = {
},
ETHEREUM_PROVIDER_URL: 'https://ether.provider',
ETHERSCAN_URL: 'https://etherscan.url',
GIT_BRANCH: 'test',
GIT_ORIGIN_URL: 'https://github.com/test/repo',
GIT_COMMIT_HASH: 'abcde01234',
GITHUB_FEEDBACK_URL: 'https://github.com/test/feedback',
};
beforeEach(() => {
@@ -59,6 +63,11 @@ beforeEach(() => {
process.env['NX_VEGA_NETWORKS'] = JSON.stringify(
mockEnvironmentState.VEGA_NETWORKS
);
process.env['NX_GIT_BRANCH'] = mockEnvironmentState.GIT_BRANCH;
process.env['NX_GIT_ORIGIN_URL'] = mockEnvironmentState.GIT_ORIGIN_URL;
process.env['NX_GIT_COMMIT_HASH'] = mockEnvironmentState.GIT_COMMIT_HASH;
process.env['NX_GITHUB_FEEDBACK_URL'] =
mockEnvironmentState.GITHUB_FEEDBACK_URL;
});
afterAll(() => {
@@ -58,6 +58,14 @@ const getBundledEnvironmentValue = (key: EnvKey) => {
return process.env['NX_ETHERSCAN_URL'];
case 'VEGA_NETWORKS':
return process.env['NX_VEGA_NETWORKS'];
case 'GIT_BRANCH':
return process.env['NX_GIT_BRANCH'];
case 'GIT_COMMIT_HASH':
return process.env['NX_GIT_COMMIT_HASH'];
case 'GIT_ORIGIN_URL':
return process.env['NX_GIT_ORIGIN_URL'];
case 'GITHUB_FEEDBACK_URL':
return process.env['NX_GITHUB_FEEDBACK_URL'];
case 'VEGA_EXPLORER_URL':
return process.env['NX_VEGA_EXPLORER_URL'];
}
@@ -23,6 +23,10 @@ const schemaObject = {
ETHERSCAN_URL: z.string().url({
message: 'The NX_ETHERSCAN_URL environment variable must be a valid url',
}),
GIT_BRANCH: z.string(),
GIT_COMMIT_HASH: z.string(),
GIT_ORIGIN_URL: z.string(),
GITHUB_FEEDBACK_URL: z.optional(z.string()),
VEGA_ENV: z.nativeEnum(Networks),
VEGA_NETWORKS: z
.object(
+12
View File
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
+18
View File
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
+21
View File
@@ -0,0 +1,21 @@
# network-info
This library was generated with [Nx](https://nx.dev).
## Prerequisites
The environment variables needed to be present for any app consuming this library.
`NX_VEGA_URL` OR `NX_VEGA_CONFIG_URL` - either the network configuration url or a url to a node to directly connect to
`NX_VEGA_NETWORKS` - JSON object with key-value pairs for environments and their deployed URLs
`NX_GITHUB_FEEDBACK_URL` - the repository's feedback URL to point to
`NX_ETHEREUM_PROVIDER_URL` - the Ethereum provider url
For examples, see Block Explorer's .env files [here](../../apps/explorer)
## Running unit tests
Run `nx test network-info` to execute the unit tests via [Jest](https://jestjs.io).
+9
View File
@@ -0,0 +1,9 @@
module.exports = {
displayName: 'network-info',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/network-info',
};
+4
View File
@@ -0,0 +1,4 @@
{
"name": "@vegaprotocol/network-info",
"version": "0.0.1"
}
+43
View File
@@ -0,0 +1,43 @@
{
"root": "libs/network-info",
"sourceRoot": "libs/network-info/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nrwl/web:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/network-info",
"tsConfig": "libs/network-info/tsconfig.lib.json",
"project": "libs/network-info/package.json",
"entryFile": "libs/network-info/src/index.ts",
"external": ["react/jsx-runtime"],
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
"compiler": "babel",
"assets": [
{
"glob": "libs/network-info/README.md",
"input": ".",
"output": "."
}
]
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/network-info/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/network-info"],
"options": {
"jestConfig": "libs/network-info/jest.config.js",
"passWithNoTests": true
}
}
}
}
+1
View File
@@ -0,0 +1 @@
export * from './network-info';
+87
View File
@@ -0,0 +1,87 @@
import { useState } from 'react';
import { t } from '@vegaprotocol/react-helpers';
import { Link, Lozenge } from '@vegaprotocol/ui-toolkit';
import {
useEnvironment,
NetworkSwitcherDialog,
} from '@vegaprotocol/environment';
const getFeedbackLinks = (gitOriginUrl?: string) =>
[
{
name: 'Github',
url: gitOriginUrl,
},
].filter((link) => !!link.url);
export const NetworkInfo = () => {
const [isNetworkConfigOpen, setNetworkConfigOpen] = useState(false);
const {
VEGA_URL,
VEGA_NETWORKS,
GIT_COMMIT_HASH,
GIT_ORIGIN_URL,
GITHUB_FEEDBACK_URL,
ETHEREUM_PROVIDER_URL,
} = useEnvironment();
const feedbackLinks = getFeedbackLinks(GITHUB_FEEDBACK_URL);
return (
<>
<div>
<p className="mb-16">
{t('Reading network data from')}{' '}
<Lozenge className="text-black dark:text-white bg-white-60 dark:bg-black-60">
{VEGA_URL}
</Lozenge>
. <Link onClick={() => setNetworkConfigOpen(true)}>{t('Edit')}</Link>
</p>
<p className="mb-[1rem]">
{t('Reading Ethereum data from')}{' '}
<Lozenge className="text-black dark:text-white bg-white-60 dark:bg-black-60">
{ETHEREUM_PROVIDER_URL}
</Lozenge>
.{' '}
</p>
{GIT_COMMIT_HASH && GIT_ORIGIN_URL && (
<p className="mb-[1rem]">
{t('Version/commit hash')}:{' '}
<Link
href={`${GIT_ORIGIN_URL}/commit/${GIT_COMMIT_HASH}`}
target="_blank"
>
{GIT_COMMIT_HASH}
</Link>
</p>
)}
{feedbackLinks.length > 0 && (
<p className="mb-16">
{t('Known issues and feedback on')}{' '}
{feedbackLinks.map(({ name, url }, index) => (
<>
<Link key={index} href={url}>
{name}
</Link>
{feedbackLinks.length > 1 &&
index < feedbackLinks.length - 2 &&
','}
{feedbackLinks.length > 1 &&
index === feedbackLinks.length - 1 &&
`, ${t('and')} `}
</>
))}
</p>
)}
</div>
<NetworkSwitcherDialog
dialogOpen={isNetworkConfigOpen}
setDialogOpen={setNetworkConfigOpen}
onConnect={({ network }) => {
if (VEGA_NETWORKS[network]) {
window.location.href = VEGA_NETWORKS[network] as string;
}
}}
/>
</>
);
};
+25
View File
@@ -0,0 +1,25 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
+22
View File
@@ -0,0 +1,22 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
"../../node_modules/@nrwl/react/typings/image.d.ts"
],
"exclude": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
}
+19
View File
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.test.ts",
"**/*.spec.ts",
"**/*.test.tsx",
"**/*.spec.tsx",
"**/*.test.js",
"**/*.spec.js",
"**/*.test.jsx",
"**/*.spec.jsx",
"**/*.d.ts"
]
}
+1 -2
View File
@@ -1,5 +1,4 @@
{
"name": "@vegaprotocol/smart-contracts",
"version": "0.0.1",
"type": "commonjs"
"version": "0.0.1"
}
@@ -11,6 +11,11 @@ const Template: Story = (args) => <Lozenge {...args}>lozenge</Lozenge>;
export const Default = Template.bind({});
export const None = Template.bind({});
None.args = {
variant: Intent.None,
};
export const Primary = Template.bind({});
Primary.args = {
variant: Intent.Primary,
@@ -1,7 +1,7 @@
import type { ReactNode } from 'react';
import classNames from 'classnames';
import { getIntentTextAndBackground } from '../../utils/intent';
import { Intent } from '../../utils/intent';
import type { Intent } from '../../utils/intent';
interface LozengeProps {
children: ReactNode;
@@ -10,7 +10,7 @@ interface LozengeProps {
}
const getLozengeClasses = (
variant: LozengeProps['variant'],
variant?: LozengeProps['variant'],
className?: string
) => {
return classNames(
@@ -20,11 +20,7 @@ const getLozengeClasses = (
);
};
export const Lozenge = ({
children,
variant = Intent.None,
className,
}: LozengeProps) => {
export const Lozenge = ({ children, variant, className }: LozengeProps) => {
return (
<span className={getLozengeClasses(variant, className)}>{children}</span>
);
+1 -1
View File
@@ -28,7 +28,7 @@ export const getIntentBorder = (intent = Intent.None) => {
};
};
export const getIntentTextAndBackground = (intent = Intent.None) => {
export const getIntentTextAndBackground = (intent?: Intent) => {
return {
'bg-black text-white dark:bg-white dark:text-black': intent === Intent.None,
'bg-vega-pink text-black dark:bg-vega-yellow dark:text-black-normal':
@@ -46,6 +46,7 @@ export const TxRow = ({
href={`${ETHERSCAN_URL}/tx/${txHash}`}
title={t('View transaction on Etherscan')}
className="text-vega-pink dark:text-vega-yellow"
target="_blank"
>
{t('View on Etherscan')}
</Link>
@@ -65,6 +66,7 @@ export const TxRow = ({
href={`${ETHERSCAN_URL}/tx/${txHash}`}
title={t('View on Etherscan')}
className="text-vega-pink dark:text-vega-yellow"
target="_blank"
>
{t('View transaction on Etherscan')}
</Link>
+18
View File
@@ -0,0 +1,18 @@
import type { ExecutorContext } from '@nrwl/devkit';
import setup from '../../../utils/setup-environment';
import nextBuildExecutor from '@nrwl/next/src/executors/build/build.impl';
import { NextBuildBuilderOptions } from '@nrwl/next/src/utils/types';
type Schema = NextBuildBuilderOptions & {
env?: string;
};
export default async function build(
options: Schema,
context: ExecutorContext
): Promise<ReturnType<typeof nextBuildExecutor>> {
const { env, ...nextOptions } = options;
await setup(env, context, 'tools/executors/next/build');
return await nextBuildExecutor(nextOptions, context);
}
+50
View File
@@ -0,0 +1,50 @@
{
"cli": "nx",
"id": "build",
"description": "Serves an app using @nrwl/next:build",
"type": "object",
"properties": {
"env": {
"type": "string",
"description": "Target environment to run the application in. This assumes an .env file present in the project's root in the following format: .env.{envName}"
},
"root": {
"description": "The source root",
"type": "string"
},
"outputPath": {
"type": "string",
"description": "The output path of the generated files."
},
"fileReplacements": {
"description": "Replace files with other files in the build.",
"type": "array",
"items": {
"type": "object",
"properties": {
"replace": {
"type": "string",
"description": "The file to be replaced."
},
"with": {
"type": "string",
"description": "The file to replace with."
}
},
"additionalProperties": false,
"required": ["replace", "with"]
},
"default": []
},
"nextConfig": {
"description": "Path (relative to workspace root) to a function which takes phase, config, and builder options, and returns the resulting config. This is an advanced option and should not be used with a normal Next.js config file (i.e. `next.config.js`).",
"type": "string"
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately.",
"default": true
}
},
"required": ["root", "outputPath"]
}
+14
View File
@@ -0,0 +1,14 @@
{
"executors": {
"serve": {
"implementation": "./serve/impl",
"schema": "./serve/schema.json",
"description": "Starts a next server with an optional explicit environment."
},
"build": {
"implementation": "./build/impl",
"schema": "./build/schema.json",
"description": "Starts a next server with an optional explicit environment."
}
}
}
+18
View File
@@ -0,0 +1,18 @@
import type { ExecutorContext } from '@nrwl/devkit';
import setup from '../../../utils/setup-environment';
import nextServerExecutor from '@nrwl/next/src/executors/server/server.impl';
import { NextServeBuilderOptions } from '@nrwl/next/src/utils/types';
type Schema = NextServeBuilderOptions & {
env?: string;
};
export default async function* serve(
options: Schema,
context: ExecutorContext
): ReturnType<typeof nextServerExecutor> {
const { env, ...nextOptions } = options;
await setup(env, context, 'tools/executors/next/serve');
return yield* nextServerExecutor(nextOptions, context);
}
+54
View File
@@ -0,0 +1,54 @@
{
"cli": "nx",
"id": "serve",
"description": "Serves an app using @nrwl/next:server",
"type": "object",
"properties": {
"env": {
"type": "string",
"description": "Target environment to run the application in. This assumes an .env file present in the project's root in the following format: .env.{envName}"
},
"dev": {
"type": "boolean",
"description": "Serve the application in the dev mode.",
"default": true
},
"buildTarget": {
"type": "string",
"description": "Target which builds the application."
},
"port": {
"type": "number",
"description": "Port to listen on.",
"default": 4200
},
"staticMarkup": {
"type": "boolean",
"description": "Static markup.",
"default": false
},
"quiet": {
"type": "boolean",
"description": "Hide error messages containing server information.",
"default": false
},
"customServerPath": {
"type": "string",
"description": "Use a custom server script."
},
"hostname": {
"type": "string",
"description": "Hostname on which the application is served."
},
"proxyConfig": {
"type": "string",
"description": "Path to the proxy configuration file."
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately.",
"default": true
}
},
"required": ["buildTarget"]
}
@@ -8,6 +8,6 @@
"sourceMap": false,
"inlineSourceMap": true
},
"include": ["impl.ts"],
"include": ["build/impl.ts", "serve/impl.ts"],
"exclude": ["node_modules"]
}
-9
View File
@@ -1,9 +0,0 @@
{
"executors": {
"serve": {
"implementation": "./impl",
"schema": "./schema.json",
"description": "Starts a dev-server with an optional explicit environment."
}
}
}
+19
View File
@@ -0,0 +1,19 @@
import type { ExecutorContext } from '@nrwl/devkit';
import setup from '../../../utils/setup-environment';
import webpackBuildExecutor, {
WebWebpackExecutorOptions,
} from '@nrwl/web/src/executors/webpack/webpack.impl';
type Schema = WebWebpackExecutorOptions & {
env?: string;
};
export default async function* build(
options: Schema,
context: ExecutorContext
): ReturnType<typeof webpackBuildExecutor> {
const { env, ...buildOptions } = options;
await setup(env, context, 'tools/executors/webpack/build');
return yield* webpackBuildExecutor(buildOptions, context);
}
+359
View File
@@ -0,0 +1,359 @@
{
"cli": "nx",
"id": "build",
"description": "Serves an app using @nrwl/web:webpack",
"type": "object",
"properties": {
"env": {
"type": "string",
"description": "Target environment to run the application in. This assumes an .env file present in the project's root in the following format: .env.{envName}"
},
"crossOrigin": {
"type": "string",
"description": "The `crossorigin` attribute to use for generated javascript script tags. One of 'none' | 'anonymous' | 'use-credentials'."
},
"main": {
"type": "string",
"description": "The name of the main entry-point file."
},
"tsConfig": {
"type": "string",
"description": "The name of the Typescript configuration file."
},
"compiler": {
"type": "string",
"description": "The compiler to use.",
"enum": ["babel", "swc"],
"default": "babel"
},
"outputPath": {
"type": "string",
"description": "The output path of the generated files."
},
"deleteOutputPath": {
"type": "boolean",
"description": "Delete the output path before building.",
"default": true
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",
"default": false
},
"baseHref": {
"type": "string",
"description": "Base url for the application being built."
},
"deployUrl": {
"type": "string",
"description": "URL where the application will be deployed."
},
"vendorChunk": {
"type": "boolean",
"description": "Use a separate bundle containing only vendor libraries.",
"default": true
},
"commonChunk": {
"type": "boolean",
"description": "Use a separate bundle containing code used across multiple bundles.",
"default": true
},
"runtimeChunk": {
"type": "boolean",
"description": "Use a separate bundle containing the runtime.",
"default": true
},
"sourceMap": {
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
"default": true,
"oneOf": [
{
"type": "boolean"
},
{
"type": "string"
}
]
},
"progress": {
"type": "boolean",
"description": "Log progress to the console while building.",
"default": false
},
"assets": {
"type": "array",
"description": "List of static application assets.",
"default": [],
"items": {
"$ref": "#/definitions/assetPattern"
}
},
"index": {
"type": "string",
"description": "HTML File which will be contain the application."
},
"scripts": {
"type": "array",
"description": "External Scripts which will be included before the main application entry.",
"items": {
"$ref": "#/definitions/extraEntryPoint"
},
"default": []
},
"styles": {
"type": "array",
"description": "External Styles which will be included with the application",
"items": {
"$ref": "#/definitions/extraEntryPoint"
},
"default": []
},
"budgets": {
"description": "Budget thresholds to ensure parts of your application stay within boundaries which you set.",
"type": "array",
"items": {
"$ref": "#/definitions/budget"
},
"default": []
},
"namedChunks": {
"type": "boolean",
"description": "Names the produced bundles according to their entry file.",
"default": true
},
"outputHashing": {
"type": "string",
"description": "Define the output filename cache-busting hashing mode.",
"default": "none",
"enum": ["none", "all", "media", "bundles"]
},
"stylePreprocessorOptions": {
"description": "Options to pass to style preprocessors.",
"type": "object",
"properties": {
"includePaths": {
"description": "Paths to include. Paths will be resolved to project root.",
"type": "array",
"items": {
"type": "string"
},
"default": []
}
},
"additionalProperties": false
},
"optimization": {
"description": "Enables optimization of the build output.",
"oneOf": [
{
"type": "object",
"properties": {
"scripts": {
"type": "boolean",
"description": "Enables optimization of the scripts output.",
"default": true
},
"styles": {
"type": "boolean",
"description": "Enables optimization of the styles output.",
"default": true
}
},
"additionalProperties": false
},
{
"type": "boolean"
}
]
},
"extractCss": {
"type": "boolean",
"description": "Extract CSS into a `.css` file.",
"default": false
},
"es2015Polyfills": {
"description": "Conditional polyfills loaded in browsers which do not support `ES2015`.",
"type": "string"
},
"subresourceIntegrity": {
"type": "boolean",
"description": "Enables the use of subresource integrity validation.",
"default": false
},
"polyfills": {
"type": "string",
"description": "Polyfills to load before application"
},
"verbose": {
"type": "boolean",
"description": "Emits verbose output",
"default": false
},
"statsJson": {
"type": "boolean",
"description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' or `<https://webpack.github.io/analyse>`.",
"default": false
},
"extractLicenses": {
"type": "boolean",
"description": "Extract all licenses in a separate file, in the case of production builds only.",
"default": false
},
"memoryLimit": {
"type": "number",
"description": "Memory limit for type checking service process in `MB`.",
"default": 2048
},
"maxWorkers": {
"type": "number",
"description": "Number of workers to use for type checking.",
"default": 2
},
"fileReplacements": {
"description": "Replace files with other files in the build.",
"type": "array",
"items": {
"type": "object",
"properties": {
"replace": {
"type": "string",
"description": "The file to be replaced."
},
"with": {
"type": "string",
"description": "The file to replace with."
}
},
"additionalProperties": false,
"required": ["replace", "with"]
},
"default": []
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately.",
"default": true
},
"generateIndexHtml": {
"type": "boolean",
"description": "Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`.",
"default": true
},
"postcssConfig": {
"type": "string",
"description": "Set a path to PostCSS config that applies to the app and all libs. Defaults to `undefined`, which auto-detects postcss.config.js files in each `app`/`lib` directory."
},
"webpackConfig": {
"type": "string",
"description": "Path to a function which takes a webpack config, some context and returns the resulting webpack config. See https://nx.dev/guides/customize-webpack"
}
},
"required": ["tsConfig", "main", "index"],
"definitions": {
"assetPattern": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": {
"type": "string"
}
},
"output": {
"type": "string",
"description": "Absolute path within the output."
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{
"type": "string"
}
]
},
"budget": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The type of budget.",
"enum": ["all", "allScript", "any", "anyScript", "bundle", "initial"]
},
"name": {
"type": "string",
"description": "The name of the bundle."
},
"baseline": {
"type": "string",
"description": "The baseline size for comparison."
},
"maximumWarning": {
"type": "string",
"description": "The maximum threshold for warning relative to the baseline."
},
"maximumError": {
"type": "string",
"description": "The maximum threshold for error relative to the baseline."
},
"minimumWarning": {
"type": "string",
"description": "The minimum threshold for warning relative to the baseline."
},
"minimumError": {
"type": "string",
"description": "The minimum threshold for error relative to the baseline."
},
"warning": {
"type": "string",
"description": "The threshold for warning relative to the baseline (min & max)."
},
"error": {
"type": "string",
"description": "The threshold for error relative to the baseline (min & max)."
}
},
"additionalProperties": false,
"required": ["type"]
},
"extraEntryPoint": {
"oneOf": [
{
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "The file to include."
},
"bundleName": {
"type": "string",
"description": "The bundle name for this extra entry point."
},
"inject": {
"type": "boolean",
"description": "If the bundle will be referenced in the HTML file.",
"default": true
}
},
"additionalProperties": false,
"required": ["input"]
},
{
"type": "string",
"description": "The file to include."
}
]
}
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"executors": {
"serve": {
"implementation": "./serve/impl",
"schema": "./serve/schema.json",
"description": "Starts a dev-server with an optional explicit environment."
},
"build": {
"implementation": "./build/impl",
"schema": "./build/schema.json",
"description": "Starts a dev-server with an optional explicit environment."
}
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"executors": "./executor.json"
}
+19
View File
@@ -0,0 +1,19 @@
import type { ExecutorContext } from '@nrwl/devkit';
import setup from '../../../utils/setup-environment';
import devServerExecutor, {
WebDevServerOptions,
} from '@nrwl/web/src/executors/dev-server/dev-server.impl';
type Schema = WebDevServerOptions & {
env?: string;
};
export default async function* serve(
options: Schema,
context: ExecutorContext
): ReturnType<typeof devServerExecutor> {
const { env, ...serverOptions } = options;
await setup(env, context, 'tools/executors/webpack/serve');
return yield* devServerExecutor(serverOptions, context);
}
+13
View File
@@ -0,0 +1,13 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"types": ["node"],
"importHelpers": false,
"sourceMap": false,
"inlineSourceMap": true
},
"include": ["build/impl.ts", "serve/impl.ts"],
"exclude": ["node_modules"]
}
@@ -1,28 +1,33 @@
import * as fs from 'fs';
import * as path from 'path';
import * as dotenv from 'dotenv';
import { execSync } from 'child_process';
import * as log from 'npmlog';
import * as dotenv from 'dotenv';
import type { ExecutorContext } from '@nrwl/devkit';
import devServerExecutor, {
WebDevServerOptions,
} from '@nrwl/web/src/executors/dev-server/dev-server.impl';
type Schema = WebDevServerOptions & {
env?: string;
};
const LOGGER_SCOPE = 'tools/executors/serve';
process.env['NX_GIT_COMMIT_HASH'] = execSync('git rev-parse HEAD')
.toString()
.replace(/[\r\n]/gm, '');
process.env['NX_GIT_BRANCH'] = execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.replace(/[\r\n]/gm, '');
process.env['NX_GIT_ORIGIN_URL'] = execSync('git remote get-url origin')
.toString()
.replace('ssh://git@', 'https://')
.replace('.git', '')
.replace(/[\r\n]/gm, '');
const logEnvData = (
envMap: Record<string, string>,
envFiles: string[],
env?: string,
defaultEnvFile?: string
defaultEnvFile?: string,
loggerScope?: string
) => {
if (env && !envMap[env]) {
log.warn(LOGGER_SCOPE, `No environment called "${env}" found.`);
log.warn(loggerScope, `No environment called "${env}" found.`);
log.info(
LOGGER_SCOPE,
loggerScope,
envFiles.length > 0
? `You can create a new environment by putting an ".env.${env}" file in your project root, or you can use the following available ones: ${envFiles.join(
', '
@@ -33,14 +38,14 @@ const logEnvData = (
if (!envMap[env]) {
log.info(
LOGGER_SCOPE,
loggerScope,
defaultEnvFile
? `Using "${defaultEnvFile}" as the default project environment.`
: 'Serving the project only using the environment variables scoped to your CLI.'
);
} else {
log.info(
LOGGER_SCOPE,
loggerScope,
`Using "${envMap[env]}" as the default project environment.`
);
}
@@ -52,7 +57,7 @@ const getDefaultEnvFile = (envMap: Record<string, string>) => {
return envMap['local'] || envMap['.env'];
};
const getEnvFile = (env: string, envFiles: string[]) => {
const getEnvFile = (env: string, envFiles: string[], loggerScope?: string) => {
const envMap = envFiles.reduce(
(acc, filename) => ({
...acc,
@@ -62,28 +67,28 @@ const getEnvFile = (env: string, envFiles: string[]) => {
);
const defaultEnvFile = getDefaultEnvFile(envMap);
logEnvData(envMap, envFiles, env, defaultEnvFile);
logEnvData(envMap, envFiles, env, defaultEnvFile, loggerScope);
return envMap[env] || defaultEnvFile;
};
export default async function* serve(
options: Schema,
context: ExecutorContext
): ReturnType<typeof devServerExecutor> {
const { env, ...dsOptions } = options;
export default async function setup(
env: string,
context: ExecutorContext,
loggerScope?: string
) {
const { root } = context.workspace.projects[context.projectName];
const workspacePath = path.join(context.cwd, root);
const files = await fs.promises.readdir(workspacePath);
const envFile = getEnvFile(
env,
files.filter((f) => f.startsWith('.env'))
files.filter((f) => f.startsWith('.env')),
loggerScope
);
if (env && envFile) {
dotenv.config({ path: path.join(workspacePath, envFile), override: true });
}
return yield* devServerExecutor(dsOptions, context);
}
+1
View File
@@ -25,6 +25,7 @@
"@vegaprotocol/fills": ["libs/fills/src/index.ts"],
"@vegaprotocol/market-depth": ["libs/market-depth/src/index.ts"],
"@vegaprotocol/market-list": ["libs/market-list/src/index.ts"],
"@vegaprotocol/network-info": ["libs/network-info/src/index.ts"],
"@vegaprotocol/network-stats": ["libs/network-stats/src/index.ts"],
"@vegaprotocol/orders": ["libs/orders/src/index.ts"],
"@vegaprotocol/positions": ["libs/positions/src/index.ts"],
+1
View File
@@ -12,6 +12,7 @@
"fills": "libs/fills",
"market-depth": "libs/market-depth",
"market-list": "libs/market-list",
"network-info": "libs/network-info",
"network-stats": "libs/network-stats",
"orders": "libs/orders",
"positions": "libs/positions",