From ec062889cc66321cee69c0e9904ce9810587a303 Mon Sep 17 00:00:00 2001 From: ical10 Date: Fri, 20 Oct 2023 15:11:41 +0700 Subject: [PATCH 1/3] feat: Add support for all ink!-compatible chains --- src/chains.ts | 151 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 1 deletion(-) diff --git a/src/chains.ts b/src/chains.ts index b1747e1..530aab6 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -74,6 +74,91 @@ export const shibuya: SubstrateChain = { faucetUrls: ['https://portal.astar.network/#/shibuya-testnet/assets'], } +export const t0rn: SubstrateChain = { + network: 't0rn', + name: 'T0rn Testnet', + ss58Prefix: 42, + rpcUrls: ['wss://ws.t0rn.io'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://ws.t0rn.io', + )}/#/explorer`, + }, + testnet: true, + faucetUrls: ['https://faucet.t0rn.io'], +} + +export const bitCountryAlphaTestnet: SubstrateChain = { + network: 'bitcountry-alpha-testnet', + name: 'Bit.Country Alpha Testnet', + ss58Prefix: 268, + rpcUrls: ['wss://alphanet-rpc-gcp.bit.country'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://alphanet-rpc-gcp.bit.country', + )}#/explorer`, + }, + testnet: true, + faucetUrls: ['https://testnet.bit.country/p/wallet/balance'], +} + +export const agungTestnet: SubstrateChain = { + network: 'agung-testnet', + name: 'Agung Testnet (Peaq Network)', + ss58Prefix: 42, + rpcUrls: ['wss://wss.agung.peaq.network'], + explorerUrls: { + [SubstrateExplorer.Subscan]: `https://agung-testnet.subscan.io/`, + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://wss.agung.peaq.network', + )}/#/explorer`, + }, + testnet: true, + faucetUrls: ['https://discord.com/channels/943486047625572392/963415793394143232'], +} + +export const rococoAmplitudeTestnet: SubstrateChain = { + network: 'rococo-amplitude-testnet', + name: 'Amplitude Testnet (Foucoco)', + ss58Prefix: 57, + rpcUrls: ['wss://pencol-roc-00.pendulumchain.tech'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://pencol-roc-00.pendulumchain.tech', + )}/#/explorer`, + }, + testnet: true, + faucetUrls: [], +} + +export const phalaPOC5Testnet: SubstrateChain = { + network: 'phala-PoC-5-testnet', + name: 'Phala PoC-5 Testnet', + ss58Prefix: 30, + rpcUrls: ['wss://poc5.phala.network'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://poc5.phala.network/ws', + )}#/explorer`, + }, + testnet: true, + faucetUrls: [], +} + +export const phalaPOC6Testnet: SubstrateChain = { + network: 'phala-PoC-6-testnet', + name: 'Phala PoC-6 Testnet', + ss58Prefix: 30, + rpcUrls: ['wss://poc6.phala.network'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://poc6.phala.network/ws', + )}#/explorer`, + }, + testnet: true, + faucetUrls: [], +} + /// Canary Networks (Kusama) export const shiden: SubstrateChain = { @@ -86,6 +171,36 @@ export const shiden: SubstrateChain = { }, } +export const amplitude: SubstrateChain = { + network: 'amplitude', + name: 'Amplitude', + ss58Prefix: 57, + rpcUrls: ['wss://rpc-amplitude.pendulumchain.tech', 'wss://amplitude-rpc.dwellir.com'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://rpc-amplitude.pendulumchain.tech', + )}#/explorer`, + }, +} + +export const khala: SubstrateChain = { + network: 'khala', + name: 'Khala', + ss58Prefix: 30, + rpcUrls: [ + 'wss://khala-api.phala.network/ws', + 'wss://khala.api.onfinality.io/public-ws', + 'wss://khala-rpc.dwellir.com', + 'wss://public-rpc.pinknode.io/khala', + ], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://khala-api.phala.network/ws', + )}#/explorer`, + [SubstrateExplorer.Subscan]: `https://khala.subscan.io`, + }, +} + /// Mainnets export const alephzero: SubstrateChain = { @@ -109,7 +224,31 @@ export const astar: SubstrateChain = { explorerUrls: { [SubstrateExplorer.Subscan]: `https://astar.subscan.io`, }, - faucetUrls: [], +} + +export const pendulum: SubstrateChain = { + network: 'pendulum', + name: 'Pendulum', + ss58Prefix: 56, + rpcUrls: ['wss://rpc-pendulum.prd.pendulumchain.tech', 'wss://pendulum-rpc.dwellir.com'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://rpc-pendulum.prd.pendulumchain.tech', + )}#/explorer`, + }, +} + +export const phala: SubstrateChain = { + network: 'phala', + name: 'Phala', + ss58Prefix: 30, + rpcUrls: ['wss://api.phala.network/ws', 'wss://phala.api.onfinality.io/public-ws'], + explorerUrls: { + [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( + 'wss://api.phala.network/ws', + )}#/explorer`, + [SubstrateExplorer.Subscan]: `https://phala.subscan.io`, + }, } /** @@ -119,10 +258,20 @@ export const allSubstrateChains: SubstrateChain[] = [ development, alephzeroTestnet, rococo, + t0rn, + bitCountryAlphaTestnet, + agungTestnet, + rococoAmplitudeTestnet, + phalaPOC5Testnet, + phalaPOC6Testnet, shibuya, shiden, + amplitude, + khala, alephzero, astar, + pendulum, + phala, ] /** From a8e633d95329d7b9661e0fa7f6e9a8154c020e5d Mon Sep 17 00:00:00 2001 From: ical10 Date: Fri, 20 Oct 2023 19:32:40 +0700 Subject: [PATCH 2/3] docs(changeset): Added native support for more !ink compatible testnets (t0rn, Bit.Country, Peaq, Pendulum, Phala) and mainnets (Khala, Phala, Amplitude, Pendulum) --- .changeset/shiny-panthers-fold.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/shiny-panthers-fold.md diff --git a/.changeset/shiny-panthers-fold.md b/.changeset/shiny-panthers-fold.md new file mode 100644 index 0000000..7fe6d40 --- /dev/null +++ b/.changeset/shiny-panthers-fold.md @@ -0,0 +1,5 @@ +--- +'@scio-labs/use-inkathon': minor +--- + +Added native support for more !ink compatible testnets (t0rn, Bit.Country, Peaq, Pendulum, Phala) and mainnets (Khala, Phala, Amplitude, Pendulum) From a69c6251e1435b648372477beb2b08ece1ce20e5 Mon Sep 17 00:00:00 2001 From: Dennis Zoma Date: Sun, 22 Oct 2023 00:27:52 +0200 Subject: [PATCH 3/3] feat: Minor chain improvements/fixes --- src/chains.ts | 67 ++++++++----------------- src/helpers/initPolkadotJs.ts | 2 +- src/provider.tsx | 5 +- src/types/SubstrateChain.ts | 17 +++++++ src/types/UseInkathonProviderContext.ts | 2 +- src/types/index.ts | 1 + 6 files changed, 44 insertions(+), 50 deletions(-) create mode 100644 src/types/SubstrateChain.ts diff --git a/src/chains.ts b/src/chains.ts index 530aab6..b594475 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -1,26 +1,9 @@ -/** - * Substrate Chain Type - */ -export interface SubstrateChain { - network: string - name: string - rpcUrls: [string, ...string[]] - ss58Prefix?: number - explorerUrls?: Partial> - testnet?: boolean - faucetUrls?: string[] -} - -export enum SubstrateExplorer { - Subscan = 'subscan', - PolkadotJs = 'polkadotjs', -} +import { SubstrateChain, SubstrateExplorer } from '@/types' /** - * Defined Substrate Chain Constants + * Local Development Network */ -/// Local Development Network export const development: SubstrateChain = { network: 'development', name: 'Local Development', @@ -35,7 +18,9 @@ export const development: SubstrateChain = { faucetUrls: ['https://polkadot.js.org/apps/#/accounts?rpc=ws://127.0.0.1:9944'], } -/// Testnets +/** + * Live Testnets + */ export const alephzeroTestnet: SubstrateChain = { network: 'alephzero-testnet', @@ -53,7 +38,8 @@ export const alephzeroTestnet: SubstrateChain = { export const rococo: SubstrateChain = { network: 'rococo', - name: 'Rococo', + name: 'Rococo Contracts Testnet', + ss58Prefix: 42, rpcUrls: ['wss://rococo-contracts-rpc.polkadot.io'], explorerUrls: { [SubstrateExplorer.Subscan]: `https://rococo.subscan.io`, @@ -74,7 +60,7 @@ export const shibuya: SubstrateChain = { faucetUrls: ['https://portal.astar.network/#/shibuya-testnet/assets'], } -export const t0rn: SubstrateChain = { +export const t0rnTestnet: SubstrateChain = { network: 't0rn', name: 'T0rn Testnet', ss58Prefix: 42, @@ -104,7 +90,7 @@ export const bitCountryAlphaTestnet: SubstrateChain = { export const agungTestnet: SubstrateChain = { network: 'agung-testnet', - name: 'Agung Testnet (Peaq Network)', + name: 'Agung Testnet', ss58Prefix: 42, rpcUrls: ['wss://wss.agung.peaq.network'], explorerUrls: { @@ -117,9 +103,9 @@ export const agungTestnet: SubstrateChain = { faucetUrls: ['https://discord.com/channels/943486047625572392/963415793394143232'], } -export const rococoAmplitudeTestnet: SubstrateChain = { - network: 'rococo-amplitude-testnet', - name: 'Amplitude Testnet (Foucoco)', +export const amplitudeTestnet: SubstrateChain = { + network: 'amplitude-testnet', + name: 'Amplitude Testnet', ss58Prefix: 57, rpcUrls: ['wss://pencol-roc-00.pendulumchain.tech'], explorerUrls: { @@ -135,7 +121,7 @@ export const phalaPOC5Testnet: SubstrateChain = { network: 'phala-PoC-5-testnet', name: 'Phala PoC-5 Testnet', ss58Prefix: 30, - rpcUrls: ['wss://poc5.phala.network'], + rpcUrls: ['wss://poc5.phala.network/ws'], explorerUrls: { [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( 'wss://poc5.phala.network/ws', @@ -145,21 +131,9 @@ export const phalaPOC5Testnet: SubstrateChain = { faucetUrls: [], } -export const phalaPOC6Testnet: SubstrateChain = { - network: 'phala-PoC-6-testnet', - name: 'Phala PoC-6 Testnet', - ss58Prefix: 30, - rpcUrls: ['wss://poc6.phala.network'], - explorerUrls: { - [SubstrateExplorer.PolkadotJs]: `https://polkadot.js.org/apps/?rpc=${encodeURIComponent( - 'wss://poc6.phala.network/ws', - )}#/explorer`, - }, - testnet: true, - faucetUrls: [], -} - -/// Canary Networks (Kusama) +/** + * Live Canary Networks + */ export const shiden: SubstrateChain = { network: 'shiden', @@ -201,7 +175,9 @@ export const khala: SubstrateChain = { }, } -/// Mainnets +/** + * Live Mainnet Networks + */ export const alephzero: SubstrateChain = { network: 'alephzero', @@ -258,12 +234,11 @@ export const allSubstrateChains: SubstrateChain[] = [ development, alephzeroTestnet, rococo, - t0rn, + t0rnTestnet, bitCountryAlphaTestnet, agungTestnet, - rococoAmplitudeTestnet, + amplitudeTestnet, phalaPOC5Testnet, - phalaPOC6Testnet, shibuya, shiden, amplitude, diff --git a/src/helpers/initPolkadotJs.ts b/src/helpers/initPolkadotJs.ts index 33401d7..cc5e119 100644 --- a/src/helpers/initPolkadotJs.ts +++ b/src/helpers/initPolkadotJs.ts @@ -1,4 +1,4 @@ -import { SubstrateChain } from '@/chains' +import { SubstrateChain } from '@/types' import { ApiPromise, HttpProvider, WsProvider } from '@polkadot/api' import { ApiOptions } from '@polkadot/api/types' diff --git a/src/provider.tsx b/src/provider.tsx index ed5386a..44c32ef 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -1,6 +1,8 @@ import { accountArraysAreEqual, accountsAreEqual, initPolkadotJs } from '@/helpers' import { registerDeployments } from '@/registry' import { + SubstrateChain, + SubstrateDeployment, SubstrateWallet, UseInkathonError, UseInkathonErrorCode, @@ -18,8 +20,7 @@ import { ApiOptions } from '@polkadot/api/types' import { InjectedAccount, InjectedExtension, Unsubcall } from '@polkadot/extension-inject/types' import { Signer } from '@polkadot/types/types' import { FC, PropsWithChildren, createContext, useContext, useEffect, useState } from 'react' -import { SubstrateChain, getSubstrateChain } from './chains' -import { SubstrateDeployment } from './types/SubstrateDeployment' +import { getSubstrateChain } from './chains' const UseInkathonProviderContext = createContext(null) diff --git a/src/types/SubstrateChain.ts b/src/types/SubstrateChain.ts new file mode 100644 index 0000000..9e7d858 --- /dev/null +++ b/src/types/SubstrateChain.ts @@ -0,0 +1,17 @@ +/** + * Substrate Chain Type + */ +export interface SubstrateChain { + network: string + name: string + rpcUrls: [string, ...string[]] + ss58Prefix?: number + explorerUrls?: Partial> + testnet?: boolean + faucetUrls?: string[] +} + +export enum SubstrateExplorer { + Subscan = 'subscan', + PolkadotJs = 'polkadotjs', +} diff --git a/src/types/UseInkathonProviderContext.ts b/src/types/UseInkathonProviderContext.ts index 364eb15..684651b 100644 --- a/src/types/UseInkathonProviderContext.ts +++ b/src/types/UseInkathonProviderContext.ts @@ -1,9 +1,9 @@ import { SubstrateWallet } from '@/types' +import { SubstrateChain } from '@/types/SubstrateChain' import { ApiPromise, HttpProvider, WsProvider } from '@polkadot/api' import { InjectedAccount, InjectedExtension } from '@polkadot/extension-inject/types' import { Signer } from '@polkadot/types/types' import { Dispatch, SetStateAction } from 'react' -import { SubstrateChain } from '../chains' import { SubstrateDeployment } from './SubstrateDeployment' export type UseInkathonProviderContextType = { diff --git a/src/types/index.ts b/src/types/index.ts index 5cf1d7e..d4296d7 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,5 +1,6 @@ // @index('./*.ts', f => `export * from '${f.path}'`) export * from './ChainAsset' +export * from './SubstrateChain' export * from './SubstrateDeployment' export * from './SubstrateWallet' export * from './UseInkathonProviderContext'