endpoints.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Copyright 2017-2020 @polkadot/apps-config authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import { TFunction } from 'i18next';
  5. import { Option } from './types';
  6. interface LinkOption extends Option {
  7. dnslink?: string;
  8. }
  9. interface EnvWindow {
  10. // eslint-disable-next-line camelcase
  11. process_env?: {
  12. WS_URL: string;
  13. }
  14. }
  15. function createDev (t: TFunction): LinkOption[] {
  16. return [
  17. {
  18. dnslink: 'local',
  19. info: 'local',
  20. text: t<string>('rpc.local', 'Local Node (Own, 127.0.0.1:9944)', { ns: 'apps-config' }),
  21. value: 'ws://127.0.0.1:9944/'
  22. }
  23. ];
  24. }
  25. function createLive (t: TFunction): LinkOption[] {
  26. return [
  27. {
  28. dnslink: 'polkadot',
  29. info: 'polkadot',
  30. text: t<string>('rpc.polkadot.parity', 'Polkadot (Live, hosted by Parity)', { ns: 'apps-config' }),
  31. value: 'wss://rpc.polkadot.io'
  32. },
  33. {
  34. dnslink: 'polkadot',
  35. info: 'polkadot',
  36. text: t<string>('rpc.polkadot.w3f', 'Polkadot (Live, hosted by Web3 Foundation)', { ns: 'apps-config' }),
  37. value: 'wss://cc1-1.polkadot.network'
  38. },
  39. {
  40. dnslink: 'kusama',
  41. info: 'kusama',
  42. text: t<string>('rpc.kusama.parity', 'Kusama (Polkadot Canary, hosted by Parity)', { ns: 'apps-config' }),
  43. value: 'wss://kusama-rpc.polkadot.io/'
  44. },
  45. {
  46. dnslink: 'kusama',
  47. info: 'kusama',
  48. text: t<string>('rpc.kusama.w3f', 'Kusama (Polkadot Canary, hosted by Web3 Foundation)', { ns: 'apps-config' }),
  49. value: 'wss://cc3-5.kusama.network/'
  50. },
  51. {
  52. dnslink: 'kusama',
  53. info: 'kusama',
  54. text: t<string>('rpc.kusama.ava', 'Kusama (Polkadot Canary, user-run public nodes; see https://status.cloud.ava.do/)', { ns: 'apps-config' }),
  55. value: 'wss://kusama.polkadot.cloud.ava.do/'
  56. },
  57. {
  58. dnslink: 'centrifuge',
  59. info: 'centrifuge',
  60. text: t<string>('rpc.centrifuge', 'Centrifuge (Mainnet, hosted by Centrifuge)', { ns: 'apps-config' }),
  61. value: 'wss://fullnode.centrifuge.io'
  62. },
  63. {
  64. dnslink: 'edgeware',
  65. info: 'edgeware',
  66. text: t<string>('rpc.edgeware', 'Edgeware (Mainnet, hosted by Commonwealth Labs)', { ns: 'apps-config' }),
  67. value: 'wss://mainnet1.edgewa.re'
  68. },
  69. {
  70. dnslink: 'kulupu',
  71. info: 'substrate',
  72. text: t<string>('rpc.kulupu', 'Kulupu (Kulupu Mainnet, hosted by Kulupu)', { ns: 'apps-config' }),
  73. value: 'wss://rpc.kulupu.network/ws'
  74. }
  75. ];
  76. }
  77. function createTest (t: TFunction): LinkOption[] {
  78. return [
  79. {
  80. dnslink: 'westend',
  81. info: 'westend',
  82. text: t<string>('rpc.westend', 'Westend (Polkadot Testnet, hosted by Parity)', { ns: 'apps-config' }),
  83. value: 'wss://westend-rpc.polkadot.io'
  84. },
  85. {
  86. info: 'acala',
  87. text: t<string>('rpc.mandala', 'Mandala (Acala Testnet, hosted by Acala)', { ns: 'apps-config' }),
  88. value: 'wss://node-6684611762228215808.jm.onfinality.io/ws'
  89. },
  90. {
  91. info: 'edgeware',
  92. text: t<string>('rpc.berlin', 'Berlin (Edgeware Testnet, hosted by Commonwealth Labs)', { ns: 'apps-config' }),
  93. value: 'wss://berlin1.edgewa.re'
  94. },
  95. {
  96. info: 'substrate',
  97. text: t<string>('rpc.flamingfir', 'Flaming Fir (Substrate Testnet, hosted by Parity)', { ns: 'apps-config' }),
  98. value: 'wss://substrate-rpc.parity.io/'
  99. },
  100. {
  101. info: 'nodle',
  102. text: t<string>('rpc.arcadia', 'Arcadia (Nodle Testnet, hosted by Nodle)', { ns: 'apps-config' }),
  103. value: 'wss://arcadia1.nodleprotocol.io/'
  104. },
  105. {
  106. info: 'datahighway',
  107. isDisabled: true,
  108. text: t<string>('rpc.datahighway.harbour', 'Harbour (DataHighway Testnet, hosted by MXC)', { ns: 'apps-config' }),
  109. value: 'wss://testnet-harbour.datahighway.com'
  110. }
  111. ];
  112. }
  113. function createCustom (t: TFunction): LinkOption[] {
  114. const WS_URL = (
  115. (typeof process !== 'undefined' ? process.env?.WS_URL : undefined) ||
  116. (typeof window !== 'undefined' ? (window as EnvWindow).process_env?.WS_URL : undefined)
  117. );
  118. return WS_URL
  119. ? [
  120. {
  121. isHeader: true,
  122. text: t<string>('rpc.custom', 'Custom environment', { ns: 'apps-config' }),
  123. value: ''
  124. },
  125. {
  126. info: 'WS_URL',
  127. text: t<string>('rpc.custom.entry', 'Custom {{WS_URL}}', { ns: 'apps-config', replace: { WS_URL } }),
  128. value: WS_URL
  129. }
  130. ]
  131. : [];
  132. }
  133. // The available endpoints that will show in the dropdown. For the most part (with the exception of
  134. // Polkadot) we try to keep this to live chains only, with RPCs hosted by the community/chain vendor
  135. // info: The chain logo name as defined in ../logos, specifically in namedLogos
  136. // text: The text to display on teh dropdown
  137. // value: The actual hosted secure websocket endpoint
  138. export default function create (t: TFunction): LinkOption[] {
  139. return [
  140. ...createCustom(t),
  141. {
  142. isHeader: true,
  143. text: t<string>('rpc.header.live', 'Live networks', { ns: 'apps-config' }),
  144. value: ''
  145. },
  146. ...createLive(t),
  147. {
  148. isHeader: true,
  149. text: t<string>('rpc.header.test', 'Test networks', { ns: 'apps-config' }),
  150. value: ''
  151. },
  152. ...createTest(t),
  153. {
  154. isHeader: true,
  155. text: t<string>('rpc.header.dev', 'Development', { ns: 'apps-config' }),
  156. value: ''
  157. },
  158. ...createDev(t)
  159. ].filter(({ isDisabled }) => !isDisabled);
  160. }