Disable entries with no types (#5469)

* Disable entries with no types

* Disable unreachable

* Updated

* Adjust
This commit is contained in:
Jaco 2021-06-06 22:36:03 +03:00 committed by GitHub
parent 13f79a59a3
commit d46ff522ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 60 additions and 13 deletions

View File

@ -4,7 +4,7 @@ on:
- cron: '30 0 * * *'
jobs:
ss58:
chains:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

View File

@ -24,6 +24,6 @@ module.exports = {
},
setupFilesAfterEnv: ['<rootDir>/jest/jest-setup.ts'],
testEnvironment: 'jsdom',
testTimeout: 60000,
testTimeout: 90000,
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
};

View File

@ -18,9 +18,17 @@ interface DnsResponse {
Question: { name: string }[];
}
const FAILURES: string[] = [
'Cannot construct unknown type',
'No DNS entry for',
'Timeout connecting to'
];
const endpoints = createWsEndpoints((k: string, v?: string) => v || k, true)
.filter(({ isDisabled, value }) => !isDisabled && value && isString(value) && !value.startsWith('ws://'))
.map(({ text, value }): Partial<Endpoint> => ({ name: text as string, ws: value as string }))
.filter(({ isDisabled, isUnreachable, value }) =>
!isDisabled && !isUnreachable && value && isString(value) && !value.startsWith('ws://')
)
.map((o): Partial<Endpoint> => ({ name: o.text as string, ws: o.value as string }))
.filter((v): v is Endpoint => !!v.ws);
describe('--SLOW--: check configured chain connections', (): void => {
@ -32,12 +40,13 @@ describe('--SLOW--: check configured chain connections', (): void => {
const response = await fetch(`https://dns.google/resolve?name=${host}`);
const json = await response.json() as DnsResponse;
assert(json.Answer, `No DNS entry for ${host}`);
let provider: WsProvider | null = null;
let api: ApiPromise | null = null;
let timerId: NodeJS.Timeout | null = null;
try {
assert(json.Answer, `No DNS entry for ${host}`);
provider = new WsProvider(ws, false);
api = new ApiPromise({
provider,
@ -50,12 +59,25 @@ describe('--SLOW--: check configured chain connections', (): void => {
provider && provider.connect().catch(() => undefined);
}, 1000);
await api.isReadyOrError;
await Promise.race([
// eslint-disable-next-line promise/param-names
new Promise((_, reject): void => {
timerId = setTimeout((): void => {
timerId = null;
reject(new Error(`Timeout connecting to ${ws}`));
}, 60_000);
}),
api.isReadyOrError
]);
} catch (error) {
if (isError(error) && error.message.includes('Cannot construct unknown type')) {
if (isError(error) && FAILURES.some((f) => (error as Error).message.includes(f))) {
throw error;
}
} finally {
if (timerId) {
clearTimeout(timerId);
}
if (provider) {
try {
if (api) {

View File

@ -75,6 +75,7 @@ export function createProduction (t: TFunction, firstOnly?: boolean): LinkOption
},
{
info: 'hanonycash',
isUnreachable: true, // https://github.com/polkadot-js/apps/runs/2755409009?check_suite_focus=true
text: t('rpc.prod.hanonycash', 'Hanonycash', { ns: 'apps-config' }),
providers: {
Hanonycash: 'wss://rpc.hanonycash.com'

View File

@ -44,6 +44,7 @@ export function createKusama (t: TFunction): EndpointOption {
// NOTE: Added alphabetical based on chain name
{
info: 'bifrost',
isUnreachable: true,
paraId: 2001,
text: t('rpc.kusama.bifrost', 'Bifrost', { ns: 'apps-config' }),
providers: {
@ -52,6 +53,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'shadow',
isUnreachable: true,
paraId: 2012,
text: t('rpc.kusama.shadow', 'Crust Shadow', { ns: 'apps-config' }),
providers: {
@ -60,6 +62,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'crab',
isUnreachable: true,
paraId: 2006,
text: t('rpc.kusama.crab', 'Darwinia Crab', { ns: 'apps-config' }),
providers: {
@ -68,6 +71,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'encointer_canary',
isUnreachable: true,
paraId: 2014,
text: t('rpc.kusama.encointer', 'Encointer Canary', { ns: 'apps-config' }),
providers: {
@ -76,6 +80,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'genshiro',
isUnreachable: true,
text: t('rpc.test.equilibriumtestnet', 'Genshiro', { ns: 'apps-config' }),
providers: {
Equilibrium: 'wss://testnet.equilibrium.io'
@ -83,6 +88,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'integritee',
isUnreachable: true,
paraId: 2015,
text: t('rpc.kusama.integritee', 'IntegriTEE Network', { ns: 'apps-config' }),
providers: {
@ -91,6 +97,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'karura',
isUnreachable: true,
paraId: 2000,
text: t('rpc.kusama.karura', 'Karura', { ns: 'apps-config' }),
providers: {
@ -99,6 +106,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'khala',
isUnreachable: true,
paraId: 2004,
text: t('rpc.kusama.khala', 'Khala Network', { ns: 'apps-config' }),
providers: {
@ -107,6 +115,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'kilt',
isUnreachable: true,
paraId: 2005,
text: t('rpc.kusama.kilt', 'KILT Mainnet', { ns: 'apps-config' }),
providers: {
@ -115,14 +124,16 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'polkasmith',
isUnreachable: true,
paraId: 2009,
text: t('rpc.kusama.polkasmith', 'Polkasmith', { ns: 'apps-config' }),
providers: {
Polkasmith: 'wss-polkasmith.polkafoundry.com'
Polkasmith: 'wss://polkasmith.polkafoundry.com'
}
},
{
info: 'sakura',
isUnreachable: true,
paraId: 2016,
text: t('rpc.kusama.sakura', 'Sakura', { ns: 'apps-config' }),
providers: {
@ -131,6 +142,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'sherpax',
isUnreachable: true,
paraId: 2013,
text: t('rpc.kusama.sherpax', 'SherpaX', { ns: 'apps-config' }),
providers: {
@ -139,6 +151,7 @@ export function createKusama (t: TFunction): EndpointOption {
},
{
info: 'shiden',
isUnreachable: true,
paraId: 2007,
text: t('rpc.kusama.shiden', 'Shiden', { ns: 'apps-config' }),
providers: {

View File

@ -85,6 +85,7 @@ export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[]
},
{
info: 'dock-testnet',
isDisabled: true, // Cannot construct unknown type EpochNo
text: t('rpc.test.dock-testnet', 'Dock', { ns: 'apps-config' }),
providers: {
'Dock Association': 'wss://danforth-1.dock.io'
@ -380,6 +381,7 @@ export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[]
},
{
info: 'web3games',
isUnreachable: true, // https://github.com/polkadot-js/apps/runs/2755409009?check_suite_focus=true
text: t('rpc.test.web3games', 'Web3Games', { ns: 'apps-config' }),
providers: {
Web3Games: 'wss://substrate.org.cn:4443'

View File

@ -9,6 +9,7 @@ export interface EndpointOption {
isChild?: boolean;
isDevelopment?: boolean;
isDisabled?: boolean;
isUnreachable?: boolean;
linked?: EndpointOption[];
info?: string;
paraId?: number;
@ -24,6 +25,7 @@ export interface LinkOption extends Option {
isChild?: boolean;
isDevelopment?: boolean;
isRelay?: boolean;
isUnreachable?: boolean;
isSpaced?: boolean;
linked?: LinkOption[];
paraId?: number;

View File

@ -21,12 +21,13 @@ export function expandLinked (input: LinkOption[]): LinkOption[] {
}, []);
}
export function expandEndpoint (t: TFunction, { dnslink, genesisHash, info, isChild, isDisabled, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly?: boolean): LinkOption[] {
export function expandEndpoint (t: TFunction, { dnslink, genesisHash, info, isChild, isDisabled, isUnreachable, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly?: boolean): LinkOption[] {
const base = {
genesisHash,
info,
isChild,
isDisabled,
isUnreachable,
paraId,
teleport,
text

View File

@ -18,7 +18,7 @@ interface Props {
value: Network;
}
function NetworkDisplay ({ affinity, apiUrl, className = '', setApiUrl, value: { icon, isChild, name, providers } }: Props): React.ReactElement<Props> {
function NetworkDisplay ({ affinity, apiUrl, className = '', setApiUrl, value: { icon, isChild, isUnreachable, name, providers } }: Props): React.ReactElement<Props> {
const isSelected = useMemo(
() => providers.some(({ url }) => url === apiUrl),
[apiUrl, providers]
@ -40,10 +40,10 @@ function NetworkDisplay ({ affinity, apiUrl, className = '', setApiUrl, value: {
);
return (
<div className={`${className}${isSelected ? ' isSelected highlight--border' : ''}`}>
<div className={`${className}${isSelected ? ' isSelected highlight--border' : ''}${isUnreachable ? ' isUnreachable' : ''}`}>
<div
className={`endpointSection${isChild ? ' isChild' : ''}`}
onClick={_selectUrl}
onClick={isUnreachable ? undefined : _selectUrl}
>
<ChainImg
className='endpointIcon'
@ -74,6 +74,10 @@ export default React.memo(styled(NetworkDisplay)`
padding: 0.375rem 0.5rem 0.375rem 1rem;
position: relative;
&.isUnreachable {
opacity: 0.5;
}
&.isSelected,
&:hover {
background: var(--bg-table);

View File

@ -57,6 +57,7 @@ function combineEndpoints (endpoints: LinkOption[]): Group[] {
prev.networks.push({
icon: e.info,
isChild: e.isChild,
isUnreachable: e.isUnreachable,
name: e.text as string,
providers: [prov]
});

View File

@ -6,6 +6,7 @@ import React from 'react';
export interface Network {
icon?: string;
isChild?: boolean;
isUnreachable?: boolean;
name: string;
providers: {
name: string;