Update backup url

This commit is contained in:
armaniferrante 2021-06-16 22:17:23 -07:00
parent 96b5b7ff2a
commit 7035297775
No known key found for this signature in database
GPG Key ID: 58BEF301E91F7828
3 changed files with 18 additions and 16 deletions

View File

@ -1,36 +1,36 @@
import { clusterApiUrl } from '@solana/web3.js';
import { MAINNET_URL, MAINNET_VIP_URL } from '../utils/connection';
import { MAINNET_URL, MAINNET_BACKUP_URL } from '../utils/connection';
export const CLUSTERS = [
{
name: 'mainnet-beta',
apiUrl: MAINNET_URL,
label: 'Mainnet Beta',
clusterSlug: 'mainnet-beta',
label: 'Mainnet Beta',
clusterSlug: 'mainnet-beta',
},
{
name: 'mainnet-beta-backup',
apiUrl: MAINNET_VIP_URL,
label: 'Mainnet Beta Backup',
clusterSlug: 'mainnet-beta',
apiUrl: MAINNET_BACKUP_URL,
label: 'Mainnet Beta Backup',
clusterSlug: 'mainnet-beta',
},
{
name: 'devnet',
apiUrl: clusterApiUrl('devnet'),
label: 'Devnet',
clusterSlug: 'devnet',
label: 'Devnet',
clusterSlug: 'devnet',
},
{
name: 'testnet',
apiUrl: clusterApiUrl('testnet'),
label: 'Testnet',
clusterSlug: 'testnet',
label: 'Testnet',
clusterSlug: 'testnet',
},
{
name: 'localnet',
apiUrl: 'http://localhost:8899',
label: null,
clusterSlug: 'localnet',
label: null,
clusterSlug: 'localnet',
}
];

View File

@ -17,7 +17,9 @@ const ConnectionContext = React.createContext<{
} | null>(null);
export const MAINNET_URL = 'https://solana-api.projectserum.com';
export const MAINNET_VIP_URL = 'https://vip-api-1e4b2d8l9r.mainnet-beta.solana.com';
// No backup url for now. Leave the variable to not break wallets that
// have saved the url in their local storage, previously.
export const MAINNET_BACKUP_URL = 'https://solana-api.projectserum.com/';
export function ConnectionProvider({ children }) {
const [endpoint, setEndpoint] = useLocalStorageState(
'connectionEndpoint',
@ -56,7 +58,7 @@ export function useIsProdNetwork() {
if (!context) {
throw new Error('Missing connection context');
}
return context.endpoint === MAINNET_URL || context.endpoint === MAINNET_VIP_URL;
return context.endpoint === MAINNET_URL || context.endpoint === MAINNET_BACKUP_URL;
}
export function useSolanaExplorerUrlSuffix() {

View File

@ -3,7 +3,7 @@ import EventEmitter from 'events';
import {
useConnectionConfig,
MAINNET_URL,
MAINNET_VIP_URL,
MAINNET_BACKUP_URL,
} from '../connection';
import { useListener } from '../utils';
import { clusterForEndpoint } from '../clusters';
@ -278,7 +278,7 @@ export function TokenRegistryProvider(props) {
const { endpoint } = useConnectionConfig();
const [tokenInfos, setTokenInfos] = useState(null);
useEffect(() => {
if (endpoint !== MAINNET_VIP_URL && endpoint !== MAINNET_URL) return;
if (endpoint !== MAINNET_BACKUP_URL && endpoint !== MAINNET_URL) return;
const tokenListProvider = new TokenListProvider();
tokenListProvider.resolve().then((tokenListContainer) => {
const cluster = clusterForEndpoint(endpoint);