Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions app/utils/__tests__/cluster.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { afterEach, describe, expect, it, vi } from 'vitest';

import { modifyUrl } from '../cluster';

describe('modifyUrl', () => {
afterEach(() => {
vi.unstubAllGlobals();
});

it('returns url unchanged when hostname is localhost', () => {
vi.stubGlobal('location', { hostname: 'localhost' });

expect(modifyUrl('https://api.mainnet.solana.com')).toBe('https://api.mainnet.solana.com');
expect(modifyUrl('https://api.devnet.solana.com')).toBe('https://api.devnet.solana.com');
});

it('replaces "api" with "explorer-api" when hostname is not localhost', () => {
vi.stubGlobal('location', { hostname: 'explorer.solana.com' });

expect(modifyUrl('https://api.mainnet.solana.com')).toBe('https://explorer-api.mainnet.solana.com');
expect(modifyUrl('https://api.devnet.solana.com')).toBe('https://explorer-api.devnet.solana.com');
});

it('returns url unchanged when url has no "api" and hostname is not localhost', () => {
vi.stubGlobal('location', { hostname: 'explorer.solana.com' });

expect(modifyUrl('https://simd-0296.surfnet.dev:8899')).toBe('https://simd-0296.surfnet.dev:8899');
});
});
4 changes: 2 additions & 2 deletions app/utils/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export function clusterName(cluster: Cluster): string {
}
}

export const MAINNET_BETA_URL = 'https://api.mainnet-beta.solana.com';
export const MAINNET_BETA_URL = 'https://api.mainnet.solana.com';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that test files still referencing api.mainnet-beta.solana.com are updated:

  • app/features/security-txt/model/__tests__/useSecurityTxt.spec.ts:16
  • app/components/inspector/__tests__/InspectorPage.spec.tsx:142
  • app/components/account/__tests__/AccountHeader.spec.tsx:16
  • CONTRIBUTING.md:31

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, there are a lot of changes required. The goal here is to make it work.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. There will be a consecutive task with changes in the whole project. Agreed.

export const TESTNET_URL = 'https://api.testnet.solana.com';
export const DEVNET_URL = 'https://api.devnet.solana.com';
export const SIMD296_URL = 'https://simd-0296.surfnet.dev:8899';

const modifyUrl = (url: string): string => {
export const modifyUrl = (url: string): string => {
if (typeof window !== 'undefined' && window.location.hostname === 'localhost') {
return url;
} else {
Expand Down
2 changes: 1 addition & 1 deletion scripts/fetch_mainnet_activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_epoch_for_slot(epoch_schedule: dict, slot: int) -> int:
async def main():
features = get_features()

connection = AsyncClient('https://api.mainnet-beta.solana.com')
connection = AsyncClient('https://api.mainnet.solana.com')
epoch_schedule = (await connection.get_epoch_schedule()).value

for feature in features:
Expand Down