diff --git a/apps/docs/docs/getting-started/setup.mdx b/apps/docs/docs/getting-started/setup.mdx index db7110d9..af4e9d87 100644 --- a/apps/docs/docs/getting-started/setup.mdx +++ b/apps/docs/docs/getting-started/setup.mdx @@ -72,14 +72,17 @@ import { chainSpec } from "polkadot-api/chains/polkadot"; import { getSmProvider } from "polkadot-api/sm-provider"; import { startFromWorker } from "polkadot-api/smoldot/from-worker"; -const smoldot = startFromWorker(new SmWorker()); -const chain = smoldot.addChain({ chainSpec }); +const smoldot = startFromWorker( + new Worker(new URL("polkadot-api/smoldot/worker", import.meta.url), { + type: "module", + }), +); const config: Config = { chains: { polkadot: { descriptor: polkadot, - provider: getSmProvider(chain), + provider: getSmProvider(smoldot.addChain({ chainSpec })), }, }, wallets: [new InjectedConnector()], diff --git a/apps/example/src/config.ts b/apps/example/src/config.ts index e33bccee..1353050c 100644 --- a/apps/example/src/config.ts +++ b/apps/example/src/config.ts @@ -4,10 +4,11 @@ import type { Config } from "@reactive-dot/types"; import { getSmProvider } from "polkadot-api/sm-provider"; import { startFromWorker } from "polkadot-api/smoldot/from-worker"; -const createSmoldotWorker = () => +const smoldotPromise = startFromWorker( new Worker(new URL("polkadot-api/smoldot/worker", import.meta.url), { type: "module", - }); + }), +); const config: Config = { chains: { @@ -15,7 +16,7 @@ const config: Config = { descriptor: polkadot, provider: getSmProvider( import("polkadot-api/chains/polkadot").then(({ chainSpec }) => - startFromWorker(createSmoldotWorker()).addChain({ chainSpec }), + smoldotPromise.addChain({ chainSpec }), ), ), }, @@ -23,7 +24,7 @@ const config: Config = { descriptor: kusama, provider: getSmProvider( import("polkadot-api/chains/ksmcc3").then(({ chainSpec }) => - startFromWorker(createSmoldotWorker()).addChain({ chainSpec }), + smoldotPromise.addChain({ chainSpec }), ), ), }, @@ -31,7 +32,7 @@ const config: Config = { descriptor: westend, provider: getSmProvider( import("polkadot-api/chains/westend2").then(({ chainSpec }) => - startFromWorker(createSmoldotWorker()).addChain({ chainSpec }), + smoldotPromise.addChain({ chainSpec }), ), ), },