Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Retrieving public endpoints with createWsEndpoints function #829

Merged
merged 3 commits into from
Feb 1, 2022
Merged
Changes from 2 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
28 changes: 10 additions & 18 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '@polkadot/api-augment';

import { ApiPromise } from '@polkadot/api';
import * as apps from '@polkadot/apps-config/api';
import { createWsEndpoints } from '@polkadot/apps-config/endpoints';
import { WsProvider } from '@polkadot/rpc-provider';
import { OverrideBundleType, RegistryTypes } from '@polkadot/types/types';
import { json } from 'express';
Expand Down Expand Up @@ -102,26 +103,17 @@ async function main() {
function startUpPrompt(wsUrl: string, chainName: string, implName: string) {
const { logger } = Log;
const { config } = SidecarConfig;

/**
* Best effort list of known public nodes that do not encourage high traffic
* sidecar installations connecting to them for non - testing / development purposes.
* Retrieving public endpoints from @polkadot/apps-config/endpoints
*/
const publicWsUrls: string[] = [
'wss://rpc.polkadot.io',
'wss://cc1-1.polkadot.network',
'wss://kusama-rpc.polkadot.io',
'wss://cc3-5.kusama.network',
'wss://fullnode.centrifuge.io',
'wss://crab.darwinia.network',
'wss://mainnet-node.dock.io',
'wss://mainnet1.edgewa.re',
'wss://rpc.kulupu.corepaper.org/ws',
'wss://main1.nodleprotocol.io',
'wss://rpc.plasmnet.io/',
'wss://mainnet-rpc.stafi.io',
'wss://rpc.subsocial.network',
'wss://full-nodes-lb.kilt.io:443',
];
const endpoints = createWsEndpoints(<T = string>(): T => '' as unknown as T);
const publicWsUrls: string[] = endpoints
.map(function (endpoint) {
niklasad1 marked this conversation as resolved.
Show resolved Hide resolved
if (endpoint.value && endpoint.info != 'local') return endpoint.value;
else return '';
Imod7 marked this conversation as resolved.
Show resolved Hide resolved
})
.filter((x) => x !== '');

logger.info(
`Connected to chain ${chainName} on the ${implName} client at ${config.SUBSTRATE.WS_URL}`
Expand Down