|
1 | 1 | 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' |
5 | 5 | 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' |
6 | 8 |
|
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 | +// ) |
14 | 16 |
|
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 | +// ) |
18 | 32 |
|
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)) |
25 | 40 |
|
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 | + ), |
31 | 54 | ) |
32 | 55 |
|
33 | | -export const polkadotClient = createClient(getSmProvider(dotRelayChain)) |
34 | 56 | 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 | + ), |
36 | 66 | ) |
37 | | -export const peopleClient = createClient(getSmProvider(peopleParaChain)) |
38 | 67 |
|
39 | 68 | // API stuff |
40 | 69 | export const api: TypedApi<typeof collectives> = |
|
0 commit comments