From 7c6cc5ea2c13479a5746df1df9da946c29077a4b Mon Sep 17 00:00:00 2001 From: wirednkod Date: Mon, 31 May 2021 12:44:31 +0300 Subject: [PATCH 01/45] integrate apps with smoldot init --- package.json | 1 + packages/apps/webpack.serve.cjs | 2 +- packages/react-api/package.json | 3 + packages/react-api/src/Api.tsx | 59 +++-- yarn.lock | 436 +++++++++++++++++++++++++++++++- 5 files changed, 468 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index ad790c1bceb9..ade08c6664fc 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "@pinata/sdk": "^1.1.20", "@polkadot/dev": "^0.62.14", "@polkadot/ts": "^0.3.66", + "@substrate/connect": "0.3.1-test", "@types/bn.js": "^4.11.6", "@types/chart.js": "^2.9.32", "@types/file-saver": "^2.0.2", diff --git a/packages/apps/webpack.serve.cjs b/packages/apps/webpack.serve.cjs index 970594202a2b..ffd847533ed1 100644 --- a/packages/apps/webpack.serve.cjs +++ b/packages/apps/webpack.serve.cjs @@ -9,7 +9,7 @@ const { merge } = require('webpack-merge'); const baseConfig = require('./webpack.base.cjs'); module.exports = merge( - baseConfig(__dirname, 'development'), + baseConfig(__dirname, 'production'), { devServer: { open: false, diff --git a/packages/react-api/package.json b/packages/react-api/package.json index 85f86218846f..f506aefec0ba 100644 --- a/packages/react-api/package.json +++ b/packages/react-api/package.json @@ -9,5 +9,8 @@ "@polkadot/extension-dapp": "^0.37.3-19", "@polkadot/x-rxjs": "^6.4.1", "fflate": "^0.6.10" + }, + "devDependencies": { + "@substrate/connect": "0.3.1-test" } } diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index c076fdc942cc..98bef5aec5ce 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -7,6 +7,7 @@ import type { ChainProperties, ChainType } from '@polkadot/types/interfaces'; import type { KeyringStore } from '@polkadot/ui-keyring/types'; import type { ApiProps, ApiState } from './types'; +import { Detector } from '@substrate/connect'; import React, { useContext, useEffect, useMemo, useState } from 'react'; import store from 'store'; @@ -17,7 +18,6 @@ import { web3Accounts, web3Enable } from '@polkadot/extension-dapp'; import { TokenUnit } from '@polkadot/react-components/InputNumber'; import { StatusContext } from '@polkadot/react-components/Status'; import ApiSigner from '@polkadot/react-signer/signers/ApiSigner'; -import { WsProvider } from '@polkadot/rpc-provider'; import { keyring } from '@polkadot/ui-keyring'; import { settings } from '@polkadot/ui-settings'; import { formatBalance, isTestChain } from '@polkadot/util'; @@ -192,32 +192,37 @@ function Api ({ children, store, url }: Props): React.ReactElement | null // initial initialization useEffect((): void => { - const provider = new WsProvider(url); - const signer = new ApiSigner(registry, queuePayload, queueSetTxStatus); - const types = getDevTypes(); - - api = new ApiPromise({ provider, registry, signer, types, typesBundle, typesChain }); - - api.on('connected', () => setIsApiConnected(true)); - api.on('disconnected', () => setIsApiConnected(false)); - api.on('error', (error: Error) => setApiError(error.message)); - api.on('ready', (): void => { - const injectedPromise = web3Enable('polkadot-js/apps'); - - injectedPromise - .then(setExtensions) - .catch(console.error); - - loadOnReady(api, injectedPromise, store, types) - .then(setState) - .catch((error): void => { - console.error(error); - - setApiError((error as Error).message); - }); - }); - - setIsApiInitialized(true); + async function apiConnect () { + const detect = new Detector('PolkadotJS apps'); + const network = 'westend'; + const signer = new ApiSigner(registry, queuePayload, queueSetTxStatus); + const types = getDevTypes(); + const options = { registry, signer, types, typesBundle, typesChain }; + + api = await detect.connect(network, undefined, options); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + api.isReady.then(() => { + setIsApiInitialized(true); + setIsApiConnected(true); + console.log('ready'); + const injectedPromise = web3Enable('polkadot-js/apps'); + + injectedPromise + .then(setExtensions) + .catch(console.error); + + loadOnReady(api, injectedPromise, store, types) + .then(setState) + .catch((error): void => { + console.error(error); + + setApiError((error as Error).message); + }); + }); + } + + // eslint-disable-next-line no-void + void apiConnect(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/yarn.lock b/yarn.lock index 093390a8cd94..b8fe0f427637 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2804,6 +2804,7 @@ __metadata: "@polkadot/api": ^4.10.1 "@polkadot/extension-dapp": ^0.37.3-19 "@polkadot/x-rxjs": ^6.4.1 + "@substrate/connect": 0.3.1-test fflate: ^0.6.10 languageName: unknown linkType: soft @@ -2963,6 +2964,23 @@ __metadata: languageName: node linkType: hard +"@polkadot/rpc-provider@npm:^4.10.1": + version: 4.12.1 + resolution: "@polkadot/rpc-provider@npm:4.12.1" + dependencies: + "@babel/runtime": ^7.14.0 + "@polkadot/types": 4.12.1 + "@polkadot/util": ^6.6.1 + "@polkadot/util-crypto": ^6.6.1 + "@polkadot/x-fetch": ^6.6.1 + "@polkadot/x-global": ^6.6.1 + "@polkadot/x-ws": ^6.6.1 + bn.js: ^4.11.9 + eventemitter3: ^4.0.7 + checksum: 073308b9ff8249526beb056c399f1994e8bf88ecaf033a6df6e973c9da24f22d77fdbb2aeb30c5976823c6fdb2a55621f7c33545280c5ea5096e526cccbf2315 + languageName: node + linkType: hard + "@polkadot/test-support@0.91.3-8, @polkadot/test-support@workspace:packages/test-support": version: 0.0.0-use.local resolution: "@polkadot/test-support@workspace:packages/test-support" @@ -3163,6 +3181,18 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-fetch@npm:^6.6.1": + version: 6.6.1 + resolution: "@polkadot/x-fetch@npm:6.6.1" + dependencies: + "@babel/runtime": ^7.14.0 + "@polkadot/x-global": 6.6.1 + "@types/node-fetch": ^2.5.10 + node-fetch: ^2.6.1 + checksum: 9f00162938ccd075b01d66d2f998375d905b0ce4901e965c994095d5c152106d0c3b30b84e83bbdda3ef6fd2deb49e816c2cbdc269efdbef8352441e915f3337 + languageName: node + linkType: hard + "@polkadot/x-global@npm:6.4.1, @polkadot/x-global@npm:^6.4.1": version: 6.4.1 resolution: "@polkadot/x-global@npm:6.4.1" @@ -3174,6 +3204,17 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-global@npm:6.6.1, @polkadot/x-global@npm:^6.6.1": + version: 6.6.1 + resolution: "@polkadot/x-global@npm:6.6.1" + dependencies: + "@babel/runtime": ^7.14.0 + "@types/node-fetch": ^2.5.10 + node-fetch: ^2.6.1 + checksum: 0ceb6c46ba5e56cbbb7be52bb03c9eae1d7ae9a83c2c7ced49e34d389b9bf3c4e9af38b67017933f3af4990e05f5d64c80cd5f247243e18a94866b88f0a833df + languageName: node + linkType: hard + "@polkadot/x-randomvalues@npm:6.4.1": version: 6.4.1 resolution: "@polkadot/x-randomvalues@npm:6.4.1" @@ -3226,6 +3267,18 @@ __metadata: languageName: node linkType: hard +"@polkadot/x-ws@npm:^6.6.1": + version: 6.6.1 + resolution: "@polkadot/x-ws@npm:6.6.1" + dependencies: + "@babel/runtime": ^7.14.0 + "@polkadot/x-global": 6.6.1 + "@types/websocket": ^1.0.2 + websocket: ^1.0.34 + checksum: cb70a9b9e2bf1bac617f5278c9d4b3ba47c4598c2d63513c2cb5bed58d56380a909b1d87a22e401225321992d806239cfc64412413894605a112faf7f4fde5b6 + languageName: node + linkType: hard + "@polymathnetwork/polymesh-types@npm:^0.0.2": version: 0.0.2 resolution: "@polymathnetwork/polymesh-types@npm:0.0.2" @@ -3402,6 +3455,30 @@ __metadata: languageName: node linkType: hard +"@substrate/connect-extension-protocol@npm:^0.3.0": + version: 0.3.0 + resolution: "@substrate/connect-extension-protocol@npm:0.3.0" + checksum: 4a93d4cb6d0ac25b6150c4039d3fc64534b08a61a7432dedd151afbb1422c959c3e0b4cd268e42cdf343b72d40f0e7295787fae2249874c3421a5fa14813c01d + languageName: node + linkType: hard + +"@substrate/connect@npm:0.3.1-test": + version: 0.3.1-test + resolution: "@substrate/connect@npm:0.3.1-test" + dependencies: + "@polkadot/rpc-provider": ^4.10.1 + "@substrate/connect-extension-protocol": ^0.3.0 + browserify-fs: ^1.0.0 + eventemitter3: ^4.0.7 + file-entry-cache: ^6.0.1 + mkdirp: ^1.0.4 + smoldot: ^0.2.0 + peerDependencies: + "@polkadot/wasm-crypto": ^3.2.2 + checksum: 37e407ce7ce34dc0f9e192f7a029c27eb29f2e452b97a15639b9218848836cd743927f0f600ede937508f74a46b6c6b1058d09a94fcb7d2fed54d30d12cc379d + languageName: node + linkType: hard + "@szmarczak/http-timer@npm:^1.1.2": version: 1.1.2 resolution: "@szmarczak/http-timer@npm:1.1.2" @@ -4503,6 +4580,15 @@ __metadata: languageName: node linkType: hard +"abstract-leveldown@npm:~0.12.0, abstract-leveldown@npm:~0.12.1": + version: 0.12.4 + resolution: "abstract-leveldown@npm:0.12.4" + dependencies: + xtend: ~3.0.0 + checksum: 342fbea39a3441c0f39f4c45a1b706f7225f8d6d48e2ba8aed92e253faaeed5759c0b3ee372d29b104c5e56ef1a0cac6793023c5859e67d2a4070e2d6a88c977 + languageName: node + linkType: hard + "accepts@npm:~1.3.4, accepts@npm:~1.3.5, accepts@npm:~1.3.7": version: 1.3.7 resolution: "accepts@npm:1.3.7" @@ -5616,6 +5702,15 @@ __metadata: languageName: node linkType: hard +"bl@npm:~0.8.1": + version: 0.8.2 + resolution: "bl@npm:0.8.2" + dependencies: + readable-stream: ~1.0.26 + checksum: 7bf1f598c6b4fb49bab0e3e4738dc356b9b8734a503d17533e3c0a31c91e8bcaeb2eb3cd086b02b50e0d9f4503d967cf0d66cca4bea2b3c8c463d3d5455d971d + languageName: node + linkType: hard + "blakejs@npm:^1.1.0": version: 1.1.0 resolution: "blakejs@npm:1.1.0" @@ -5803,6 +5898,17 @@ __metadata: languageName: node linkType: hard +"browserify-fs@npm:^1.0.0": + version: 1.0.0 + resolution: "browserify-fs@npm:1.0.0" + dependencies: + level-filesystem: ^1.0.1 + level-js: ^2.1.3 + levelup: ^0.18.2 + checksum: edd4823cf86fbb994f1cc462833b85947243e6d27b97b52ab3f4a074525dc6f6e1f4ec5fd247ac76d376386136fcfe11f2588ae24016ec9e2c087d4ab40b5982 + languageName: node + linkType: hard + "browserify-rsa@npm:^4.0.0, browserify-rsa@npm:^4.0.1": version: 4.1.0 resolution: "browserify-rsa@npm:4.1.0" @@ -5928,7 +6034,7 @@ __metadata: languageName: node linkType: hard -"buffer@npm:^6.0.3": +"buffer@npm:^6.0.1, buffer@npm:^6.0.3": version: 6.0.3 resolution: "buffer@npm:6.0.3" dependencies: @@ -6531,6 +6637,13 @@ __metadata: languageName: node linkType: hard +"clone@npm:~0.1.9": + version: 0.1.19 + resolution: "clone@npm:0.1.19" + checksum: 7b223bc71277484ea146fc9eb11fc16ef2920c90ec3902a1956ccf737533dbbcf3937fa43e9b2d5307262f8ad8758777e9e11ad01510919b3d2170337cd773c2 + languageName: node + linkType: hard + "cloneable-readable@npm:^1.0.0": version: 1.1.3 resolution: "cloneable-readable@npm:1.1.3" @@ -6778,7 +6891,7 @@ __metadata: languageName: node linkType: hard -"concat-stream@npm:^1.6.2": +"concat-stream@npm:^1.4.4, concat-stream@npm:^1.6.2": version: 1.6.2 resolution: "concat-stream@npm:1.6.2" dependencies: @@ -7472,6 +7585,15 @@ __metadata: languageName: node linkType: hard +"deferred-leveldown@npm:~0.2.0": + version: 0.2.0 + resolution: "deferred-leveldown@npm:0.2.0" + dependencies: + abstract-leveldown: ~0.12.1 + checksum: 3b2cb80044de4a79178a5e9eb1261f6b036cb5e23199f88488798f3342254c48f6e6be85bfd70bb204c175154be3dd79617f2e33f9736862d7ea64f027877f13 + languageName: node + linkType: hard + "define-properties@npm:^1.1.2, define-properties@npm:^1.1.3": version: 1.1.3 resolution: "define-properties@npm:1.1.3" @@ -8435,6 +8557,17 @@ __metadata: languageName: node linkType: hard +"errno@npm:^0.1.1, errno@npm:~0.1.1": + version: 0.1.8 + resolution: "errno@npm:0.1.8" + dependencies: + prr: ~1.0.1 + bin: + errno: cli.js + checksum: daf7a2aab678c3e5207eabc15e0f40bf1617cb1f69a120cac1b0418876e2f855d7eecb45818bf75a377f1566047ead322188613a12e9fb45145d98c32b6e718b + languageName: node + linkType: hard + "error-ex@npm:^1.2.0, error-ex@npm:^1.3.1": version: 1.3.2 resolution: "error-ex@npm:1.3.2" @@ -9564,7 +9697,7 @@ __metadata: languageName: node linkType: hard -"foreach@npm:^2.0.5": +"foreach@npm:^2.0.5, foreach@npm:~2.0.1": version: 2.0.5 resolution: "foreach@npm:2.0.5" checksum: 890d6c3dec185be6b1f7a94003d67d1b36a068fd7ac5a89f92818c3459d7d43e040a0b228a632e2e50d8a5aa804da6a5d27258ccbc1b7b724fe39eea3834f240 @@ -9765,6 +9898,15 @@ fsevents@~2.1.2: languageName: node linkType: hard +"fwd-stream@npm:^1.0.4": + version: 1.0.4 + resolution: "fwd-stream@npm:1.0.4" + dependencies: + readable-stream: ~1.0.26-4 + checksum: 38234fd4d5a3a21b169a5a73b02729178095549b98261033f2ae673a254cdd556a93c56f889432d65e5e717b95f6c5d5b5b2e4f49dd6dc0f93526a8d9e5a29a0 + languageName: node + linkType: hard + "gauge@npm:^v2.7.4, gauge@npm:~2.7.3": version: 2.7.4 resolution: "gauge@npm:2.7.4" @@ -10881,6 +11023,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"idb-wrapper@npm:^1.5.0": + version: 1.7.2 + resolution: "idb-wrapper@npm:1.7.2" + checksum: 00a28e546dcb6c4c36eba4c8d9a1febfd0b546804fc76524ebc1b79005fe9718c7785fd61cdbfbc2923fc0c6ab86199a0a87097200c1ac828bb60985ba24c889 + languageName: node + linkType: hard + "ieee754@npm:^1.1.13, ieee754@npm:^1.2.1": version: 1.2.1 resolution: "ieee754@npm:1.2.1" @@ -10959,6 +11108,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"indexof@npm:~0.0.1": + version: 0.0.1 + resolution: "indexof@npm:0.0.1" + checksum: 23dd379c2dec86d0f2d06d96b085bc2d30776d4222b6bea188dc02a742fcb7cab103da94bd1386fdff4c223b3948e7b165e1f5a6f747becc1c306c1f73468f4e + languageName: node + linkType: hard + "inflight@npm:^1.0.4": version: 1.0.6 resolution: "inflight@npm:1.0.6" @@ -10969,7 +11125,7 @@ fsevents@~2.1.2: languageName: node linkType: hard -"inherits@npm:2, inherits@npm:2.0.4, inherits@npm:^2.0.1, inherits@npm:^2.0.3, inherits@npm:^2.0.4, inherits@npm:~2.0.3, inherits@npm:~2.0.4": +"inherits@npm:2, inherits@npm:2.0.4, inherits@npm:^2.0.1, inherits@npm:^2.0.3, inherits@npm:^2.0.4, inherits@npm:~2.0.1, inherits@npm:~2.0.3, inherits@npm:~2.0.4": version: 2.0.4 resolution: "inherits@npm:2.0.4" checksum: 98426da247ddfc3dcd7d7daedd90c3ca32d5b08deca08949726f12d49232aef94772a07b36cf4ff833e105ae2ef931777f6de4a6dd8245a216b9299ad4a50bea @@ -11490,6 +11646,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"is-object@npm:~0.1.2": + version: 0.1.2 + resolution: "is-object@npm:0.1.2" + checksum: 474330d03106e49e138e76c0edb7e768a1b15a01bfe501db59c82b9484279038b49dbd71e41188a1072cc08add17a17d9bf9c870396de27e95f43ff52af08bc3 + languageName: node + linkType: hard + "is-path-cwd@npm:^2.2.0": version: 2.2.0 resolution: "is-path-cwd@npm:2.2.0" @@ -11691,6 +11854,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"is@npm:~0.2.6": + version: 0.2.7 + resolution: "is@npm:0.2.7" + checksum: 2f6815f96c8a885c44a47a1763133ba4dc858cb77257c285be4b0e8b7c3d22a839daa9d03890cc0316ea42be5e3c0c5ec621bb128e3cddf22e3f7a0035e4eecb + languageName: node + linkType: hard + "isarray@npm:0.0.1": version: 0.0.1 resolution: "isarray@npm:0.0.1" @@ -11712,6 +11882,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"isbuffer@npm:~0.0.0": + version: 0.0.0 + resolution: "isbuffer@npm:0.0.0" + checksum: 336c7bf564a389bd4cd0c03f8350ae9051b84c4b200c53a700a3ec0cf23249d064b0997efa084b8786bf2115686738d60f8fb122f83c7ebf22c2d9d690b81a20 + languageName: node + linkType: hard + "isexe@npm:^2.0.0": version: 2.0.0 resolution: "isexe@npm:2.0.0" @@ -12664,6 +12841,109 @@ fsevents@~2.1.2: languageName: node linkType: hard +"level-blobs@npm:^0.1.7": + version: 0.1.7 + resolution: "level-blobs@npm:0.1.7" + dependencies: + level-peek: 1.0.6 + once: ^1.3.0 + readable-stream: ^1.0.26-4 + checksum: ec242e4e886053a7764d56490a79e57a627e6c36bac8a8e17edf72f9097bd9ff11b082cec94a3ebb10f1c9d0650bd530a32032886888bab4d7adc4deb61ecca4 + languageName: node + linkType: hard + +"level-filesystem@npm:^1.0.1": + version: 1.2.0 + resolution: "level-filesystem@npm:1.2.0" + dependencies: + concat-stream: ^1.4.4 + errno: ^0.1.1 + fwd-stream: ^1.0.4 + level-blobs: ^0.1.7 + level-peek: ^1.0.6 + level-sublevel: ^5.2.0 + octal: ^1.0.0 + once: ^1.3.0 + xtend: ^2.2.0 + checksum: 288f2c4cded0beb5bf3aac7a00f8a027479871cadf33ca2eb836a4677655f328458a88b0b468f1ba0764d09abefba101d95657309c5e96700dbdf8911a479d38 + languageName: node + linkType: hard + +"level-fix-range@npm:2.0": + version: 2.0.0 + resolution: "level-fix-range@npm:2.0.0" + dependencies: + clone: ~0.1.9 + checksum: bffade56acce6f940c8ae4a34752896a73fa056b84fa89a6f9fd9b1c0de54eab9fc0efe83531195e98cde58bfa3b328d74b7ed1af5714100eecf7aa668801cab + languageName: node + linkType: hard + +"level-fix-range@npm:~1.0.2": + version: 1.0.2 + resolution: "level-fix-range@npm:1.0.2" + checksum: 820d7777880f9ec5c96eeb1e523a595b8158f2b398d8036a288d949967e7293823fea33bb8bc000ba893bfa11e5980e32f40c7f31e36f4fc39cf7fb14aa7b84c + languageName: node + linkType: hard + +"level-hooks@npm:>=4.4.0 <5": + version: 4.5.0 + resolution: "level-hooks@npm:4.5.0" + dependencies: + string-range: ~1.2 + checksum: 6f3aa7a155f8f0641617c89439e2d627a9febef968c6480401068df7c636a6ff9b14a77f12b7a2448f0dd59299490bf19b02b8b104ccf5f40f7915b79859d8fe + languageName: node + linkType: hard + +"level-js@npm:^2.1.3": + version: 2.2.4 + resolution: "level-js@npm:2.2.4" + dependencies: + abstract-leveldown: ~0.12.0 + idb-wrapper: ^1.5.0 + isbuffer: ~0.0.0 + ltgt: ^2.1.2 + typedarray-to-buffer: ~1.0.0 + xtend: ~2.1.2 + checksum: 4a2acbf9cbb68d8d772fb1b4aefe9babf80464b0c3c8e1b53325fe2e48f7c55b5ba5b5b89939e2659e55e3c347d7f0bdfa2716ce041c6fae9bdcab605e748e69 + languageName: node + linkType: hard + +"level-peek@npm:1.0.6, level-peek@npm:^1.0.6": + version: 1.0.6 + resolution: "level-peek@npm:1.0.6" + dependencies: + level-fix-range: ~1.0.2 + checksum: f777fc225a6316c5ec0bec889674061b7fce20fcba9b2b9c35917d7bf45cf54de54178303352aac23feaff9fcaa5faa0faf5f99210a07bb090985bde6aa47431 + languageName: node + linkType: hard + +"level-sublevel@npm:^5.2.0": + version: 5.2.3 + resolution: "level-sublevel@npm:5.2.3" + dependencies: + level-fix-range: 2.0 + level-hooks: ">=4.4.0 <5" + string-range: ~1.2.1 + xtend: ~2.0.4 + checksum: da77cbdf50c89b7aeb503c5a93755821f89a528f24465263b302f2f5606bf7c14b1e2465b26c1c3212fc9d834dc310f04b5417f67620f7132561542468702248 + languageName: node + linkType: hard + +"levelup@npm:^0.18.2": + version: 0.18.6 + resolution: "levelup@npm:0.18.6" + dependencies: + bl: ~0.8.1 + deferred-leveldown: ~0.2.0 + errno: ~0.1.1 + prr: ~0.0.0 + readable-stream: ~1.0.26 + semver: ~2.3.1 + xtend: ~3.0.0 + checksum: dd26e7206b2fdd8b0b6d7e53d2f231d1b6bbfd132bc005a693d2f982af377670fd338d5e1030544c5b32aac3ab19963c8ae945e97d386fd25ba30a1de14f11ff + languageName: node + linkType: hard + "leven@npm:^3.1.0": version: 3.1.0 resolution: "leven@npm:3.1.0" @@ -12992,6 +13272,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"ltgt@npm:^2.1.2": + version: 2.2.1 + resolution: "ltgt@npm:2.2.1" + checksum: 680494cb8f5ff63432f9802bac743cf6798b494dc3ea46b704e69c0c0655018eb83f0c25d76220f0877bda8aabf6f3d107f173597c98f22c6977422bb29fbc93 + languageName: node + linkType: hard + "lz-string@npm:^1.4.4": version: 1.4.4 resolution: "lz-string@npm:1.4.4" @@ -14212,6 +14499,24 @@ fsevents@~2.1.2: languageName: node linkType: hard +"object-keys@npm:~0.2.0": + version: 0.2.0 + resolution: "object-keys@npm:0.2.0" + dependencies: + foreach: ~2.0.1 + indexof: ~0.0.1 + is: ~0.2.6 + checksum: 678b584c3ac9ac4eb778b5621ef9e7e24b56a74eae118d884a5247b46b9c6e37d60794c054d8b5fafd315fc2e33ec323ff704b8679c91897fe09e3b518e9768c + languageName: node + linkType: hard + +"object-keys@npm:~0.4.0": + version: 0.4.0 + resolution: "object-keys@npm:0.4.0" + checksum: 71d8801c2f70f692e3813c7dc1e15ad50d46000f7e0bd73e72617d4db4fb4812a4ac4be1f4cd47e06e3c0272253ebc5e44847188b64934c0a5ea0ade51b8275d + languageName: node + linkType: hard + "object-visit@npm:^1.0.0": version: 1.0.1 resolution: "object-visit@npm:1.0.1" @@ -14296,6 +14601,13 @@ fsevents@~2.1.2: languageName: node linkType: hard +"octal@npm:^1.0.0": + version: 1.0.0 + resolution: "octal@npm:1.0.0" + checksum: bb463ddc04a6ca7c0dca3ffe07169f9cc9fdc262a2888356439defa14d092bef375459cc67dda26ebe73f2e4c2a614e9f313a8d221b6d08d8590183cf029fc94 + languageName: node + linkType: hard + "on-finished@npm:~2.3.0": version: 2.3.0 resolution: "on-finished@npm:2.3.0" @@ -14936,6 +15248,7 @@ fsevents@~2.1.2: "@pinata/sdk": ^1.1.20 "@polkadot/dev": ^0.62.14 "@polkadot/ts": ^0.3.66 + "@substrate/connect": 0.3.1-test "@types/bn.js": ^4.11.6 "@types/chart.js": ^2.9.32 "@types/file-saver": ^2.0.2 @@ -15405,6 +15718,20 @@ fsevents@~2.1.2: languageName: node linkType: hard +"prr@npm:~0.0.0": + version: 0.0.0 + resolution: "prr@npm:0.0.0" + checksum: 4d5df0173699edf58bd5ac4223b5f67202e1f8b67186cf248f55de4c2f103ff626cedab4f19f8902622890448e2785c48e7d82a65a0371789cea3808c94b5c87 + languageName: node + linkType: hard + +"prr@npm:~1.0.1": + version: 1.0.1 + resolution: "prr@npm:1.0.1" + checksum: ac5c0986b46390140b920b8e7f6b56e769a00620af02b6bbdfc6658e8a36b876569c8f174a7c209843f5b9af3d13cbf847c2a9dded4d965b01afbfa5ea8d0761 + languageName: node + linkType: hard + "pseudomap@npm:^1.0.2": version: 1.0.2 resolution: "pseudomap@npm:1.0.2" @@ -15950,6 +16277,18 @@ fsevents@~2.1.2: languageName: node linkType: hard +"readable-stream@npm:^1.0.26-4": + version: 1.1.14 + resolution: "readable-stream@npm:1.1.14" + dependencies: + core-util-is: ~1.0.0 + inherits: ~2.0.1 + isarray: 0.0.1 + string_decoder: ~0.10.x + checksum: e4c30b6b8495c11fc83e1b5fcb03b378127d93c953413973a25500991d0bf2b2e158e329d0f56d294e24a61c7751b874570158f24f97ebacb8a5f2fdcc05a0ec + languageName: node + linkType: hard + "readable-stream@npm:^2.0.0, readable-stream@npm:^2.0.1, readable-stream@npm:^2.0.2, readable-stream@npm:^2.0.5, readable-stream@npm:^2.0.6, readable-stream@npm:^2.1.5, readable-stream@npm:^2.2.2, readable-stream@npm:^2.3.3, readable-stream@npm:^2.3.5, readable-stream@npm:^2.3.6, readable-stream@npm:~2.3.6": version: 2.3.7 resolution: "readable-stream@npm:2.3.7" @@ -15965,6 +16304,18 @@ fsevents@~2.1.2: languageName: node linkType: hard +"readable-stream@npm:~1.0.26, readable-stream@npm:~1.0.26-4": + version: 1.0.34 + resolution: "readable-stream@npm:1.0.34" + dependencies: + core-util-is: ~1.0.0 + inherits: ~2.0.1 + isarray: 0.0.1 + string_decoder: ~0.10.x + checksum: 90f868f0a37e97794ce963f92c3dd8997a66a2143f867075521ac6905ed49967f425842de0dc53a952a49c60aa81e1239af6e32348e9f3dadffd61101b1c4fdc + languageName: node + linkType: hard + "readdir-glob@npm:^1.0.0": version: 1.1.1 resolution: "readdir-glob@npm:1.1.1" @@ -16865,6 +17216,15 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"semver@npm:~2.3.1": + version: 2.3.2 + resolution: "semver@npm:2.3.2" + bin: + semver: ./bin/semver + checksum: 7279e7c9a66364b2506de425fcea974ba415dc2a1fdb1f7cb62c8b99b5ade865a3045496245485e3c460aedaf80954624a61afcaae62f25a3b59ebd248afa19d + languageName: node + linkType: hard + "send@npm:0.17.1": version: 0.17.1 resolution: "send@npm:0.17.1" @@ -17148,6 +17508,18 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"smoldot@npm:^0.2.0": + version: 0.2.0 + resolution: "smoldot@npm:0.2.0" + dependencies: + buffer: ^6.0.1 + performance-now: ^2.1.0 + randombytes: ^2.1.0 + websocket: ^1.0.32 + checksum: 9aacea44fced02ce846f6f5e1412530241316ec40d0cbbc3341ab491aa742ed84538fc9672fc5a5a9eec00135a56a2cd63b4555ae4113dd72495a786ed4d4faf + languageName: node + linkType: hard + "snapdragon-node@npm:^2.0.1": version: 2.1.1 resolution: "snapdragon-node@npm:2.1.1" @@ -17610,6 +17982,13 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"string-range@npm:~1.2, string-range@npm:~1.2.1": + version: 1.2.2 + resolution: "string-range@npm:1.2.2" + checksum: 76cb6fb3ed612f2d56ff4faf7e7567a2f1256dd7a9509c064b5dd663a9f68da29b80eae9e8697255efcbddb321ab6ad6caa7aad2b32dffff47cfacc35b909d21 + languageName: node + linkType: hard + "string-width@npm:^1.0.1": version: 1.0.2 resolution: "string-width@npm:1.0.2" @@ -17697,6 +18076,13 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"string_decoder@npm:~0.10.x": + version: 0.10.31 + resolution: "string_decoder@npm:0.10.31" + checksum: ae53bca3796913fe686c6b519299a3631d04f0d388f35e7412914e3d351024f711d783d0415babfec276f5f533e84fae687e77220829d872fadb5bb9f7190890 + languageName: node + linkType: hard + "string_decoder@npm:~1.1.1": version: 1.1.1 resolution: "string_decoder@npm:1.1.1" @@ -18718,6 +19104,13 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"typedarray-to-buffer@npm:~1.0.0": + version: 1.0.4 + resolution: "typedarray-to-buffer@npm:1.0.4" + checksum: b3d5b7b9bdef9fa405b06f8f0d845f1fb88ceaef4e295b157a7a4bfd33c37104c88f8b0215ef2b9f1311f502c3f7912f182e31adac9dcdf3c7b5641d622c2175 + languageName: node + linkType: hard + "typedarray@npm:^0.0.6": version: 0.0.6 resolution: "typedarray@npm:0.0.6" @@ -19590,7 +19983,7 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard -"websocket@npm:^1.0.34": +"websocket@npm:^1.0.32, websocket@npm:^1.0.34": version: 1.0.34 resolution: "websocket@npm:1.0.34" dependencies: @@ -19848,6 +20241,13 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"xtend@npm:^2.2.0": + version: 2.2.0 + resolution: "xtend@npm:2.2.0" + checksum: 00be16e6d1805a214808aa2d548b10717e564af701fe1ef66af1fae31681efb3a9acfcc60fd993eb513b6bc6a25444050651026472d319b49b1783101b50d493 + languageName: node + linkType: hard + "xtend@npm:^4.0.1, xtend@npm:~4.0.0, xtend@npm:~4.0.1": version: 4.0.2 resolution: "xtend@npm:4.0.2" @@ -19855,6 +20255,32 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard +"xtend@npm:~2.0.4": + version: 2.0.6 + resolution: "xtend@npm:2.0.6" + dependencies: + is-object: ~0.1.2 + object-keys: ~0.2.0 + checksum: 9702ce0c9adfd06b57c854bc182833182e726091de016ef3f7f196ac1b34b46ab6f3cefcfb77b65dd3e9fe184f9908d16f33c748dad048fb05add867aeb3a9f0 + languageName: node + linkType: hard + +"xtend@npm:~2.1.2": + version: 2.1.2 + resolution: "xtend@npm:2.1.2" + dependencies: + object-keys: ~0.4.0 + checksum: 363fc1d7f18cdeaae36d675b4aa46bbfd3d39b9fd6d71956e390113724ce5b60c5abf19ac5d3cf4be0d788899522fe854a4bc557832f53b9f603e3f395a882bd + languageName: node + linkType: hard + +"xtend@npm:~3.0.0": + version: 3.0.0 + resolution: "xtend@npm:3.0.0" + checksum: bcba207830b7842d5052eac815872b89b070eba9dd0e1e4087b58fb8e780de21c051fbefdb43e80950ab2caf2895d4a4803332d3f9e98fcdff3db5933f0ab286 + languageName: node + linkType: hard + "xxhashjs@npm:^0.2.2": version: 0.2.2 resolution: "xxhashjs@npm:0.2.2" From 1a47f4489aa5ff3f2512cbd8eaf2941bbf9e556c Mon Sep 17 00:00:00 2001 From: wirednkod Date: Tue, 1 Jun 2021 12:01:07 +0300 Subject: [PATCH 02/45] Add a new category for substrate connect light clients to be grouped under. Add translations; Alter Api.tsx in order to choose between light clients and/or url addresses --- package.json | 2 +- packages/apps-config/src/endpoints/index.ts | 14 +++++ .../src/endpoints/substrateConnect.ts | 48 ++++++++++++++ .../apps/public/locales/en/apps-config.json | 6 +- .../apps/public/locales/es/translation.json | 1 + .../apps/public/locales/fr/translation.json | 1 + .../apps/public/locales/id/translation.json | 1 + .../apps/public/locales/it/translation.json | 1 + .../apps/public/locales/ja/translation.json | 1 + .../apps/public/locales/ko/translation.json | 1 + .../apps/public/locales/pt/translation.json | 1 + .../apps/public/locales/ru/translation.json | 1 + packages/react-api/package.json | 2 +- packages/react-api/src/Api.tsx | 63 ++++++++++++++++--- yarn.lock | 22 +++---- 15 files changed, 141 insertions(+), 24 deletions(-) create mode 100644 packages/apps-config/src/endpoints/substrateConnect.ts diff --git a/package.json b/package.json index ade08c6664fc..6934e30f0ab2 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "@pinata/sdk": "^1.1.20", "@polkadot/dev": "^0.62.14", "@polkadot/ts": "^0.3.66", - "@substrate/connect": "0.3.1-test", + "@substrate/connect": "0.3.1-test2", "@types/bn.js": "^4.11.6", "@types/chart.js": "^2.9.32", "@types/file-saver": "^2.0.2", diff --git a/packages/apps-config/src/endpoints/index.ts b/packages/apps-config/src/endpoints/index.ts index 590e7776f7ef..002c67513114 100644 --- a/packages/apps-config/src/endpoints/index.ts +++ b/packages/apps-config/src/endpoints/index.ts @@ -7,6 +7,7 @@ import type { LinkOption } from '../settings/types'; import { createCustom, createDev, createOwn } from './development'; import { createProduction } from './production'; import { createProductionRelays } from './productionRelays'; +import { createSubstrateConnect } from './substrateConnect'; import { createTesting } from './testing'; import { createTestingRelays } from './testingRelays'; @@ -49,6 +50,19 @@ export function createWsEndpoints (t: TFunction): LinkOption[] { value: '' }, ...createTesting(t), + /** The categorization below is a grouping of substrate connect light clients + * As soon as this implementation took place first I will leave it here for the PR + * in order to decide if we want it as different category or not + **/ + { + isDisabled: false, + isHeader: true, + isSpaced: true, + text: t('rpc.header.lighclients', 'Light Clients (Substrate Connect)', { ns: 'apps-config' }), + textBy: '', + value: '' + }, + ...createSubstrateConnect(t), { isDevelopment: true, isDisabled: false, diff --git a/packages/apps-config/src/endpoints/substrateConnect.ts b/packages/apps-config/src/endpoints/substrateConnect.ts new file mode 100644 index 000000000000..d7a446ac1d64 --- /dev/null +++ b/packages/apps-config/src/endpoints/substrateConnect.ts @@ -0,0 +1,48 @@ +// Copyright 2017-2021 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { TFunction } from 'i18next'; +import type { LinkOption } from '../settings/types'; + +import { expandEndpoints } from './util'; + +/* eslint-disable sort-keys */ + +// The available endpoints that will show in the dropdown. For the most part (with the exception of +// Polkadot) we try to keep this to live chains only, with RPCs hosted by the community/chain vendor +// info: The chain logo name as defined in ../ui/logos/index.ts in namedLogos (this also needs to align with @polkadot/networks) +// text: The text to display on the dropdown +// value: The actual hosted secure websocket endpoint + +// ws addresses in Providers are not real - just a hack to allow "switch" to be activated (needs valid url) +// and the .substrateconnect exists in order to identify that this is a light client provider +// so that we can (in packages/react-api/src/Api.tsx) instead of calling a new WsProvider instead trigger +// a new Detector that will run Substrate-Connect +export function createSubstrateConnect (t: TFunction): LinkOption[] { + return expandEndpoints(t, [ + { + dnslink: 'Polkadot (Production)', + info: 'polkadot', + text: t('rpc.polkadot.substrateconnect', 'Polkadot (Production)', { ns: 'apps-config' }), + providers: { + 'your browser': 'ws://polkadot.substrateconnect' + } + }, + { + dnslink: 'Kusama (Production)', + info: 'kusama', + text: t('rpc.kusama.substrateconnect', 'Kusama (Production)', { ns: 'apps-config' }), + providers: { + 'your browser': 'ws://kusama.substrateconnect' + } + }, + { + dnslink: 'Westend (Test)', + info: 'westend', + text: t('rpc.westend.substrateconnect', 'Westend (Test)', { ns: 'apps-config' }), + providers: { + 'your browser': 'ws://westend.substrateconnect' + } + } + ]); +} diff --git a/packages/apps/public/locales/en/apps-config.json b/packages/apps/public/locales/en/apps-config.json index da12a91fc3e9..a137d663a92c 100644 --- a/packages/apps/public/locales/en/apps-config.json +++ b/packages/apps/public/locales/en/apps-config.json @@ -5,6 +5,7 @@ "rpc.dev.custom.own": "Custom", "rpc.dev.local": "Local Node", "rpc.header.dev": "Development", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Live networks", "rpc.header.live.relay": "Live relays & parachains", "rpc.header.test": "Test networks", @@ -18,7 +19,9 @@ "rpc.kusama.shadow": "Crust Shadow", "rpc.kusama.shell": "Shell", "rpc.kusama.sherpax": "SherpaX", + "rpc.kusama.substrateconnect": "Kusama (Production)", "rpc.polkadot.parity": "Polkadot", + "rpc.polkadot.substrateconnect": "Polkadot (Production)", "rpc.prod.centrifuge": "Centrifuge", "rpc.prod.chainx": "ChainX", "rpc.prod.crab": "Darwinia Crab", @@ -134,5 +137,6 @@ "rpc.test.zero": "Zero", "rpc.westend": "Westend", "rpc.westend.shell": "Shell", + "rpc.westend.substrateconnect": "Westend (Test)", "ss58.default": "Default for the connected node" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/es/translation.json b/packages/apps/public/locales/es/translation.json index 620675cc8b55..b7b6d9b5212f 100644 --- a/packages/apps/public/locales/es/translation.json +++ b/packages/apps/public/locales/es/translation.json @@ -961,6 +961,7 @@ "rpc.edgeware": "Edgeware (red principal Edgeware, ofrecido por Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Testnet Substrate, ofrecido por Parity)", "rpc.header.dev": "Desarrollo", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Redes en funcionamiento", "rpc.header.test": "Redes de prueba", "rpc.kulupu": "Kulupu (Red principal Kulupu, ofrecido por Kulupu)", diff --git a/packages/apps/public/locales/fr/translation.json b/packages/apps/public/locales/fr/translation.json index f49b112de486..08edcb59e6f5 100644 --- a/packages/apps/public/locales/fr/translation.json +++ b/packages/apps/public/locales/fr/translation.json @@ -1308,6 +1308,7 @@ "rpc.equilibrium": "Equilibrium", "rpc.flamingfir": "Flaming Fir (Testnet Substrate, hébergé par Parity)", "rpc.header.dev": "Développement", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Réseau Live", "rpc.header.test": "Réseaux de test", "rpc.hosted.by": "hébergé par {{host}}", diff --git a/packages/apps/public/locales/id/translation.json b/packages/apps/public/locales/id/translation.json index de1521739776..447f31f676ac 100644 --- a/packages/apps/public/locales/id/translation.json +++ b/packages/apps/public/locales/id/translation.json @@ -1254,6 +1254,7 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, dihosting oleh Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, dihosting oleh Parity)", "rpc.header.dev": "Pengembangan", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Jaringan Live", "rpc.header.test": "Jaringan tes", "rpc.kilt": "KILT Protocol (KILT Mashnet, dihosting oleh KILT Protocol)", diff --git a/packages/apps/public/locales/it/translation.json b/packages/apps/public/locales/it/translation.json index 99ebafd4669c..4db244aadf80 100644 --- a/packages/apps/public/locales/it/translation.json +++ b/packages/apps/public/locales/it/translation.json @@ -1299,6 +1299,7 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, ospitato da Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, ospitato da Parity)", "rpc.header.dev": "Sviluppo", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Mainnet", "rpc.header.test": "Testnet", "rpc.kilt": "KILT Protocol (KILT Mashnet, ospitato da KILT Protocol)", diff --git a/packages/apps/public/locales/ja/translation.json b/packages/apps/public/locales/ja/translation.json index 63033c929396..e5bc3f15ff37 100644 --- a/packages/apps/public/locales/ja/translation.json +++ b/packages/apps/public/locales/ja/translation.json @@ -499,6 +499,7 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, hosted by Parity)", "rpc.header.dev": "開発環境", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "メイン環境", "rpc.header.test": "テストネット", "rpc.kulupu": "Kulupu (Kulupu Mainnet, hosted by Kulupu)", diff --git a/packages/apps/public/locales/ko/translation.json b/packages/apps/public/locales/ko/translation.json index 6b593374d62a..9274f4a4cdcd 100644 --- a/packages/apps/public/locales/ko/translation.json +++ b/packages/apps/public/locales/ko/translation.json @@ -1271,6 +1271,7 @@ "rpc.equilibrium": "평형", "rpc.flamingfir": "Flaming Fir(서브스트레이트 테스트넷, Parity가 운영함)", "rpc.header.dev": "개발자 설정", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "라이브넷들", "rpc.header.test": "테스트넷들", "rpc.hosted.by": "운영하다 {{host}}", diff --git a/packages/apps/public/locales/pt/translation.json b/packages/apps/public/locales/pt/translation.json index 05828951977c..853b91985eff 100644 --- a/packages/apps/public/locales/pt/translation.json +++ b/packages/apps/public/locales/pt/translation.json @@ -966,6 +966,7 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, hospedado pelo Commonwealth Labs)", "rpc.flamingfir": "Fir flamejante (Substrate Testnet, hospedado pela Parity)", "rpc.header.dev": "Desenvolvimento", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Redes ativas", "rpc.header.test": "Redes de teste", "rpc.kulupu": "Grupos (Grupos Mainnet, hospedados por Grupos)", diff --git a/packages/apps/public/locales/ru/translation.json b/packages/apps/public/locales/ru/translation.json index 4d1649b8efba..290353ab5570 100644 --- a/packages/apps/public/locales/ru/translation.json +++ b/packages/apps/public/locales/ru/translation.json @@ -979,6 +979,7 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, hosted by Parity)", "rpc.header.dev": "Разработка", + "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Рабочие сети", "rpc.header.test": "Тестовые сети", "rpc.kulupu": "Kulupu (Kulupu Mainnet, hosted by Kulupu)", diff --git a/packages/react-api/package.json b/packages/react-api/package.json index f506aefec0ba..2e01c77f1720 100644 --- a/packages/react-api/package.json +++ b/packages/react-api/package.json @@ -11,6 +11,6 @@ "fflate": "^0.6.10" }, "devDependencies": { - "@substrate/connect": "0.3.1-test" + "@substrate/connect": "0.3.1-test2" } } diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index 98bef5aec5ce..36a9488dbf62 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -26,6 +26,7 @@ import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defau import ApiContext from './ApiContext'; import registry from './typeRegistry'; import { decodeUrlTypes } from './urlTypes'; +import { WsProvider } from '@polkadot/api'; interface Props { children: React.ReactNode; @@ -190,21 +191,62 @@ function Api ({ children, store, url }: Props): React.ReactElement | null [apiError, extensions, isApiConnected, isApiInitialized, state] ); + const supportedLightNetworks = ['kusama', 'polkadot', 'westend']; + // initial initialization useEffect((): void => { - async function apiConnect () { + async function substrateConnectApi (network: string) { const detect = new Detector('PolkadotJS apps'); - const network = 'westend'; const signer = new ApiSigner(registry, queuePayload, queueSetTxStatus); const types = getDevTypes(); const options = { registry, signer, types, typesBundle, typesChain }; - api = await detect.connect(network, undefined, options); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - api.isReady.then(() => { - setIsApiInitialized(true); - setIsApiConnected(true); - console.log('ready'); + try { + api = await detect.connect(network, undefined, options); + // eslint-disable-next-line @typescript-eslint/no-floating-promises + api.isReady.then(() => { + setIsApiInitialized(true); + setIsApiConnected(true); + console.log('ready'); + const injectedPromise = web3Enable('polkadot-js/apps'); + + injectedPromise + .then(setExtensions) + .catch(console.error); + + loadOnReady(api, injectedPromise, store, types) + .then(setState) + .catch((error): void => { + console.error(error); + + setApiError((error as Error).message); + }); + }).catch(console.error); + } catch (err) { + console.error(err); + } + } + + if (url?.includes('substrateconnect')) { + const network = url?.replace('ws://', '').split('.')[0]; + + if (!supportedLightNetworks.includes(network)) { + throw Error('Unsupported Light Client Network'); + } + + // eslint-disable-next-line no-void + void substrateConnectApi(network); + } else { + const provider = new WsProvider(url); + const signer = new ApiSigner(registry, queuePayload, queueSetTxStatus); + const types = getDevTypes(); + + api = new ApiPromise({ provider, registry, signer, types, typesBundle, typesChain }); + + api.on('connected', () => setIsApiConnected(true)); + api.on('disconnected', () => setIsApiConnected(false)); + api.on('error', (error: Error) => setApiError(error.message)); + api.on('ready', (): void => { const injectedPromise = web3Enable('polkadot-js/apps'); injectedPromise @@ -219,10 +261,11 @@ function Api ({ children, store, url }: Props): React.ReactElement | null setApiError((error as Error).message); }); }); + + setIsApiInitialized(true); + // eslint-disable-next-line react-hooks/exhaustive-deps } - // eslint-disable-next-line no-void - void apiConnect(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/yarn.lock b/yarn.lock index b8fe0f427637..9a2cab2d2ede 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2804,7 +2804,7 @@ __metadata: "@polkadot/api": ^4.10.1 "@polkadot/extension-dapp": ^0.37.3-19 "@polkadot/x-rxjs": ^6.4.1 - "@substrate/connect": 0.3.1-test + "@substrate/connect": 0.3.1-test2 fflate: ^0.6.10 languageName: unknown linkType: soft @@ -3462,9 +3462,9 @@ __metadata: languageName: node linkType: hard -"@substrate/connect@npm:0.3.1-test": - version: 0.3.1-test - resolution: "@substrate/connect@npm:0.3.1-test" +"@substrate/connect@npm:0.3.1-test2": + version: 0.3.1-test2 + resolution: "@substrate/connect@npm:0.3.1-test2" dependencies: "@polkadot/rpc-provider": ^4.10.1 "@substrate/connect-extension-protocol": ^0.3.0 @@ -3472,10 +3472,10 @@ __metadata: eventemitter3: ^4.0.7 file-entry-cache: ^6.0.1 mkdirp: ^1.0.4 - smoldot: ^0.2.0 + smoldot: ^0.2.1 peerDependencies: "@polkadot/wasm-crypto": ^3.2.2 - checksum: 37e407ce7ce34dc0f9e192f7a029c27eb29f2e452b97a15639b9218848836cd743927f0f600ede937508f74a46b6c6b1058d09a94fcb7d2fed54d30d12cc379d + checksum: bcf65a236c42783a97e235c6dd3f6b1d310f696c4c76903308235a1eb1f5d828d2b49c8bada6c37ddc3b67af229934622878c820ccfcba94711347ab04180f8b languageName: node linkType: hard @@ -15248,7 +15248,7 @@ fsevents@~2.1.2: "@pinata/sdk": ^1.1.20 "@polkadot/dev": ^0.62.14 "@polkadot/ts": ^0.3.66 - "@substrate/connect": 0.3.1-test + "@substrate/connect": 0.3.1-test2 "@types/bn.js": ^4.11.6 "@types/chart.js": ^2.9.32 "@types/file-saver": ^2.0.2 @@ -17508,15 +17508,15 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard -"smoldot@npm:^0.2.0": - version: 0.2.0 - resolution: "smoldot@npm:0.2.0" +"smoldot@npm:^0.2.1": + version: 0.2.1 + resolution: "smoldot@npm:0.2.1" dependencies: buffer: ^6.0.1 performance-now: ^2.1.0 randombytes: ^2.1.0 websocket: ^1.0.32 - checksum: 9aacea44fced02ce846f6f5e1412530241316ec40d0cbbc3341ab491aa742ed84538fc9672fc5a5a9eec00135a56a2cd63b4555ae4113dd72495a786ed4d4faf + checksum: f48ca8f8b5484b7b9798757e2723a8193c47fdf989eac6978c574e55c01c5784809f3d2b07efc7a5e4841ba4b7736d0fc80682cef12254db602cfd4c165511d2 languageName: node linkType: hard From b4183635496c0e6d03299e2b23bb5a3fc12d852b Mon Sep 17 00:00:00 2001 From: wirednkod Date: Tue, 1 Jun 2021 12:03:06 +0300 Subject: [PATCH 03/45] remove supportedLightClient array that was introduced. SubstrateConnect already has the information included and will return error if no supported network is found --- packages/react-api/src/Api.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/react-api/src/Api.tsx b/packages/react-api/src/Api.tsx index 36a9488dbf62..42186e253408 100644 --- a/packages/react-api/src/Api.tsx +++ b/packages/react-api/src/Api.tsx @@ -191,8 +191,6 @@ function Api ({ children, store, url }: Props): React.ReactElement | null [apiError, extensions, isApiConnected, isApiInitialized, state] ); - const supportedLightNetworks = ['kusama', 'polkadot', 'westend']; - // initial initialization useEffect((): void => { async function substrateConnectApi (network: string) { @@ -230,10 +228,6 @@ function Api ({ children, store, url }: Props): React.ReactElement | null if (url?.includes('substrateconnect')) { const network = url?.replace('ws://', '').split('.')[0]; - if (!supportedLightNetworks.includes(network)) { - throw Error('Unsupported Light Client Network'); - } - // eslint-disable-next-line no-void void substrateConnectApi(network); } else { From 0e327a0fd1ae733a2266fba35eedbabc167185a3 Mon Sep 17 00:00:00 2001 From: wirednkod Date: Tue, 1 Jun 2021 15:30:22 +0300 Subject: [PATCH 04/45] rollback 'hacky' changes in order to proceed with better implementation --- packages/apps-config/src/endpoints/index.ts | 14 -------------- packages/apps/public/locales/en/apps-config.json | 4 ---- packages/apps/public/locales/es/translation.json | 3 +-- packages/apps/public/locales/fr/translation.json | 3 +-- packages/apps/public/locales/id/translation.json | 3 +-- packages/apps/public/locales/it/translation.json | 3 +-- packages/apps/public/locales/ja/translation.json | 3 +-- packages/apps/public/locales/ko/translation.json | 3 +-- packages/apps/public/locales/pt/translation.json | 3 +-- packages/apps/public/locales/ru/translation.json | 3 +-- 10 files changed, 8 insertions(+), 34 deletions(-) diff --git a/packages/apps-config/src/endpoints/index.ts b/packages/apps-config/src/endpoints/index.ts index 002c67513114..590e7776f7ef 100644 --- a/packages/apps-config/src/endpoints/index.ts +++ b/packages/apps-config/src/endpoints/index.ts @@ -7,7 +7,6 @@ import type { LinkOption } from '../settings/types'; import { createCustom, createDev, createOwn } from './development'; import { createProduction } from './production'; import { createProductionRelays } from './productionRelays'; -import { createSubstrateConnect } from './substrateConnect'; import { createTesting } from './testing'; import { createTestingRelays } from './testingRelays'; @@ -50,19 +49,6 @@ export function createWsEndpoints (t: TFunction): LinkOption[] { value: '' }, ...createTesting(t), - /** The categorization below is a grouping of substrate connect light clients - * As soon as this implementation took place first I will leave it here for the PR - * in order to decide if we want it as different category or not - **/ - { - isDisabled: false, - isHeader: true, - isSpaced: true, - text: t('rpc.header.lighclients', 'Light Clients (Substrate Connect)', { ns: 'apps-config' }), - textBy: '', - value: '' - }, - ...createSubstrateConnect(t), { isDevelopment: true, isDisabled: false, diff --git a/packages/apps/public/locales/en/apps-config.json b/packages/apps/public/locales/en/apps-config.json index a137d663a92c..6a6c888e7832 100644 --- a/packages/apps/public/locales/en/apps-config.json +++ b/packages/apps/public/locales/en/apps-config.json @@ -5,7 +5,6 @@ "rpc.dev.custom.own": "Custom", "rpc.dev.local": "Local Node", "rpc.header.dev": "Development", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Live networks", "rpc.header.live.relay": "Live relays & parachains", "rpc.header.test": "Test networks", @@ -19,9 +18,7 @@ "rpc.kusama.shadow": "Crust Shadow", "rpc.kusama.shell": "Shell", "rpc.kusama.sherpax": "SherpaX", - "rpc.kusama.substrateconnect": "Kusama (Production)", "rpc.polkadot.parity": "Polkadot", - "rpc.polkadot.substrateconnect": "Polkadot (Production)", "rpc.prod.centrifuge": "Centrifuge", "rpc.prod.chainx": "ChainX", "rpc.prod.crab": "Darwinia Crab", @@ -137,6 +134,5 @@ "rpc.test.zero": "Zero", "rpc.westend": "Westend", "rpc.westend.shell": "Shell", - "rpc.westend.substrateconnect": "Westend (Test)", "ss58.default": "Default for the connected node" } diff --git a/packages/apps/public/locales/es/translation.json b/packages/apps/public/locales/es/translation.json index b7b6d9b5212f..bb0c37b0a38f 100644 --- a/packages/apps/public/locales/es/translation.json +++ b/packages/apps/public/locales/es/translation.json @@ -961,7 +961,6 @@ "rpc.edgeware": "Edgeware (red principal Edgeware, ofrecido por Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Testnet Substrate, ofrecido por Parity)", "rpc.header.dev": "Desarrollo", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Redes en funcionamiento", "rpc.header.test": "Redes de prueba", "rpc.kulupu": "Kulupu (Red principal Kulupu, ofrecido por Kulupu)", @@ -1120,4 +1119,4 @@ "{{threshold}}, not passing": "{{threshold}}, no pasará", "{{threshold}}, passing": "{{threshold}}, de aprobación", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x saldo de votos, bloqueado por {{lock}}x sentencia ({{period}} días." -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/fr/translation.json b/packages/apps/public/locales/fr/translation.json index 08edcb59e6f5..d7aa9102637b 100644 --- a/packages/apps/public/locales/fr/translation.json +++ b/packages/apps/public/locales/fr/translation.json @@ -1308,7 +1308,6 @@ "rpc.equilibrium": "Equilibrium", "rpc.flamingfir": "Flaming Fir (Testnet Substrate, hébergé par Parity)", "rpc.header.dev": "Développement", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Réseau Live", "rpc.header.test": "Réseaux de test", "rpc.hosted.by": "hébergé par {{host}}", @@ -1529,4 +1528,4 @@ "{{threshold}}, not passing": "{{seuil} }, ne dépassant pas", "{{threshold}}, passing": "{{seuil}}, passant", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}} x solde de vote, verrouillé pendant {{lock}} x décret ({{period}} jours)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/id/translation.json b/packages/apps/public/locales/id/translation.json index 447f31f676ac..f5029ace04f8 100644 --- a/packages/apps/public/locales/id/translation.json +++ b/packages/apps/public/locales/id/translation.json @@ -1254,7 +1254,6 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, dihosting oleh Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, dihosting oleh Parity)", "rpc.header.dev": "Pengembangan", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Jaringan Live", "rpc.header.test": "Jaringan tes", "rpc.kilt": "KILT Protocol (KILT Mashnet, dihosting oleh KILT Protocol)", @@ -1455,4 +1454,4 @@ "{{threshold}}, not passing": "{{threshold}}, tidak melewati", "{{threshold}}, passing": "{{threshold}}, melewati", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x memilih saldo, terkunci untuk {{lock}}x berlaku ({{period}} hari)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/it/translation.json b/packages/apps/public/locales/it/translation.json index 4db244aadf80..f2e593213cb9 100644 --- a/packages/apps/public/locales/it/translation.json +++ b/packages/apps/public/locales/it/translation.json @@ -1299,7 +1299,6 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, ospitato da Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, ospitato da Parity)", "rpc.header.dev": "Sviluppo", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Mainnet", "rpc.header.test": "Testnet", "rpc.kilt": "KILT Protocol (KILT Mashnet, ospitato da KILT Protocol)", @@ -1507,4 +1506,4 @@ "{{threshold}}, passing": "{{threshold}}, approvato", "{{type}} copied": "{{type}} copiato", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}} x moltiplicatore di voto, fondi bloccati per {{lock}}x = {{period}} giorni" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/ja/translation.json b/packages/apps/public/locales/ja/translation.json index e5bc3f15ff37..a801556d982a 100644 --- a/packages/apps/public/locales/ja/translation.json +++ b/packages/apps/public/locales/ja/translation.json @@ -499,7 +499,6 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, hosted by Parity)", "rpc.header.dev": "開発環境", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "メイン環境", "rpc.header.test": "テストネット", "rpc.kulupu": "Kulupu (Kulupu Mainnet, hosted by Kulupu)", @@ -569,4 +568,4 @@ "{{relayDispatchQueueSize}} dispatch messages pending": "{{relayDispatchQueueSize}} ディスパッチメッセージペンディング", "{{seconds}} s": "{{seconds}} 秒", "{{step}}. Sign with your ETH address": "{{step}}. ETHアドレスでサインしてください" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/ko/translation.json b/packages/apps/public/locales/ko/translation.json index 9274f4a4cdcd..f3852b8b57c3 100644 --- a/packages/apps/public/locales/ko/translation.json +++ b/packages/apps/public/locales/ko/translation.json @@ -1271,7 +1271,6 @@ "rpc.equilibrium": "평형", "rpc.flamingfir": "Flaming Fir(서브스트레이트 테스트넷, Parity가 운영함)", "rpc.header.dev": "개발자 설정", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "라이브넷들", "rpc.header.test": "테스트넷들", "rpc.hosted.by": "운영하다 {{host}}", @@ -1484,4 +1483,4 @@ "{{threshold}}, not passing": "{{threshold}}, 통과되지 않았습니다", "{{threshold}}, passing": "{{threshold}}, 통과되었습니다", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x 투표 발란스, 잠금 {{lock}}x제정 ({{period}} days)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/pt/translation.json b/packages/apps/public/locales/pt/translation.json index 853b91985eff..71a0274af0d8 100644 --- a/packages/apps/public/locales/pt/translation.json +++ b/packages/apps/public/locales/pt/translation.json @@ -966,7 +966,6 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, hospedado pelo Commonwealth Labs)", "rpc.flamingfir": "Fir flamejante (Substrate Testnet, hospedado pela Parity)", "rpc.header.dev": "Desenvolvimento", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Redes ativas", "rpc.header.test": "Redes de teste", "rpc.kulupu": "Grupos (Grupos Mainnet, hospedados por Grupos)", @@ -1127,4 +1126,4 @@ "{{threshold}}, not passing": "{{threshold}}, não passando", "{{threshold}}, passing": "{{threshold}}, passando", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}} x saldo de votos, bloqueado por {{lock}} x promulgação ({{period}} dias)" -} \ No newline at end of file +} diff --git a/packages/apps/public/locales/ru/translation.json b/packages/apps/public/locales/ru/translation.json index 290353ab5570..09410cf4aca1 100644 --- a/packages/apps/public/locales/ru/translation.json +++ b/packages/apps/public/locales/ru/translation.json @@ -979,7 +979,6 @@ "rpc.edgeware": "Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)", "rpc.flamingfir": "Flaming Fir (Substrate Testnet, hosted by Parity)", "rpc.header.dev": "Разработка", - "rpc.header.lighclients": "Light Clients (Substrate Connect)", "rpc.header.live": "Рабочие сети", "rpc.header.test": "Тестовые сети", "rpc.kulupu": "Kulupu (Kulupu Mainnet, hosted by Kulupu)", @@ -1138,4 +1137,4 @@ "{{threshold}}, not passing": "{{threshold}}, не проходит", "{{threshold}}, passing": "{{threshold}}, проходит", "{{value}}x voting balance, locked for {{lock}}x enactment ({{period}} days)": "{{value}}x баланс голосования, заблокировано на {{lock}}x ({{period}} дней)" -} \ No newline at end of file +} From 9ec926b6786eeb244a64a705dcc69154244de6eb Mon Sep 17 00:00:00 2001 From: wirednkod Date: Thu, 3 Jun 2021 13:58:27 +0300 Subject: [PATCH 05/45] alter configuration of testing and production networks in order to introduce light client type --- .../apps-config/src/endpoints/production.ts | 63 +++++----- .../src/endpoints/productionRelayKusama.ts | 22 ++-- .../src/endpoints/productionRelayPolkadot.ts | 8 +- .../src/endpoints/substrateConnect.ts | 48 -------- packages/apps-config/src/endpoints/testing.ts | 115 +++++++++--------- .../src/endpoints/testingRelayRococo.ts | 99 +++++++-------- .../src/endpoints/testingRelayWestend.ts | 12 +- packages/apps-config/src/endpoints/types.ts | 19 ++- packages/apps-config/src/endpoints/util.ts | 9 +- packages/apps-config/src/settings/types.ts | 1 + .../apps/public/locales/en/apps-config.json | 3 +- packages/apps/src/Endpoints/types.ts | 1 + 12 files changed, 193 insertions(+), 207 deletions(-) delete mode 100644 packages/apps-config/src/endpoints/substrateConnect.ts diff --git a/packages/apps-config/src/endpoints/production.ts b/packages/apps-config/src/endpoints/production.ts index 1d56b1f07272..e2b064a579f2 100644 --- a/packages/apps-config/src/endpoints/production.ts +++ b/packages/apps-config/src/endpoints/production.ts @@ -4,6 +4,7 @@ import type { TFunction } from 'i18next'; import type { LinkOption } from '../settings/types'; +import { EndpointType } from './types'; import { expandEndpoints } from './util'; /* eslint-disable sort-keys */ @@ -22,38 +23,38 @@ export function createProduction (t: TFunction): LinkOption[] { info: 'centrifuge', text: t('rpc.prod.centrifuge', 'Centrifuge', { ns: 'apps-config' }), providers: { - Centrifuge: 'wss://fullnode.centrifuge.io' + Centrifuge: { type: EndpointType.jrpc, url: 'wss://fullnode.centrifuge.io' } } }, { info: 'crab', text: t('rpc.prod.crab', 'Darwinia Crab', { ns: 'apps-config' }), providers: { - 'Darwinia Network': 'wss://crab-rpc.darwinia.network' + 'Darwinia Network': { type: EndpointType.jrpc, url: 'wss://crab-rpc.darwinia.network' } } }, { info: 'chainx', text: t('rpc.prod.chainx', 'ChainX', { ns: 'apps-config' }), providers: { - ChainX: 'wss://mainnet.chainx.org/ws', - 'Patract Elara': 'wss://chainx.elara.patract.io' + ChainX: { type: EndpointType.jrpc, url: 'wss://mainnet.chainx.org/ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://chainx.elara.patract.io' } } }, { info: 'darwinia', text: t('rpc.prod.darwinia', 'Darwinia', { ns: 'apps-config' }), providers: { - 'Darwinia Network': 'wss://rpc.darwinia.network', - 'Patract Elara': 'wss://darwinia.elara.patract.io' + 'Darwinia Network': { type: EndpointType.jrpc, url: 'wss://rpc.darwinia.network' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://darwinia.elara.patract.io' } } }, { info: 'dock-mainnet', text: t('rpc.prod.dock-mainnet', 'Dock', { ns: 'apps-config' }), providers: { - 'Dock Association': 'wss://mainnet-node.dock.io', - 'Patract Elara': 'wss://dock.elara.patract.io' + 'Dock Association': { type: EndpointType.jrpc, url: 'wss://mainnet-node.dock.io' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://dock.elara.patract.io' } } }, { @@ -61,32 +62,32 @@ export function createProduction (t: TFunction): LinkOption[] { info: 'edgeware', text: t('rpc.prod.edgeware', 'Edgeware', { ns: 'apps-config' }), providers: { - 'Commonwealth Labs': 'wss://mainnet1.edgewa.re', - 'Patract Elara': 'wss://edgeware.elara.patract.io', - OnFinality: 'wss://edgeware.api.onfinality.io/public-ws' + 'Commonwealth Labs': { type: EndpointType.jrpc, url: 'wss://mainnet1.edgewa.re' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://edgeware.elara.patract.io' }, + OnFinality: { type: EndpointType.jrpc, url: 'wss://edgeware.api.onfinality.io/public-ws' } } }, { info: 'equilibrium', text: t('rpc.prod.equilibrium', 'Equilibrium', { ns: 'apps-config' }), providers: { - Equilibrium: 'wss://node.equilibrium.io' + Equilibrium: { type: EndpointType.jrpc, url: 'wss://node.equilibrium.io' } } }, { info: 'hanonycash', text: t('rpc.prod.hanonycash', 'Hanonycash', { ns: 'apps-config' }), providers: { - Hanonycash: 'wss://rpc.hanonycash.com' + Hanonycash: { type: EndpointType.jrpc, url: 'wss://rpc.hanonycash.com' } } }, { info: 'snakenet', text: t('rpc.prod.hydra', 'HydraDX', { ns: 'apps-config' }), providers: { - HydraDX: 'wss://rpc-01.snakenet.hydradx.io', - 'Galactic Council': 'wss://rpc-02.snakenet.hydradx.io', - Archives: 'wss://archive.snakenet.hydradx.io' + HydraDX: { type: EndpointType.jrpc, url: 'wss://rpc-01.snakenet.hydradx.io' }, + 'Galactic Council': { type: EndpointType.jrpc, url: 'wss://rpc-02.snakenet.hydradx.io' }, + Archives: { type: EndpointType.jrpc, url: 'wss://archive.snakenet.hydradx.io' } } }, { @@ -94,45 +95,45 @@ export function createProduction (t: TFunction): LinkOption[] { info: 'kulupu', text: t('rpc.prod.kulupu', 'Kulupu', { ns: 'apps-config' }), providers: { - Kulupu: 'wss://rpc.kulupu.corepaper.org/ws', - 'Patract Elara': 'wss://kulupu.elara.patract.io' + Kulupu: { type: EndpointType.jrpc, url: 'wss://rpc.kulupu.corepaper.org/ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://kulupu.elara.patract.io' } } }, { info: 'neatcoin', text: t('rpc.prod.neatcoin', 'Neatcoin', { ns: 'apps-config' }), providers: { - Neatcoin: 'wss://rpc.neatcoin.org/ws' + Neatcoin: { type: EndpointType.jrpc, url: 'wss://rpc.neatcoin.org/ws' } } }, { info: 'nodle', text: t('rpc.prod.nodle-main', 'Nodle', { ns: 'apps-config' }), providers: { - Nodle: 'wss://main3.nodleprotocol.io', - 'Patract Elara': 'wss://nodle.elara.patract.io' + Nodle: { type: EndpointType.jrpc, url: 'wss://main3.nodleprotocol.io' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://nodle.elara.patract.io' } } }, { info: 'plasm', text: t('rpc.prod.plasm', 'Plasm', { ns: 'apps-config' }), providers: { - 'Stake Technologies': 'wss://rpc.plasmnet.io/', - 'Patract Elara': 'wss://plasm.elara.patract.io' + 'Stake Technologies': { type: EndpointType.jrpc, url: 'wss://rpc.plasmnet.io/' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://plasm.elara.patract.io' } } }, { info: 'riochain', text: t('rpc.prod.riochain', 'RioChain', { ns: 'apps-config' }), providers: { - RioChain: 'wss://node.v1.riochain.io' + RioChain: { type: EndpointType.jrpc, url: 'wss://node.v1.riochain.io' } } }, { info: 'sora-substrate', text: t('rpc.prod.sora-substrate', 'SORA', { ns: 'apps-config' }), providers: { - Soramitsu: 'wss://ws.sora2.soramitsu.co.jp' + Soramitsu: { type: EndpointType.jrpc, url: 'wss://ws.sora2.soramitsu.co.jp' } } }, { @@ -140,30 +141,30 @@ export function createProduction (t: TFunction): LinkOption[] { isDisabled: true, // Cannot find type ChainId text: t('rpc.prod.stafi', 'Stafi', { ns: 'apps-config' }), providers: { - 'Stafi Foundation': 'wss://mainnet-rpc.stafi.io', - 'Patract Elara': 'wss://stafi.elara.patract.io' + 'Stafi Foundation': { type: EndpointType.jrpc, url: 'wss://mainnet-rpc.stafi.io' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://stafi.elara.patract.io' } } }, { info: 'subsocial', text: t('rpc.prod.subsocial', 'Subsocial', { ns: 'apps-config' }), providers: { - DappForce: 'wss://rpc.subsocial.network', - 'Patract Elara': 'wss://subsocial.elara.patract.io' + DappForce: { type: EndpointType.jrpc, url: 'wss://rpc.subsocial.network' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://subsocial.elara.patract.io' } } }, { info: 'uniarts', text: t('rpc.prod.uniarts', 'UniArts', { ns: 'apps-config' }), providers: { - UniArts: 'wss://mainnet.uniarts.vip:9443' + UniArts: { type: EndpointType.jrpc, url: 'wss://mainnet.uniarts.vip:9443' } } }, { info: 'westlake', text: t('rpc.prod.westlake', 'Westlake', { ns: 'apps-config' }), providers: { - DataHighway: 'wss://westlake.datahighway.com' + DataHighway: { type: EndpointType.jrpc, url: 'wss://westlake.datahighway.com' } } } ]); diff --git a/packages/apps-config/src/endpoints/productionRelayKusama.ts b/packages/apps-config/src/endpoints/productionRelayKusama.ts index b2cfdf1adcee..83bb4686da2d 100644 --- a/packages/apps-config/src/endpoints/productionRelayKusama.ts +++ b/packages/apps-config/src/endpoints/productionRelayKusama.ts @@ -5,6 +5,7 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; import { KUSAMA_GENESIS } from '../api/constants'; +import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -20,9 +21,10 @@ export function createKusama (t: TFunction): EndpointOption { info: 'kusama', text: t('rpc.kusama.parity', 'Kusama', { ns: 'apps-config' }), providers: { - Parity: 'wss://kusama-rpc.polkadot.io', - OnFinality: 'wss://kusama.api.onfinality.io/public-ws', - 'Patract Elara': 'wss://kusama.elara.patract.io' + Parity: { type: EndpointType.jrpc, url: 'wss://kusama-rpc.polkadot.io' }, + OnFinality: { type: EndpointType.jrpc, url: 'wss://kusama.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://kusama.elara.patract.io' }, + 'light client': { type: EndpointType.substrateconnect, chain: 'kusama-substrate-connect' } }, linked: [ // (1) all system parachains (none available yet) @@ -33,7 +35,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 1000, text: t('rpc.kusama.shell', 'Shell', { ns: 'apps-config' }), providers: { - Parity: 'wss://kusama-shell-rpc.parity.io' + Parity: { type: EndpointType.jrpc, url: 'wss://kusama-shell-rpc.parity.io' } } }, /// (3) parachains with id, see Rococo (info here maps to the actual "named icon") @@ -44,7 +46,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2001, text: t('rpc.kusama.bifrost', 'Bifrost', { ns: 'apps-config' }), providers: { - Bifrost: 'wss://bifrost-rpc.liebi.com/ws' + Bifrost: { type: EndpointType.jrpc, url: 'wss://bifrost-rpc.liebi.com/ws' } } }, { @@ -52,7 +54,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2006, text: t('rpc.kusama.crab', 'Darwinia Crab', { ns: 'apps-config' }), providers: { - Crab: 'wss://crab-rpc.darwinia.network/' + Crab: { type: EndpointType.jrpc, url: 'wss://crab-rpc.darwinia.network/' } } }, { @@ -60,7 +62,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2012, text: t('rpc.kusama.shadow', 'Crust Shadow', { ns: 'apps-config' }), providers: { - Crust: 'wss://shadow.crust.network/' + Crust: { type: EndpointType.jrpc, url: 'wss://shadow.crust.network/' } } }, { @@ -68,7 +70,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2004, text: t('rpc.kusama.khala', 'Khala Network', { ns: 'apps-config' }), providers: { - Phala: 'wss://khala.phala.network/ws' + Phala: { type: EndpointType.jrpc, url: 'wss://khala.phala.network/ws' } } }, { @@ -76,7 +78,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2005, text: t('rpc.kusama.kilt', 'KILT Mainnet', { ns: 'apps-config' }), providers: { - 'KILT Protocol': 'wss://mainnet.kilt.io/' + 'KILT Protocol': { type: EndpointType.jrpc, url: 'wss://mainnet.kilt.io/' } } }, { @@ -84,7 +86,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2013, text: t('rpc.kusama.sherpax', 'SherpaX', { ns: 'apps-config' }), providers: { - ChainX: 'wss://sherpax.chainx.org' + ChainX: { type: EndpointType.jrpc, url: 'wss://sherpax.chainx.org' } } } ] diff --git a/packages/apps-config/src/endpoints/productionRelayPolkadot.ts b/packages/apps-config/src/endpoints/productionRelayPolkadot.ts index 08f3280c1fc2..ae24ef7fdfb9 100644 --- a/packages/apps-config/src/endpoints/productionRelayPolkadot.ts +++ b/packages/apps-config/src/endpoints/productionRelayPolkadot.ts @@ -5,6 +5,7 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; import { POLKADOT_GENESIS } from '../api/constants'; +import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -20,9 +21,10 @@ export function createPolkadot (t: TFunction): EndpointOption { info: 'polkadot', text: t('rpc.polkadot.parity', 'Polkadot', { ns: 'apps-config' }), providers: { - Parity: 'wss://rpc.polkadot.io', - OnFinality: 'wss://polkadot.api.onfinality.io/public-ws', - 'Patract Elara': 'wss://polkadot.elara.patract.io' + Parity: { type: EndpointType.jrpc, url: 'wss://rpc.polkadot.io' }, + OnFinality: { type: EndpointType.jrpc, url: 'wss://polkadot.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://polkadot.elara.patract.io' }, + 'light client': { type: EndpointType.substrateconnect, chain: 'polkadot-substrate-connect' } }, linked: [ // (1) system parachains (none available yet) diff --git a/packages/apps-config/src/endpoints/substrateConnect.ts b/packages/apps-config/src/endpoints/substrateConnect.ts deleted file mode 100644 index d7a446ac1d64..000000000000 --- a/packages/apps-config/src/endpoints/substrateConnect.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017-2021 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { TFunction } from 'i18next'; -import type { LinkOption } from '../settings/types'; - -import { expandEndpoints } from './util'; - -/* eslint-disable sort-keys */ - -// The available endpoints that will show in the dropdown. For the most part (with the exception of -// Polkadot) we try to keep this to live chains only, with RPCs hosted by the community/chain vendor -// info: The chain logo name as defined in ../ui/logos/index.ts in namedLogos (this also needs to align with @polkadot/networks) -// text: The text to display on the dropdown -// value: The actual hosted secure websocket endpoint - -// ws addresses in Providers are not real - just a hack to allow "switch" to be activated (needs valid url) -// and the .substrateconnect exists in order to identify that this is a light client provider -// so that we can (in packages/react-api/src/Api.tsx) instead of calling a new WsProvider instead trigger -// a new Detector that will run Substrate-Connect -export function createSubstrateConnect (t: TFunction): LinkOption[] { - return expandEndpoints(t, [ - { - dnslink: 'Polkadot (Production)', - info: 'polkadot', - text: t('rpc.polkadot.substrateconnect', 'Polkadot (Production)', { ns: 'apps-config' }), - providers: { - 'your browser': 'ws://polkadot.substrateconnect' - } - }, - { - dnslink: 'Kusama (Production)', - info: 'kusama', - text: t('rpc.kusama.substrateconnect', 'Kusama (Production)', { ns: 'apps-config' }), - providers: { - 'your browser': 'ws://kusama.substrateconnect' - } - }, - { - dnslink: 'Westend (Test)', - info: 'westend', - text: t('rpc.westend.substrateconnect', 'Westend (Test)', { ns: 'apps-config' }), - providers: { - 'your browser': 'ws://westend.substrateconnect' - } - } - ]); -} diff --git a/packages/apps-config/src/endpoints/testing.ts b/packages/apps-config/src/endpoints/testing.ts index 70f07e23996c..a66b77a18551 100644 --- a/packages/apps-config/src/endpoints/testing.ts +++ b/packages/apps-config/src/endpoints/testing.ts @@ -4,6 +4,7 @@ import type { TFunction } from 'i18next'; import type { LinkOption } from '../settings/types'; +import { EndpointType } from './types'; import { expandEndpoints } from './util'; /* eslint-disable sort-keys */ @@ -21,42 +22,42 @@ export function createTesting (t: TFunction): LinkOption[] { info: 'centrifuge', text: t('rpc.test.amber', 'Amber', { ns: 'apps-config' }), providers: { - Centrifuge: 'wss://fullnode.amber.centrifuge.io' + Centrifuge: { type: EndpointType.jrpc, url: 'wss://fullnode.amber.centrifuge.io' } } }, { info: 'nodle', text: t('rpc.test.nodle-arcadia', 'Arcadia', { ns: 'apps-config' }), providers: { - Nodle: 'wss://arcadia1.nodleprotocol.io' + Nodle: { type: EndpointType.jrpc, url: 'wss://arcadia1.nodleprotocol.io' } } }, { info: 'edgeware', text: t('rpc.test.beresheet', 'Beresheet', { ns: 'apps-config' }), providers: { - 'Commonwealth Labs': 'wss://beresheet1.edgewa.re' + 'Commonwealth Labs': { type: EndpointType.jrpc, url: 'wss://beresheet1.edgewa.re' } } }, { info: 'bitcountry', text: t('rpc.test.bitcountry', 'Bit.Country Tewai', { ns: 'apps-config' }), providers: { - 'Bit.Country': 'wss://whenua.bit.country' + 'Bit.Country': { type: EndpointType.jrpc, url: 'wss://whenua.bit.country' } } }, { info: 'bifrost', text: t('rpc.test.bifrost', 'Bifrost Asgard', { ns: 'apps-config' }), providers: { - Bifrost: 'wss://testnet.liebi.com' + Bifrost: { type: EndpointType.jrpc, url: 'wss://testnet.liebi.com' } } }, { info: 'canvas', text: t('rpc.test.canvas', 'Canvas', { ns: 'apps-config' }), providers: { - Parity: 'wss://canvas-rpc.parity.io' + Parity: { type: EndpointType.jrpc, url: 'wss://canvas-rpc.parity.io' } } }, { @@ -64,15 +65,15 @@ export function createTesting (t: TFunction): LinkOption[] { isDisabled: true, // Cannot construct unknown type BridgeNetworks text: t('rpc.test.clover.finance', 'Clover', { ns: 'apps-config' }), providers: { - Clover: 'wss://api.clover.finance/' + Clover: { type: EndpointType.jrpc, url: 'wss://api.clover.finance/' } } }, { info: 'crust', text: t('rpc.test.crust.network', 'Crust Maxwell', { ns: 'apps-config' }), providers: { - 'Crust Network': 'wss://api.crust.network/', - 'DCloud Foundation': 'wss://api.decloudf.com/' + 'Crust Network': { type: EndpointType.jrpc, url: 'wss://api.crust.network/' }, + 'DCloud Foundation': { type: EndpointType.jrpc, url: 'wss://api.decloudf.com/' } } }, { @@ -80,288 +81,288 @@ export function createTesting (t: TFunction): LinkOption[] { isDisabled: true, text: t('rpc.test.datahighway.spreehafen', 'Spreehafen', { ns: 'apps-config' }), providers: { - MXC: 'wss://spreehafen.datahighway.com' + MXC: { type: EndpointType.jrpc, url: 'wss://spreehafen.datahighway.com' } } }, { info: 'dock-testnet', text: t('rpc.test.dock-testnet', 'Dock', { ns: 'apps-config' }), providers: { - 'Dock Association': 'wss://danforth-1.dock.io' + 'Dock Association': { type: EndpointType.jrpc, url: 'wss://danforth-1.dock.io' } } }, { info: 'dotmog', text: t('rpc.test.dotmog', 'DOTMog', { ns: 'apps-config' }), providers: { - DOTMog: 'wss://mogiway-01.dotmog.com' + DOTMog: { type: EndpointType.jrpc, url: 'wss://mogiway-01.dotmog.com' } } }, { info: 'dusty', text: t('rpc.test.dusty', 'Dusty', { ns: 'apps-config' }), providers: { - 'Stake Technologies': 'wss://rpc.dusty.plasmnet.io/' + 'Stake Technologies': { type: EndpointType.jrpc, url: 'wss://rpc.dusty.plasmnet.io/' } } }, { info: 'encointer_cantillon', text: t('rpc.test.encointer.cantillon', 'Encointer Cantillon', { ns: 'apps-config' }), providers: { - 'Encointer Association': 'wss://cantillon.encointer.org' + 'Encointer Association': { type: EndpointType.jrpc, url: 'wss://cantillon.encointer.org' } } }, { info: 'encointer_gesell', text: t('rpc.test.encointer.gesell', 'Encointer Gesell', { ns: 'apps-config' }), providers: { - 'Encointer Association': 'wss://gesell.encointer.org' + 'Encointer Association': { type: EndpointType.jrpc, url: 'wss://gesell.encointer.org' } } }, { info: 'equilibrium', text: t('rpc.test.equilibriumtestnet', 'Equilibrium', { ns: 'apps-config' }), providers: { - Equilibrium: 'wss://testnet.equilibrium.io' + Equilibrium: { type: EndpointType.jrpc, url: 'wss://testnet.equilibrium.io' } } }, { info: 'substrate', text: t('rpc.test.flamingfir', 'Flaming Fir', { ns: 'apps-config' }), providers: { - Parity: 'wss://substrate-rpc.parity.io' + Parity: { type: EndpointType.jrpc, url: 'wss://substrate-rpc.parity.io' } } }, { info: 'Galital', text: t('rpc.test.galital', 'Galital PC2', { ns: 'apps-config' }), providers: { - StarkleyTech: 'wss://galital-rpc-testnet.starkleytech.com' + StarkleyTech: { type: EndpointType.jrpc, url: 'wss://galital-rpc-testnet.starkleytech.com' } } }, { info: 'galois', text: t('rpc.test.galois', 'Galois', { ns: 'apps-config' }), providers: { - MathWallet: 'wss://galois-hk.maiziqianbao.net/ws', - 'MathWallet Backup': 'wss://galois.maiziqianbao.net/ws' + MathWallet: { type: EndpointType.jrpc, url: 'wss://galois-hk.maiziqianbao.net/ws' }, + 'MathWallet Backup': { type: EndpointType.jrpc, url: 'wss://galois.maiziqianbao.net/ws' } } }, { info: 'gamepower', text: t('rpc.test.gamepower', 'GamePower', { ns: 'apps-config' }), providers: { - GamePower: 'wss://gamepower.io' + GamePower: { type: EndpointType.jrpc, url: 'wss://gamepower.io' } } }, { info: 'geek', text: t('rpc.test.geek', 'GeekCash', { ns: 'apps-config' }), providers: { - 'Geek Team': 'wss://testnet.geekcash.org' + 'Geek Team': { type: EndpointType.jrpc, url: 'wss://testnet.geekcash.org' } } }, { info: 'halongbay', text: t('rpc.test.halongbay', 'Halongbay Testnet', { ns: 'apps-config' }), providers: { - Halongbay: 'wss://halongbay.polkafoundry.com' + Halongbay: { type: EndpointType.jrpc, url: 'wss://halongbay.polkafoundry.com' } } }, { info: 'ipse', text: t('rpc.test.ipse', 'IPSE', { ns: 'apps-config' }), providers: { - 'IPSE China': 'wss://testnet-china.ipse.io', - 'IPSE USA': 'wss://testnet-usa.ipse.io', - 'IPSE Europe': 'wss://testnet-europe.ipse.io' + 'IPSE China': { type: EndpointType.jrpc, url: 'wss://testnet-china.ipse.io' }, + 'IPSE USA': { type: EndpointType.jrpc, url: 'wss://testnet-usa.ipse.io' }, + 'IPSE Europe': { type: EndpointType.jrpc, url: 'wss://testnet-europe.ipse.io' } } }, { info: 'jupiter', text: t('rpc.test.jupiter', 'Jupiter', { ns: 'apps-config' }), providers: { - Elara: 'wss://jupiter-poa.elara.patract.io', - Patract: 'wss://ws.jupiter-poa.patract.cn' + Elara: { type: EndpointType.jrpc, url: 'wss://jupiter-poa.elara.patract.io' }, + Patract: { type: EndpointType.jrpc, url: 'wss://ws.jupiter-poa.patract.cn' } } }, { info: 'kilt', text: t('rpc.test.kilt', 'KILT Mashnet', { ns: 'apps-config' }), providers: { - 'KILT Protocol': 'wss://full-nodes.kilt.io:9944/' + 'KILT Protocol': { type: EndpointType.jrpc, url: 'wss://full-nodes.kilt.io:9944/' } } }, { info: 'litentry', text: t('rpc.test.litentry', 'Litentry Testnet', { ns: 'apps-config' }), providers: { - Litentry: 'wss://testnet.litentry.io' + Litentry: { type: EndpointType.jrpc, url: 'wss://testnet.litentry.io' } } }, { info: 'acala', text: t('rpc.test.mandala', 'Mandala', { ns: 'apps-config' }), providers: { - Acala: 'wss://acala-mandala.api.onfinality.io/public-ws', - 'Patract Elara': 'wss://mandala.elara.patract.io' + Acala: { type: EndpointType.jrpc, url: 'wss://acala-mandala.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://mandala.elara.patract.io' } } }, { info: 'moonbaseAlpha', text: t('rpc.test.moonbeam', 'Moonbase Alpha', { ns: 'apps-config' }), providers: { - 'Moonbeam Network': 'wss://wss.testnet.moonbeam.network', - OnFinality: 'wss://moonbeam-alpha.api.onfinality.io/public-ws', - 'Patract Elara': 'wss://moonbase.moonbeam.elara.patract.io' + 'Moonbeam Network': { type: EndpointType.jrpc, url: 'wss://wss.testnet.moonbeam.network' }, + OnFinality: { type: EndpointType.jrpc, url: 'wss://moonbeam-alpha.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://moonbase.moonbeam.elara.patract.io' } } }, { info: 'mybank', text: t('rpc.test.mybank', 'mybank.network', { ns: 'apps-config' }), providers: { - MYBANK: 'wss://mybank.network/substrate' + MYBANK: { type: EndpointType.jrpc, url: 'wss://mybank.network/substrate' } } }, { info: 'nftmart', text: t('rpc.test.nftmart', 'NFTMart', { ns: 'apps-config' }), providers: { - NFTMartDev: 'wss://dev-ws.nftmart.io', - NFTMartStaging: 'wss://staging-ws.nftmart.io' + NFTMartDev: { type: EndpointType.jrpc, url: 'wss://dev-ws.nftmart.io' }, + NFTMartStaging: { type: EndpointType.jrpc, url: 'wss://staging-ws.nftmart.io' } } }, { info: 'pangolin', text: t('rpc.test.pangolin', 'Pangolin', { ns: 'apps-config' }), providers: { - 'Darwinia Network': 'wss://pangolin-rpc.darwinia.network' + 'Darwinia Network': { type: EndpointType.jrpc, url: 'wss://pangolin-rpc.darwinia.network' } } }, { info: 'phala', text: t('rpc.test.phala', 'Phala PoC-4', { ns: 'apps-config' }), providers: { - 'Phala Network': 'wss://poc4.phala.network/ws' + 'Phala Network': { type: EndpointType.jrpc, url: 'wss://poc4.phala.network/ws' } } }, { info: 'phoenix', text: t('rpc.test.phoenix', 'Phoenix Mashnet', { ns: 'apps-config' }), providers: { - 'phoenix Protocol': 'wss://phoenix-ws.coinid.pro/' + 'phoenix Protocol': { type: EndpointType.jrpc, url: 'wss://phoenix-ws.coinid.pro/' } } }, { info: 'polkadex', text: t('rpc.test.polkadex', 'Polkadex', { ns: 'apps-config' }), providers: { - 'Polkadex Team': 'wss://blockchain.polkadex.trade' + 'Polkadex Team': { type: EndpointType.jrpc, url: 'wss://blockchain.polkadex.trade' } } }, { info: 'polkabtc', text: t('rpc.test.polkabtc', 'PolkaBTC', { ns: 'apps-config' }), providers: { - Interlay: 'wss://beta.polkabtc.io/api/parachain' + Interlay: { type: EndpointType.jrpc, url: 'wss://beta.polkabtc.io/api/parachain' } } }, { info: 'polymesh', text: t('rpc.test.polymesh', 'Polymesh ITN', { ns: 'apps-config' }), providers: { - Polymath: 'wss://itn-rpc.polymesh.live' + Polymath: { type: EndpointType.jrpc, url: 'wss://itn-rpc.polymesh.live' } } }, { info: 'prism', text: t('rpc.test.prism', 'Prism', { ns: 'apps-config' }), providers: { - Prism: 'wss://testnet.psm.link' + Prism: { type: EndpointType.jrpc, url: 'wss://testnet.psm.link' } } }, { info: 'realis', text: t('rpc.test.realis', 'Realis.Network', { ns: 'apps-config' }), providers: { - 'Realis.Network': 'wss://rpc.realis.network/' + 'Realis.Network': { type: EndpointType.jrpc, url: 'wss://rpc.realis.network/' } } }, { info: 'riochain', text: t('rpc.test.riochain', 'RioChain', { ns: 'apps-config' }), providers: { - 'RioChain Staging': 'wss://node.v1.staging.riochain.io' + 'RioChain Staging': { type: EndpointType.jrpc, url: 'wss://node.v1.staging.riochain.io' } } }, { info: 'sora-substrate', text: t('rpc.test.sora-substrate-staging', 'SORA-staging', { ns: 'apps-config' }), providers: { - Soramitsu: 'wss://ws.stage.sora2.soramitsu.co.jp' + Soramitsu: { type: EndpointType.jrpc, url: 'wss://ws.stage.sora2.soramitsu.co.jp' } } }, { info: 'ternoa-chaos', text: t('rpc.test.ternoa-chaos', 'Ternoa Chaos', { ns: 'apps-config' }), providers: { - CapsuleCorp: 'wss://chaos.ternoa.com' + CapsuleCorp: { type: EndpointType.jrpc, url: 'wss://chaos.ternoa.com' } } }, { info: 'laminar', text: t('rpc.test.turbulence', 'Turbulence', { ns: 'apps-config' }), providers: { - Laminar: 'wss://testnet-node-1.laminar-chain.laminar.one/ws' + Laminar: { type: EndpointType.jrpc, url: 'wss://testnet-node-1.laminar-chain.laminar.one/ws' } } }, { info: 'uniarts', text: t('rpc.test.uniarts', 'UniArts', { ns: 'apps-config' }), providers: { - UniArts: 'wss://testnet.uniarts.me' + UniArts: { type: EndpointType.jrpc, url: 'wss://testnet.uniarts.me' } } }, { info: 'unique', text: t('rpc.test.unique', 'Unique', { ns: 'apps-config' }), providers: { - Unique: 'wss://testnet2.uniquenetwork.io' + Unique: { type: EndpointType.jrpc, url: 'wss://testnet2.uniquenetwork.io' } } }, { info: 'unitv', text: t('rpc.test.unitv', 'Unit Network', { ns: 'apps-config' }), providers: { - 'Unit Network': 'wss://unitventures.io/' + 'Unit Network': { type: EndpointType.jrpc, url: 'wss://unitventures.io/' } } }, { info: 'vodka', text: t('rpc.test.vodka', 'Vodka', { ns: 'apps-config' }), providers: { - Vodka: 'wss://vodka.rpc.neatcoin.org/ws' + Vodka: { type: EndpointType.jrpc, url: 'wss://vodka.rpc.neatcoin.org/ws' } } }, { info: 'web3games', text: t('rpc.test.web3games', 'Web3Games', { ns: 'apps-config' }), providers: { - Web3Games: 'wss://substrate.org.cn:4443' + Web3Games: { type: EndpointType.jrpc, url: 'wss://substrate.org.cn:4443' } } }, { info: 'zeitgeist', text: t('rpc.test.zeitgeist', 'Zeitgeist Battery Park', { ns: 'apps-config' }), providers: { - Zeitgeist: 'wss://bp-rpc.zeitgeist.pm' + Zeitgeist: { type: EndpointType.jrpc, url: 'wss://bp-rpc.zeitgeist.pm' } } }, { info: 'zero', text: t('rpc.test.zero', 'Zero', { ns: 'apps-config' }), providers: { - ZERO: 'wss://alphaville.zero.io' + ZERO: { type: EndpointType.jrpc, url: 'wss://alphaville.zero.io' } } } ]); diff --git a/packages/apps-config/src/endpoints/testingRelayRococo.ts b/packages/apps-config/src/endpoints/testingRelayRococo.ts index d5db5e5154f7..2b384c29868b 100644 --- a/packages/apps-config/src/endpoints/testingRelayRococo.ts +++ b/packages/apps-config/src/endpoints/testingRelayRococo.ts @@ -5,6 +5,7 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; import { ROCOCO_GENESIS } from '../api/constants'; +import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -22,10 +23,10 @@ export function createRococo (t: TFunction): EndpointOption { info: 'rococo', text: t('rpc.rococo', 'Rococo', { ns: 'apps-config' }), providers: { - Parity: 'wss://rococo-rpc.polkadot.io', - OnFinality: 'wss://rococo.api.onfinality.io/public-ws', - 'Patract Elara': 'wss://rococo.elara.patract.io', - 'Ares Protocol': 'wss://rococo.aresprotocol.com' + Parity: { type: EndpointType.jrpc, url: 'wss://rococo-rpc.polkadot.io' }, + OnFinality: { type: EndpointType.jrpc, url: 'wss://rococo.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://rococo.elara.patract.io' }, + 'Ares Protocol': { type: EndpointType.jrpc, url: 'wss://rococo.aresprotocol.com' } }, linked: [ // these are the base chains @@ -34,7 +35,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 100, text: t('rpc.rococo.tick', 'Tick', { ns: 'apps-config' }), providers: { - Parity: 'wss://tick-rpc.polkadot.io' + Parity: { type: EndpointType.jrpc, url: 'wss://tick-rpc.polkadot.io' } } }, { @@ -42,7 +43,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 110, text: t('rpc.rococo.trick', 'Trick', { ns: 'apps-config' }), providers: { - Parity: 'wss://trick-rpc.polkadot.io' + Parity: { type: EndpointType.jrpc, url: 'wss://trick-rpc.polkadot.io' } } }, { @@ -50,7 +51,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 120, text: t('rpc.rococo.track', 'Track', { ns: 'apps-config' }), providers: { - Parity: 'wss://track-rpc.polkadot.io' + Parity: { type: EndpointType.jrpc, url: 'wss://track-rpc.polkadot.io' } } }, { @@ -58,7 +59,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1, text: t('rpc.rococo.statemint', 'Statemint', { ns: 'apps-config' }), providers: { - Parity: 'wss://statemint-rococo-rpc.parity.io' + Parity: { type: EndpointType.jrpc, url: 'wss://statemint-rococo-rpc.parity.io' } } }, // add any additional parachains here, alphabetical @@ -67,7 +68,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2048, text: t('rpc.rococo.apron', 'Apron PC1', { ns: 'apps-config' }), providers: { - 'Apron Network': 'wss://rococo.apron.network' + 'Apron Network': { type: EndpointType.jrpc, url: 'wss://rococo.apron.network' } } }, { @@ -75,7 +76,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1006, text: t('rpc.rococo.ares', 'Ares PC1', { ns: 'apps-config' }), providers: { - 'Ares Protocol': 'wss://rococo.parachain.aresprotocol.com' + 'Ares Protocol': { type: EndpointType.jrpc, url: 'wss://rococo.parachain.aresprotocol.com' } } }, { @@ -83,7 +84,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1024, text: t('rpc.rococo.bifrost', 'Bifrost PC1', { ns: 'apps-config' }), providers: { - Bifrost: 'wss://rococo-1.testnet.liebi.com' + Bifrost: { type: EndpointType.jrpc, url: 'wss://rococo-1.testnet.liebi.com' } } }, { @@ -91,7 +92,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1008, text: t('rpc.rococo.bitcountry', 'Bit.Country PC1', { ns: 'apps-config' }), providers: { - BitCountry: 'wss://tewai-parachain.bit.country:9955' + BitCountry: { type: EndpointType.jrpc, url: 'wss://tewai-parachain.bit.country:9955' } } }, { @@ -99,7 +100,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 10001, text: t('rpc.rococo.centrifuge', 'Centrifuge Charcoal', { ns: 'apps-config' }), providers: { - Centrifuge: 'wss://fullnode-collator.charcoal.centrifuge.io' + Centrifuge: { type: EndpointType.jrpc, url: 'wss://fullnode-collator.charcoal.centrifuge.io' } } }, { @@ -110,7 +111,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 229, text: t('rpc.rococo.clover', 'Clover PC1', { ns: 'apps-config' }), providers: { - Clover: 'wss://api-rococo.clover.finance' + Clover: { type: EndpointType.jrpc, url: 'wss://api-rococo.clover.finance' } } }, { @@ -121,7 +122,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 9, text: t('rpc.rococo.crab', 'Darwinia Crab PC2', { ns: 'apps-config' }), providers: { - Darwinia: 'wss://crab-pc2-rpc.darwinia.network' + Darwinia: { type: EndpointType.jrpc, url: 'wss://crab-pc2-rpc.darwinia.network' } } }, { @@ -129,7 +130,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2001, text: t('rpc.rococo.crust', 'Crust PC1', { ns: 'apps-config' }), providers: { - Crust: 'wss://api-rococo.crust.network' + Crust: { type: EndpointType.jrpc, url: 'wss://api-rococo.crust.network' } } }, { @@ -137,7 +138,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1059, text: t('rpc.rococo.chainx', 'ChainX PC1', { ns: 'apps-config' }), providers: { - ChainX: 'wss://sherpax.chainx.org' + ChainX: { type: EndpointType.jrpc, url: 'wss://sherpax.chainx.org' } } }, { @@ -148,7 +149,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 18, text: t('rpc.rococo.darwinia', 'Darwinia PC2', { ns: 'apps-config' }), providers: { - Darwinia: 'wss://pc2-rpc.darwinia.network' + Darwinia: { type: EndpointType.jrpc, url: 'wss://pc2-rpc.darwinia.network' } } }, { @@ -159,7 +160,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2, text: t('rpc.rococo.datahighway', 'DataHighway', { ns: 'apps-config' }), providers: { - DataHighway: 'wss://spreehafen.datahighway.com' + DataHighway: { type: EndpointType.jrpc, url: 'wss://spreehafen.datahighway.com' } } }, { @@ -167,7 +168,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2003, text: t('rpc.rococo.eave', 'Steam PC', { ns: 'apps-config' }), providers: { - EAVE: 'wss://steamcollator.eave.network' + EAVE: { type: EndpointType.jrpc, url: 'wss://steamcollator.eave.network' } } }, { @@ -175,7 +176,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1862, text: t('rpc.rococo.encointer', 'Encointer PC1', { ns: 'apps-config' }), providers: { - Encointer: 'wss://rococo.encointer.org' + Encointer: { type: EndpointType.jrpc, url: 'wss://rococo.encointer.org' } } }, { @@ -186,7 +187,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 42, text: t('rpc.rococo.equilibrium', 'Equilibrium', { ns: 'apps-config' }), providers: { - Equilibrium: 'wss://rococo.equilibrium.io' + Equilibrium: { type: EndpointType.jrpc, url: 'wss://rococo.equilibrium.io' } } }, { @@ -194,7 +195,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1230, text: t('rpc.rococo.galital', 'Galital PC1', { ns: 'apps-config' }), providers: { - StarkleyTech: 'wss://galital-rpc.starkleytech.com' + StarkleyTech: { type: EndpointType.jrpc, url: 'wss://galital-rpc.starkleytech.com' } } }, { @@ -202,7 +203,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 82406, text: t('rpc.rococo.hydrate', 'Hydrate', { ns: 'apps-config' }), providers: { - HydraDX: 'wss://hydrate-rpc.hydradx.io:9944' + HydraDX: { type: EndpointType.jrpc, url: 'wss://hydrate-rpc.hydradx.io:9944' } } }, { @@ -210,7 +211,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 7766, text: t('rpc.rococo.idavoll', 'Idavoll', { ns: 'apps-config' }), providers: { - Idavoll: 'wss://rococo.idavoll.network' + Idavoll: { type: EndpointType.jrpc, url: 'wss://rococo.idavoll.network' } } }, { @@ -218,7 +219,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1983, text: t('rpc.rococo.integritee', 'IntegriTEE PC1', { ns: 'apps-config' }), providers: { - SCS: 'wss://rococo.integritee.network' + SCS: { type: EndpointType.jrpc, url: 'wss://rococo.integritee.network' } } }, { @@ -226,7 +227,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 12623, text: t('rpc.rococo.kilt', 'KILT PC1', { ns: 'apps-config' }), providers: { - 'KILT Protocol': 'wss://para.rococo-v1.kilt.io' + 'KILT Protocol': { type: EndpointType.jrpc, url: 'wss://para.rococo-v1.kilt.io' } } }, { @@ -234,7 +235,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 18403, text: t('rpc.rococo.konomi', 'Komomi Network', { ns: 'apps-config' }), providers: { - 'Konomi Network': 'wss://rococo.konomi.tech' + 'Konomi Network': { type: EndpointType.jrpc, url: 'wss://rococo.konomi.tech' } } }, { @@ -242,7 +243,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1984, text: t('rpc.rocco.litentry', 'Litentry Rostock', { ns: 'apps-config' }), providers: { - Litentry: 'wss://rococov1.litentry.io' + Litentry: { type: EndpointType.jrpc, url: 'wss://rococov1.litentry.io' } } }, { @@ -250,7 +251,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1000, text: t('rpc.rococo.acala', 'Mandala PC2', { ns: 'apps-config' }), providers: { - Acala: 'wss://rococo-1.acala.laminar.one' + Acala: { type: EndpointType.jrpc, url: 'wss://rococo-1.acala.laminar.one' } } }, { @@ -261,7 +262,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 40, text: t('rpc.rococo.mathchain', 'MathChain PC1', { ns: 'apps-config' }), providers: { - MathWallet: 'wss://testpara.maiziqianbao.net/ws' + MathWallet: { type: EndpointType.jrpc, url: 'wss://testpara.maiziqianbao.net/ws' } } }, { @@ -269,7 +270,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2021, text: t('rpc.rococo.manta', 'Manta PC1', { ns: 'apps-config' }), providers: { - Manta: 'wss://rococo.manta.network' + Manta: { type: EndpointType.jrpc, url: 'wss://rococo.manta.network' } } }, { @@ -277,7 +278,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1286, text: t('rpc.rococo.moonrock', 'Moonrock', { ns: 'apps-config' }), providers: { - Moonrock: 'wss://wss-moonrock.gcp.purestake.run' + Moonrock: { type: EndpointType.jrpc, url: 'wss://wss-moonrock.gcp.purestake.run' } } }, { @@ -285,7 +286,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 18888, text: t('rpc.rococo.parami', 'Parami PC2', { ns: 'apps-config' }), providers: { - Parami: 'wss://rococo.parami.io' + Parami: { type: EndpointType.jrpc, url: 'wss://rococo.parami.io' } } }, { @@ -293,7 +294,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1010, text: t('rpc.rococo.jupiter', 'Patract Jupiter PC1', { ns: 'apps-config' }), providers: { - jupiter: 'wss://ws.rococo.jupiter.patract.cn' + jupiter: { type: EndpointType.jrpc, url: 'wss://ws.rococo.jupiter.patract.cn' } } }, { @@ -301,7 +302,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1030, text: t('rpc.rococo.phala', 'Phala PC1', { ns: 'apps-config' }), providers: { - Phala: 'wss://rococov1.phala.network/ws' + Phala: { type: EndpointType.jrpc, url: 'wss://rococov1.phala.network/ws' } } }, { @@ -309,7 +310,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 6806, text: t('rpc.rococo.phoenix', 'PHOENIX PC1', { ns: 'apps-config' }), providers: { - 'PHOENIX Protocol': 'wss://phoenix-ws.coinid.pro' + 'PHOENIX Protocol': { type: EndpointType.jrpc, url: 'wss://phoenix-ws.coinid.pro' } } }, { @@ -317,7 +318,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 5000, text: t('rpc.rococo.plasm', 'Plasm PC2', { ns: 'apps-config' }), providers: { - PlasmNetwork: 'wss://rpc.rococo.plasmnet.io' + PlasmNetwork: { type: EndpointType.jrpc, url: 'wss://rpc.rococo.plasmnet.io' } } }, { @@ -328,7 +329,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 21, text: t('rpc.rococo.polkabtc', 'PolkaBTC PC1', { ns: 'apps-config' }), providers: { - Interlay: 'wss://rococo.polkabtc.io/api/parachain' + Interlay: { type: EndpointType.jrpc, url: 'wss://rococo.polkabtc.io/api/parachain' } } }, { @@ -336,7 +337,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1111, text: t('rpc.rococo.polkafoundry', 'PolkaFoundry PC1', { ns: 'apps-config' }), providers: { - PolkaFoundry: 'wss://rococo.polkafoundry.com' + PolkaFoundry: { type: EndpointType.jrpc, url: 'wss://rococo.polkafoundry.com' } } }, { @@ -344,7 +345,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2002, text: t('rpc.rococo.prism', 'Prism PC1', { ns: 'apps-config' }), providers: { - Prism: 'wss://rococo.psm.link' + Prism: { type: EndpointType.jrpc, url: 'wss://rococo.psm.link' } } }, { @@ -352,7 +353,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 3000, text: t('rpc.rococo.robonomics', 'Robonomics PC2', { ns: 'apps-config' }), providers: { - Airalab: 'wss://rococo.parachain.robonomics.network' + Airalab: { type: EndpointType.jrpc, url: 'wss://rococo.parachain.robonomics.network' } } }, { @@ -363,7 +364,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 888, text: t('rpc.rococo.subdao', 'SubDAO PC1', { ns: 'apps-config' }), providers: { - SubDAONetwork: 'wss://parachain.subdao.network' + SubDAONetwork: { type: EndpointType.jrpc, url: 'wss://parachain.subdao.network' } } }, { @@ -374,7 +375,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 28, text: t('rpc.rococo.subsocial', 'Subsocial PC1', { ns: 'apps-config' }), providers: { - DappForce: 'wss://roc.subsocial.network' + DappForce: { type: EndpointType.jrpc, url: 'wss://roc.subsocial.network' } } }, { @@ -382,7 +383,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 6633, text: t('rpc.rococo.trustbase', 'TrustBase PC1', { ns: 'apps-config' }), providers: { - TrustBase: 'wss://rococo.trustednodes.net' + TrustBase: { type: EndpointType.jrpc, url: 'wss://rococo.trustednodes.net' } } }, { @@ -393,7 +394,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 3, text: t('rpc.rococo.unitv', 'Unit Network', { ns: 'apps-config' }), providers: { - 'Unit Network': 'wss://unitp.io' + 'Unit Network': { type: EndpointType.jrpc, url: 'wss://unitp.io' } } }, { @@ -401,7 +402,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 3586, text: t('rpc.rococo.vln', 'Valiu Liquidity Network PC', { ns: 'apps-config' }), providers: { - Valiu: 'wss://vln.valiu.dev' + Valiu: { type: EndpointType.jrpc, url: 'wss://vln.valiu.dev' } } }, { @@ -409,7 +410,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 9123, text: t('rpc.rococo.zeitgeist', 'Zeitgeist PC', { ns: 'apps-config' }), providers: { - Zeitgeist: 'wss://roc.zeitgeist.pm' + Zeitgeist: { type: EndpointType.jrpc, url: 'wss://roc.zeitgeist.pm' } } }, { @@ -417,7 +418,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1188, text: t('rpc.rococo.zenlink', 'Zenlink PC1', { ns: 'apps-config' }), providers: { - Zenlink: 'wss://rococo-parachain.zenlink.pro' + Zenlink: { type: EndpointType.jrpc, url: 'wss://rococo-parachain.zenlink.pro' } } } ] diff --git a/packages/apps-config/src/endpoints/testingRelayWestend.ts b/packages/apps-config/src/endpoints/testingRelayWestend.ts index 676693140624..ff9ed55f5992 100644 --- a/packages/apps-config/src/endpoints/testingRelayWestend.ts +++ b/packages/apps-config/src/endpoints/testingRelayWestend.ts @@ -5,6 +5,7 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; import { WESTEND_GENESIS } from '../api/constants'; +import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -22,10 +23,11 @@ export function createWestend (t: TFunction): EndpointOption { info: 'westend', text: t('rpc.westend', 'Westend', { ns: 'apps-config' }), providers: { - Parity: 'wss://westend-rpc.polkadot.io', - 'NodeFactory(Vedran)': 'wss://westend.vedran.nodefactory.io/ws', - 'Patract Elara': 'wss://westend.elara.patract.io', - OnFinality: 'wss://westend.api.onfinality.io/public-ws' + Parity: { type: EndpointType.jrpc, url: 'wss://westend-rpc.polkadot.io' }, + 'NodeFactory(Vedran)': { type: EndpointType.jrpc, url: 'wss://westend.vedran.nodefactory.io/ws' }, + 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://westend.elara.patract.io' }, + OnFinality: { type: EndpointType.jrpc, url: 'wss://westend.api.onfinality.io/public-ws' }, + 'light client': { type: EndpointType.substrateconnect, chain: 'westend-substrate-connect' } }, linked: [ // (1) system parachains (none available yet) @@ -36,7 +38,7 @@ export function createWestend (t: TFunction): EndpointOption { paraId: 1070, text: t('rpc.westend.shell', 'Shell', { ns: 'apps-config' }), providers: { - Parity: 'wss://westend-shell-rpc.parity.io' + Parity: { type: EndpointType.jrpc, url: 'wss://westend-shell-rpc.parity.io' } } } // (3) parachains with id, see Rococo (info here maps to the actual "named icon") diff --git a/packages/apps-config/src/endpoints/types.ts b/packages/apps-config/src/endpoints/types.ts index 412a5b6a1885..44509c76ddaa 100644 --- a/packages/apps-config/src/endpoints/types.ts +++ b/packages/apps-config/src/endpoints/types.ts @@ -10,6 +10,23 @@ export interface EndpointOption { linked?: EndpointOption[]; info?: string; paraId?: number; - providers: Record; + providers: Record; text: React.ReactNode; } + +type Endpoint = JsonRpcEndpoint | SubstrateConnectEndpoint; + +interface JsonRpcEndpoint { + type: EndpointType.jrpc; + url: string; +} + +interface SubstrateConnectEndpoint { + type: EndpointType.substrateconnect; + chain: string; +} + +export enum EndpointType { + jrpc = 'json-rpc', + substrateconnect = 'substrate-connect' +} diff --git a/packages/apps-config/src/endpoints/util.ts b/packages/apps-config/src/endpoints/util.ts index 3aafd0e8049c..4264e0bd93f9 100644 --- a/packages/apps-config/src/endpoints/util.ts +++ b/packages/apps-config/src/endpoints/util.ts @@ -5,6 +5,8 @@ import type { TFunction } from 'i18next'; import type { LinkOption } from '../settings/types'; import type { EndpointOption } from './types'; +import { EndpointType } from './types'; + export function expandLinked (input: LinkOption[]): LinkOption[] { return input.reduce((result: LinkOption[], entry): LinkOption[] => { result.push(entry); @@ -36,8 +38,11 @@ export function expandEndpoint (t: TFunction, input: EndpointOption): LinkOption const result = Object.entries(providers).map(([host, value], index): LinkOption => ({ ...base, dnslink: index === 0 ? dnslink : undefined, - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host } }), - value + isLightClient: value.type === EndpointType.substrateconnect, + textBy: (value.type === EndpointType.jrpc) + ? t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host } }) + : t('lightclient.experimental', 'light client (experimental)', { ns: 'apps-config' }), + value: (value.type === EndpointType.jrpc) ? value.url : value.chain })); if (linked) { diff --git a/packages/apps-config/src/settings/types.ts b/packages/apps-config/src/settings/types.ts index 349fbefc8f58..e9291e4fc77a 100644 --- a/packages/apps-config/src/settings/types.ts +++ b/packages/apps-config/src/settings/types.ts @@ -16,6 +16,7 @@ export interface LinkOption extends Option { isChild?: boolean; isDevelopment?: boolean; isSpaced?: boolean; + isLightClient?: boolean; linked?: LinkOption[]; paraId?: number; textBy: string; diff --git a/packages/apps/public/locales/en/apps-config.json b/packages/apps/public/locales/en/apps-config.json index 6a6c888e7832..ac7098ac471c 100644 --- a/packages/apps/public/locales/en/apps-config.json +++ b/packages/apps/public/locales/en/apps-config.json @@ -1,4 +1,5 @@ { + "lightclient.experimental": "light client (experimental)", "lng.detect": "Default browser language (auto-detect)", "rpc.dev.custom": "Custom environment", "rpc.dev.custom.entry": "Custom {{WS_URL}}", @@ -135,4 +136,4 @@ "rpc.westend": "Westend", "rpc.westend.shell": "Shell", "ss58.default": "Default for the connected node" -} +} \ No newline at end of file diff --git a/packages/apps/src/Endpoints/types.ts b/packages/apps/src/Endpoints/types.ts index f80aaa8ddaa1..16bd42fcba69 100644 --- a/packages/apps/src/Endpoints/types.ts +++ b/packages/apps/src/Endpoints/types.ts @@ -6,6 +6,7 @@ import React from 'react'; export interface Network { icon?: string; isChild?: boolean; + isLightClient?: boolean; name: string; providers: { name: string; From 322003bd713d290d634e42b26fbce85ac8adae6f Mon Sep 17 00:00:00 2001 From: wirednkod Date: Thu, 10 Jun 2021 18:16:51 +0300 Subject: [PATCH 06/45] upgrade substrate connect to 0.3.7 --- package.json | 2 +- packages/react-api/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6934e30f0ab2..4aa169f3f92c 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "@pinata/sdk": "^1.1.20", "@polkadot/dev": "^0.62.14", "@polkadot/ts": "^0.3.66", - "@substrate/connect": "0.3.1-test2", + "@substrate/connect": "0.3.7", "@types/bn.js": "^4.11.6", "@types/chart.js": "^2.9.32", "@types/file-saver": "^2.0.2", diff --git a/packages/react-api/package.json b/packages/react-api/package.json index 2e01c77f1720..9c086cdedab9 100644 --- a/packages/react-api/package.json +++ b/packages/react-api/package.json @@ -11,6 +11,6 @@ "fflate": "^0.6.10" }, "devDependencies": { - "@substrate/connect": "0.3.1-test2" + "@substrate/connect": "0.3.7" } } From 92c5cbc720a312f31cdcdaa477e432ea0559c759 Mon Sep 17 00:00:00 2001 From: wirednkod Date: Sat, 19 Jun 2021 15:42:19 +0300 Subject: [PATCH 07/45] implementation for integrating substrate-connect --- .../apps-config/src/endpoints/production.ts | 64 +++++----- .../src/endpoints/productionRelayKusama.ts | 24 ++-- .../src/endpoints/productionRelayPolkadot.ts | 10 +- packages/apps-config/src/endpoints/testing.ts | 116 +++++++++--------- .../src/endpoints/testingRelayRococo.ts | 100 +++++++-------- .../src/endpoints/testingRelayWestend.ts | 14 +-- packages/apps-config/src/endpoints/types.ts | 19 +-- packages/apps-config/src/endpoints/util.ts | 8 +- packages/apps/src/Endpoints/index.tsx | 31 +++-- packages/apps/src/Root.tsx | 2 +- packages/apps/src/initSettings.ts | 38 ++++-- packages/apps/src/overlays/Connecting.tsx | 17 ++- .../src/CreateAccount.slow.spec.tsx | 7 +- .../page-bounties/src/Bounties.slow.spec.tsx | 8 +- packages/react-api/src/Api.tsx | 24 ++-- yarn.lock | 22 ++-- 16 files changed, 270 insertions(+), 234 deletions(-) diff --git a/packages/apps-config/src/endpoints/production.ts b/packages/apps-config/src/endpoints/production.ts index e2b064a579f2..b9093874bfa9 100644 --- a/packages/apps-config/src/endpoints/production.ts +++ b/packages/apps-config/src/endpoints/production.ts @@ -4,7 +4,7 @@ import type { TFunction } from 'i18next'; import type { LinkOption } from '../settings/types'; -import { EndpointType } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; import { expandEndpoints } from './util'; /* eslint-disable sort-keys */ @@ -23,38 +23,38 @@ export function createProduction (t: TFunction): LinkOption[] { info: 'centrifuge', text: t('rpc.prod.centrifuge', 'Centrifuge', { ns: 'apps-config' }), providers: { - Centrifuge: { type: EndpointType.jrpc, url: 'wss://fullnode.centrifuge.io' } + Centrifuge: { type: 'json-rpc' as EndpointType, param: 'wss://fullnode.centrifuge.io' } } }, { info: 'crab', text: t('rpc.prod.crab', 'Darwinia Crab', { ns: 'apps-config' }), providers: { - 'Darwinia Network': { type: EndpointType.jrpc, url: 'wss://crab-rpc.darwinia.network' } + 'Darwinia Network': { type: 'json-rpc' as EndpointType, param: 'wss://crab-rpc.darwinia.network' } } }, { info: 'chainx', text: t('rpc.prod.chainx', 'ChainX', { ns: 'apps-config' }), providers: { - ChainX: { type: EndpointType.jrpc, url: 'wss://mainnet.chainx.org/ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://chainx.elara.patract.io' } + ChainX: { type: 'json-rpc' as EndpointType, param: 'wss://mainnet.chainx.org/ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://chainx.elara.patract.io' } } }, { info: 'darwinia', text: t('rpc.prod.darwinia', 'Darwinia', { ns: 'apps-config' }), providers: { - 'Darwinia Network': { type: EndpointType.jrpc, url: 'wss://rpc.darwinia.network' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://darwinia.elara.patract.io' } + 'Darwinia Network': { type: 'json-rpc' as EndpointType, param: 'wss://rpc.darwinia.network' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://darwinia.elara.patract.io' } } }, { info: 'dock-mainnet', text: t('rpc.prod.dock-mainnet', 'Dock', { ns: 'apps-config' }), providers: { - 'Dock Association': { type: EndpointType.jrpc, url: 'wss://mainnet-node.dock.io' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://dock.elara.patract.io' } + 'Dock Association': { type: 'json-rpc' as EndpointType, param: 'wss://mainnet-node.dock.io' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://dock.elara.patract.io' } } }, { @@ -62,32 +62,32 @@ export function createProduction (t: TFunction): LinkOption[] { info: 'edgeware', text: t('rpc.prod.edgeware', 'Edgeware', { ns: 'apps-config' }), providers: { - 'Commonwealth Labs': { type: EndpointType.jrpc, url: 'wss://mainnet1.edgewa.re' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://edgeware.elara.patract.io' }, - OnFinality: { type: EndpointType.jrpc, url: 'wss://edgeware.api.onfinality.io/public-ws' } + 'Commonwealth Labs': { type: 'json-rpc' as EndpointType, param: 'wss://mainnet1.edgewa.re' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://edgeware.elara.patract.io' }, + OnFinality: { type: 'json-rpc' as EndpointType, param: 'wss://edgeware.api.onfinality.io/public-ws' } } }, { info: 'equilibrium', text: t('rpc.prod.equilibrium', 'Equilibrium', { ns: 'apps-config' }), providers: { - Equilibrium: { type: EndpointType.jrpc, url: 'wss://node.equilibrium.io' } + Equilibrium: { type: 'json-rpc' as EndpointType, param: 'wss://node.equilibrium.io' } } }, { info: 'hanonycash', text: t('rpc.prod.hanonycash', 'Hanonycash', { ns: 'apps-config' }), providers: { - Hanonycash: { type: EndpointType.jrpc, url: 'wss://rpc.hanonycash.com' } + Hanonycash: { type: 'json-rpc' as EndpointType, param: 'wss://rpc.hanonycash.com' } } }, { info: 'snakenet', text: t('rpc.prod.hydra', 'HydraDX', { ns: 'apps-config' }), providers: { - HydraDX: { type: EndpointType.jrpc, url: 'wss://rpc-01.snakenet.hydradx.io' }, - 'Galactic Council': { type: EndpointType.jrpc, url: 'wss://rpc-02.snakenet.hydradx.io' }, - Archives: { type: EndpointType.jrpc, url: 'wss://archive.snakenet.hydradx.io' } + HydraDX: { type: 'json-rpc' as EndpointType, param: 'wss://rpc-01.snakenet.hydradx.io' }, + 'Galactic Council': { type: 'json-rpc' as EndpointType, param: 'wss://rpc-02.snakenet.hydradx.io' }, + Archives: { type: 'json-rpc' as EndpointType, param: 'wss://archive.snakenet.hydradx.io' } } }, { @@ -95,45 +95,45 @@ export function createProduction (t: TFunction): LinkOption[] { info: 'kulupu', text: t('rpc.prod.kulupu', 'Kulupu', { ns: 'apps-config' }), providers: { - Kulupu: { type: EndpointType.jrpc, url: 'wss://rpc.kulupu.corepaper.org/ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://kulupu.elara.patract.io' } + Kulupu: { type: 'json-rpc' as EndpointType, param: 'wss://rpc.kulupu.corepaper.org/ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://kulupu.elara.patract.io' } } }, { info: 'neatcoin', text: t('rpc.prod.neatcoin', 'Neatcoin', { ns: 'apps-config' }), providers: { - Neatcoin: { type: EndpointType.jrpc, url: 'wss://rpc.neatcoin.org/ws' } + Neatcoin: { type: 'json-rpc' as EndpointType, param: 'wss://rpc.neatcoin.org/ws' } } }, { info: 'nodle', text: t('rpc.prod.nodle-main', 'Nodle', { ns: 'apps-config' }), providers: { - Nodle: { type: EndpointType.jrpc, url: 'wss://main3.nodleprotocol.io' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://nodle.elara.patract.io' } + Nodle: { type: 'json-rpc' as EndpointType, param: 'wss://main3.nodleprotocol.io' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://nodle.elara.patract.io' } } }, { info: 'plasm', text: t('rpc.prod.plasm', 'Plasm', { ns: 'apps-config' }), providers: { - 'Stake Technologies': { type: EndpointType.jrpc, url: 'wss://rpc.plasmnet.io/' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://plasm.elara.patract.io' } + 'Stake Technologies': { type: 'json-rpc' as EndpointType, param: 'wss://rpc.plasmnet.io/' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://plasm.elara.patract.io' } } }, { info: 'riochain', text: t('rpc.prod.riochain', 'RioChain', { ns: 'apps-config' }), providers: { - RioChain: { type: EndpointType.jrpc, url: 'wss://node.v1.riochain.io' } + RioChain: { type: 'json-rpc' as EndpointType, param: 'wss://node.v1.riochain.io' } } }, { info: 'sora-substrate', text: t('rpc.prod.sora-substrate', 'SORA', { ns: 'apps-config' }), providers: { - Soramitsu: { type: EndpointType.jrpc, url: 'wss://ws.sora2.soramitsu.co.jp' } + Soramitsu: { type: 'json-rpc' as EndpointType, param: 'wss://ws.sora2.soramitsu.co.jp' } } }, { @@ -141,30 +141,30 @@ export function createProduction (t: TFunction): LinkOption[] { isDisabled: true, // Cannot find type ChainId text: t('rpc.prod.stafi', 'Stafi', { ns: 'apps-config' }), providers: { - 'Stafi Foundation': { type: EndpointType.jrpc, url: 'wss://mainnet-rpc.stafi.io' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://stafi.elara.patract.io' } + 'Stafi Foundation': { type: 'json-rpc' as EndpointType, param: 'wss://mainnet-rpc.stafi.io' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://stafi.elara.patract.io' } } }, { info: 'subsocial', text: t('rpc.prod.subsocial', 'Subsocial', { ns: 'apps-config' }), providers: { - DappForce: { type: EndpointType.jrpc, url: 'wss://rpc.subsocial.network' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://subsocial.elara.patract.io' } + DappForce: { type: 'json-rpc' as EndpointType, param: 'wss://rpc.subsocial.network' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://subsocial.elara.patract.io' } } }, { info: 'uniarts', text: t('rpc.prod.uniarts', 'UniArts', { ns: 'apps-config' }), providers: { - UniArts: { type: EndpointType.jrpc, url: 'wss://mainnet.uniarts.vip:9443' } + UniArts: { type: 'json-rpc' as EndpointType, param: 'wss://mainnet.uniarts.vip:9443' } } }, { info: 'westlake', text: t('rpc.prod.westlake', 'Westlake', { ns: 'apps-config' }), providers: { - DataHighway: { type: EndpointType.jrpc, url: 'wss://westlake.datahighway.com' } + DataHighway: { type: 'json-rpc' as EndpointType, param: 'wss://westlake.datahighway.com' } } } ]); diff --git a/packages/apps-config/src/endpoints/productionRelayKusama.ts b/packages/apps-config/src/endpoints/productionRelayKusama.ts index 83bb4686da2d..7ad409619033 100644 --- a/packages/apps-config/src/endpoints/productionRelayKusama.ts +++ b/packages/apps-config/src/endpoints/productionRelayKusama.ts @@ -4,8 +4,8 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; import { KUSAMA_GENESIS } from '../api/constants'; -import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -21,10 +21,10 @@ export function createKusama (t: TFunction): EndpointOption { info: 'kusama', text: t('rpc.kusama.parity', 'Kusama', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://kusama-rpc.polkadot.io' }, - OnFinality: { type: EndpointType.jrpc, url: 'wss://kusama.api.onfinality.io/public-ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://kusama.elara.patract.io' }, - 'light client': { type: EndpointType.substrateconnect, chain: 'kusama-substrate-connect' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://kusama-rpc.polkadot.io' }, + OnFinality: { type: 'json-rpc' as EndpointType, param: 'wss://kusama.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://kusama.elara.patract.io' }, + 'light client': { type: 'substrate-connect' as EndpointType, param: 'kusama-substrate-connect' } }, linked: [ // (1) all system parachains (none available yet) @@ -35,7 +35,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 1000, text: t('rpc.kusama.shell', 'Shell', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://kusama-shell-rpc.parity.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://kusama-shell-rpc.parity.io' } } }, /// (3) parachains with id, see Rococo (info here maps to the actual "named icon") @@ -46,7 +46,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2001, text: t('rpc.kusama.bifrost', 'Bifrost', { ns: 'apps-config' }), providers: { - Bifrost: { type: EndpointType.jrpc, url: 'wss://bifrost-rpc.liebi.com/ws' } + Bifrost: { type: 'json-rpc' as EndpointType, param: 'wss://bifrost-rpc.liebi.com/ws' } } }, { @@ -54,7 +54,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2006, text: t('rpc.kusama.crab', 'Darwinia Crab', { ns: 'apps-config' }), providers: { - Crab: { type: EndpointType.jrpc, url: 'wss://crab-rpc.darwinia.network/' } + Crab: { type: 'json-rpc' as EndpointType, param: 'wss://crab-rpc.darwinia.network/' } } }, { @@ -62,7 +62,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2012, text: t('rpc.kusama.shadow', 'Crust Shadow', { ns: 'apps-config' }), providers: { - Crust: { type: EndpointType.jrpc, url: 'wss://shadow.crust.network/' } + Crust: { type: 'json-rpc' as EndpointType, param: 'wss://shadow.crust.network/' } } }, { @@ -70,7 +70,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2004, text: t('rpc.kusama.khala', 'Khala Network', { ns: 'apps-config' }), providers: { - Phala: { type: EndpointType.jrpc, url: 'wss://khala.phala.network/ws' } + Phala: { type: 'json-rpc' as EndpointType, param: 'wss://khala.phala.network/ws' } } }, { @@ -78,7 +78,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2005, text: t('rpc.kusama.kilt', 'KILT Mainnet', { ns: 'apps-config' }), providers: { - 'KILT Protocol': { type: EndpointType.jrpc, url: 'wss://mainnet.kilt.io/' } + 'KILT Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://mainnet.kilt.io/' } } }, { @@ -86,7 +86,7 @@ export function createKusama (t: TFunction): EndpointOption { paraId: 2013, text: t('rpc.kusama.sherpax', 'SherpaX', { ns: 'apps-config' }), providers: { - ChainX: { type: EndpointType.jrpc, url: 'wss://sherpax.chainx.org' } + ChainX: { type: 'json-rpc' as EndpointType, param: 'wss://sherpax.chainx.org' } } } ] diff --git a/packages/apps-config/src/endpoints/productionRelayPolkadot.ts b/packages/apps-config/src/endpoints/productionRelayPolkadot.ts index ae24ef7fdfb9..58a7d088861b 100644 --- a/packages/apps-config/src/endpoints/productionRelayPolkadot.ts +++ b/packages/apps-config/src/endpoints/productionRelayPolkadot.ts @@ -4,8 +4,8 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; import { POLKADOT_GENESIS } from '../api/constants'; -import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -21,10 +21,10 @@ export function createPolkadot (t: TFunction): EndpointOption { info: 'polkadot', text: t('rpc.polkadot.parity', 'Polkadot', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://rpc.polkadot.io' }, - OnFinality: { type: EndpointType.jrpc, url: 'wss://polkadot.api.onfinality.io/public-ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://polkadot.elara.patract.io' }, - 'light client': { type: EndpointType.substrateconnect, chain: 'polkadot-substrate-connect' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://rpc.polkadot.io' }, + OnFinality: { type: 'json-rpc' as EndpointType, param: 'wss://polkadot.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://polkadot.elara.patract.io' }, + 'light client': { type: 'substrate-connect' as EndpointType, param: 'polkadot-substrate-connect' } }, linked: [ // (1) system parachains (none available yet) diff --git a/packages/apps-config/src/endpoints/testing.ts b/packages/apps-config/src/endpoints/testing.ts index a66b77a18551..2e06aefcf034 100644 --- a/packages/apps-config/src/endpoints/testing.ts +++ b/packages/apps-config/src/endpoints/testing.ts @@ -4,7 +4,7 @@ import type { TFunction } from 'i18next'; import type { LinkOption } from '../settings/types'; -import { EndpointType } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; import { expandEndpoints } from './util'; /* eslint-disable sort-keys */ @@ -22,42 +22,42 @@ export function createTesting (t: TFunction): LinkOption[] { info: 'centrifuge', text: t('rpc.test.amber', 'Amber', { ns: 'apps-config' }), providers: { - Centrifuge: { type: EndpointType.jrpc, url: 'wss://fullnode.amber.centrifuge.io' } + Centrifuge: { type: 'json-rpc' as EndpointType, param: 'wss://fullnode.amber.centrifuge.io' } } }, { info: 'nodle', text: t('rpc.test.nodle-arcadia', 'Arcadia', { ns: 'apps-config' }), providers: { - Nodle: { type: EndpointType.jrpc, url: 'wss://arcadia1.nodleprotocol.io' } + Nodle: { type: 'json-rpc' as EndpointType, param: 'wss://arcadia1.nodleprotocol.io' } } }, { info: 'edgeware', text: t('rpc.test.beresheet', 'Beresheet', { ns: 'apps-config' }), providers: { - 'Commonwealth Labs': { type: EndpointType.jrpc, url: 'wss://beresheet1.edgewa.re' } + 'Commonwealth Labs': { type: 'json-rpc' as EndpointType, param: 'wss://beresheet1.edgewa.re' } } }, { info: 'bitcountry', text: t('rpc.test.bitcountry', 'Bit.Country Tewai', { ns: 'apps-config' }), providers: { - 'Bit.Country': { type: EndpointType.jrpc, url: 'wss://whenua.bit.country' } + 'Bit.Country': { type: 'json-rpc' as EndpointType, param: 'wss://whenua.bit.country' } } }, { info: 'bifrost', text: t('rpc.test.bifrost', 'Bifrost Asgard', { ns: 'apps-config' }), providers: { - Bifrost: { type: EndpointType.jrpc, url: 'wss://testnet.liebi.com' } + Bifrost: { type: 'json-rpc' as EndpointType, param: 'wss://testnet.liebi.com' } } }, { info: 'canvas', text: t('rpc.test.canvas', 'Canvas', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://canvas-rpc.parity.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://canvas-rpc.parity.io' } } }, { @@ -65,15 +65,15 @@ export function createTesting (t: TFunction): LinkOption[] { isDisabled: true, // Cannot construct unknown type BridgeNetworks text: t('rpc.test.clover.finance', 'Clover', { ns: 'apps-config' }), providers: { - Clover: { type: EndpointType.jrpc, url: 'wss://api.clover.finance/' } + Clover: { type: 'json-rpc' as EndpointType, param: 'wss://api.clover.finance/' } } }, { info: 'crust', text: t('rpc.test.crust.network', 'Crust Maxwell', { ns: 'apps-config' }), providers: { - 'Crust Network': { type: EndpointType.jrpc, url: 'wss://api.crust.network/' }, - 'DCloud Foundation': { type: EndpointType.jrpc, url: 'wss://api.decloudf.com/' } + 'Crust Network': { type: 'json-rpc' as EndpointType, param: 'wss://api.crust.network/' }, + 'DCloud Foundation': { type: 'json-rpc' as EndpointType, param: 'wss://api.decloudf.com/' } } }, { @@ -81,288 +81,288 @@ export function createTesting (t: TFunction): LinkOption[] { isDisabled: true, text: t('rpc.test.datahighway.spreehafen', 'Spreehafen', { ns: 'apps-config' }), providers: { - MXC: { type: EndpointType.jrpc, url: 'wss://spreehafen.datahighway.com' } + MXC: { type: 'json-rpc' as EndpointType, param: 'wss://spreehafen.datahighway.com' } } }, { info: 'dock-testnet', text: t('rpc.test.dock-testnet', 'Dock', { ns: 'apps-config' }), providers: { - 'Dock Association': { type: EndpointType.jrpc, url: 'wss://danforth-1.dock.io' } + 'Dock Association': { type: 'json-rpc' as EndpointType, param: 'wss://danforth-1.dock.io' } } }, { info: 'dotmog', text: t('rpc.test.dotmog', 'DOTMog', { ns: 'apps-config' }), providers: { - DOTMog: { type: EndpointType.jrpc, url: 'wss://mogiway-01.dotmog.com' } + DOTMog: { type: 'json-rpc' as EndpointType, param: 'wss://mogiway-01.dotmog.com' } } }, { info: 'dusty', text: t('rpc.test.dusty', 'Dusty', { ns: 'apps-config' }), providers: { - 'Stake Technologies': { type: EndpointType.jrpc, url: 'wss://rpc.dusty.plasmnet.io/' } + 'Stake Technologies': { type: 'json-rpc' as EndpointType, param: 'wss://rpc.dusty.plasmnet.io/' } } }, { info: 'encointer_cantillon', text: t('rpc.test.encointer.cantillon', 'Encointer Cantillon', { ns: 'apps-config' }), providers: { - 'Encointer Association': { type: EndpointType.jrpc, url: 'wss://cantillon.encointer.org' } + 'Encointer Association': { type: 'json-rpc' as EndpointType, param: 'wss://cantillon.encointer.org' } } }, { info: 'encointer_gesell', text: t('rpc.test.encointer.gesell', 'Encointer Gesell', { ns: 'apps-config' }), providers: { - 'Encointer Association': { type: EndpointType.jrpc, url: 'wss://gesell.encointer.org' } + 'Encointer Association': { type: 'json-rpc' as EndpointType, param: 'wss://gesell.encointer.org' } } }, { info: 'equilibrium', text: t('rpc.test.equilibriumtestnet', 'Equilibrium', { ns: 'apps-config' }), providers: { - Equilibrium: { type: EndpointType.jrpc, url: 'wss://testnet.equilibrium.io' } + Equilibrium: { type: 'json-rpc' as EndpointType, param: 'wss://testnet.equilibrium.io' } } }, { info: 'substrate', text: t('rpc.test.flamingfir', 'Flaming Fir', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://substrate-rpc.parity.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://substrate-rpc.parity.io' } } }, { info: 'Galital', text: t('rpc.test.galital', 'Galital PC2', { ns: 'apps-config' }), providers: { - StarkleyTech: { type: EndpointType.jrpc, url: 'wss://galital-rpc-testnet.starkleytech.com' } + StarkleyTech: { type: 'json-rpc' as EndpointType, param: 'wss://galital-rpc-testnet.starkleytech.com' } } }, { info: 'galois', text: t('rpc.test.galois', 'Galois', { ns: 'apps-config' }), providers: { - MathWallet: { type: EndpointType.jrpc, url: 'wss://galois-hk.maiziqianbao.net/ws' }, - 'MathWallet Backup': { type: EndpointType.jrpc, url: 'wss://galois.maiziqianbao.net/ws' } + MathWallet: { type: 'json-rpc' as EndpointType, param: 'wss://galois-hk.maiziqianbao.net/ws' }, + 'MathWallet Backup': { type: 'json-rpc' as EndpointType, param: 'wss://galois.maiziqianbao.net/ws' } } }, { info: 'gamepower', text: t('rpc.test.gamepower', 'GamePower', { ns: 'apps-config' }), providers: { - GamePower: { type: EndpointType.jrpc, url: 'wss://gamepower.io' } + GamePower: { type: 'json-rpc' as EndpointType, param: 'wss://gamepower.io' } } }, { info: 'geek', text: t('rpc.test.geek', 'GeekCash', { ns: 'apps-config' }), providers: { - 'Geek Team': { type: EndpointType.jrpc, url: 'wss://testnet.geekcash.org' } + 'Geek Team': { type: 'json-rpc' as EndpointType, param: 'wss://testnet.geekcash.org' } } }, { info: 'halongbay', text: t('rpc.test.halongbay', 'Halongbay Testnet', { ns: 'apps-config' }), providers: { - Halongbay: { type: EndpointType.jrpc, url: 'wss://halongbay.polkafoundry.com' } + Halongbay: { type: 'json-rpc' as EndpointType, param: 'wss://halongbay.polkafoundry.com' } } }, { info: 'ipse', text: t('rpc.test.ipse', 'IPSE', { ns: 'apps-config' }), providers: { - 'IPSE China': { type: EndpointType.jrpc, url: 'wss://testnet-china.ipse.io' }, - 'IPSE USA': { type: EndpointType.jrpc, url: 'wss://testnet-usa.ipse.io' }, - 'IPSE Europe': { type: EndpointType.jrpc, url: 'wss://testnet-europe.ipse.io' } + 'IPSE China': { type: 'json-rpc' as EndpointType, param: 'wss://testnet-china.ipse.io' }, + 'IPSE USA': { type: 'json-rpc' as EndpointType, param: 'wss://testnet-usa.ipse.io' }, + 'IPSE Europe': { type: 'json-rpc' as EndpointType, param: 'wss://testnet-europe.ipse.io' } } }, { info: 'jupiter', text: t('rpc.test.jupiter', 'Jupiter', { ns: 'apps-config' }), providers: { - Elara: { type: EndpointType.jrpc, url: 'wss://jupiter-poa.elara.patract.io' }, - Patract: { type: EndpointType.jrpc, url: 'wss://ws.jupiter-poa.patract.cn' } + Elara: { type: 'json-rpc' as EndpointType, param: 'wss://jupiter-poa.elara.patract.io' }, + Patract: { type: 'json-rpc' as EndpointType, param: 'wss://ws.jupiter-poa.patract.cn' } } }, { info: 'kilt', text: t('rpc.test.kilt', 'KILT Mashnet', { ns: 'apps-config' }), providers: { - 'KILT Protocol': { type: EndpointType.jrpc, url: 'wss://full-nodes.kilt.io:9944/' } + 'KILT Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://full-nodes.kilt.io:9944/' } } }, { info: 'litentry', text: t('rpc.test.litentry', 'Litentry Testnet', { ns: 'apps-config' }), providers: { - Litentry: { type: EndpointType.jrpc, url: 'wss://testnet.litentry.io' } + Litentry: { type: 'json-rpc' as EndpointType, param: 'wss://testnet.litentry.io' } } }, { info: 'acala', text: t('rpc.test.mandala', 'Mandala', { ns: 'apps-config' }), providers: { - Acala: { type: EndpointType.jrpc, url: 'wss://acala-mandala.api.onfinality.io/public-ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://mandala.elara.patract.io' } + Acala: { type: 'json-rpc' as EndpointType, param: 'wss://acala-mandala.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://mandala.elara.patract.io' } } }, { info: 'moonbaseAlpha', text: t('rpc.test.moonbeam', 'Moonbase Alpha', { ns: 'apps-config' }), providers: { - 'Moonbeam Network': { type: EndpointType.jrpc, url: 'wss://wss.testnet.moonbeam.network' }, - OnFinality: { type: EndpointType.jrpc, url: 'wss://moonbeam-alpha.api.onfinality.io/public-ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://moonbase.moonbeam.elara.patract.io' } + 'Moonbeam Network': { type: 'json-rpc' as EndpointType, param: 'wss://wss.testnet.moonbeam.network' }, + OnFinality: { type: 'json-rpc' as EndpointType, param: 'wss://moonbeam-alpha.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://moonbase.moonbeam.elara.patract.io' } } }, { info: 'mybank', text: t('rpc.test.mybank', 'mybank.network', { ns: 'apps-config' }), providers: { - MYBANK: { type: EndpointType.jrpc, url: 'wss://mybank.network/substrate' } + MYBANK: { type: 'json-rpc' as EndpointType, param: 'wss://mybank.network/substrate' } } }, { info: 'nftmart', text: t('rpc.test.nftmart', 'NFTMart', { ns: 'apps-config' }), providers: { - NFTMartDev: { type: EndpointType.jrpc, url: 'wss://dev-ws.nftmart.io' }, - NFTMartStaging: { type: EndpointType.jrpc, url: 'wss://staging-ws.nftmart.io' } + NFTMartDev: { type: 'json-rpc' as EndpointType, param: 'wss://dev-ws.nftmart.io' }, + NFTMartStaging: { type: 'json-rpc' as EndpointType, param: 'wss://staging-ws.nftmart.io' } } }, { info: 'pangolin', text: t('rpc.test.pangolin', 'Pangolin', { ns: 'apps-config' }), providers: { - 'Darwinia Network': { type: EndpointType.jrpc, url: 'wss://pangolin-rpc.darwinia.network' } + 'Darwinia Network': { type: 'json-rpc' as EndpointType, param: 'wss://pangolin-rpc.darwinia.network' } } }, { info: 'phala', text: t('rpc.test.phala', 'Phala PoC-4', { ns: 'apps-config' }), providers: { - 'Phala Network': { type: EndpointType.jrpc, url: 'wss://poc4.phala.network/ws' } + 'Phala Network': { type: 'json-rpc' as EndpointType, param: 'wss://poc4.phala.network/ws' } } }, { info: 'phoenix', text: t('rpc.test.phoenix', 'Phoenix Mashnet', { ns: 'apps-config' }), providers: { - 'phoenix Protocol': { type: EndpointType.jrpc, url: 'wss://phoenix-ws.coinid.pro/' } + 'phoenix Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://phoenix-ws.coinid.pro/' } } }, { info: 'polkadex', text: t('rpc.test.polkadex', 'Polkadex', { ns: 'apps-config' }), providers: { - 'Polkadex Team': { type: EndpointType.jrpc, url: 'wss://blockchain.polkadex.trade' } + 'Polkadex Team': { type: 'json-rpc' as EndpointType, param: 'wss://blockchain.polkadex.trade' } } }, { info: 'polkabtc', text: t('rpc.test.polkabtc', 'PolkaBTC', { ns: 'apps-config' }), providers: { - Interlay: { type: EndpointType.jrpc, url: 'wss://beta.polkabtc.io/api/parachain' } + Interlay: { type: 'json-rpc' as EndpointType, param: 'wss://beta.polkabtc.io/api/parachain' } } }, { info: 'polymesh', text: t('rpc.test.polymesh', 'Polymesh ITN', { ns: 'apps-config' }), providers: { - Polymath: { type: EndpointType.jrpc, url: 'wss://itn-rpc.polymesh.live' } + Polymath: { type: 'json-rpc' as EndpointType, param: 'wss://itn-rpc.polymesh.live' } } }, { info: 'prism', text: t('rpc.test.prism', 'Prism', { ns: 'apps-config' }), providers: { - Prism: { type: EndpointType.jrpc, url: 'wss://testnet.psm.link' } + Prism: { type: 'json-rpc' as EndpointType, param: 'wss://testnet.psm.link' } } }, { info: 'realis', text: t('rpc.test.realis', 'Realis.Network', { ns: 'apps-config' }), providers: { - 'Realis.Network': { type: EndpointType.jrpc, url: 'wss://rpc.realis.network/' } + 'Realis.Network': { type: 'json-rpc' as EndpointType, param: 'wss://rpc.realis.network/' } } }, { info: 'riochain', text: t('rpc.test.riochain', 'RioChain', { ns: 'apps-config' }), providers: { - 'RioChain Staging': { type: EndpointType.jrpc, url: 'wss://node.v1.staging.riochain.io' } + 'RioChain Staging': { type: 'json-rpc' as EndpointType, param: 'wss://node.v1.staging.riochain.io' } } }, { info: 'sora-substrate', text: t('rpc.test.sora-substrate-staging', 'SORA-staging', { ns: 'apps-config' }), providers: { - Soramitsu: { type: EndpointType.jrpc, url: 'wss://ws.stage.sora2.soramitsu.co.jp' } + Soramitsu: { type: 'json-rpc' as EndpointType, param: 'wss://ws.stage.sora2.soramitsu.co.jp' } } }, { info: 'ternoa-chaos', text: t('rpc.test.ternoa-chaos', 'Ternoa Chaos', { ns: 'apps-config' }), providers: { - CapsuleCorp: { type: EndpointType.jrpc, url: 'wss://chaos.ternoa.com' } + CapsuleCorp: { type: 'json-rpc' as EndpointType, param: 'wss://chaos.ternoa.com' } } }, { info: 'laminar', text: t('rpc.test.turbulence', 'Turbulence', { ns: 'apps-config' }), providers: { - Laminar: { type: EndpointType.jrpc, url: 'wss://testnet-node-1.laminar-chain.laminar.one/ws' } + Laminar: { type: 'json-rpc' as EndpointType, param: 'wss://testnet-node-1.laminar-chain.laminar.one/ws' } } }, { info: 'uniarts', text: t('rpc.test.uniarts', 'UniArts', { ns: 'apps-config' }), providers: { - UniArts: { type: EndpointType.jrpc, url: 'wss://testnet.uniarts.me' } + UniArts: { type: 'json-rpc' as EndpointType, param: 'wss://testnet.uniarts.me' } } }, { info: 'unique', text: t('rpc.test.unique', 'Unique', { ns: 'apps-config' }), providers: { - Unique: { type: EndpointType.jrpc, url: 'wss://testnet2.uniquenetwork.io' } + Unique: { type: 'json-rpc' as EndpointType, param: 'wss://testnet2.uniquenetwork.io' } } }, { info: 'unitv', text: t('rpc.test.unitv', 'Unit Network', { ns: 'apps-config' }), providers: { - 'Unit Network': { type: EndpointType.jrpc, url: 'wss://unitventures.io/' } + 'Unit Network': { type: 'json-rpc' as EndpointType, param: 'wss://unitventures.io/' } } }, { info: 'vodka', text: t('rpc.test.vodka', 'Vodka', { ns: 'apps-config' }), providers: { - Vodka: { type: EndpointType.jrpc, url: 'wss://vodka.rpc.neatcoin.org/ws' } + Vodka: { type: 'json-rpc' as EndpointType, param: 'wss://vodka.rpc.neatcoin.org/ws' } } }, { info: 'web3games', text: t('rpc.test.web3games', 'Web3Games', { ns: 'apps-config' }), providers: { - Web3Games: { type: EndpointType.jrpc, url: 'wss://substrate.org.cn:4443' } + Web3Games: { type: 'json-rpc' as EndpointType, param: 'wss://substrate.org.cn:4443' } } }, { info: 'zeitgeist', text: t('rpc.test.zeitgeist', 'Zeitgeist Battery Park', { ns: 'apps-config' }), providers: { - Zeitgeist: { type: EndpointType.jrpc, url: 'wss://bp-rpc.zeitgeist.pm' } + Zeitgeist: { type: 'json-rpc' as EndpointType, param: 'wss://bp-rpc.zeitgeist.pm' } } }, { info: 'zero', text: t('rpc.test.zero', 'Zero', { ns: 'apps-config' }), providers: { - ZERO: { type: EndpointType.jrpc, url: 'wss://alphaville.zero.io' } + ZERO: { type: 'json-rpc' as EndpointType, param: 'wss://alphaville.zero.io' } } } ]); diff --git a/packages/apps-config/src/endpoints/testingRelayRococo.ts b/packages/apps-config/src/endpoints/testingRelayRococo.ts index 2b384c29868b..cd21973659cb 100644 --- a/packages/apps-config/src/endpoints/testingRelayRococo.ts +++ b/packages/apps-config/src/endpoints/testingRelayRococo.ts @@ -4,8 +4,8 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; import { ROCOCO_GENESIS } from '../api/constants'; -import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -23,10 +23,10 @@ export function createRococo (t: TFunction): EndpointOption { info: 'rococo', text: t('rpc.rococo', 'Rococo', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://rococo-rpc.polkadot.io' }, - OnFinality: { type: EndpointType.jrpc, url: 'wss://rococo.api.onfinality.io/public-ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://rococo.elara.patract.io' }, - 'Ares Protocol': { type: EndpointType.jrpc, url: 'wss://rococo.aresprotocol.com' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://rococo-rpc.polkadot.io' }, + OnFinality: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.api.onfinality.io/public-ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://rococo.elara.patract.io' }, + 'Ares Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://rococo.aresprotocol.com' } }, linked: [ // these are the base chains @@ -35,7 +35,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 100, text: t('rpc.rococo.tick', 'Tick', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://tick-rpc.polkadot.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://tick-rpc.polkadot.io' } } }, { @@ -43,7 +43,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 110, text: t('rpc.rococo.trick', 'Trick', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://trick-rpc.polkadot.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://trick-rpc.polkadot.io' } } }, { @@ -51,7 +51,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 120, text: t('rpc.rococo.track', 'Track', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://track-rpc.polkadot.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://track-rpc.polkadot.io' } } }, { @@ -59,7 +59,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1, text: t('rpc.rococo.statemint', 'Statemint', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://statemint-rococo-rpc.parity.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://statemint-rococo-rpc.parity.io' } } }, // add any additional parachains here, alphabetical @@ -68,7 +68,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2048, text: t('rpc.rococo.apron', 'Apron PC1', { ns: 'apps-config' }), providers: { - 'Apron Network': { type: EndpointType.jrpc, url: 'wss://rococo.apron.network' } + 'Apron Network': { type: 'json-rpc' as EndpointType, param: 'wss://rococo.apron.network' } } }, { @@ -76,7 +76,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1006, text: t('rpc.rococo.ares', 'Ares PC1', { ns: 'apps-config' }), providers: { - 'Ares Protocol': { type: EndpointType.jrpc, url: 'wss://rococo.parachain.aresprotocol.com' } + 'Ares Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://rococo.parachain.aresprotocol.com' } } }, { @@ -84,7 +84,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1024, text: t('rpc.rococo.bifrost', 'Bifrost PC1', { ns: 'apps-config' }), providers: { - Bifrost: { type: EndpointType.jrpc, url: 'wss://rococo-1.testnet.liebi.com' } + Bifrost: { type: 'json-rpc' as EndpointType, param: 'wss://rococo-1.testnet.liebi.com' } } }, { @@ -92,7 +92,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1008, text: t('rpc.rococo.bitcountry', 'Bit.Country PC1', { ns: 'apps-config' }), providers: { - BitCountry: { type: EndpointType.jrpc, url: 'wss://tewai-parachain.bit.country:9955' } + BitCountry: { type: 'json-rpc' as EndpointType, param: 'wss://tewai-parachain.bit.country:9955' } } }, { @@ -100,7 +100,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 10001, text: t('rpc.rococo.centrifuge', 'Centrifuge Charcoal', { ns: 'apps-config' }), providers: { - Centrifuge: { type: EndpointType.jrpc, url: 'wss://fullnode-collator.charcoal.centrifuge.io' } + Centrifuge: { type: 'json-rpc' as EndpointType, param: 'wss://fullnode-collator.charcoal.centrifuge.io' } } }, { @@ -111,7 +111,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 229, text: t('rpc.rococo.clover', 'Clover PC1', { ns: 'apps-config' }), providers: { - Clover: { type: EndpointType.jrpc, url: 'wss://api-rococo.clover.finance' } + Clover: { type: 'json-rpc' as EndpointType, param: 'wss://api-rococo.clover.finance' } } }, { @@ -122,7 +122,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 9, text: t('rpc.rococo.crab', 'Darwinia Crab PC2', { ns: 'apps-config' }), providers: { - Darwinia: { type: EndpointType.jrpc, url: 'wss://crab-pc2-rpc.darwinia.network' } + Darwinia: { type: 'json-rpc' as EndpointType, param: 'wss://crab-pc2-rpc.darwinia.network' } } }, { @@ -130,7 +130,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2001, text: t('rpc.rococo.crust', 'Crust PC1', { ns: 'apps-config' }), providers: { - Crust: { type: EndpointType.jrpc, url: 'wss://api-rococo.crust.network' } + Crust: { type: 'json-rpc' as EndpointType, param: 'wss://api-rococo.crust.network' } } }, { @@ -138,7 +138,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1059, text: t('rpc.rococo.chainx', 'ChainX PC1', { ns: 'apps-config' }), providers: { - ChainX: { type: EndpointType.jrpc, url: 'wss://sherpax.chainx.org' } + ChainX: { type: 'json-rpc' as EndpointType, param: 'wss://sherpax.chainx.org' } } }, { @@ -149,7 +149,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 18, text: t('rpc.rococo.darwinia', 'Darwinia PC2', { ns: 'apps-config' }), providers: { - Darwinia: { type: EndpointType.jrpc, url: 'wss://pc2-rpc.darwinia.network' } + Darwinia: { type: 'json-rpc' as EndpointType, param: 'wss://pc2-rpc.darwinia.network' } } }, { @@ -160,7 +160,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2, text: t('rpc.rococo.datahighway', 'DataHighway', { ns: 'apps-config' }), providers: { - DataHighway: { type: EndpointType.jrpc, url: 'wss://spreehafen.datahighway.com' } + DataHighway: { type: 'json-rpc' as EndpointType, param: 'wss://spreehafen.datahighway.com' } } }, { @@ -168,7 +168,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2003, text: t('rpc.rococo.eave', 'Steam PC', { ns: 'apps-config' }), providers: { - EAVE: { type: EndpointType.jrpc, url: 'wss://steamcollator.eave.network' } + EAVE: { type: 'json-rpc' as EndpointType, param: 'wss://steamcollator.eave.network' } } }, { @@ -176,7 +176,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1862, text: t('rpc.rococo.encointer', 'Encointer PC1', { ns: 'apps-config' }), providers: { - Encointer: { type: EndpointType.jrpc, url: 'wss://rococo.encointer.org' } + Encointer: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.encointer.org' } } }, { @@ -187,7 +187,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 42, text: t('rpc.rococo.equilibrium', 'Equilibrium', { ns: 'apps-config' }), providers: { - Equilibrium: { type: EndpointType.jrpc, url: 'wss://rococo.equilibrium.io' } + Equilibrium: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.equilibrium.io' } } }, { @@ -195,7 +195,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1230, text: t('rpc.rococo.galital', 'Galital PC1', { ns: 'apps-config' }), providers: { - StarkleyTech: { type: EndpointType.jrpc, url: 'wss://galital-rpc.starkleytech.com' } + StarkleyTech: { type: 'json-rpc' as EndpointType, param: 'wss://galital-rpc.starkleytech.com' } } }, { @@ -203,7 +203,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 82406, text: t('rpc.rococo.hydrate', 'Hydrate', { ns: 'apps-config' }), providers: { - HydraDX: { type: EndpointType.jrpc, url: 'wss://hydrate-rpc.hydradx.io:9944' } + HydraDX: { type: 'json-rpc' as EndpointType, param: 'wss://hydrate-rpc.hydradx.io:9944' } } }, { @@ -211,7 +211,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 7766, text: t('rpc.rococo.idavoll', 'Idavoll', { ns: 'apps-config' }), providers: { - Idavoll: { type: EndpointType.jrpc, url: 'wss://rococo.idavoll.network' } + Idavoll: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.idavoll.network' } } }, { @@ -219,7 +219,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1983, text: t('rpc.rococo.integritee', 'IntegriTEE PC1', { ns: 'apps-config' }), providers: { - SCS: { type: EndpointType.jrpc, url: 'wss://rococo.integritee.network' } + SCS: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.integritee.network' } } }, { @@ -227,7 +227,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 12623, text: t('rpc.rococo.kilt', 'KILT PC1', { ns: 'apps-config' }), providers: { - 'KILT Protocol': { type: EndpointType.jrpc, url: 'wss://para.rococo-v1.kilt.io' } + 'KILT Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://para.rococo-v1.kilt.io' } } }, { @@ -235,7 +235,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 18403, text: t('rpc.rococo.konomi', 'Komomi Network', { ns: 'apps-config' }), providers: { - 'Konomi Network': { type: EndpointType.jrpc, url: 'wss://rococo.konomi.tech' } + 'Konomi Network': { type: 'json-rpc' as EndpointType, param: 'wss://rococo.konomi.tech' } } }, { @@ -243,7 +243,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1984, text: t('rpc.rocco.litentry', 'Litentry Rostock', { ns: 'apps-config' }), providers: { - Litentry: { type: EndpointType.jrpc, url: 'wss://rococov1.litentry.io' } + Litentry: { type: 'json-rpc' as EndpointType, param: 'wss://rococov1.litentry.io' } } }, { @@ -251,7 +251,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1000, text: t('rpc.rococo.acala', 'Mandala PC2', { ns: 'apps-config' }), providers: { - Acala: { type: EndpointType.jrpc, url: 'wss://rococo-1.acala.laminar.one' } + Acala: { type: 'json-rpc' as EndpointType, param: 'wss://rococo-1.acala.laminar.one' } } }, { @@ -262,7 +262,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 40, text: t('rpc.rococo.mathchain', 'MathChain PC1', { ns: 'apps-config' }), providers: { - MathWallet: { type: EndpointType.jrpc, url: 'wss://testpara.maiziqianbao.net/ws' } + MathWallet: { type: 'json-rpc' as EndpointType, param: 'wss://testpara.maiziqianbao.net/ws' } } }, { @@ -270,7 +270,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2021, text: t('rpc.rococo.manta', 'Manta PC1', { ns: 'apps-config' }), providers: { - Manta: { type: EndpointType.jrpc, url: 'wss://rococo.manta.network' } + Manta: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.manta.network' } } }, { @@ -278,7 +278,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1286, text: t('rpc.rococo.moonrock', 'Moonrock', { ns: 'apps-config' }), providers: { - Moonrock: { type: EndpointType.jrpc, url: 'wss://wss-moonrock.gcp.purestake.run' } + Moonrock: { type: 'json-rpc' as EndpointType, param: 'wss://wss-moonrock.gcp.purestake.run' } } }, { @@ -286,7 +286,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 18888, text: t('rpc.rococo.parami', 'Parami PC2', { ns: 'apps-config' }), providers: { - Parami: { type: EndpointType.jrpc, url: 'wss://rococo.parami.io' } + Parami: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.parami.io' } } }, { @@ -294,7 +294,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1010, text: t('rpc.rococo.jupiter', 'Patract Jupiter PC1', { ns: 'apps-config' }), providers: { - jupiter: { type: EndpointType.jrpc, url: 'wss://ws.rococo.jupiter.patract.cn' } + jupiter: { type: 'json-rpc' as EndpointType, param: 'wss://ws.rococo.jupiter.patract.cn' } } }, { @@ -302,7 +302,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1030, text: t('rpc.rococo.phala', 'Phala PC1', { ns: 'apps-config' }), providers: { - Phala: { type: EndpointType.jrpc, url: 'wss://rococov1.phala.network/ws' } + Phala: { type: 'json-rpc' as EndpointType, param: 'wss://rococov1.phala.network/ws' } } }, { @@ -310,7 +310,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 6806, text: t('rpc.rococo.phoenix', 'PHOENIX PC1', { ns: 'apps-config' }), providers: { - 'PHOENIX Protocol': { type: EndpointType.jrpc, url: 'wss://phoenix-ws.coinid.pro' } + 'PHOENIX Protocol': { type: 'json-rpc' as EndpointType, param: 'wss://phoenix-ws.coinid.pro' } } }, { @@ -318,7 +318,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 5000, text: t('rpc.rococo.plasm', 'Plasm PC2', { ns: 'apps-config' }), providers: { - PlasmNetwork: { type: EndpointType.jrpc, url: 'wss://rpc.rococo.plasmnet.io' } + PlasmNetwork: { type: 'json-rpc' as EndpointType, param: 'wss://rpc.rococo.plasmnet.io' } } }, { @@ -329,7 +329,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 21, text: t('rpc.rococo.polkabtc', 'PolkaBTC PC1', { ns: 'apps-config' }), providers: { - Interlay: { type: EndpointType.jrpc, url: 'wss://rococo.polkabtc.io/api/parachain' } + Interlay: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.polkabtc.io/api/parachain' } } }, { @@ -337,7 +337,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1111, text: t('rpc.rococo.polkafoundry', 'PolkaFoundry PC1', { ns: 'apps-config' }), providers: { - PolkaFoundry: { type: EndpointType.jrpc, url: 'wss://rococo.polkafoundry.com' } + PolkaFoundry: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.polkafoundry.com' } } }, { @@ -345,7 +345,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 2002, text: t('rpc.rococo.prism', 'Prism PC1', { ns: 'apps-config' }), providers: { - Prism: { type: EndpointType.jrpc, url: 'wss://rococo.psm.link' } + Prism: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.psm.link' } } }, { @@ -353,7 +353,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 3000, text: t('rpc.rococo.robonomics', 'Robonomics PC2', { ns: 'apps-config' }), providers: { - Airalab: { type: EndpointType.jrpc, url: 'wss://rococo.parachain.robonomics.network' } + Airalab: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.parachain.robonomics.network' } } }, { @@ -364,7 +364,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 888, text: t('rpc.rococo.subdao', 'SubDAO PC1', { ns: 'apps-config' }), providers: { - SubDAONetwork: { type: EndpointType.jrpc, url: 'wss://parachain.subdao.network' } + SubDAONetwork: { type: 'json-rpc' as EndpointType, param: 'wss://parachain.subdao.network' } } }, { @@ -375,7 +375,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 28, text: t('rpc.rococo.subsocial', 'Subsocial PC1', { ns: 'apps-config' }), providers: { - DappForce: { type: EndpointType.jrpc, url: 'wss://roc.subsocial.network' } + DappForce: { type: 'json-rpc' as EndpointType, param: 'wss://roc.subsocial.network' } } }, { @@ -383,7 +383,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 6633, text: t('rpc.rococo.trustbase', 'TrustBase PC1', { ns: 'apps-config' }), providers: { - TrustBase: { type: EndpointType.jrpc, url: 'wss://rococo.trustednodes.net' } + TrustBase: { type: 'json-rpc' as EndpointType, param: 'wss://rococo.trustednodes.net' } } }, { @@ -394,7 +394,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 3, text: t('rpc.rococo.unitv', 'Unit Network', { ns: 'apps-config' }), providers: { - 'Unit Network': { type: EndpointType.jrpc, url: 'wss://unitp.io' } + 'Unit Network': { type: 'json-rpc' as EndpointType, param: 'wss://unitp.io' } } }, { @@ -402,7 +402,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 3586, text: t('rpc.rococo.vln', 'Valiu Liquidity Network PC', { ns: 'apps-config' }), providers: { - Valiu: { type: EndpointType.jrpc, url: 'wss://vln.valiu.dev' } + Valiu: { type: 'json-rpc' as EndpointType, param: 'wss://vln.valiu.dev' } } }, { @@ -410,7 +410,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 9123, text: t('rpc.rococo.zeitgeist', 'Zeitgeist PC', { ns: 'apps-config' }), providers: { - Zeitgeist: { type: EndpointType.jrpc, url: 'wss://roc.zeitgeist.pm' } + Zeitgeist: { type: 'json-rpc' as EndpointType, param: 'wss://roc.zeitgeist.pm' } } }, { @@ -418,7 +418,7 @@ export function createRococo (t: TFunction): EndpointOption { paraId: 1188, text: t('rpc.rococo.zenlink', 'Zenlink PC1', { ns: 'apps-config' }), providers: { - Zenlink: { type: EndpointType.jrpc, url: 'wss://rococo-parachain.zenlink.pro' } + Zenlink: { type: 'json-rpc' as EndpointType, param: 'wss://rococo-parachain.zenlink.pro' } } } ] diff --git a/packages/apps-config/src/endpoints/testingRelayWestend.ts b/packages/apps-config/src/endpoints/testingRelayWestend.ts index ff9ed55f5992..e3c624a4f614 100644 --- a/packages/apps-config/src/endpoints/testingRelayWestend.ts +++ b/packages/apps-config/src/endpoints/testingRelayWestend.ts @@ -4,8 +4,8 @@ import type { TFunction } from 'i18next'; import type { EndpointOption } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; import { WESTEND_GENESIS } from '../api/constants'; -import { EndpointType } from './types'; /* eslint-disable sort-keys */ @@ -23,11 +23,11 @@ export function createWestend (t: TFunction): EndpointOption { info: 'westend', text: t('rpc.westend', 'Westend', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://westend-rpc.polkadot.io' }, - 'NodeFactory(Vedran)': { type: EndpointType.jrpc, url: 'wss://westend.vedran.nodefactory.io/ws' }, - 'Patract Elara': { type: EndpointType.jrpc, url: 'wss://westend.elara.patract.io' }, - OnFinality: { type: EndpointType.jrpc, url: 'wss://westend.api.onfinality.io/public-ws' }, - 'light client': { type: EndpointType.substrateconnect, chain: 'westend-substrate-connect' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://westend-rpc.polkadot.io' }, + 'NodeFactory(Vedran)': { type: 'json-rpc' as EndpointType, param: 'wss://westend.vedran.nodefactory.io/ws' }, + 'Patract Elara': { type: 'json-rpc' as EndpointType, param: 'wss://westend.elara.patract.io' }, + OnFinality: { type: 'json-rpc' as EndpointType, param: 'wss://westend.api.onfinality.io/public-ws' }, + 'light client': { type: 'substrate-connect' as EndpointType, param: 'westend-substrate-connect' } }, linked: [ // (1) system parachains (none available yet) @@ -38,7 +38,7 @@ export function createWestend (t: TFunction): EndpointOption { paraId: 1070, text: t('rpc.westend.shell', 'Shell', { ns: 'apps-config' }), providers: { - Parity: { type: EndpointType.jrpc, url: 'wss://westend-shell-rpc.parity.io' } + Parity: { type: 'json-rpc' as EndpointType, param: 'wss://westend-shell-rpc.parity.io' } } } // (3) parachains with id, see Rococo (info here maps to the actual "named icon") diff --git a/packages/apps-config/src/endpoints/types.ts b/packages/apps-config/src/endpoints/types.ts index 44509c76ddaa..b4fecf78ba7c 100644 --- a/packages/apps-config/src/endpoints/types.ts +++ b/packages/apps-config/src/endpoints/types.ts @@ -1,6 +1,8 @@ // Copyright 2017-2021 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 +import { Endpoint } from '../../../../../ui/packages/ui-settings/src/types'; + export interface EndpointOption { dnslink?: string; genesisHash?: string; @@ -13,20 +15,3 @@ export interface EndpointOption { providers: Record; text: React.ReactNode; } - -type Endpoint = JsonRpcEndpoint | SubstrateConnectEndpoint; - -interface JsonRpcEndpoint { - type: EndpointType.jrpc; - url: string; -} - -interface SubstrateConnectEndpoint { - type: EndpointType.substrateconnect; - chain: string; -} - -export enum EndpointType { - jrpc = 'json-rpc', - substrateconnect = 'substrate-connect' -} diff --git a/packages/apps-config/src/endpoints/util.ts b/packages/apps-config/src/endpoints/util.ts index 4264e0bd93f9..39434cc5ede8 100644 --- a/packages/apps-config/src/endpoints/util.ts +++ b/packages/apps-config/src/endpoints/util.ts @@ -5,7 +5,7 @@ import type { TFunction } from 'i18next'; import type { LinkOption } from '../settings/types'; import type { EndpointOption } from './types'; -import { EndpointType } from './types'; +import { EndpointType } from '../../../../../ui/packages/ui-settings/src/types'; export function expandLinked (input: LinkOption[]): LinkOption[] { return input.reduce((result: LinkOption[], entry): LinkOption[] => { @@ -38,11 +38,11 @@ export function expandEndpoint (t: TFunction, input: EndpointOption): LinkOption const result = Object.entries(providers).map(([host, value], index): LinkOption => ({ ...base, dnslink: index === 0 ? dnslink : undefined, - isLightClient: value.type === EndpointType.substrateconnect, - textBy: (value.type === EndpointType.jrpc) + isLightClient: value.type === 'substrate-connect' as EndpointType, + textBy: (value.type === 'json-rpc' as EndpointType) ? t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host } }) : t('lightclient.experimental', 'light client (experimental)', { ns: 'apps-config' }), - value: (value.type === EndpointType.jrpc) ? value.url : value.chain + value: value.param as string })); if (linked) { diff --git a/packages/apps/src/Endpoints/index.tsx b/packages/apps/src/Endpoints/index.tsx index dd3f944b2667..3e22b6529934 100644 --- a/packages/apps/src/Endpoints/index.tsx +++ b/packages/apps/src/Endpoints/index.tsx @@ -14,6 +14,7 @@ import styled from 'styled-components'; import { createWsEndpoints, CUSTOM_ENDPOINT_KEY } from '@polkadot/apps-config'; import { Button, Input, Sidebar } from '@polkadot/react-components'; import { settings } from '@polkadot/ui-settings'; +import { Endpoint, EndpointType } from '@polkadot/ui-settings/types'; import { isAscii } from '@polkadot/util'; import { useTranslation } from '../translate'; @@ -43,13 +44,21 @@ function isValidUrl (url: string): boolean { ); } +function getApiType (apiUrl: string): Endpoint { + if (apiUrl.includes('-substrate-connect')) { + return { param: apiUrl, type: 'substrate-connect' as EndpointType }; + } + + return { param: apiUrl, type: 'json-rpc' as EndpointType }; +} + function combineEndpoints (endpoints: LinkOption[]): Group[] { return endpoints.reduce((result: Group[], e): Group[] => { if (e.isHeader) { result.push({ header: e.text, isDevelopment: e.isDevelopment, isSpaced: e.isSpaced, networks: [] }); } else { const prev = result[result.length - 1]; - const prov = { name: e.textBy, url: e.value as string }; + const prov = { isLightClient: e.isLightClient, name: e.textBy, url: e.value as string }; if (prev.networks[prev.networks.length - 1] && e.text === prev.networks[prev.networks.length - 1].name) { prev.networks[prev.networks.length - 1].providers.push(prov); @@ -215,21 +224,29 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem const _onApply = useCallback( (): void => { settings.set({ ...(settings.get()), apiUrl }); - - window.location.assign(`${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(apiUrl)}${window.location.hash}`); + window.location.assign(`${window.location.origin}${window.location.pathname}${getApiType(apiUrl).type === 'substrate-connect' as EndpointType ? '?sc=' : '?rpc='}${encodeURIComponent(apiUrl)}${window.location.hash}`); // window.location.reload(); - onClose(); }, [apiUrl, onClose] ); + const isSwitchDisabled = (): boolean => { + if (!hasUrlChanged) { return true; } + + if (getApiType(apiUrl).type === 'substrate-connect' as EndpointType) { return false; } + + if (isUrlValid) { return false; } + + return true; + }; + return ( ('Switch')} onClick={_onApply} /> @@ -254,7 +271,7 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem
('custom endpoint')} onChange={_onChangeCustom} @@ -269,7 +286,7 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem :