Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/great-crabs-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@venusprotocol/chains": minor
"@venusprotocol/evm": minor
---

add auto-reload ui support for new hardforks config
42 changes: 42 additions & 0 deletions apps/evm/src/App/ChainUpgradeHandler/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { renderComponent } from 'testUtils/render';

import type { MockInstance } from 'vitest';
import { ChainUpgradeHandler } from '../';

const runtimeTimestamp = new Date().getTime();
const upgradeTimestamps = [new Date(runtimeTimestamp + 2000)];
const fakeNowMs = runtimeTimestamp + 12000;

describe('ChainUpgradeHandler', () => {
const original = window.location;
let reloadSpy: MockInstance;

beforeEach(() => {
// 1. Redefine the 'reload' property on window.location to be configurable.
// This is necessary because it is non-configurable by default in jsdom.
Object.defineProperty(window, 'location', {
configurable: true,
value: () => {}, // Provide a dummy function initially
});

Object.defineProperty(window.location, 'reload', {
configurable: true,
value: () => {}, // Provide a dummy function initially
});

// 2. Create the spy on the now-configurable property.
reloadSpy = vi.spyOn(window.location, 'reload');
});

afterAll(() => {
Object.defineProperty(window, 'location', { configurable: true, value: original });
});

it('auto reload after passing hardforks', () => {
vi.useFakeTimers().setSystemTime(new Date(fakeNowMs));

renderComponent(<ChainUpgradeHandler upgradeTimestamps={upgradeTimestamps} />);

expect(reloadSpy).toHaveBeenCalled();
});
});
98 changes: 49 additions & 49 deletions apps/evm/src/App/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { opBnbTestnetFourierForkTimestamp } from '@venusprotocol/chains';

import { QueryClientProvider } from '@tanstack/react-query';
import { queryClient } from 'clients/api';
import config from 'config';
import { useChain } from 'hooks/useChain';
import { AnalyticProvider } from 'libs/analytics';
import { ErrorBoundary } from 'libs/errors';
import { SentryErrorInfo } from 'libs/errors/SentryErrorInfo';
Expand All @@ -22,61 +21,62 @@ const GaslessChecker = safeLazyLoad(() => import('containers/GaslessChecker'));
const ResendPayingGasModal = safeLazyLoad(() => import('containers/ResendPayingGasModal'));
const ImportPositionsModal = safeLazyLoad(() => import('containers/ImportPositionsModal'));

const App = () => (
<>
{
// Only index production with search engines
config.environment !== 'production' && (
<Helmet>
<meta name="robots" content="noindex" />
</Helmet>
)
}
const App = () => {
const { hardforks } = useChain();
const upgradeTimestamps = (hardforks ?? []).map(hardfork => new Date(hardfork.startTimestamp));

return (
<>
{
// Only index production with search engines
config.environment !== 'production' && (
<Helmet>
<meta name="robots" content="noindex" />
</Helmet>
)
}

<HashRouter>
<MuiThemeProvider>
<QueryClientProvider client={queryClient}>
<ErrorBoundary>
<Web3Wrapper>
<AnalyticProvider>
<Routes />
<HashRouter>
<MuiThemeProvider>
<QueryClientProvider client={queryClient}>
<ErrorBoundary>
<Web3Wrapper>
<AnalyticProvider>
<Routes />

<Suspense>
<NotificationCenter />
</Suspense>
<Suspense>
<NotificationCenter />
</Suspense>

<Suspense>
<AppVersionChecker />
</Suspense>
<Suspense>
<AppVersionChecker />
</Suspense>

<Suspense>
<GaslessChecker />
</Suspense>
<Suspense>
<GaslessChecker />
</Suspense>

<Suspense>
<ResendPayingGasModal />
</Suspense>
<Suspense>
<ResendPayingGasModal />
</Suspense>

<Suspense>
<ImportPositionsModal />
</Suspense>
<Suspense>
<ImportPositionsModal />
</Suspense>

<ThemeHandler />
<ThemeHandler />

<ChainUpgradeHandler
upgradeTimestamps={
config.network === 'testnet' ? [opBnbTestnetFourierForkTimestamp] : []
}
/>
<ChainUpgradeHandler upgradeTimestamps={upgradeTimestamps} />

<SentryErrorInfo />
</AnalyticProvider>
</Web3Wrapper>
</ErrorBoundary>
</QueryClientProvider>
</MuiThemeProvider>
</HashRouter>
</>
);
<SentryErrorInfo />
</AnalyticProvider>
</Web3Wrapper>
</ErrorBoundary>
</QueryClientProvider>
</MuiThemeProvider>
</HashRouter>
</>
);
};

export default App;
2 changes: 0 additions & 2 deletions packages/chains/src/chains/chainMetadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { iconSrcs } from '../../generated/manifests/chainIcons';
import { bnb, eth } from '../../tokens/nativeTokens';
import { type Chain, ChainId } from '../../types';

export const opBnbTestnetFourierForkTimestamp = new Date('2025-11-06T03:00:00Z');

export const chains: Record<ChainId, Chain> = {
[ChainId.BSC_MAINNET]: {
name: 'BNB Chain',
Expand Down