Skip to content

Commit d581aef

Browse files
authored
Merge pull request #858 from polkadot-fellows/replace-smoldot-with-rpc
replace smoldot with WSS
2 parents 4df3dbe + 6592d0f commit d581aef

File tree

8 files changed

+94
-56
lines changed

8 files changed

+94
-56
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- uses: pnpm/action-setup@v4
13-
- uses: actions/setup-node@v4
13+
- uses: actions/setup-node@v5
1414
with:
15-
node-version: 21
15+
node-version: 22
1616
cache: 'pnpm'
1717
- run: pnpm install
1818
- run: pnpm build

.github/workflows/gh-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- uses: pnpm/action-setup@v4
13-
- uses: actions/setup-node@v4
13+
- uses: actions/setup-node@v5
1414
with:
15-
node-version: 18
15+
node-version: 22
1616
registry-url: https://registry.npmjs.org
1717
- run: pnpm install
1818
- name: Build

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- uses: pnpm/action-setup@v4
13-
- uses: actions/setup-node@v4
13+
- uses: actions/setup-node@v5
1414
with:
15-
node-version: 21
15+
node-version: 22
1616
cache: 'pnpm'
1717
- run: pnpm install
1818
- run: pnpm run lint

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v21.7.3
1+
v22

src/Content.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { Rfc } from '@/pages/Rfc'
1010
import { Salary } from '@/pages/Salary'
1111
import { Member } from '@/pages/Member'
1212

13-
import { useEffect, useState } from 'react'
14-
import { collectiveClient } from '@/clients'
15-
import { toast } from 'sonner'
13+
import { useState } from 'react'
14+
// import { collectiveClient } from '@/clients'
15+
// import { toast } from 'sonner'
1616
import { MainLayout } from './components/MainLayout'
1717

1818
const pages = (lcStatus: boolean) => [
@@ -59,19 +59,22 @@ const pages = (lcStatus: boolean) => [
5959
]
6060

6161
export const Content = () => {
62-
const [lightClientLoaded, setLightClientLoaded] = useState<boolean>(false)
62+
const [
63+
lightClientLoaded,
64+
//setLightClientLoaded
65+
] = useState<boolean>(false)
6366

64-
useEffect(() => {
65-
collectiveClient.finalizedBlock$.subscribe((finalizedBlock) => {
66-
if (finalizedBlock.number && !lightClientLoaded) {
67-
setLightClientLoaded(true)
68-
}
69-
})
70-
}, [lightClientLoaded])
67+
// useEffect(() => {
68+
// collectiveClient.finalizedBlock$.subscribe((finalizedBlock) => {
69+
// if (finalizedBlock.number && !lightClientLoaded) {
70+
// setLightClientLoaded(true)
71+
// }
72+
// })
73+
// }, [lightClientLoaded])
7174

72-
useEffect(() => {
73-
lightClientLoaded && toast.success('Light client: Synced')
74-
}, [lightClientLoaded])
75+
// useEffect(() => {
76+
// lightClientLoaded && toast.success('Light client: Synced')
77+
// }, [lightClientLoaded])
7578

7679
return (
7780
<MainLayout>

src/clients.tsx

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,69 @@
11
import { TypedApi, createClient } from 'polkadot-api'
2-
import { getSmProvider } from 'polkadot-api/sm-provider'
3-
import SmWorker from 'polkadot-api/smoldot/worker?worker'
4-
import { startFromWorker } from 'polkadot-api/smoldot/from-worker'
2+
// import { getSmProvider } from 'polkadot-api/sm-provider'
3+
// import SmWorker from 'polkadot-api/smoldot/worker?worker'
4+
// import { startFromWorker } from 'polkadot-api/smoldot/from-worker'
55
import { dot, collectives, people } from '@polkadot-api/descriptors'
6+
import { getWsProvider } from 'polkadot-api/ws-provider'
7+
import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat'
68

7-
const smoldot = startFromWorker(
8-
new SmWorker() /*, {maxLogLevel: 9,
9-
logCallback: (level: number, target: string, message: string) => {
10-
messages.push(`${getTickDate()} (${level})${target}\n${message}\n\n`)
11-
},
12-
}*/,
13-
)
9+
// const smoldot = startFromWorker(
10+
// new SmWorker() /*, {maxLogLevel: 9,
11+
// logCallback: (level: number, target: string, message: string) => {
12+
// messages.push(`${getTickDate()} (${level})${target}\n${message}\n\n`)
13+
// },
14+
// }*/,
15+
// )
1416

15-
const dotRelayChain = import('polkadot-api/chains/polkadot').then(
16-
({ chainSpec }) => smoldot.addChain({ chainSpec }),
17-
)
17+
// const dotRelayChain = import('polkadot-api/chains/polkadot').then(
18+
// ({ chainSpec }) => smoldot.addChain({ chainSpec }),
19+
// )
20+
// const collectivesParaChain = Promise.all([
21+
// dotRelayChain,
22+
// import('polkadot-api/chains/polkadot_collectives'),
23+
// ]).then(([relayChain, { chainSpec }]) =>
24+
// smoldot.addChain({ chainSpec, potentialRelayChains: [relayChain] }),
25+
// )
26+
// const peopleParaChain = Promise.all([
27+
// dotRelayChain,
28+
// import('polkadot-api/chains/polkadot_people'),
29+
// ]).then(([relayChain, { chainSpec }]) =>
30+
// smoldot.addChain({ chainSpec, potentialRelayChains: [relayChain] }),
31+
// )
1832

19-
const collectivesParaChain = Promise.all([
20-
dotRelayChain,
21-
import('polkadot-api/chains/polkadot_collectives'),
22-
]).then(([relayChain, { chainSpec }]) =>
23-
smoldot.addChain({ chainSpec, potentialRelayChains: [relayChain] }),
24-
)
33+
// export const polkadotClient = createClient(
34+
// getSmProvider(dotRelayChain),
35+
// )
36+
// export const collectiveClient = createClient(
37+
// getSmProvider(collectivesParaChain),
38+
// )
39+
// export const peopleClient = createClient(getSmProvider(peopleParaChain))
2540

26-
const peopleParaChain = Promise.all([
27-
dotRelayChain,
28-
import('polkadot-api/chains/polkadot_people'),
29-
]).then(([relayChain, { chainSpec }]) =>
30-
smoldot.addChain({ chainSpec, potentialRelayChains: [relayChain] }),
41+
export const polkadotClient = createClient(
42+
withPolkadotSdkCompat(
43+
getWsProvider([
44+
'wss://polkadot-public-rpc.blockops.network/ws',
45+
'wss://polkadot-rpc.dwellir.com',
46+
'wss://polkadot.api.onfinality.io/public-ws',
47+
'wss://rpc.ibp.network/polkadot',
48+
'wss://polkadot.dotters.network',
49+
'wss://polkadot.public.curie.radiumblock.co/ws',
50+
'wss://rpc-polkadot.luckyfriday.io',
51+
'wss://dot-rpc.stakeworld.io',
52+
]),
53+
),
3154
)
3255

33-
export const polkadotClient = createClient(getSmProvider(dotRelayChain))
3456
export const collectiveClient = createClient(
35-
getSmProvider(collectivesParaChain),
57+
withPolkadotSdkCompat(
58+
getWsProvider(['wss://polkadot-collectives-rpc.polkadot.io']),
59+
),
60+
)
61+
62+
export const peopleClient = createClient(
63+
withPolkadotSdkCompat(
64+
getWsProvider(['wss://polkadot-people-rpc.polkadot.io']),
65+
),
3666
)
37-
export const peopleClient = createClient(getSmProvider(peopleParaChain))
3867

3968
// API stuff
4069
export const api: TypedApi<typeof collectives> =

src/header.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import { RouterType, openInNewTab, resources, routes } from '@/lib/utils'
1010

1111
import { PanelLeft, Moon, Sun, NotebookText, BookOpenText } from 'lucide-react'
1212
import { getLinks } from './Resources'
13-
import { FaCheckCircle, FaGithub } from 'react-icons/fa'
14-
import { TbLoaderQuarter } from 'react-icons/tb'
13+
import {
14+
// FaCheckCircle,
15+
FaGithub,
16+
} from 'react-icons/fa'
17+
// import { TbLoaderQuarter } from 'react-icons/tb'
1518
import { useTheme } from './components/theme-provider'
1619
import { useEffect, useState } from 'react'
1720
import { collectiveClient } from './clients'
@@ -185,7 +188,7 @@ export const Header = ({ lightClientLoaded, setLightClientLoaded }: Props) => {
185188
</Accordion>
186189
</nav>
187190
<nav className="fixed bottom-16 flex flex-col gap-4">
188-
<a
191+
{/* <a
189192
href="#"
190193
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
191194
>
@@ -195,7 +198,7 @@ export const Header = ({ lightClientLoaded, setLightClientLoaded }: Props) => {
195198
<FaCheckCircle className="text-[#00b300]" />
196199
)}
197200
Light Client {!lightClientLoaded ? `syncing` : `synced`}
198-
</a>
201+
</a> */}
199202
<a
200203
href="#"
201204
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"

src/navigation.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import {
77
import { RouterType, routes } from '@/lib/utils'
88
import { Link, useLocation } from 'react-router-dom'
99
import PolkadotIcon from '@/assets/img/polkadotIcon.svg?react'
10-
import { FaCheckCircle, FaGithub } from 'react-icons/fa'
11-
import { TbLoaderQuarter } from 'react-icons/tb'
10+
import {
11+
// FaCheckCircle,
12+
FaGithub,
13+
} from 'react-icons/fa'
14+
// import { TbLoaderQuarter } from 'react-icons/tb'
1215

1316
import { BookOpenText, Moon, Sun } from 'lucide-react'
1417
import { Button } from '@/components/ui/button'
@@ -172,7 +175,7 @@ export const Navigation = ({
172175
</TooltipTrigger>
173176
<TooltipContent side="top">Toggle theme</TooltipContent>
174177
</Tooltip>
175-
<Tooltip>
178+
{/* <Tooltip>
176179
<TooltipTrigger asChild>
177180
<a
178181
href="#"
@@ -191,7 +194,7 @@ export const Navigation = ({
191194
<TooltipContent side="top">
192195
Light Client {!lightClientLoaded ? `syncing` : `synced`}
193196
</TooltipContent>
194-
</Tooltip>
197+
</Tooltip> */}
195198
</nav>
196199
<div className="flex flex-col items-center px-2 pb-5 text-sm font-bold text-primary">
197200
<span>Polkadot Technical Fellowship</span>

0 commit comments

Comments
 (0)