Skip to content

Commit d46ff52

Browse files
authored
Disable entries with no types (polkadot-js#5469)
* Disable entries with no types * Disable unreachable * Updated * Adjust
1 parent 13f79a5 commit d46ff52

File tree

11 files changed

+60
-13
lines changed

11 files changed

+60
-13
lines changed

.github/workflows/chain-types.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
- cron: '30 0 * * *'
55

66
jobs:
7-
ss58:
7+
chains:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2

jest.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ module.exports = {
2424
},
2525
setupFilesAfterEnv: ['<rootDir>/jest/jest-setup.ts'],
2626
testEnvironment: 'jsdom',
27-
testTimeout: 60000,
27+
testTimeout: 90000,
2828
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
2929
};

packages/apps-config/src/ciChainTypes.spec.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ interface DnsResponse {
1818
Question: { name: string }[];
1919
}
2020

21+
const FAILURES: string[] = [
22+
'Cannot construct unknown type',
23+
'No DNS entry for',
24+
'Timeout connecting to'
25+
];
26+
2127
const endpoints = createWsEndpoints((k: string, v?: string) => v || k, true)
22-
.filter(({ isDisabled, value }) => !isDisabled && value && isString(value) && !value.startsWith('ws://'))
23-
.map(({ text, value }): Partial<Endpoint> => ({ name: text as string, ws: value as string }))
28+
.filter(({ isDisabled, isUnreachable, value }) =>
29+
!isDisabled && !isUnreachable && value && isString(value) && !value.startsWith('ws://')
30+
)
31+
.map((o): Partial<Endpoint> => ({ name: o.text as string, ws: o.value as string }))
2432
.filter((v): v is Endpoint => !!v.ws);
2533

2634
describe('--SLOW--: check configured chain connections', (): void => {
@@ -32,12 +40,13 @@ describe('--SLOW--: check configured chain connections', (): void => {
3240
const response = await fetch(`https://dns.google/resolve?name=${host}`);
3341
const json = await response.json() as DnsResponse;
3442

35-
assert(json.Answer, `No DNS entry for ${host}`);
36-
3743
let provider: WsProvider | null = null;
3844
let api: ApiPromise | null = null;
45+
let timerId: NodeJS.Timeout | null = null;
3946

4047
try {
48+
assert(json.Answer, `No DNS entry for ${host}`);
49+
4150
provider = new WsProvider(ws, false);
4251
api = new ApiPromise({
4352
provider,
@@ -50,12 +59,25 @@ describe('--SLOW--: check configured chain connections', (): void => {
5059
provider && provider.connect().catch(() => undefined);
5160
}, 1000);
5261

53-
await api.isReadyOrError;
62+
await Promise.race([
63+
// eslint-disable-next-line promise/param-names
64+
new Promise((_, reject): void => {
65+
timerId = setTimeout((): void => {
66+
timerId = null;
67+
reject(new Error(`Timeout connecting to ${ws}`));
68+
}, 60_000);
69+
}),
70+
api.isReadyOrError
71+
]);
5472
} catch (error) {
55-
if (isError(error) && error.message.includes('Cannot construct unknown type')) {
73+
if (isError(error) && FAILURES.some((f) => (error as Error).message.includes(f))) {
5674
throw error;
5775
}
5876
} finally {
77+
if (timerId) {
78+
clearTimeout(timerId);
79+
}
80+
5981
if (provider) {
6082
try {
6183
if (api) {

packages/apps-config/src/endpoints/production.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export function createProduction (t: TFunction, firstOnly?: boolean): LinkOption
7575
},
7676
{
7777
info: 'hanonycash',
78+
isUnreachable: true, // https://github.com/polkadot-js/apps/runs/2755409009?check_suite_focus=true
7879
text: t('rpc.prod.hanonycash', 'Hanonycash', { ns: 'apps-config' }),
7980
providers: {
8081
Hanonycash: 'wss://rpc.hanonycash.com'

packages/apps-config/src/endpoints/productionRelayKusama.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function createKusama (t: TFunction): EndpointOption {
4444
// NOTE: Added alphabetical based on chain name
4545
{
4646
info: 'bifrost',
47+
isUnreachable: true,
4748
paraId: 2001,
4849
text: t('rpc.kusama.bifrost', 'Bifrost', { ns: 'apps-config' }),
4950
providers: {
@@ -52,6 +53,7 @@ export function createKusama (t: TFunction): EndpointOption {
5253
},
5354
{
5455
info: 'shadow',
56+
isUnreachable: true,
5557
paraId: 2012,
5658
text: t('rpc.kusama.shadow', 'Crust Shadow', { ns: 'apps-config' }),
5759
providers: {
@@ -60,6 +62,7 @@ export function createKusama (t: TFunction): EndpointOption {
6062
},
6163
{
6264
info: 'crab',
65+
isUnreachable: true,
6366
paraId: 2006,
6467
text: t('rpc.kusama.crab', 'Darwinia Crab', { ns: 'apps-config' }),
6568
providers: {
@@ -68,6 +71,7 @@ export function createKusama (t: TFunction): EndpointOption {
6871
},
6972
{
7073
info: 'encointer_canary',
74+
isUnreachable: true,
7175
paraId: 2014,
7276
text: t('rpc.kusama.encointer', 'Encointer Canary', { ns: 'apps-config' }),
7377
providers: {
@@ -76,13 +80,15 @@ export function createKusama (t: TFunction): EndpointOption {
7680
},
7781
{
7882
info: 'genshiro',
83+
isUnreachable: true,
7984
text: t('rpc.test.equilibriumtestnet', 'Genshiro', { ns: 'apps-config' }),
8085
providers: {
8186
Equilibrium: 'wss://testnet.equilibrium.io'
8287
}
8388
},
8489
{
8590
info: 'integritee',
91+
isUnreachable: true,
8692
paraId: 2015,
8793
text: t('rpc.kusama.integritee', 'IntegriTEE Network', { ns: 'apps-config' }),
8894
providers: {
@@ -91,6 +97,7 @@ export function createKusama (t: TFunction): EndpointOption {
9197
},
9298
{
9399
info: 'karura',
100+
isUnreachable: true,
94101
paraId: 2000,
95102
text: t('rpc.kusama.karura', 'Karura', { ns: 'apps-config' }),
96103
providers: {
@@ -99,6 +106,7 @@ export function createKusama (t: TFunction): EndpointOption {
99106
},
100107
{
101108
info: 'khala',
109+
isUnreachable: true,
102110
paraId: 2004,
103111
text: t('rpc.kusama.khala', 'Khala Network', { ns: 'apps-config' }),
104112
providers: {
@@ -107,6 +115,7 @@ export function createKusama (t: TFunction): EndpointOption {
107115
},
108116
{
109117
info: 'kilt',
118+
isUnreachable: true,
110119
paraId: 2005,
111120
text: t('rpc.kusama.kilt', 'KILT Mainnet', { ns: 'apps-config' }),
112121
providers: {
@@ -115,14 +124,16 @@ export function createKusama (t: TFunction): EndpointOption {
115124
},
116125
{
117126
info: 'polkasmith',
127+
isUnreachable: true,
118128
paraId: 2009,
119129
text: t('rpc.kusama.polkasmith', 'Polkasmith', { ns: 'apps-config' }),
120130
providers: {
121-
Polkasmith: 'wss-polkasmith.polkafoundry.com'
131+
Polkasmith: 'wss://polkasmith.polkafoundry.com'
122132
}
123133
},
124134
{
125135
info: 'sakura',
136+
isUnreachable: true,
126137
paraId: 2016,
127138
text: t('rpc.kusama.sakura', 'Sakura', { ns: 'apps-config' }),
128139
providers: {
@@ -131,6 +142,7 @@ export function createKusama (t: TFunction): EndpointOption {
131142
},
132143
{
133144
info: 'sherpax',
145+
isUnreachable: true,
134146
paraId: 2013,
135147
text: t('rpc.kusama.sherpax', 'SherpaX', { ns: 'apps-config' }),
136148
providers: {
@@ -139,6 +151,7 @@ export function createKusama (t: TFunction): EndpointOption {
139151
},
140152
{
141153
info: 'shiden',
154+
isUnreachable: true,
142155
paraId: 2007,
143156
text: t('rpc.kusama.shiden', 'Shiden', { ns: 'apps-config' }),
144157
providers: {

packages/apps-config/src/endpoints/testing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[]
8585
},
8686
{
8787
info: 'dock-testnet',
88+
isDisabled: true, // Cannot construct unknown type EpochNo
8889
text: t('rpc.test.dock-testnet', 'Dock', { ns: 'apps-config' }),
8990
providers: {
9091
'Dock Association': 'wss://danforth-1.dock.io'
@@ -380,6 +381,7 @@ export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[]
380381
},
381382
{
382383
info: 'web3games',
384+
isUnreachable: true, // https://github.com/polkadot-js/apps/runs/2755409009?check_suite_focus=true
383385
text: t('rpc.test.web3games', 'Web3Games', { ns: 'apps-config' }),
384386
providers: {
385387
Web3Games: 'wss://substrate.org.cn:4443'

packages/apps-config/src/endpoints/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface EndpointOption {
99
isChild?: boolean;
1010
isDevelopment?: boolean;
1111
isDisabled?: boolean;
12+
isUnreachable?: boolean;
1213
linked?: EndpointOption[];
1314
info?: string;
1415
paraId?: number;
@@ -24,6 +25,7 @@ export interface LinkOption extends Option {
2425
isChild?: boolean;
2526
isDevelopment?: boolean;
2627
isRelay?: boolean;
28+
isUnreachable?: boolean;
2729
isSpaced?: boolean;
2830
linked?: LinkOption[];
2931
paraId?: number;

packages/apps-config/src/endpoints/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ export function expandLinked (input: LinkOption[]): LinkOption[] {
2121
}, []);
2222
}
2323

24-
export function expandEndpoint (t: TFunction, { dnslink, genesisHash, info, isChild, isDisabled, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly?: boolean): LinkOption[] {
24+
export function expandEndpoint (t: TFunction, { dnslink, genesisHash, info, isChild, isDisabled, isUnreachable, linked, paraId, providers, teleport, text }: EndpointOption, firstOnly?: boolean): LinkOption[] {
2525
const base = {
2626
genesisHash,
2727
info,
2828
isChild,
2929
isDisabled,
30+
isUnreachable,
3031
paraId,
3132
teleport,
3233
text

packages/apps/src/Endpoints/Network.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Props {
1818
value: Network;
1919
}
2020

21-
function NetworkDisplay ({ affinity, apiUrl, className = '', setApiUrl, value: { icon, isChild, name, providers } }: Props): React.ReactElement<Props> {
21+
function NetworkDisplay ({ affinity, apiUrl, className = '', setApiUrl, value: { icon, isChild, isUnreachable, name, providers } }: Props): React.ReactElement<Props> {
2222
const isSelected = useMemo(
2323
() => providers.some(({ url }) => url === apiUrl),
2424
[apiUrl, providers]
@@ -40,10 +40,10 @@ function NetworkDisplay ({ affinity, apiUrl, className = '', setApiUrl, value: {
4040
);
4141

4242
return (
43-
<div className={`${className}${isSelected ? ' isSelected highlight--border' : ''}`}>
43+
<div className={`${className}${isSelected ? ' isSelected highlight--border' : ''}${isUnreachable ? ' isUnreachable' : ''}`}>
4444
<div
4545
className={`endpointSection${isChild ? ' isChild' : ''}`}
46-
onClick={_selectUrl}
46+
onClick={isUnreachable ? undefined : _selectUrl}
4747
>
4848
<ChainImg
4949
className='endpointIcon'
@@ -74,6 +74,10 @@ export default React.memo(styled(NetworkDisplay)`
7474
padding: 0.375rem 0.5rem 0.375rem 1rem;
7575
position: relative;
7676
77+
&.isUnreachable {
78+
opacity: 0.5;
79+
}
80+
7781
&.isSelected,
7882
&:hover {
7983
background: var(--bg-table);

packages/apps/src/Endpoints/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function combineEndpoints (endpoints: LinkOption[]): Group[] {
5757
prev.networks.push({
5858
icon: e.info,
5959
isChild: e.isChild,
60+
isUnreachable: e.isUnreachable,
6061
name: e.text as string,
6162
providers: [prov]
6263
});

packages/apps/src/Endpoints/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React from 'react';
66
export interface Network {
77
icon?: string;
88
isChild?: boolean;
9+
isUnreachable?: boolean;
910
name: string;
1011
providers: {
1112
name: string;

0 commit comments

Comments
 (0)