Skip to content

Commit b3b7fe3

Browse files
committed
replace smoldot with WSS
1 parent 4df3dbe commit b3b7fe3

File tree

4 files changed

+82
-47
lines changed

4 files changed

+82
-47
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const Header = ({ lightClientLoaded, setLightClientLoaded }: Props) => {
185185
</Accordion>
186186
</nav>
187187
<nav className="fixed bottom-16 flex flex-col gap-4">
188-
<a
188+
{/* <a
189189
href="#"
190190
className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
191191
>
@@ -195,7 +195,7 @@ export const Header = ({ lightClientLoaded, setLightClientLoaded }: Props) => {
195195
<FaCheckCircle className="text-[#00b300]" />
196196
)}
197197
Light Client {!lightClientLoaded ? `syncing` : `synced`}
198-
</a>
198+
</a> */}
199199
<a
200200
href="#"
201201
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)