('total');
@@ -68,9 +66,9 @@ export const RewardsPage = () => {
{t('rewardsIntro')}{' '}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{
const { t } = useTranslation();
- const { VEGA_DOCS_URL } = useEnvironment();
return (
<>
@@ -16,9 +14,9 @@ export const Staking = () => {
{t('stakingIntro')}{' '}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{
const { t } = useTranslation();
- const { VEGA_DOCS_URL } = useEnvironment();
const {
appState: { decimals },
} = useAppState();
@@ -213,12 +208,12 @@ export const ValidatorTables = ({
<>
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
<>
{t('pendingDescription1')}
diff --git a/apps/governance/src/routes/staking/node/validator-table.tsx b/apps/governance/src/routes/staking/node/validator-table.tsx
index e98d61062..dc1427ff8 100644
--- a/apps/governance/src/routes/staking/node/validator-table.tsx
+++ b/apps/governance/src/routes/staking/node/validator-table.tsx
@@ -1,7 +1,11 @@
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { useEnvironment } from '@vegaprotocol/environment';
-import { createDocsLinks, ExternalLinks, toBigNum } from '@vegaprotocol/utils';
+import {
+ useEnvironment,
+ DocsLinks,
+ ExternalLinks,
+} from '@vegaprotocol/environment';
+import { toBigNum } from '@vegaprotocol/utils';
import * as Schema from '@vegaprotocol/types';
import {
Link as UTLink,
@@ -64,7 +68,7 @@ export const ValidatorTable = ({
stakedTotal,
previousEpochData,
}: ValidatorTableProps) => {
- const { ETHERSCAN_URL, VEGA_DOCS_URL } = useEnvironment();
+ const { ETHERSCAN_URL } = useEnvironment();
const { t } = useTranslation();
const {
appState: { decimals },
@@ -90,9 +94,9 @@ export const ValidatorTable = ({
<>
{t('validatorFormIntro')}{' '}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{
market?.tradableInstrument.instrument.product.settlementAsset.decimals || 0;
const symbol =
market?.tradableInstrument.instrument.product.settlementAsset.symbol;
- const { VEGA_DOCS_URL } = useEnvironment();
const { params } = useNetworkParams([
NetworkParams.market_liquidity_stakeToCcyVolume,
@@ -216,10 +214,12 @@ const LiquidityViewHeader = memo(({ marketId }: { marketId?: string }) => {
{marketId}
- {VEGA_DOCS_URL && (
-
+ {DocsLinks ? (
+
{t('Providing liquidity')}
+ ) : (
+ (null as React.ReactNode)
)}
diff --git a/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx b/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx
index 0771cbdc9..fadc70aca 100644
--- a/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx
+++ b/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx
@@ -19,11 +19,10 @@ import { useCheckLiquidityStatus } from '@vegaprotocol/liquidity';
import { AuctionTrigger, MarketTradingMode } from '@vegaprotocol/types';
import {
addDecimalsFormatNumber,
- createDocsLinks,
formatNumberPercentage,
} from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n';
-import { useEnvironment } from '@vegaprotocol/environment';
+import { DocsLinks } from '@vegaprotocol/environment';
interface Props {
marketId?: string;
@@ -47,8 +46,6 @@ export const MarketLiquiditySupplied = ({
params.market_liquidity_targetstake_triggering_ratio
);
- const { VEGA_DOCS_URL } = useEnvironment();
-
const variables = useMemo(
() => ({
marketId: marketId || '',
@@ -131,11 +128,8 @@ export const MarketLiquiditySupplied = ({
{t('View liquidity provision table')}
- {VEGA_DOCS_URL && (
-
+ {DocsLinks && (
+
{t('Learn about providing liquidity')}
)}
diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx
index 7853c3c94..92ed77c12 100644
--- a/apps/trading/components/navbar/navbar.tsx
+++ b/apps/trading/components/navbar/navbar.tsx
@@ -5,6 +5,7 @@ import {
TOKEN_GOVERNANCE,
useEnvironment,
useLinks,
+ DocsLinks,
} from '@vegaprotocol/environment';
import { t } from '@vegaprotocol/i18n';
import { useGlobalStore } from '../../stores';
@@ -22,7 +23,6 @@ import {
} from '@vegaprotocol/ui-toolkit';
import { Links, Routes } from '../../pages/client-router';
-import { createDocsLinks } from '@vegaprotocol/utils';
import { SettingsButton } from '../../client-pages/settings';
import {
ProtocolUpgradeCountdown,
@@ -34,7 +34,7 @@ export const Navbar = ({
}: {
theme: ComponentProps['theme'];
}) => {
- const { VEGA_DOCS_URL, GITHUB_FEEDBACK_URL } = useEnvironment();
+ const { GITHUB_FEEDBACK_URL } = useEnvironment();
const tokenLink = useLinks(DApp.Token);
const { marketId } = useGlobalStore((store) => ({
marketId: store.marketId,
@@ -92,15 +92,13 @@ export const Navbar = ({
{t('Governance')}
- {VEGA_DOCS_URL && GITHUB_FEEDBACK_URL && (
+ {DocsLinks?.NEW_TO_VEGA && GITHUB_FEEDBACK_URL && (
{t('Resources')}
-
+
{t('Docs')}
diff --git a/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx b/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx
index 4e7a6bc55..db39747fa 100644
--- a/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx
+++ b/apps/trading/components/welcome-dialog/risk-notice-dialog.tsx
@@ -8,11 +8,10 @@ import {
import { RISK_ACCEPTED_KEY } from '../constants';
import { TelemetryApproval } from './telemetry-approval';
import {
- DOCS_VEGA_WALLET,
- GET_VEGA_WALLET_URL,
Networks,
- useDocsLink,
useEnvironment,
+ DocsLinks,
+ ExternalLinks,
} from '@vegaprotocol/environment';
import { useLocalStorage } from '@vegaprotocol/react-helpers';
@@ -53,8 +52,6 @@ export const RiskNoticeDialog = ({ onClose, network }: Props) => {
const TestnetContent = ({ network }: { network: Networks }) => {
const { GITHUB_FEEDBACK_URL } = useEnvironment();
- const docsLink = useDocsLink();
-
return (
<>
@@ -69,16 +66,16 @@ const TestnetContent = ({ network }: { network: Networks }) => {
[network]
)}
- {GITHUB_FEEDBACK_URL && GET_VEGA_WALLET_URL && docsLink && (
+ {GITHUB_FEEDBACK_URL && DocsLinks && (
-
-
+
{t('Get a Vega Wallet')}{' '}
-
-
+
{t('Learn about Vega Wallet')}{' '}
diff --git a/apps/trading/components/welcome-dialog/welcome-notice-dialog.tsx b/apps/trading/components/welcome-dialog/welcome-notice-dialog.tsx
index a6540d3cc..add257938 100644
--- a/apps/trading/components/welcome-dialog/welcome-notice-dialog.tsx
+++ b/apps/trading/components/welcome-dialog/welcome-notice-dialog.tsx
@@ -1,13 +1,13 @@
import { ExternalLink } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/i18n';
import {
- BLOG,
DApp,
Networks,
TOKEN_NEW_MARKET_PROPOSAL,
TOKEN_PROPOSALS,
useEnvironment,
useLinks,
+ ExternalLinks,
} from '@vegaprotocol/environment';
import { ProposedMarkets } from './proposed-markets';
@@ -52,7 +52,7 @@ export const WelcomeNoticeDialog = () => {
-
+
{t('Read about the mainnet launch')}
diff --git a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx
index e0de874da..1e0350a00 100644
--- a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx
+++ b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx
@@ -2,8 +2,8 @@ import { useMemo } from 'react';
import { parseISO, isValid, isAfter } from 'date-fns';
import classNames from 'classnames';
import { useProposalOfMarketQuery } from '@vegaprotocol/proposals';
-import { useEnvironment } from '@vegaprotocol/environment';
-import { createDocsLinks, getDateTimeFormat } from '@vegaprotocol/utils';
+import { DocsLinks } from '@vegaprotocol/environment';
+import { getDateTimeFormat } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n';
import * as Schema from '@vegaprotocol/types';
import { ExternalLink, SimpleGrid } from '@vegaprotocol/ui-toolkit';
@@ -23,7 +23,6 @@ export const TradingModeTooltip = ({
skip,
skipGrid,
}: TradingModeTooltipProps) => {
- const { VEGA_DOCS_URL } = useEnvironment();
const { data: market } = useMarket(marketId);
const { data: marketData } = useStaticMarketData(marketId, skip);
const { marketTradingMode, trigger } = marketData || {};
@@ -102,9 +101,9 @@ export const TradingModeTooltip = ({
>
)}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{t('Find out more')}
@@ -126,12 +125,9 @@ export const TradingModeTooltip = ({
'This market is in auction until it reaches sufficient liquidity.'
)}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{t('Find out more')}
@@ -151,12 +147,9 @@ export const TradingModeTooltip = ({
'This market may have sufficient liquidity but there are not enough priced limit orders in the order book, which are required to deploy liquidity commitment pegged orders.'
)}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{t('Find out more')}
@@ -174,12 +167,9 @@ export const TradingModeTooltip = ({
{t('This market is in auction due to high price volatility.')}
{' '}
- {VEGA_DOCS_URL && (
+ {DocsLinks && (
{t('Find out more')}
diff --git a/libs/environment/src/hooks/use-links.ts b/libs/environment/src/hooks/use-links.ts
index ca99ac4b4..d8be6da34 100644
--- a/libs/environment/src/hooks/use-links.ts
+++ b/libs/environment/src/hooks/use-links.ts
@@ -4,6 +4,8 @@ import { Networks } from '../types';
import { useEnvironment } from './use-environment';
import { stripFullStops } from '@vegaprotocol/utils';
+const VEGA_DOCS_URL = process.env['NX_VEGA_DOCS_URL'] || '';
+
type Net = Exclude;
export enum DApp {
Explorer = 'Explorer',
@@ -50,6 +52,25 @@ const Links: { [k in DApp]: DAppLinks } = {
[DApp.Token]: TokenLinks,
};
+export const DocsLinks = VEGA_DOCS_URL
+ ? {
+ NEW_TO_VEGA: `${VEGA_DOCS_URL}/concepts/new-to-vega`,
+ AUCTION_TYPE_OPENING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-opening`,
+ AUCTION_TYPE_LIQUIDITY_MONITORING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-liquidity-monitoring`,
+ AUCTION_TYPE_PRICE_MONITORING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-price-monitoring`,
+ AUCTION_TYPE_CLOSING: `${VEGA_DOCS_URL}/concepts/trading-on-vega/trading-modes#auction-type-closing`,
+ STAKING_GUIDE: `${VEGA_DOCS_URL}/concepts/vega-chain/#staking-on-vega`,
+ REWARDS_GUIDE: `${VEGA_DOCS_URL}/concepts/trading-on-vega/fees-rewards#trading-rewards`,
+ VEGA_WALLET_CONCEPTS_URL: `${VEGA_DOCS_URL}/concepts/vega-wallet`,
+ VEGA_WALLET_TOOLS_URL: `${VEGA_DOCS_URL}/tools/vega-wallet`,
+ PROPOSALS_GUIDE: `${VEGA_DOCS_URL}/tutorials/proposals`,
+ NODE_OPERATORS: `${VEGA_DOCS_URL}/node-operators`,
+ LOSS_SOCIALIZATION: `${VEGA_DOCS_URL}/concepts/trading-on-vega/market-protections#loss-socialisation`,
+ POSITION_RESOLUTION: `${VEGA_DOCS_URL}/concepts/trading-on-vega/market-protections#position-resolution`,
+ LIQUIDITY: `${VEGA_DOCS_URL}/concepts/liquidity/provision`,
+ }
+ : undefined;
+
export const useLinks = (dapp: DApp, network?: Net) => {
const { VEGA_ENV, VEGA_EXPLORER_URL, VEGA_TOKEN_URL } = useEnvironment();
const fallback = {
@@ -84,19 +105,6 @@ export const useEtherscanLink = () => {
return link;
};
-export const useDocsLink = () => {
- const { VEGA_DOCS_URL } = useEnvironment();
- const baseUrl = trim(VEGA_DOCS_URL, '/');
- const link = useCallback(
- (url?: string) => `${baseUrl}/${trim(url, '/') || ''}`,
- [baseUrl]
- );
- return link;
-};
-
-// Vega blog
-export const BLOG = 'https://blog.vega.xyz/';
-
// Governance pages
export const TOKEN_NEW_MARKET_PROPOSAL = '/proposals/propose/new-market';
export const TOKEN_NEW_NETWORK_PARAM_PROPOSAL =
@@ -130,14 +138,20 @@ export const EXPLORER_ORACLE = '/oracles/:id';
export const ETHERSCAN_ADDRESS = '/address/:hash';
export const ETHERSCAN_TX = '/tx/:hash';
-// Console pages
-export const CONSOLE_MARKET = '/markets/:marketId';
-export const CONSOLE_MARKETS = '/markets/all';
-export const CONSOLE_PORTFOLIO = '/portfolio';
-export const CONSOLE_LIQUIDITY = 'liquidity/:marketId';
+export const ExternalLinks = {
+ FEEDBACK: 'https://github.com/vegaprotocol/feedback/discussions',
+ GITHUB: 'https://github.com/vegaprotocol/token-frontend',
+ DISCORD: 'https://vega.xyz/discord',
+ GOVERNANCE_PAGE: 'https://vega.xyz/governance',
+ VALIDATOR_FORUM: 'https://community.vega.xyz/c/mainnet-validator-candidates',
+ MARGIN_CREDIT_RISK:
+ 'https://vega.xyz/papers/margins-and-credit-risk.pdf#page=7',
+ VEGA_WALLET_URL: 'https://vega.xyz/wallet',
+ VEGA_WALLET_HOSTED_URL: 'https://vega-hosted-wallet.on.fleek.co/',
+ BLOG: 'https://blog.vega.xyz/',
+};
-// Vega XYZ
-export const GET_VEGA_WALLET_URL = 'https://vega.xyz/wallet/';
-
-// Docs
-export const DOCS_VEGA_WALLET = '/tools/vega-wallet';
+export const TokenStaticLinks = {
+ PROPOSAL_PAGE: ':tokenUrl/proposals/:proposalId',
+ UPDATE_PROPOSAL_PAGE: ':tokenUrl/proposals/propose/update-market',
+};
diff --git a/libs/market-info/src/lib/components/market-info/market-info-accordion.tsx b/libs/market-info/src/lib/components/market-info/market-info-accordion.tsx
index 750bfbbb8..9aaf6e8fd 100644
--- a/libs/market-info/src/lib/components/market-info/market-info-accordion.tsx
+++ b/libs/market-info/src/lib/components/market-info/market-info-accordion.tsx
@@ -1,5 +1,5 @@
-import { useEnvironment } from '@vegaprotocol/environment';
-import { removePaginationWrapper, TokenLinks } from '@vegaprotocol/utils';
+import { TokenStaticLinks, useEnvironment } from '@vegaprotocol/environment';
+import { removePaginationWrapper } from '@vegaprotocol/utils';
import { t } from '@vegaprotocol/i18n';
import { useDataProvider } from '@vegaprotocol/data-provider';
import * as Schema from '@vegaprotocol/types';
@@ -236,7 +236,7 @@ export const MarketInfoAccordion = ({
{VEGA_TOKEN_URL && (
{
onClose?: (data: Position) => void;
@@ -397,9 +396,7 @@ export const PNLCell = ({
valueFormatted,
data,
}: VegaICellRendererParams) => {
- const { VEGA_DOCS_URL } = useEnvironment();
- const LOSS_SOCIALIZATION_LINK =
- VEGA_DOCS_URL && createDocsLinks(VEGA_DOCS_URL).LOSS_SOCIALIZATION;
+ const LOSS_SOCIALIZATION_LINK = DocsLinks?.LOSS_SOCIALIZATION ?? '';
if (!data) {
return <>->;
@@ -423,7 +420,7 @@ export const PNLCell = ({
{t('Lifetime loss socialisation deductions: %s', lossesFormatted)}
- {VEGA_DOCS_URL && (
+ {LOSS_SOCIALIZATION_LINK && (
{t('Read more about loss socialisation')}
@@ -440,8 +437,6 @@ export const OpenVolumeCell = ({
valueFormatted,
data,
}: VegaICellRendererParams) => {
- const { VEGA_DOCS_URL } = useEnvironment();
-
if (!data) {
return <>->;
}
@@ -451,8 +446,7 @@ export const OpenVolumeCell = ({
return <>{valueFormatted}>;
}
- const POSITION_RESOLUTION_LINK =
- VEGA_DOCS_URL && createDocsLinks(VEGA_DOCS_URL).POSITION_RESOLUTION;
+ const POSITION_RESOLUTION_LINK = DocsLinks?.POSITION_RESOLUTION ?? '';
return (
- {VEGA_DOCS_URL && (
+ {POSITION_RESOLUTION_LINK && (
{t('Read more about position resolution')}
diff --git a/libs/utils/src/index.ts b/libs/utils/src/index.ts
index 7a49c1ae0..3d7927235 100644
--- a/libs/utils/src/index.ts
+++ b/libs/utils/src/index.ts
@@ -6,7 +6,6 @@ export * from './lib/get-user-locale';
export * from './lib/helpers';
export * from './lib/is-asset-erc20';
export * from './lib/is-valid-url';
-export * from './lib/links';
export * from './lib/local-logger';
export * from './lib/local-storage';
export * from './lib/markets';
diff --git a/libs/utils/src/lib/links.ts b/libs/utils/src/lib/links.ts
deleted file mode 100644
index b3c8bce97..000000000
--- a/libs/utils/src/lib/links.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/** createDocsLinks returns external documentation links that are specific to an environment
- * @param {string} docsUrl - the documentation URL for the environment ex. https://docs.vega.xyz/testnet or https://docs.vega.xyz/mainnet (NX_VEGA_DOCS_URL)
- */
-
-export const createDocsLinks = (docsUrl: string) => ({
- NEW_TO_VEGA: `${docsUrl}/concepts/new-to-vega`,
- AUCTION_TYPE_OPENING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-opening`,
- AUCTION_TYPE_LIQUIDITY_MONITORING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-liquidity-monitoring`,
- AUCTION_TYPE_PRICE_MONITORING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-price-monitoring`,
- AUCTION_TYPE_CLOSING: `${docsUrl}/concepts/trading-on-vega/trading-modes#auction-type-closing`,
- STAKING_GUIDE: `${docsUrl}/concepts/vega-chain/#staking-on-vega`,
- REWARDS_GUIDE: `${docsUrl}/concepts/trading-on-vega/fees-rewards#trading-rewards`,
- VEGA_WALLET_CONCEPTS_URL: `${docsUrl}/concepts/vega-wallet`,
- PROPOSALS_GUIDE: `${docsUrl}/tutorials/proposals`,
- NODE_OPERATORS: `${docsUrl}/node-operators`,
- LOSS_SOCIALIZATION: `${docsUrl}/concepts/trading-on-vega/market-protections#loss-socialisation`,
- POSITION_RESOLUTION: `${docsUrl}/concepts/trading-on-vega/market-protections#position-resolution`,
- LIQUIDITY: `${docsUrl}/concepts/liquidity/provision`,
-});
-
-export const ExternalLinks = {
- FEEDBACK: 'https://github.com/vegaprotocol/feedback/discussions',
- GITHUB: 'https://github.com/vegaprotocol/token-frontend',
- DISCORD: 'https://vega.xyz/discord',
- GOVERNANCE_PAGE: 'https://vega.xyz/governance',
- VALIDATOR_FORUM: 'https://community.vega.xyz/c/mainnet-validator-candidates',
- MARGIN_CREDIT_RISK:
- 'https://vega.xyz/papers/margins-and-credit-risk.pdf#page=7',
- VEGA_WALLET_URL: 'https://vega.xyz/wallet',
- VEGA_WALLET_HOSTED_URL: 'https://vega-hosted-wallet.on.fleek.co/',
-};
-
-export const TokenLinks = {
- PROPOSAL_PAGE: ':tokenUrl/proposals/:proposalId',
- UPDATE_PROPOSAL_PAGE: ':tokenUrl/proposals/propose/update-market',
-};
diff --git a/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx b/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx
index 820ae9505..96b7cd7cc 100644
--- a/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx
+++ b/libs/wallet/src/connect-dialog/connect-dialog-elements.tsx
@@ -1,5 +1,4 @@
-import { useEnvironment } from '@vegaprotocol/environment';
-import { createDocsLinks, ExternalLinks } from '@vegaprotocol/utils';
+import { DocsLinks, ExternalLinks } from '@vegaprotocol/environment';
import { t } from '@vegaprotocol/i18n';
import { Link } from '@vegaprotocol/ui-toolkit';
import type { ReactNode } from 'react';
@@ -20,7 +19,6 @@ export const ConnectDialogContent = ({ children }: { children: ReactNode }) => {
};
export const ConnectDialogFooter = ({ children }: { children?: ReactNode }) => {
- const { VEGA_DOCS_URL } = useEnvironment();
return (
);
- const { VEGA_DOCS_URL } = useEnvironment();
if (error) {
if (error.code === ClientErrors.NO_SERVICE.code) {
@@ -173,10 +171,8 @@ const Error = ({
<>
{capitalize(error.message)}
{'. '}
- {VEGA_DOCS_URL && (
-
+ {DocsLinks && (
+
{t('Read the docs to troubleshoot')}
)}