Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a8bcad59f | ||
|
|
07ab34044f | ||
|
|
2d4be5fcb3 | ||
|
|
835f2b793f | ||
|
|
d50b988b4a | ||
|
|
a6aec899c8 |
+10
-4
@@ -1,4 +1,4 @@
|
||||
import { useMemo, useEffect, useState, useCallback } from 'react';
|
||||
import { useMemo, useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { AsyncRenderer, Pagination } from '@vegaprotocol/ui-toolkit';
|
||||
import { removePaginationWrapper } from '@vegaprotocol/utils';
|
||||
@@ -86,12 +86,18 @@ export const EpochIndividualRewards = ({
|
||||
[epochId, page, refetch, delegationsPagination, pubKey]
|
||||
);
|
||||
|
||||
const prevEpochIdRef = useRef<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// when the epoch changes, we want to refetch the data to update the current page
|
||||
if (data) {
|
||||
if (prevEpochIdRef.current === null) {
|
||||
prevEpochIdRef.current = epochId;
|
||||
} else if (epochId !== prevEpochIdRef.current) {
|
||||
// When the epoch changes, we want to refetch the data to update the current page
|
||||
refetchData();
|
||||
}
|
||||
}, [epochId, data, refetchData]);
|
||||
|
||||
prevEpochIdRef.current = epochId;
|
||||
}, [epochId, refetchData]);
|
||||
|
||||
return (
|
||||
<AsyncRenderer
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ NX_SUCCESSOR_MARKETS=true
|
||||
NX_STOP_ORDERS=true
|
||||
NX_ICEBERG_ORDERS=true
|
||||
# NX_PRODUCT_PERPETUALS
|
||||
NX_METAMASK_SNAPS=false
|
||||
NX_METAMASK_SNAPS=true
|
||||
|
||||
NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz
|
||||
NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket
|
||||
|
||||
@@ -9,5 +9,11 @@ export const AnnouncementBanner = () => {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <Banner app="console" configUrl={ANNOUNCEMENTS_CONFIG_URL} />;
|
||||
return (
|
||||
<Banner
|
||||
app="console"
|
||||
configUrl={ANNOUNCEMENTS_CONFIG_URL}
|
||||
background="url('/banner-bg.jpg')"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,33 +4,24 @@ export default function Document() {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
{/*
|
||||
{/*
|
||||
meta tags
|
||||
- next advised against using _document for this, so they exist in our
|
||||
- next advised against using _document for this, so they exist in our
|
||||
- single page index.page.tsx
|
||||
*/}
|
||||
|
||||
{/* icons */}
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/x-icon"
|
||||
href="https://static.vega.xyz/favicon.ico"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
content="https://static.vega.xyz/favicon.ico"
|
||||
/>
|
||||
|
||||
{/* fonts */}
|
||||
{/* preload fonts */}
|
||||
<link
|
||||
rel="preload"
|
||||
href="https://static.vega.xyz/AlphaLyrae-Medium.woff2"
|
||||
href="/AlphaLyrae-Medium.woff2"
|
||||
as="font"
|
||||
type="font/woff2"
|
||||
/>
|
||||
|
||||
{/* styles */}
|
||||
<link rel="stylesheet" href="https://static.vega.xyz/fonts.css" />
|
||||
{/* icons */}
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" content="/favicon.ico" />
|
||||
|
||||
{/* eslint-disable-next-line @next/next/no-css-tags */}
|
||||
<link rel="stylesheet" href="/preloader.css" media="all" />
|
||||
|
||||
|
||||
@@ -19,17 +19,11 @@ export default function Index() {
|
||||
<meta name="og:url" content="https://console.vega.xyz/" />
|
||||
<meta name="og:title" content="Vega Protocol - Console" />
|
||||
<meta name="og:site_name" content="Vega Protocol - Console" />
|
||||
<meta name="og:image" content="https://static.vega.xyz/favicon.ico" />
|
||||
<meta
|
||||
name="twitter:card"
|
||||
content="https://static.vega.xyz/favicon.ico"
|
||||
/>
|
||||
<meta name="og:image" content="./favicon.ico" />
|
||||
<meta name="twitter:card" content="./favicon.ico" />
|
||||
<meta name="twitter:title" content="Vega Protocol - Console" />
|
||||
<meta name="twitter:description" content="Vega Protocol - Console" />
|
||||
<meta
|
||||
name="twitter:image"
|
||||
content="https://static.vega.xyz/favicon.ico"
|
||||
/>
|
||||
<meta name="twitter:image" content="./favicon.ico" />
|
||||
<meta name="twitter:image:alt" content="VEGA logo" />
|
||||
<meta name="twitter:site" content="@vegaprotocol" />
|
||||
</Head>
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
@import 'ag-grid-community/styles/ag-grid.css';
|
||||
@import 'ag-grid-community/styles/ag-theme-balham.css';
|
||||
|
||||
/** Load AlphaLyrae font */
|
||||
@font-face {
|
||||
font-family: AlphaLyrae;
|
||||
src: url('/AlphaLyrae-Medium.woff2') format('woff2'),
|
||||
url('/AlphaLyrae-Medium.woff') format('woff');
|
||||
}
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
@@ -14,6 +14,7 @@ import {
|
||||
export type AnnouncementBannerProps = {
|
||||
app: AppNameType;
|
||||
configUrl: string;
|
||||
background?: string;
|
||||
};
|
||||
|
||||
// run only if below the allowed maximum delay ~24.8 days (https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value)
|
||||
@@ -36,6 +37,7 @@ const doesEndInTheFuture = (now: Date, data: Announcement) => {
|
||||
export const AnnouncementBanner = ({
|
||||
app,
|
||||
configUrl,
|
||||
background,
|
||||
}: AnnouncementBannerProps) => {
|
||||
const [isVisible, setVisible] = useState(false);
|
||||
const { data, reload } = useAnnouncement(app, configUrl);
|
||||
@@ -79,10 +81,10 @@ export const AnnouncementBanner = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<Banner className="relative px-10">
|
||||
<Banner className="relative px-10" background={background}>
|
||||
<div
|
||||
data-testid="app-announcement"
|
||||
className="relative font-alpha flex gap-2 justify-center text-center text-lg text-white"
|
||||
className="relative flex justify-center text-lg text-center text-white font-alpha gap-2"
|
||||
>
|
||||
<span>{data.text}</span>{' '}
|
||||
{data.urlText && data.url && (
|
||||
@@ -90,7 +92,7 @@ export const AnnouncementBanner = ({
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
className="absolute right-0 top-0 p-4 w-10 h-full flex items-center justify-center text-white"
|
||||
className="absolute top-0 right-0 flex items-center justify-center w-10 h-full p-4 text-white"
|
||||
data-testid="app-announcement-close"
|
||||
onClick={() => {
|
||||
setVisible(false);
|
||||
|
||||
@@ -4,14 +4,27 @@ import type { ReactNode } from 'react';
|
||||
export interface BannerProps {
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
background?: string;
|
||||
}
|
||||
|
||||
export const AnnouncementBanner = ({ className, children }: BannerProps) => {
|
||||
const bannerClasses = classnames(
|
||||
"bg-[url('https://static.vega.xyz/assets/img/banner-bg.jpg')] bg-cover bg-center bg-no-repeat",
|
||||
'p-4',
|
||||
className
|
||||
);
|
||||
export const AnnouncementBanner = ({
|
||||
className,
|
||||
children,
|
||||
background = 'url("https://static.vega.xyz/assets/img/banner-bg.jpg")',
|
||||
}: BannerProps) => {
|
||||
const bannerClasses = classnames('p-4', className);
|
||||
|
||||
return <div className={bannerClasses}>{children}</div>;
|
||||
return (
|
||||
<div
|
||||
className={bannerClasses}
|
||||
style={{
|
||||
background,
|
||||
backgroundRepeat: 'no-repeat',
|
||||
backgroundPosition: 'center',
|
||||
backgroundSize: 'cover',
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -155,8 +155,7 @@ const ConnectDialogContainer = ({
|
||||
|
||||
const isDesktopWalletRunning = useIsWalletServiceRunning(
|
||||
walletUrl,
|
||||
connectors['jsonRpc'],
|
||||
appChainId
|
||||
connectors['jsonRpc']
|
||||
);
|
||||
|
||||
const snapStatus = useSnapStatus(
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { renderHook, waitFor } from '@testing-library/react';
|
||||
import { JsonRpcConnector } from './connectors';
|
||||
import { useIsWalletServiceRunning } from './use-is-wallet-service-running';
|
||||
|
||||
describe('useIsWalletServiceRunning', () => {
|
||||
it('returns true if wallet is running', async () => {
|
||||
const url = 'https://foo.bar.com';
|
||||
const connector = new JsonRpcConnector();
|
||||
const spyOnCheckCompat = jest
|
||||
.spyOn(connector, 'checkCompat')
|
||||
.mockResolvedValue(true);
|
||||
const { result } = renderHook(() =>
|
||||
useIsWalletServiceRunning(url, connector)
|
||||
);
|
||||
|
||||
expect(result.current).toBe(null);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(spyOnCheckCompat).toHaveBeenCalled();
|
||||
expect(result.current).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns false if wallet is not running', async () => {
|
||||
const url = 'https://foo.bar.com';
|
||||
const connector = new JsonRpcConnector();
|
||||
const spyOnCheckCompat = jest
|
||||
.spyOn(connector, 'checkCompat')
|
||||
.mockRejectedValue(false);
|
||||
const { result } = renderHook(() =>
|
||||
useIsWalletServiceRunning(url, connector)
|
||||
);
|
||||
|
||||
expect(result.current).toBe(null);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(spyOnCheckCompat).toHaveBeenCalled();
|
||||
expect(result.current).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { JsonRpcConnector } from './connectors';
|
||||
|
||||
export const useIsWalletServiceRunning = (
|
||||
url: string,
|
||||
connector: JsonRpcConnector | undefined
|
||||
) => {
|
||||
const [isRunning, setIsRunning] = useState<boolean | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!connector) return;
|
||||
|
||||
if (url && url !== connector.url) {
|
||||
connector.url = url;
|
||||
}
|
||||
|
||||
const check = async () => {
|
||||
try {
|
||||
// we are not checking wallet compatibility here, only that the wallet is running
|
||||
await connector.checkCompat();
|
||||
setIsRunning(true);
|
||||
} catch {
|
||||
setIsRunning(false);
|
||||
}
|
||||
};
|
||||
|
||||
// check immediately
|
||||
check();
|
||||
|
||||
// check every second for quick feedback to the user
|
||||
const interval = setInterval(check, 1000);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [connector, url]);
|
||||
|
||||
return isRunning;
|
||||
};
|
||||
@@ -1,47 +0,0 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import type { JsonRpcConnector } from './connectors';
|
||||
import { ClientErrors } from './connectors';
|
||||
|
||||
export const useIsWalletServiceRunning = (
|
||||
url: string,
|
||||
connector: JsonRpcConnector | undefined,
|
||||
appChainId: string
|
||||
) => {
|
||||
const [run, setRun] = useState<boolean | null>(null);
|
||||
|
||||
const checkState = useCallback(async () => {
|
||||
if (!connector) return false;
|
||||
|
||||
if (url && url !== connector.url) {
|
||||
connector.url = url;
|
||||
}
|
||||
|
||||
try {
|
||||
await connector.checkCompat();
|
||||
const chainIdResult = await connector.getChainId();
|
||||
if (chainIdResult.chainID !== appChainId) {
|
||||
throw ClientErrors.WRONG_NETWORK;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, [connector, url, appChainId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!connector) return;
|
||||
|
||||
let interval: NodeJS.Timeout;
|
||||
checkState().then((value) => {
|
||||
setRun(value);
|
||||
interval = setInterval(async () => {
|
||||
setRun(await checkState());
|
||||
}, 1000 * 10);
|
||||
});
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [checkState, connector]);
|
||||
|
||||
return run;
|
||||
};
|
||||
Reference in New Issue
Block a user