Compare commits

..
Author SHA1 Message Date
Matthew Russell 598cfbd372 chore: tidy imports 2023-06-26 14:30:11 -07:00
Matthew Russell 0fd277f7cc chore: remove unnecessary spreading of store slice 2023-06-26 14:24:41 -07:00
Matthew Russell 212a8f6409 chore: lint 2023-06-26 14:20:36 -07:00
Matthew Russell fdbb41a27c test: add test for orders-container hooks 2023-06-26 14:20:36 -07:00
Matthew Russell 72d8805b52 chore: use separate selectors for get and set store 2023-06-26 14:20:36 -07:00
Matthew Russell e78dd4206c chore: move custom orders container logic to own hook 2023-06-26 14:20:36 -07:00
Matthew Russell 5f3414cfec chore: revert setting of row data 2023-06-26 14:20:36 -07:00
Matthew Russell 0bf1efc3c9 fix: order filters 2023-06-26 14:20:36 -07:00
Matthew Russell 475fa9768a chore: split orderlist store selectors 2023-06-26 14:20:36 -07:00
Matthew Russell 709076724f chore: used shared data grid store type 2023-06-26 14:20:36 -07:00
Matthew Russell d9d4d5529d chore: remove subscribe selector from orders store 2023-06-26 14:20:36 -07:00
Matthew Russell f3607a77ab feat: add shared data grid slice for grid store logic 2023-06-26 14:20:36 -07:00
Matthew Russell 5fa7078833 chore: remove unnecessary usage of subscribeWithSelector 2023-06-26 14:20:36 -07:00
Matthew Russell ccd0007e36 test: separate column width set and get tests 2023-06-26 14:20:36 -07:00
Matthew Russell 7d3c2ff44c chore: make AccountsManager optionally take grid props 2023-06-26 14:20:36 -07:00
Matthew Russell 420b58c6ea chore: remove test warnings and stray log 2023-06-26 14:20:36 -07:00
Matthew Russell 287a0cae58 test: add unit test for use-datagrid-events hook 2023-06-26 14:20:35 -07:00
Matthew Russell c4decf3f2d chore: rename data grid hook 2023-06-26 14:20:34 -07:00
Matthew Russell 43012d8cdd chore: delete useColumnSizes hook 2023-06-26 14:19:08 -07:00
Matthew Russell 4c6af7bfc6 chore: make buttons overlay bottom rows 2023-06-26 14:19:08 -07:00
Matthew Russell 92bf90e976 test: add mocked gridProps to account manager test 2023-06-26 14:19:08 -07:00
Matthew Russell d9d45451bb chore: delete bottom placeholder hook 2023-06-26 14:19:08 -07:00
Matthew Russell d059b3f710 feat: update other tables to use stored grid data 2023-06-26 14:19:08 -07:00
Matthew Russell 0152720006 feat: update other tables to use stored grid data 2023-06-26 14:19:06 -07:00
Matthew Russell 0d41f2a3cf chore: improve types and add debounce 2023-06-26 14:15:45 -07:00
Matthew Russell a3bb50fdc5 refactor: store column state and filter model 2023-06-26 14:15:45 -07:00
Matthew Russell 84e19427c7 feat: remove column sizes use and store key props 2023-06-26 14:15:44 -07:00
34 changed files with 106 additions and 228 deletions
+19 -41
View File
@@ -6,9 +6,7 @@ on:
- release/* - release/*
- develop - develop
- main - main
# uncomment pull_request and comment pull_request_target to test CI changes against feature branch not target branch (develop) pull_request:
# pull_request:
pull_request_target:
types: types:
- opened - opened
- ready_for_review - ready_for_review
@@ -22,8 +20,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Cache node modules - name: Cache node modules
id: cache id: cache
@@ -64,7 +60,6 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup node - name: Setup node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
@@ -112,82 +107,65 @@ jobs:
echo "Branch slug: ${branch_slug}" echo "Branch slug: ${branch_slug}"
echo ">>>> eof debug" echo ">>>> eof debug"
projects_array=() projects_e2e=""
preview_governance="not deployed" preview_governance="not deployed"
preview_trading="not deployed" preview_trading="not deployed"
preview_explorer="not deployed" preview_explorer="not deployed"
preview_tools="not deployed" preview_tools="not deployed"
# parse if affected is any of three main applications, if none - use all of them
if echo "$affected" | grep -q governance; then if echo "$affected" | grep -q governance; then
echo "Governance is affected" echo "Governance is affected"
projects_array+=("governance") projects_e2e+='"governance-e2e" '
preview_governance=$(printf "https://%s.%s.vega.rocks" "governance" "$branch_slug") preview_governance=$(printf "https://%s.%s.vega.rocks" "governance" "$branch_slug")
fi fi
if echo "$affected" | grep -q trading; then if echo "$affected" | grep -q trading; then
echo "Trading is affected" echo "Trading is affected"
projects_array+=("trading") projects_e2e+='"trading-e2e" '
preview_trading=$(printf "https://%s.%s.vega.rocks" "trading" "$branch_slug") preview_trading=$(printf "https://%s.%s.vega.rocks" "trading" "$branch_slug")
fi fi
if echo "$affected" | grep -q explorer; then if echo "$affected" | grep -q explorer; then
echo "Explorer is affected" echo "Explorer is affected"
projects_array+=("explorer") projects_e2e+='"explorer-e2e" '
preview_explorer=$(printf "https://%s.%s.vega.rocks" "explorer" "$branch_slug") preview_explorer=$(printf "https://%s.%s.vega.rocks" "explorer" "$branch_slug")
fi fi
if [[ ${#projects_array[@]} -eq 0 ]]; then if [[ -z "$projects_e2e" ]]; then
projects_array=("governance" "trading" "explorer") projects_e2e+='"governance-e2e" "trading-e2e" "explorer-e2e" '
preview_governance=$(printf "https://%s.%s.vega.rocks" "governance" "$branch_slug") preview_governance=$(printf "https://%s.%s.vega.rocks" "governance" "$branch_slug")
preview_trading=$(printf "https://%s.%s.vega.rocks" "trading" "$branch_slug") preview_trading=$(printf "https://%s.%s.vega.rocks" "trading" "$branch_slug")
preview_explorer=$(printf "https://%s.%s.vega.rocks" "explorer" "$branch_slug") preview_explorer=$(printf "https://%s.%s.vega.rocks" "explorer" "$branch_slug")
fi fi
projects="$(echo $projects_e2e | sed 's|-e2e||g')"
# applications parsed before this loop are applicable for running e2e-tests
projects_e2e_array=()
for project in "${projects_array[@]}"; do
projects_e2e_array+=("${project}-e2e")
done
# all applications below this loop are not applicable for running e2e-test
# check if pull request event to deploy tools
if [[ "${{ github.event_name }}" = "pull_request" ]]; then if [[ "${{ github.event_name }}" = "pull_request" ]]; then
if echo "$affected" | grep -q multisig-signer; then if echo "$affected" | grep -q multisig-signer; then
echo "Tools are affected" echo "Tools are affected"
# tools are only applicable to check previews or deploy from develop to mainnet
echo "Deploying tools on preview" echo "Deploying tools on preview"
preview_tools=$(printf "https://%s.%s.vega.rocks" "tools" "$branch_slug") preview_tools=$(printf "https://%s.%s.vega.rocks" "tools" "$branch_slug")
projects+=' "multisig-signer" '
projects_array+=("multisig-signer")
fi fi
# those apps deploy only from develop to mainnet
elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then elif [[ "${{ github.ref }}" =~ .*develop$ ]]; then
if echo "$affected" | grep -q multisig-signer; then if echo "$affected" | grep -q multisig-signer; then
echo "Tools are affected" echo "Tools are affected"
# tools are only applicable to check previews or deploy from develop to mainnet
echo "Deploying tools on s3" echo "Deploying tools on s3"
projects+=' "multisig-signer" '
projects_array+=("multisig-signer")
fi fi
if echo "$affected" | grep -q static; then if echo "$affected" | grep -q static; then
echo "static is affected" echo "static is affected"
echo "Deploying static on s3" echo "Deploying static on s3"
projects+=' "static" '
projects_array+=("static")
fi fi
if echo "$affected" | grep -q ui-toolkit; then if echo "$affected" | grep -q ui-toolkit; then
echo "ui-toolkit is affected" echo "ui-toolkit is affected"
echo "Deploying ui-toolkit on s3" echo "Deploying ui-toolkit on s3"
projects+=' "ui-toolkit" '
projects_array+=("ui-toolkit")
fi fi
fi fi
echo "Projects: ${projects_array[@]}" projects_e2e=${projects_e2e%?}
echo "Projects E2E: ${projects_e2e_array[@]}" projects_e2e=[${projects_e2e// /,}]
projects_json=$(jq -M --compact-output --null-input '$ARGS.positional' --args -- "${projects_array[@]}") projects=[${projects// /,}]
projects_e2e_json=$(jq -M --compact-output --null-input '$ARGS.positional' --args -- "${projects_e2e_array[@]}") echo PROJECTS_E2E=$projects_e2e >> $GITHUB_ENV
echo PROJECTS=$projects >> $GITHUB_ENV
echo PROJECTS_E2E=$projects_e2e_json >> $GITHUB_ENV
echo PROJECTS=$projects_json >> $GITHUB_ENV
echo PREVIEW_GOVERNANCE=$preview_governance >> $GITHUB_ENV echo PREVIEW_GOVERNANCE=$preview_governance >> $GITHUB_ENV
echo PREVIEW_TRADING=$preview_trading >> $GITHUB_ENV echo PREVIEW_TRADING=$preview_trading >> $GITHUB_ENV
echo PREVIEW_EXPLORER=$preview_explorer >> $GITHUB_ENV echo PREVIEW_EXPLORER=$preview_explorer >> $GITHUB_ENV
-1
View File
@@ -33,7 +33,6 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
path: './frontend-monorepo' path: './frontend-monorepo'
ref: ${{ github.event.pull_request.head.sha || github.sha }}
# Restore node_modules from cache if possible # Restore node_modules from cache if possible
- name: Restore node_modules from cache - name: Restore node_modules from cache
-2
View File
@@ -11,8 +11,6 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup node - name: Setup node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
-2
View File
@@ -19,8 +19,6 @@ jobs:
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Set up QEMU - name: Set up QEMU
id: quemu id: quemu
-1
View File
@@ -14,7 +14,6 @@ NX_VEGA_WALLET_URL=http://localhost:1789
NX_ETH_LOCAL_PROVIDER_URL=http://localhost:8545/ NX_ETH_LOCAL_PROVIDER_URL=http://localhost:8545/
NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supply green clown session" NX_ETH_WALLET_MNEMONIC="ozone access unlock valid olympic save include omit supply green clown session"
NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72
NX_SENTRY_DSN=https://dummy@o999999.ingest.sentry.io/9999999
# Expose some env vars to cypress environment for market setup # Expose some env vars to cypress environment for market setup
CYPRESS_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit supply green clown session CYPRESS_ETH_WALLET_MNEMONIC=ozone access unlock valid olympic save include omit supply green clown session
+1 -1
View File
@@ -2,7 +2,7 @@ NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9
NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_ETHERSCAN_URL=https://sepolia.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613 NX_TRADING_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/devnet1/vegawallet-devnet1.toml
NX_VEGA_ENV=DEVNET NX_VEGA_ENV=DEVNET
NX_VEGA_EXPLORER_URL=https://dev.explorer.vega.xyz NX_VEGA_EXPLORER_URL=https://dev.explorer.vega.xyz
+1 -1
View File
@@ -1,7 +1,7 @@
NX_ETHEREUM_PROVIDER_URL=https://eth-mainnet.gateway.pokt.network/v1/lb/af6a2d529a11f8158bc8ca2a NX_ETHEREUM_PROVIDER_URL=https://eth-mainnet.gateway.pokt.network/v1/lb/af6a2d529a11f8158bc8ca2a
NX_ETHERSCAN_URL=https://etherscan.io NX_ETHERSCAN_URL=https://etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613 NX_TRADING_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/mainnet1/mainnet1.toml NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/mainnet1/mainnet1.toml
NX_VEGA_ENV=MAINNET NX_VEGA_ENV=MAINNET
NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz NX_VEGA_EXPLORER_URL=https://explorer.vega.xyz
+1 -1
View File
@@ -2,7 +2,7 @@ NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9
NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_ETHERSCAN_URL=https://sepolia.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613 NX_TRADING_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml
NX_VEGA_ENV=STAGNET1 NX_VEGA_ENV=STAGNET1
NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks
+1 -1
View File
@@ -2,7 +2,7 @@ NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9
NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_ETHERSCAN_URL=https://sepolia.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613 NX_TRADING_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml
NX_VEGA_ENV=TESTNET NX_VEGA_ENV=TESTNET
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
+1 -1
View File
@@ -2,7 +2,7 @@ NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9
NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_ETHERSCAN_URL=https://sepolia.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz
NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613 NX_TRADING_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613
NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks/master/testnet2/testnet2.toml
NX_VEGA_ENV=VALIDATOR_TESTNET NX_VEGA_ENV=VALIDATOR_TESTNET
NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks NX_VEGA_EXPLORER_URL=https://explorer.validators-testnet.vega.rocks
@@ -1,25 +1,17 @@
import { render, screen } from '@testing-library/react'; import { render, screen, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { TelemetryApproval } from './telemetry-approval'; import { TelemetryApproval } from './telemetry-approval';
jest.mock('@vegaprotocol/logger', () => ({
SentryInit: () => undefined,
SentryClose: () => undefined,
}));
jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ VEGA_ENV: 'test', SENTRY_DSN: 'sentry-dsn' }),
}));
describe('TelemetryApproval', () => { describe('TelemetryApproval', () => {
it('click on checkbox should be properly handled', async () => { it('click on checkbox should be properly handled', () => {
const helpText = 'My help text'; const helpText = 'My help text';
render(<TelemetryApproval helpText={helpText} />); render(<TelemetryApproval helpText={helpText} />);
expect(screen.getByRole('checkbox')).toHaveAttribute( expect(screen.getByRole('checkbox')).toHaveAttribute(
'data-state', 'data-state',
'unchecked' 'unchecked'
); );
await userEvent.click(screen.getByRole('checkbox')); act(() => {
screen.getByRole('checkbox').click();
});
expect(screen.getByRole('checkbox')).toHaveAttribute( expect(screen.getByRole('checkbox')).toHaveAttribute(
'data-state', 'data-state',
'checked' 'checked'
@@ -11,7 +11,6 @@ import { WelcomeNoticeDialog } from './welcome-notice-dialog';
import { useGlobalStore } from '../../stores'; import { useGlobalStore } from '../../stores';
import { useEnvironment } from '@vegaprotocol/environment'; import { useEnvironment } from '@vegaprotocol/environment';
import { Networks } from '@vegaprotocol/environment'; import { Networks } from '@vegaprotocol/environment';
import { isTestEnv } from '@vegaprotocol/utils';
export const WelcomeDialog = () => { export const WelcomeDialog = () => {
const { VEGA_ENV } = useEnvironment(); const { VEGA_ENV } = useEnvironment();
@@ -32,7 +31,9 @@ export const WelcomeDialog = () => {
); );
const isRiskDialogNeeded = const isRiskDialogNeeded =
riskAccepted !== 'true' && VEGA_ENV !== Networks.MAINNET && !isTestEnv(); riskAccepted !== 'true' &&
VEGA_ENV !== Networks.MAINNET &&
!('Cypress' in window);
const isWelcomeDialogNeeded = pathname === '/' || shouldDisplayWelcomeDialog; const isWelcomeDialogNeeded = pathname === '/' || shouldDisplayWelcomeDialog;
+20
View File
@@ -0,0 +1,20 @@
const windowOrDefault = (key: string, defaultValue?: string) => {
if (typeof window !== 'undefined') {
if (window._env_ && window._env_[key]) {
return window._env_[key];
}
}
return defaultValue || '';
};
/**
* Need to have default value as next in-lines environment variables. Cannot figure out dynamic keys.
* So must provide the default with the key so that next can figure it out.
*/
export const ENV = {
envName: windowOrDefault('NX_VEGA_ENV', process.env['NX_VEGA_ENV']),
dsn: windowOrDefault(
'NX_TRADING_SENTRY_DSN',
process.env['NX_TRADING_SENTRY_DSN']
),
};
+1
View File
@@ -0,0 +1 @@
export * from './env';
@@ -12,26 +12,22 @@ jest.mock('@vegaprotocol/react-helpers', () => ({
.fn() .fn()
.mockImplementation(() => [false, mockSetValue, mockRemoveValue]), .mockImplementation(() => [false, mockSetValue, mockRemoveValue]),
})); }));
jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({ VEGA_ENV: 'test', SENTRY_DSN: 'sentry-dsn' }),
}));
describe('useTelemetryApproval', () => { describe('useTelemetryApproval', () => {
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
it('hook should return proper array', () => { it('hook should return proper array', () => {
const { result } = renderHook(() => useTelemetryApproval()); const res = renderHook(() => useTelemetryApproval());
expect(result.current[0]).toEqual(false); expect(res.result.current[0]).toEqual(false);
expect(result.current[1]).toEqual(expect.any(Function)); expect(res.result.current[1]).toEqual(expect.any(Function));
expect(useLocalStorage).toHaveBeenCalledWith(STORAGE_KEY); expect(useLocalStorage).toHaveBeenCalledWith(STORAGE_KEY);
}); });
it('hook should init stuff properly', async () => { it('hook should init stuff properly', async () => {
const { result } = renderHook(() => useTelemetryApproval()); const res = renderHook(() => useTelemetryApproval());
await act(() => { await act(() => {
result.current[1](true); res.result.current[1](true);
}); });
await waitFor(() => { await waitFor(() => {
expect(SentryInit).toHaveBeenCalled(); expect(SentryInit).toHaveBeenCalled();
@@ -40,9 +36,9 @@ describe('useTelemetryApproval', () => {
}); });
it('hook should close stuff properly', async () => { it('hook should close stuff properly', async () => {
const { result } = renderHook(() => useTelemetryApproval()); const res = renderHook(() => useTelemetryApproval());
await act(() => { await act(() => {
result.current[1](false); res.result.current[1](false);
}); });
await waitFor(() => { await waitFor(() => {
expect(SentryClose).toHaveBeenCalled(); expect(SentryClose).toHaveBeenCalled();
@@ -1,25 +1,24 @@
import { useLocalStorage } from '@vegaprotocol/react-helpers'; import { useLocalStorage } from '@vegaprotocol/react-helpers';
import { useCallback } from 'react'; import { useCallback } from 'react';
import { SentryInit, SentryClose } from '@vegaprotocol/logger'; import { SentryInit, SentryClose } from '@vegaprotocol/logger';
import { useEnvironment } from '@vegaprotocol/environment'; import { ENV } from '../config';
export const STORAGE_KEY = 'vega_telemetry_approval'; export const STORAGE_KEY = 'vega_telemetry_approval';
export const useTelemetryApproval = (): [ export const useTelemetryApproval = (): [
value: boolean, value: boolean,
setValue: (value: boolean) => void setValue: (value: boolean) => void
] => { ] => {
const { VEGA_ENV, SENTRY_DSN } = useEnvironment();
const [value, setValue, removeValue] = useLocalStorage(STORAGE_KEY); const [value, setValue, removeValue] = useLocalStorage(STORAGE_KEY);
const setApprove = useCallback( const setApprove = useCallback(
(value: boolean) => { (value: boolean) => {
if (value && SENTRY_DSN) { if (value) {
SentryInit(SENTRY_DSN, VEGA_ENV); SentryInit(ENV.dsn, ENV.envName);
return setValue('1'); return setValue('1');
} }
SentryClose(); SentryClose();
removeValue(); removeValue();
}, },
[setValue, removeValue, SENTRY_DSN, VEGA_ENV] [setValue, removeValue]
); );
return [Boolean(value), setApprove]; return [Boolean(value), setApprove];
}; };
+2 -2
View File
@@ -34,6 +34,7 @@ import { ViewingBanner } from '../components/viewing-banner';
import { AnnouncementBanner, UpgradeBanner } from '../components/banner'; import { AnnouncementBanner, UpgradeBanner } from '../components/banner';
import { AppLoader, DynamicLoader } from '../components/app-loader'; import { AppLoader, DynamicLoader } from '../components/app-loader';
import { Navbar } from '../components/navbar'; import { Navbar } from '../components/navbar';
import { ENV } from '../lib/config';
import { useDataProvider } from '@vegaprotocol/data-provider'; import { useDataProvider } from '@vegaprotocol/data-provider';
import { activeOrdersProvider } from '@vegaprotocol/orders'; import { activeOrdersProvider } from '@vegaprotocol/orders';
import { useTelemetryApproval } from '../lib/hooks/use-telemetry-approval'; import { useTelemetryApproval } from '../lib/hooks/use-telemetry-approval';
@@ -154,11 +155,10 @@ const PartyData = () => {
}; };
const MaybeConnectEagerly = () => { const MaybeConnectEagerly = () => {
const { VEGA_ENV, SENTRY_DSN } = useEnvironment();
useVegaEagerConnect(Connectors); useVegaEagerConnect(Connectors);
const [isTelemetryApproved] = useTelemetryApproval(); const [isTelemetryApproved] = useTelemetryApproval();
useEthereumEagerConnect( useEthereumEagerConnect(
isTelemetryApproved ? { dsn: SENTRY_DSN, env: VEGA_ENV } : {} isTelemetryApproved ? { dsn: ENV.dsn, env: ENV.envName } : {}
); );
const { pubKey, connect } = useVegaWallet(); const { pubKey, connect } = useVegaWallet();
+4
View File
@@ -20,6 +20,10 @@ export default function Document() {
href="https://static.vega.xyz/favicon.ico" href="https://static.vega.xyz/favicon.ico"
/> />
<script src="/theme-setter.js" type="text/javascript" async /> <script src="/theme-setter.js" type="text/javascript" async />
{['1', 'true'].includes(process.env['NX_USE_ENV_OVERRIDES'] || '') ? (
/* eslint-disable-next-line @next/next/no-sync-scripts */
<script src="/assets/env-config.js" type="text/javascript" />
) : null}
</Head> </Head>
<body className="font-alpha dark:bg-black dark:text-white"> <body className="font-alpha dark:bg-black dark:text-white">
<Main /> <Main />
+1 -9
View File
@@ -1,12 +1,4 @@
{ {
"presets": [ "presets": ["@nrwl/next/babel"],
[
"@nrwl/next/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": [] "plugins": []
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "__generated__"], "ignorePatterns": ["!**/*", "__generated__", "__generated___"],
"overrides": [ "overrides": [
{ {
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+1 -1
View File
@@ -8,7 +8,7 @@
"executor": "@nrwl/web:rollup", "executor": "@nrwl/web:rollup",
"outputs": ["{options.outputPath}"], "outputs": ["{options.outputPath}"],
"options": { "options": {
"outputPath": "dist/libs/announcements", "outputPath": "dist/libs/accounts",
"tsConfig": "libs/announcements/tsconfig.lib.json", "tsConfig": "libs/announcements/tsconfig.lib.json",
"project": "libs/announcements/package.json", "project": "libs/announcements/package.json",
"entryFile": "libs/announcements/src/index.ts", "entryFile": "libs/announcements/src/index.ts",
+1 -1
View File
@@ -131,7 +131,7 @@ export const CandlesChartContainer = ({
return ( return (
<div className="h-full flex flex-col"> <div className="h-full flex flex-col">
<div className="px-4 py-2 flex flex-row flex-wrap gap-2"> <div className="px-4 py-2 flex flex-row flex-wrap gap-4">
<DropdownMenu <DropdownMenu
trigger={ trigger={
<DropdownMenuTrigger> <DropdownMenuTrigger>
@@ -124,7 +124,7 @@ export const DealTicket = ({
normalizedOrder.size, normalizedOrder.size,
market.positionDecimalPlaces market.positionDecimalPlaces
).multipliedBy(toBigNum(price, market.decimalPlaces)), ).multipliedBy(toBigNum(price, market.decimalPlaces)),
market.decimalPlaces asset.decimals
); );
} }
return null; return null;
@@ -133,6 +133,7 @@ export const DealTicket = ({
normalizedOrder?.size, normalizedOrder?.size,
market.decimalPlaces, market.decimalPlaces,
market.positionDecimalPlaces, market.positionDecimalPlaces,
asset.decimals,
]); ]);
const feeEstimate = useEstimateFees( const feeEstimate = useEstimateFees(
@@ -301,25 +301,6 @@ describe('useEnvironment', () => {
expect(fetch).toHaveBeenCalledWith(configUrl); expect(fetch).toHaveBeenCalledWith(configUrl);
}); });
it('uses env vars from window._env_ if set', async () => {
const url = 'http://foo.bar.com';
// @ts-ignore _env_ is declared in app
window._env_ = {
VEGA_URL: url,
};
const { result } = setup();
await act(async () => {
result.current.initialize();
});
expect(result.current.VEGA_URL).toBe(url);
// @ts-ignore delete _env_
delete window['_env_'];
});
it('sets error if environment is invalid', async () => { it('sets error if environment is invalid', async () => {
const error = console.error; const error = console.error;
console.error = noop; console.error = noop;
+23 -96
View File
@@ -269,96 +269,34 @@ const testSubscription = (client: Client) => {
* here to appease the environment store interface * here to appease the environment store interface
*/ */
function compileEnvVars() { function compileEnvVars() {
const VEGA_ENV = windowOrDefault( const VEGA_ENV = process.env['NX_VEGA_ENV'] as Networks;
'VEGA_ENV',
process.env['NX_VEGA_ENV']
) as Networks;
const env: Environment = { const env: Environment = {
VEGA_URL: windowOrDefault('VEGA_URL', process.env['NX_VEGA_URL']), VEGA_URL: process.env['NX_VEGA_URL'],
VEGA_ENV, VEGA_ENV,
VEGA_CONFIG_URL: windowOrDefault( VEGA_CONFIG_URL: process.env['NX_VEGA_CONFIG_URL'] as string,
'VEGA_CONFIG_URL', VEGA_NETWORKS: parseNetworks(process.env['NX_VEGA_NETWORKS']),
process.env['NX_VEGA_CONFIG_URL'] as string VEGA_WALLET_URL: process.env['NX_VEGA_WALLET_URL'] as string,
), HOSTED_WALLET_URL: process.env['NX_HOSTED_WALLET_URL'],
VEGA_NETWORKS: parseNetworks( ETHERSCAN_URL: getEtherscanUrl(VEGA_ENV, process.env['NX_ETHERSCAN_URL']),
windowOrDefault('VEGA_NETWORKS', process.env['NX_VEGA_NETWORKS'])
),
VEGA_WALLET_URL: windowOrDefault(
'VEGA_WALLET_URL',
process.env['NX_VEGA_WALLET_URL'] as string
),
HOSTED_WALLET_URL: windowOrDefault(
'HOSTED_WALLET_URL',
process.env['NX_HOSTED_WALLET_URL']
),
ETHERSCAN_URL: getEtherscanUrl(
VEGA_ENV,
windowOrDefault('ETHERSCAN_URL', process.env['NX_ETHERSCAN_URL'])
),
ETHEREUM_PROVIDER_URL: getEthereumProviderUrl( ETHEREUM_PROVIDER_URL: getEthereumProviderUrl(
VEGA_ENV, VEGA_ENV,
windowOrDefault( process.env['NX_ETHEREUM_PROVIDER_URL']
'ETHEREUM_PROVIDER_URL',
process.env['NX_ETHEREUM_PROVIDER_URL']
)
), ),
ETH_LOCAL_PROVIDER_URL: windowOrDefault( ETH_LOCAL_PROVIDER_URL: process.env['NX_ETH_LOCAL_PROVIDER_URL'],
'ETH_LOCAL_PROVIDER_URL', ETH_WALLET_MNEMONIC: process.env['NX_ETH_WALLET_MNEMONIC'],
process.env['NX_ETH_LOCAL_PROVIDER_URL'] ORACLE_PROOFS_URL: process.env['NX_ORACLE_PROOFS_URL'],
), VEGA_DOCS_URL: process.env['NX_VEGA_DOCS_URL'],
ETH_WALLET_MNEMONIC: windowOrDefault( VEGA_CONSOLE_URL: process.env['NX_VEGA_CONSOLE_URL'],
'ETH_WALLET_MNEMONIC', VEGA_EXPLORER_URL: process.env['NX_VEGA_EXPLORER_URL'],
process.env['NX_ETH_WALLET_MNEMONIC'] VEGA_TOKEN_URL: process.env['NX_VEGA_TOKEN_URL'],
), GITHUB_FEEDBACK_URL: process.env['NX_GITHUB_FEEDBACK_URL'],
ORACLE_PROOFS_URL: windowOrDefault( MAINTENANCE_PAGE: parseBoolean(process.env['NX_MAINTENANCE_PAGE']),
'ORACLE_PROOFS_URL', GIT_BRANCH: process.env['GIT_COMMIT_BRANCH'],
process.env['NX_ORACLE_PROOFS_URL'] GIT_COMMIT_HASH: process.env['GIT_COMMIT_HASH'],
), GIT_ORIGIN_URL: process.env['GIT_ORIGIN_URL'],
VEGA_DOCS_URL: windowOrDefault( ANNOUNCEMENTS_CONFIG_URL: process.env['NX_ANNOUNCEMENTS_CONFIG_URL'],
'VEGA_DOCS_URL', VEGA_INCIDENT_URL: process.env['NX_VEGA_INCIDENT_URL'],
process.env['NX_VEGA_DOCS_URL'] APP_VERSION: process.env['NX_APP_VERSION'],
),
VEGA_CONSOLE_URL: windowOrDefault(
'VEGA_CONSOLE_URL',
process.env['NX_VEGA_CONSOLE_URL']
),
VEGA_EXPLORER_URL: windowOrDefault(
'VEGA_EXPLORER_URL',
process.env['NX_VEGA_EXPLORER_URL']
),
VEGA_TOKEN_URL: windowOrDefault(
'VEGA_TOKEN_URL',
process.env['NX_VEGA_TOKEN_URL']
),
GITHUB_FEEDBACK_URL: windowOrDefault(
'GITHUB_FEEDBACK_URL',
process.env['NX_GITHUB_FEEDBACK_URL']
),
MAINTENANCE_PAGE: parseBoolean(
windowOrDefault('MAINTENANCE_PAGE', process.env['NX_MAINTENANCE_PAGE'])
),
GIT_BRANCH: windowOrDefault(
'GIT_COMMIT_BRANCH',
process.env['GIT_COMMIT_BRANCH']
),
GIT_COMMIT_HASH: windowOrDefault(
'GIT_COMMIT_HASH',
process.env['GIT_COMMIT_HASH']
),
GIT_ORIGIN_URL: windowOrDefault(
'GIT_ORIGIN_URL',
process.env['GIT_ORIGIN_URL']
),
ANNOUNCEMENTS_CONFIG_URL: windowOrDefault(
'ANNOUNCEMENTS_CONFIG_URL',
process.env['NX_ANNOUNCEMENTS_CONFIG_URL']
),
VEGA_INCIDENT_URL: windowOrDefault(
'VEGA_INCIDENT_URL',
process.env['NX_VEGA_INCIDENT_URL']
),
APP_VERSION: windowOrDefault('APP_VERSION', process.env['NX_APP_VERSION']),
SENTRY_DSN: windowOrDefault('SENTRY_DSN', process.env['NX_SENTRY_DSN']),
}; };
return env; return env;
@@ -403,14 +341,3 @@ function getEtherscanUrl(
? 'https://etherscan.io' ? 'https://etherscan.io'
: 'https://sepolia.etherscan.io'; : 'https://sepolia.etherscan.io';
} }
export function windowOrDefault(key: string, defaultValue?: string) {
if (typeof window !== 'undefined') {
// @ts-ignore avoid conflic in env
if (window._env_ && window._env_[key]) {
// @ts-ignore presence has been check above
return window._env_[key];
}
}
return defaultValue || undefined;
}
@@ -5,7 +5,6 @@ import { useEnvironment } from './use-environment';
import { useNavigatorOnline } from '@vegaprotocol/react-helpers'; import { useNavigatorOnline } from '@vegaprotocol/react-helpers';
import { Intent } from '@vegaprotocol/ui-toolkit'; import { Intent } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/i18n'; import { t } from '@vegaprotocol/i18n';
import { isTestEnv } from '@vegaprotocol/utils';
const POLL_INTERVAL = 1000; const POLL_INTERVAL = 1000;
const BLOCK_THRESHOLD = 3; const BLOCK_THRESHOLD = 3;
@@ -39,7 +38,7 @@ export const useNodeHealth = () => {
return; return;
} }
if (!isTestEnv() && window.location.hostname !== 'localhost') { if (!('Cypress' in window) && window.location.hostname !== 'localhost') {
startPolling(POLL_INTERVAL); startPolling(POLL_INTERVAL);
} }
}, [error, startPolling, stopPolling]); }, [error, startPolling, stopPolling]);
@@ -52,7 +52,6 @@ const schemaObject = {
ANNOUNCEMENTS_CONFIG_URL: z.optional(z.string()), ANNOUNCEMENTS_CONFIG_URL: z.optional(z.string()),
VEGA_INCIDENT_URL: z.optional(z.string()), VEGA_INCIDENT_URL: z.optional(z.string()),
APP_VERSION: z.optional(z.string()), APP_VERSION: z.optional(z.string()),
SENTRY_DSN: z.optional(z.string()),
}; };
// combine schema above with custom rule to ensure either // combine schema above with custom rule to ensure either
@@ -1,6 +1,6 @@
import { useMemo, useEffect } from 'react'; import { useMemo, useEffect } from 'react';
import * as Schema from '@vegaprotocol/types'; import * as Schema from '@vegaprotocol/types';
import { removePaginationWrapper, isTestEnv } from '@vegaprotocol/utils'; import { removePaginationWrapper } from '@vegaprotocol/utils';
import { useProtocolUpgradeProposalsQuery } from './__generated__/ProtocolUpgradeProposals'; import { useProtocolUpgradeProposalsQuery } from './__generated__/ProtocolUpgradeProposals';
export const useNextProtocolUpgradeProposals = (since?: number) => { export const useNextProtocolUpgradeProposals = (since?: number) => {
@@ -21,7 +21,7 @@ export const useNextProtocolUpgradeProposals = (since?: number) => {
return; return;
} }
if (!isTestEnv() && window.location.hostname !== 'localhost') { if (!('Cypress' in window) && window.location.hostname !== 'localhost') {
startPolling(5000); startPolling(5000);
} }
}, [error, startPolling, stopPolling]); }, [error, startPolling, stopPolling]);
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useBlockStatisticsQuery } from './__generated__/BlockStatistics'; import { useBlockStatisticsQuery } from './__generated__/BlockStatistics';
import sum from 'lodash/sum'; import sum from 'lodash/sum';
import { isTestEnv } from '@vegaprotocol/utils';
const DEFAULT_POLLS = 10; const DEFAULT_POLLS = 10;
const INTERVAL = 1000; const INTERVAL = 1000;
@@ -21,7 +20,7 @@ const useAverageBlockDuration = (polls = DEFAULT_POLLS) => {
return; return;
} }
if (!isTestEnv() && window.location.hostname !== 'localhost') { if (!('Cypress' in window) && window.location.hostname !== 'localhost') {
startPolling(INTERVAL); startPolling(INTERVAL);
} }
}, [error, startPolling, stopPolling]); }, [error, startPolling, stopPolling]);
-1
View File
@@ -14,4 +14,3 @@ export * from './lib/remove-pagination-wrapper';
export * from './lib/time'; export * from './lib/time';
export * from './lib/validate'; export * from './lib/validate';
export * from './lib/resolve-network-name'; export * from './lib/resolve-network-name';
export * from './lib/is-test-env';
-3
View File
@@ -1,3 +0,0 @@
export const isTestEnv = () => {
return window && 'Cypress' in window;
};
+1 -2
View File
@@ -3,7 +3,6 @@ import { WalletClientError } from '@vegaprotocol/wallet-client';
import type { JsonRpcConnector } from './connectors'; import type { JsonRpcConnector } from './connectors';
import { ClientErrors } from './connectors'; import { ClientErrors } from './connectors';
import { useVegaWallet } from './use-vega-wallet'; import { useVegaWallet } from './use-vega-wallet';
import { isTestEnv } from '@vegaprotocol/utils';
export enum Status { export enum Status {
Idle = 'Idle', Idle = 'Idle',
@@ -35,7 +34,7 @@ export const useJsonRpcConnect = (onConnect: () => void) => {
// Do not throw in when cypress is running as trading app relies on // Do not throw in when cypress is running as trading app relies on
// mocks which result in a mismatch between chainId for app and // mocks which result in a mismatch between chainId for app and
// chainId for wallet // chainId for wallet
if (!isTestEnv()) { if (!('Cypress' in window)) {
const chainIdResult = await connector.getChainId(); const chainIdResult = await connector.getChainId();
if (chainIdResult.chainID !== appChainId) { if (chainIdResult.chainID !== appChainId) {
// Throw wallet error for consistent error handling // Throw wallet error for consistent error handling
+1 -2
View File
@@ -7,7 +7,6 @@ import type { Connector } from '@web3-react/types';
import { WalletConnect } from '@web3-react/walletconnect-v2'; import { WalletConnect } from '@web3-react/walletconnect-v2';
import { useEffect, useRef } from 'react'; import { useEffect, useRef } from 'react';
import { useWeb3ConnectStore } from './web3-connect-store'; import { useWeb3ConnectStore } from './web3-connect-store';
import { isTestEnv } from '@vegaprotocol/utils';
export const ETHEREUM_EAGER_CONNECT = 'ethereum-eager-connect'; export const ETHEREUM_EAGER_CONNECT = 'ethereum-eager-connect';
@@ -19,7 +18,7 @@ export const useEagerConnect = (loggerConf: LoggerProps) => {
const logger = localLoggerFactory(loggerConf); const logger = localLoggerFactory(loggerConf);
useEffect(() => { useEffect(() => {
if (attemptedRef.current || isTestEnv()) return; if (attemptedRef.current || 'Cypress' in window) return;
const stored = getConnector(connectors, eagerConnector); const stored = getConnector(connectors, eagerConnector);
+1
View File
@@ -22,6 +22,7 @@
"echo $NX_VEGA_URL", "echo $NX_VEGA_URL",
"echo $NX_TENDERMINT_URL", "echo $NX_TENDERMINT_URL",
"echo $NX_TENDERMINT_WEBSOCKET_URL", "echo $NX_TENDERMINT_WEBSOCKET_URL",
"echo $NX_USE_ENV_OVERRIDES",
"echo $NX_ETHEREUM_PROVIDER_URL" "echo $NX_ETHEREUM_PROVIDER_URL"
], ],
"url": "https://cloud.nx.app" "url": "https://cloud.nx.app"