From af44988d9ee404c087fb49b39045e1cd9f4485aa Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 14 Dec 2020 12:40:07 +0100 Subject: [PATCH] Split endpoints into own area (#4204) * Split endpoints into own area * Export endpoint key --- CHANGELOG.md | 27 ++ .../spec/{moonbeam-rpc.ts => frontier-rpc.ts} | 2 +- .../src/api/bundle/spec/moonbeam.ts | 2 +- .../apps-config/src/endpoints/development.ts | 71 +++ packages/apps-config/src/endpoints/index.ts | 43 ++ .../apps-config/src/endpoints/production.ts | 150 ++++++ packages/apps-config/src/endpoints/testing.ts | 134 ++++++ packages/apps-config/src/index.ts | 1 + .../apps-config/src/settings/constants.ts | 4 - .../apps-config/src/settings/endpoints.ts | 432 ------------------ packages/apps-config/src/settings/index.ts | 2 - 11 files changed, 428 insertions(+), 440 deletions(-) rename packages/apps-config/src/api/bundle/spec/{moonbeam-rpc.ts => frontier-rpc.ts} (98%) create mode 100644 packages/apps-config/src/endpoints/development.ts create mode 100644 packages/apps-config/src/endpoints/index.ts create mode 100644 packages/apps-config/src/endpoints/production.ts create mode 100644 packages/apps-config/src/endpoints/testing.ts delete mode 100644 packages/apps-config/src/settings/constants.ts delete mode 100644 packages/apps-config/src/settings/endpoints.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 29eb30dbd0..b57e657431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # CHANGELOG +## 0.71.1 Dec 14, 2020 + +Contributed: + +- Update it i18n (Thanks to https://github.com/fomod-in) +- Add endpoint & types for MatchChain Galois (Thanks to https://github.com/hging) +- Change endpoint for Sora (Thanks to https://github.com/stefashkaa) +- Adjust Centrifuge types after upgrade (Thanks to https://github.com/mikiquantum) +- Adjust Moonbeam types for future upgrades (Thanks to https://github.com/joelamouche) +- Adjust Equilibrium types for balances (Thanks to https://github.com/pr0fedt) +- Adjust bounties layout & add counter (Thanks to https://github.com/MiZiet) +- Add max-width for content layouts (Thanks to https://github.com/MiZiet) +- Use API derives for bounties (Thanks to https://github.com/krzysztof-jelski & https://github.com/MiZiet) +- Extra type-only imports into seperate groups (Thanks to https://github.com/ekowalsk) + +Changes: + +- Multisig/Proxy add is only active when accounts are available +- Adjust error popups to cater for strings as thrown (in addition to Error object) +- Ensure that bad/erroneous judgements has the highest display priority +- Detect new weight definitions for max batch-size calculations (with old fallback) +- Move Sora & Moonbean type definitions to bundle-only +- Allow for custom chain RPC definitions via typesBundle +- Split endpoint definitions into folder (dev/prod/test) +- Adjust Tooltip formatting with consistency between balances/locks + + ## 0.70.1 Dec 7, 2020 Contributed: diff --git a/packages/apps-config/src/api/bundle/spec/moonbeam-rpc.ts b/packages/apps-config/src/api/bundle/spec/frontier-rpc.ts similarity index 98% rename from packages/apps-config/src/api/bundle/spec/moonbeam-rpc.ts rename to packages/apps-config/src/api/bundle/spec/frontier-rpc.ts index 485e03345c..21d802dfda 100644 --- a/packages/apps-config/src/api/bundle/spec/moonbeam-rpc.ts +++ b/packages/apps-config/src/api/bundle/spec/frontier-rpc.ts @@ -3,7 +3,7 @@ import type { DefinitionRpc, DefinitionRpcParam } from '@polkadot/types/types'; -export default function (): Record> { +export default function createFrontier (): Record> { function generateDescription (description:string, returnType:string, params:DefinitionRpcParam[] = []): DefinitionRpc { return { description, diff --git a/packages/apps-config/src/api/bundle/spec/moonbeam.ts b/packages/apps-config/src/api/bundle/spec/moonbeam.ts index c6932104ff..cb9477cc19 100644 --- a/packages/apps-config/src/api/bundle/spec/moonbeam.ts +++ b/packages/apps-config/src/api/bundle/spec/moonbeam.ts @@ -3,7 +3,7 @@ import type { OverrideBundleDefinition } from '@polkadot/types/types'; -import rpcGen from './moonbeam-rpc'; +import rpcGen from './frontier-rpc'; // structs need to be in order /* eslint-disable sort-keys */ diff --git a/packages/apps-config/src/endpoints/development.ts b/packages/apps-config/src/endpoints/development.ts new file mode 100644 index 0000000000..4685b4fffd --- /dev/null +++ b/packages/apps-config/src/endpoints/development.ts @@ -0,0 +1,71 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { TFunction } from 'i18next'; +import type { LinkOption } from '../settings/types'; + +export const CUSTOM_ENDPOINT_KEY = 'polkadot-app-custom-endpoints'; + +interface EnvWindow { + // eslint-disable-next-line camelcase + process_env?: { + WS_URL: string; + } +} + +export function createCustom (t: TFunction): LinkOption[] { + const WS_URL = ( + (typeof process !== 'undefined' ? process.env?.WS_URL : undefined) || + (typeof window !== 'undefined' ? (window as EnvWindow).process_env?.WS_URL : undefined) + ); + + return WS_URL + ? [ + { + isHeader: true, + text: t('rpc.custom', 'Custom environment', { ns: 'apps-config' }), + textBy: '', + value: '' + }, + { + info: 'WS_URL', + text: t('rpc.custom.entry', 'Custom {{WS_URL}}', { ns: 'apps-config', replace: { WS_URL } }), + textBy: WS_URL, + value: WS_URL + } + ] + : []; +} + +export function createOwn (t: TFunction): LinkOption[] { + try { + const storedItems = localStorage.getItem(CUSTOM_ENDPOINT_KEY); + + if (storedItems) { + const items = JSON.parse(storedItems) as string[]; + + return items.map((textBy) => ({ + info: 'local', + text: t('rpc.custom.entry', 'Custom', { ns: 'apps-config' }), + textBy, + value: textBy + })); + } + } catch (e) { + console.error(e); + } + + return []; +} + +export function createDev (t: TFunction): LinkOption[] { + return [ + { + dnslink: 'local', + info: 'local', + text: t('rpc.local', 'Local Node', { ns: 'apps-config' }), + textBy: '127.0.0.1:9944', + value: 'ws://127.0.0.1:9944' + } + ]; +} diff --git a/packages/apps-config/src/endpoints/index.ts b/packages/apps-config/src/endpoints/index.ts new file mode 100644 index 0000000000..d6380e98d5 --- /dev/null +++ b/packages/apps-config/src/endpoints/index.ts @@ -0,0 +1,43 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { TFunction } from 'i18next'; +import type { LinkOption } from '../settings/types'; + +import { createCustom, createDev, createOwn } from './development'; +import { createProduction } from './production'; +import { createTesting } from './testing'; + +export { CUSTOM_ENDPOINT_KEY } from './development'; + +export function createWsEndpoints (t: TFunction): LinkOption[] { + return [ + ...createCustom(t), + { + isDisabled: false, + isHeader: true, + text: t('rpc.header.live', 'Live networks', { ns: 'apps-config' }), + textBy: '', + value: '' + }, + ...createProduction(t), + { + isDisabled: false, + isHeader: true, + text: t('rpc.header.test', 'Test networks', { ns: 'apps-config' }), + textBy: '', + value: '' + }, + ...createTesting(t), + { + isDevelopment: true, + isDisabled: false, + isHeader: true, + text: t('rpc.header.dev', 'Development', { ns: 'apps-config' }), + textBy: '', + value: '' + }, + ...createDev(t), + ...createOwn(t) + ].filter(({ isDisabled }) => !isDisabled); +} diff --git a/packages/apps-config/src/endpoints/production.ts b/packages/apps-config/src/endpoints/production.ts new file mode 100644 index 0000000000..695b9e131d --- /dev/null +++ b/packages/apps-config/src/endpoints/production.ts @@ -0,0 +1,150 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { TFunction } from 'i18next'; +import type { LinkOption } from '../settings/types'; + +// 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 + +export function createProduction (t: TFunction): LinkOption[] { + return [ + // fixed, polkadot + { + dnslink: 'polkadot', + info: 'polkadot', + text: t('rpc.polkadot.parity', 'Polkadot', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), + value: 'wss://rpc.polkadot.io' + }, + { + info: 'polkadot', + text: t('rpc.polkadot.w3f', 'Polkadot', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Web3 Foundation' } }), + value: 'wss://cc1-1.polkadot.network' + }, + { + info: 'polkadot', + text: t('rpc.polkadot.onfinality', 'Polkadot', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'OnFinality' } }), + value: 'wss://polkadot.api.onfinality.io/public-ws' + }, + { + info: 'polkadot', + text: t('rpc.polkadot.patractlabs', 'Polkadot', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Patract Elara' } }), + value: 'wss://polkadot.elara.patract.io' + }, + { + dnslink: 'kusama', + info: 'kusama', + text: t('rpc.kusama.parity', 'Kusama', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), + value: 'wss://kusama-rpc.polkadot.io' + }, + { + info: 'kusama', + text: t('rpc.kusama.w3f', 'Kusama', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Web3 Foundation' } }), + value: 'wss://cc3-5.kusama.network' + }, + { + info: 'kusama', + text: t('rpc.kusama.onfinality', 'Kusama', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'OnFinality' } }), + value: 'wss://kusama.api.onfinality.io/public-ws' + }, + { + info: 'kusama', + text: t('rpc.kusama.patractlabs', 'Kusama', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Patract Elara' } }), + value: 'wss://kusama.elara.patract.io' + }, + { + info: 'kusama', + isDisabled: true, + text: t('rpc.kusama.ava', 'Kusama', { ns: 'apps-config' }), + textBy: t('rpc.ava.summary', 'user-run public nodes; see https://status.cloud.ava.do/', { ns: 'apps-config' }), + value: 'wss://kusama.polkadot.cloud.ava.do' + }, + // alphabetical based on chain name + { + dnslink: 'centrifuge', + info: 'centrifuge', + text: t('rpc.centrifuge', 'Centrifuge', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Centrifuge' } }), + value: 'wss://fullnode.centrifuge.io' + }, + { + info: 'crab', + text: t('rpc.crab', 'Darwinia Crab', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), + value: 'wss://crab.darwinia.network' + }, + { + info: 'darwinia', + text: t('rpc.darwinia', 'Darwinia', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), + value: 'wss://cc1.darwinia.network' + }, + { + info: 'dock-mainnet', + text: t('rpc.dock-mainnet', 'Dock Mainnet', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Dock Association' } }), + value: 'wss://mainnet-node.dock.io' + }, + { + dnslink: 'edgeware', + info: 'edgeware', + text: t('rpc.edgeware', 'Edgeware', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Commonwealth Labs' } }), + value: 'wss://mainnet4.edgewa.re' + }, + { + info: 'equilibrium', + text: t('rpc.equilibrium', 'Equilibrium Mainnet', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Equilibrium' } }), + value: 'wss://tge.equilibrium.io' + }, + { + info: 'hanonycash', + text: t('rpc.hanonycash', 'hanonycash', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'hanonycash' } }), + value: 'wss://rpc.hanonycash.com' + }, + { + dnslink: 'kulupu', + info: 'kulupu', + text: t('rpc.kulupu', 'Kulupu', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Kulupu' } }), + value: 'wss://rpc.kulupu.corepaper.org/ws' + }, + { + info: 'nodle', + text: t('rpc.nodle-main', 'Nodle Main', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Nodle' } }), + value: 'wss://main1.nodleprotocol.io' + }, + { + info: 'plasm', + text: t('rpc.plasm', 'Plasm', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stake Technologies' } }), + value: 'wss://rpc.plasmnet.io/' + }, + { + info: 'stafi', + text: t('rpc.stafi', 'Stafi', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stafi Foundation' } }), + value: 'wss://mainnet-rpc.stafi.io' + }, + { + info: 'subsocial', + text: t('rpc.subsocial', 'Subsocial', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'DappForce' } }), + value: 'wss://rpc.subsocial.network' + } + ]; +} diff --git a/packages/apps-config/src/endpoints/testing.ts b/packages/apps-config/src/endpoints/testing.ts new file mode 100644 index 0000000000..465bf8688d --- /dev/null +++ b/packages/apps-config/src/endpoints/testing.ts @@ -0,0 +1,134 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { TFunction } from 'i18next'; +import type { LinkOption } from '../settings/types'; + +// 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 + +export function createTesting (t: TFunction): LinkOption[] { + return [ + // alphabetical based on chain name + { + info: 'centrifuge', + text: t('rpc.amber', 'Amber', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Centrifuge' } }), + value: 'wss://fullnode.amber.centrifuge.io' + }, + { + info: 'nodle', + text: t('rpc.nodle-arcadia', 'Arcadia', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Nodle' } }), + value: 'wss://arcadia1.nodleprotocol.io' + }, + { + info: 'edgeware', + text: t('rpc.beresheet', 'Beresheet', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Commonwealth Labs' } }), + value: 'wss://beresheet1.edgewa.re' + }, + { + info: 'bifrost', + text: t('rpc.bifrost', 'Bifrost Asgard', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Bifrost' } }), + value: 'wss://testnet.liebi.com' + }, + { + info: 'canvas', + text: t('rpc.canvas', 'Canvas', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), + value: 'wss://canvas-rpc.parity.io' + }, + { + info: 'crust', + text: t('rpc.crust.network', 'Crust Maxwell CC2', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Crust Network' } }), + value: 'wss://api.crust.network/' + }, + { + info: 'datahighway', + isDisabled: true, + text: t('rpc.datahighway.harbour', 'Harbour', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'MXC' } }), + value: 'wss://testnet-harbour.datahighway.com' + }, + { + info: 'dock-testnet', + text: t('rpc.dock-testnet', 'Dock Testnet', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Dock Association' } }), + value: 'wss://danforth-1.dock.io' + }, + { + info: 'dusty', + text: t('rpc.dusty', 'Dusty', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stake Technologies' } }), + value: 'wss://rpc.dusty.plasmnet.io/' + }, + { + info: 'equilibrium', + text: t('rpc.equilibriumtestnet', 'Equilibrium Testnet', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Equilibrium' } }), + value: 'wss://api.mvp.testnet.equilibrium.io' + }, + { + info: 'substrate', + text: t('rpc.flamingfir', 'Flaming Fir', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), + value: 'wss://substrate-rpc.parity.io' + }, + { + dnslink: 'galois', + info: 'galois', + text: t('rpc.galois', 'Galois', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'MathWallet' } }), + value: 'wss://galois.maiziqianbao.net/ws' + }, + { + info: 'acala', + text: t('rpc.mandala', 'Mandala', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Acala' } }), + value: 'wss://node-6714447553211260928.rz.onfinality.io/ws' + }, + { + info: 'kilt', + text: t('rpc.kilt', 'Mashnet', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'KILT Protocol' } }), + value: 'wss://full-nodes.kilt.io:9944/' + }, + { + info: 'moonbaseAlpha', + text: t('rpc.moonbeam', 'Moonbase Alpha', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Moonbeam Network' } }), + value: 'wss://wss.testnet.moonbeam.network' + }, + { + info: 'phala', + text: t('rpc.phala', 'Phala PoC-3', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Phala Network' } }), + value: 'wss://poc3.phala.network/ws' + }, + { + info: 'laminar', + text: t('rpc.turbulence', 'Turbulence', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Laminar' } }), + value: 'wss://testnet-node-1.laminar-chain.laminar.one/ws' + }, + { + info: 'sora-substrate', + text: t('rpc.sora-substrate', 'SORA-Substrate', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Soramitsu' } }), + value: 'wss://ws.stage.sora2.soramitsu.co.jp' + }, + { + dnslink: 'westend', + info: 'westend', + text: t('rpc.westend', 'Westend', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), + value: 'wss://westend-rpc.polkadot.io' + } + ]; +} diff --git a/packages/apps-config/src/index.ts b/packages/apps-config/src/index.ts index e4acd537f9..31c0d0d9cc 100644 --- a/packages/apps-config/src/index.ts +++ b/packages/apps-config/src/index.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 export * from './api'; +export * from './endpoints'; export * from './extensions'; export * from './links'; export * from './settings'; diff --git a/packages/apps-config/src/settings/constants.ts b/packages/apps-config/src/settings/constants.ts deleted file mode 100644 index d571c79e3b..0000000000 --- a/packages/apps-config/src/settings/constants.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2017-2020 @polkadot/apps authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -export const CUSTOM_ENDPOINT_KEY = 'polkadot-app-custom-endpoints'; diff --git a/packages/apps-config/src/settings/endpoints.ts b/packages/apps-config/src/settings/endpoints.ts deleted file mode 100644 index ed42c17cf9..0000000000 --- a/packages/apps-config/src/settings/endpoints.ts +++ /dev/null @@ -1,432 +0,0 @@ -// Copyright 2017-2020 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { TFunction } from 'i18next'; -import type { LinkOption } from './types'; - -import { CUSTOM_ENDPOINT_KEY } from './constants'; - -interface EnvWindow { - // eslint-disable-next-line camelcase - process_env?: { - WS_URL: string; - } -} - -// 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 - -function createOwn (t: TFunction): LinkOption[] { - try { - const storedItems = localStorage.getItem(CUSTOM_ENDPOINT_KEY); - - if (storedItems) { - const items = JSON.parse(storedItems) as string[]; - - return items.map((textBy) => ({ - info: 'local', - text: t('rpc.custom.entry', 'Custom', { ns: 'apps-config' }), - textBy, - value: textBy - })); - } - } catch (e) { - console.error(e); - } - - return []; -} - -function createDev (t: TFunction): LinkOption[] { - return [ - { - dnslink: 'local', - info: 'local', - text: t('rpc.local', 'Local Node', { ns: 'apps-config' }), - textBy: '127.0.0.1:9944', - value: 'ws://127.0.0.1:9944' - } - ]; -} - -function createLiveNetworks (t: TFunction): LinkOption[] { - return [ - // fixed, polkadot - { - dnslink: 'polkadot', - info: 'polkadot', - text: t('rpc.polkadot.parity', 'Polkadot', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - value: 'wss://rpc.polkadot.io' - }, - { - info: 'polkadot', - text: t('rpc.polkadot.w3f', 'Polkadot', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Web3 Foundation' } }), - value: 'wss://cc1-1.polkadot.network' - }, - { - info: 'polkadot', - text: t('rpc.polkadot.onfinality', 'Polkadot', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'OnFinality' } }), - value: 'wss://polkadot.api.onfinality.io/public-ws' - }, - { - info: 'polkadot', - text: t('rpc.polkadot.patractlabs', 'Polkadot', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Patract Elara' } }), - value: 'wss://polkadot.elara.patract.io' - }, - { - dnslink: 'kusama', - info: 'kusama', - text: t('rpc.kusama.parity', 'Kusama', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - value: 'wss://kusama-rpc.polkadot.io' - }, - { - info: 'kusama', - text: t('rpc.kusama.w3f', 'Kusama', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Web3 Foundation' } }), - value: 'wss://cc3-5.kusama.network' - }, - { - info: 'kusama', - text: t('rpc.kusama.onfinality', 'Kusama', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'OnFinality' } }), - value: 'wss://kusama.api.onfinality.io/public-ws' - }, - { - info: 'kusama', - text: t('rpc.kusama.patractlabs', 'Kusama', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Patract Elara' } }), - value: 'wss://kusama.elara.patract.io' - }, - { - info: 'kusama', - isDisabled: true, - text: t('rpc.kusama.ava', 'Kusama', { ns: 'apps-config' }), - textBy: t('rpc.ava.summary', 'user-run public nodes; see https://status.cloud.ava.do/', { ns: 'apps-config' }), - value: 'wss://kusama.polkadot.cloud.ava.do' - }, - // alphabetical based on chain name - { - dnslink: 'centrifuge', - info: 'centrifuge', - text: t('rpc.centrifuge', 'Centrifuge', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Centrifuge' } }), - value: 'wss://fullnode.centrifuge.io' - }, - { - info: 'crab', - text: t('rpc.crab', 'Darwinia Crab', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), - value: 'wss://crab.darwinia.network' - }, - { - info: 'darwinia', - text: t('rpc.darwinia', 'Darwinia', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), - value: 'wss://cc1.darwinia.network' - }, - { - info: 'dock-mainnet', - text: t('rpc.dock-mainnet', 'Dock Mainnet', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Dock Association' } }), - value: 'wss://mainnet-node.dock.io' - }, - { - dnslink: 'edgeware', - info: 'edgeware', - text: t('rpc.edgeware', 'Edgeware', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Commonwealth Labs' } }), - value: 'wss://mainnet4.edgewa.re' - }, - { - info: 'equilibrium', - text: t('rpc.equilibrium', 'Equilibrium Mainnet', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Equilibrium' } }), - value: 'wss://tge.equilibrium.io' - }, - { - info: 'hanonycash', - text: t('rpc.hanonycash', 'hanonycash', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'hanonycash' } }), - value: 'wss://rpc.hanonycash.com' - }, - { - dnslink: 'kulupu', - info: 'kulupu', - text: t('rpc.kulupu', 'Kulupu', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Kulupu' } }), - value: 'wss://rpc.kulupu.corepaper.org/ws' - }, - { - info: 'nodle', - text: t('rpc.nodle-main', 'Nodle Main', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Nodle' } }), - value: 'wss://main1.nodleprotocol.io' - }, - { - info: 'plasm', - text: t('rpc.plasm', 'Plasm', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stake Technologies' } }), - value: 'wss://rpc.plasmnet.io/' - }, - { - info: 'stafi', - text: t('rpc.stafi', 'Stafi', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stafi Foundation' } }), - value: 'wss://mainnet-rpc.stafi.io' - }, - { - info: 'subsocial', - text: t('rpc.subsocial', 'Subsocial', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'DappForce' } }), - value: 'wss://rpc.subsocial.network' - } - ]; -} - -function createTestNetworks (t: TFunction): LinkOption[] { - return [ - // polkadot test relays - // { - // dnslink: 'rococo', - // info: 'rococo', - // text: t('rpc.rococo', 'Rococo', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - // value: 'wss://rococo-rpc.polkadot.io' - // }, - // { - // info: 'rococoTick', - // isChild: true, - // text: t('rpc.rococo.tick', 'Tick', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - // value: 'wss://tick-rpc.polkadot.io' - // }, - // { - // info: 'rococoTrick', - // isChild: true, - // text: t('rpc.rococo.trick', 'Trick', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Prity' } }), - // value: 'wss://trick-rpc.polkadot.io' - // }, - // { - // info: 'rococoTrack', - // isChild: true, - // text: t('rpc.rococo.track', 'Track', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - // value: 'wss://track-rpc.polkadot.io' - // }, - // { - // info: 'rococoAcala', - // isChild: true, - // text: t('rpc.rococo.acala', 'Mandala PC1', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Acala' } }), - // value: 'wss://rococo-1.acala.laminar.one' - // }, - // { - // info: 'rococoDarwinia', - // isChild: true, - // text: t('rpc.rococo.darwinia', 'Darwinia PC1', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), - // value: 'wss://parachain-rpc.darwinia.network' - // }, - // { - // info: 'rococoPlasm', - // isChild: true, - // text: t('rpc.rococo.plasm', 'Plasm PC1', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stake Technologies' } }), - // value: 'wss://rpc.parachain.plasmnet.io' - // }, - // { - // info: 'rococoRobonomics', - // isChild: true, - // text: t('rpc.rococo.robonomics', 'Robonomics PC1', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Airalab' } }), - // value: 'wss://parachain-rpc.robonomics.network' - // }, - // { - // info: 'rococoLaminar', - // isChild: true, - // text: t('rpc.rococo.laminar', 'Turbulence PC1', { ns: 'apps-config' }), - // textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Laminar' } }), - // value: 'wss://rococo-1.laminar-chain.laminar.one' - // }, - // alphabetical based on chain name - { - info: 'centrifuge', - text: t('rpc.amber', 'Amber', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Centrifuge' } }), - value: 'wss://fullnode.amber.centrifuge.io' - }, - { - info: 'nodle', - text: t('rpc.nodle-arcadia', 'Arcadia', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Nodle' } }), - value: 'wss://arcadia1.nodleprotocol.io' - }, - { - info: 'edgeware', - text: t('rpc.beresheet', 'Beresheet', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Commonwealth Labs' } }), - value: 'wss://beresheet1.edgewa.re' - }, - { - info: 'bifrost', - text: t('rpc.bifrost', 'Bifrost Asgard', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Bifrost' } }), - value: 'wss://testnet.liebi.com' - }, - { - info: 'canvas', - text: t('rpc.canvas', 'Canvas', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - value: 'wss://canvas-rpc.parity.io' - }, - { - info: 'crust', - text: t('rpc.crust.network', 'Crust Maxwell CC2', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Crust Network' } }), - value: 'wss://api.crust.network/' - }, - { - info: 'datahighway', - isDisabled: true, - text: t('rpc.datahighway.harbour', 'Harbour', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'MXC' } }), - value: 'wss://testnet-harbour.datahighway.com' - }, - { - info: 'dock-testnet', - text: t('rpc.dock-testnet', 'Dock Testnet', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Dock Association' } }), - value: 'wss://danforth-1.dock.io' - }, - { - info: 'dusty', - text: t('rpc.dusty', 'Dusty', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Stake Technologies' } }), - value: 'wss://rpc.dusty.plasmnet.io/' - }, - { - info: 'equilibrium', - text: t('rpc.equilibriumtestnet', 'Equilibrium Testnet', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Equilibrium' } }), - value: 'wss://api.mvp.testnet.equilibrium.io' - }, - { - info: 'substrate', - text: t('rpc.flamingfir', 'Flaming Fir', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - value: 'wss://substrate-rpc.parity.io' - }, - { - info: 'acala', - text: t('rpc.mandala', 'Mandala', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Acala' } }), - value: 'wss://node-6714447553211260928.rz.onfinality.io/ws' - }, - { - info: 'kilt', - text: t('rpc.kilt', 'Mashnet', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'KILT Protocol' } }), - value: 'wss://full-nodes.kilt.io:9944/' - }, - { - info: 'moonbaseAlpha', - text: t('rpc.moonbeam', 'Moonbase Alpha', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Moonbeam Network' } }), - value: 'wss://wss.testnet.moonbeam.network' - }, - { - info: 'phala', - text: t('rpc.phala', 'Phala PoC-3', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Phala Network' } }), - value: 'wss://poc3.phala.network/ws' - }, - { - info: 'laminar', - text: t('rpc.turbulence', 'Turbulence', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Laminar' } }), - value: 'wss://testnet-node-1.laminar-chain.laminar.one/ws' - }, - { - info: 'sora-substrate', - text: t('rpc.sora-substrate', 'SORA-Substrate', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Soramitsu' } }), - value: 'wss://ws.stage.sora2.soramitsu.co.jp' - }, - { - dnslink: 'westend', - info: 'westend', - text: t('rpc.westend', 'Westend', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Parity' } }), - value: 'wss://westend-rpc.polkadot.io' - }, - { - dnslink: 'galois', - info: 'galois', - text: t('rpc.galois', 'Galois', { ns: 'apps-config' }), - textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'MathWallet ' } }), - value: 'wss://galois.maiziqianbao.net/ws' - } - ]; -} - -function createCustom (t: TFunction): LinkOption[] { - const WS_URL = ( - (typeof process !== 'undefined' ? process.env?.WS_URL : undefined) || - (typeof window !== 'undefined' ? (window as EnvWindow).process_env?.WS_URL : undefined) - ); - - return WS_URL - ? [ - { - isHeader: true, - text: t('rpc.custom', 'Custom environment', { ns: 'apps-config' }), - textBy: '', - value: '' - }, - { - info: 'WS_URL', - text: t('rpc.custom.entry', 'Custom {{WS_URL}}', { ns: 'apps-config', replace: { WS_URL } }), - textBy: WS_URL, - value: WS_URL - } - ] - : []; -} - -export function createWsEndpoints (t: TFunction): LinkOption[] { - return [ - ...createCustom(t), - { - isHeader: true, - text: t('rpc.header.live', 'Live networks', { ns: 'apps-config' }), - textBy: '', - value: '' - }, - ...createLiveNetworks(t), - { - isHeader: true, - text: t('rpc.header.test', 'Test networks', { ns: 'apps-config' }), - textBy: '', - value: '' - }, - ...createTestNetworks(t), - { - isDevelopment: true, - isHeader: true, - text: t('rpc.header.dev', 'Development', { ns: 'apps-config' }), - textBy: '', - value: '' - }, - ...createDev(t), - ...createOwn(t) - ].filter(({ isDisabled }) => !isDisabled); -} diff --git a/packages/apps-config/src/settings/index.ts b/packages/apps-config/src/settings/index.ts index 1895a8be89..14cbdb4a73 100644 --- a/packages/apps-config/src/settings/index.ts +++ b/packages/apps-config/src/settings/index.ts @@ -1,8 +1,6 @@ // Copyright 2017-2020 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -export * from './constants'; -export * from './endpoints'; export * from './ethereumNetworks'; export * from './languages'; export * from './ss58';