mirror of
https://github.com/logos-messaging/docs.waku.org.git
synced 2026-01-03 21:33:05 +00:00
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";(self.webpackChunkwaku_guide=self.webpackChunkwaku_guide||[]).push([[1651],{28453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>a});var r=i(96540);const t={},o=r.createContext(t);function s(e){const n=r.useContext(o);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:s(e.components),r.createElement(o.Provider,{value:n},e.children)}},42227:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>s,metadata:()=>r,toc:()=>d});const r=JSON.parse('{"id":"migrations/js-waku/migration_v0.026_0.027","title":"Migrating to Waku v0.027","description":"A migration guide for refactoring your application code from Waku v0.026 to v0.027.","source":"@site/docs/migrations/js-waku/migration_v0.026_0.027.md","sourceDirName":"migrations/js-waku","slug":"/migrations/js-waku/migration_v0.026_0.027","permalink":"/migrations/js-waku/migration_v0.026_0.027","draft":false,"unlisted":false,"editUrl":"https://github.com/waku-org/docs.waku.org/tree/develop/docs/migrations/js-waku/migration_v0.026_0.027.md","tags":[],"version":"current","lastUpdatedAt":null,"frontMatter":{}}');var t=i(74848),o=i(28453);const s={},a="Migrating to Waku v0.027",c={},d=[{value:"Table of Contents",id:"table-of-contents",level:2},{value:"Network Configuration",id:"network-configuration",level:2},{value:"Default Network Configuration",id:"default-network-configuration",level:3},{value:"Static Sharding",id:"static-sharding",level:3},{value:"Auto Sharding",id:"auto-sharding",level:3},{value:"Pubsub Topic Configuration",id:"pubsub-topic-configuration",level:2},{value:"Removed APIs",id:"removed-apis",level:2},{value:"Type Changes",id:"type-changes",level:2},{value:"Internal/Private Utility Function Changes",id:"internalprivate-utility-function-changes",level:2}];function l(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"migrating-to-waku-v0027",children:"Migrating to Waku v0.027"})}),"\n",(0,t.jsx)(n.p,{children:"A migration guide for refactoring your application code from Waku v0.026 to v0.027."}),"\n",(0,t.jsx)(n.h2,{id:"table-of-contents",children:"Table of Contents"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"#migrating-to-waku-v0027",children:"Migrating to Waku v0.027"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#table-of-contents",children:"Table of Contents"})}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.a,{href:"#network-configuration",children:"Network Configuration"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#default-network-configuration",children:"Default Network Configuration"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#static-sharding",children:"Static Sharding"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#auto-sharding",children:"Auto Sharding"})}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#pubsub-topic-configuration",children:"Pubsub Topic Configuration"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#removed-apis",children:"Removed APIs"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#type-changes",children:"Type Changes"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"#internalprivate-utility-function-changes",children:"Internal/Private Utility Function Changes"})}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"network-configuration",children:"Network Configuration"}),"\n",(0,t.jsx)(n.p,{children:"The way to configure network settings for a Waku node has been simplified. The new NetworkConfig type only allows for Static Sharding or Auto Sharding."}),"\n",(0,t.jsx)(n.h3,{id:"default-network-configuration",children:"Default Network Configuration"}),"\n",(0,t.jsx)(n.p,{children:"If no network configuration is provided when creating a Light Node, The Waku Network configuration will be used by default."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Before"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode();\n// This would use the default pubsub topic, that was, `/waku/2/default-waku/proto`\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"After"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode();\n// This will now use The Waku Network configuration by default:\n// { clusterId: 1, shards: [0,1,2,3,4,5,6,7] }\n'})}),"\n",(0,t.jsx)(n.h3,{id:"static-sharding",children:"Static Sharding"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Before"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n shardInfo: {\n clusterId: 1,\n shards: [0, 1, 2, 3]\n }\n});\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"After"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n networkConfig: {\n clusterId: 1,\n shards: [0, 1, 2, 3]\n }\n});\n'})}),"\n",(0,t.jsx)(n.h3,{id:"auto-sharding",children:"Auto Sharding"}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Before"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n shardInfo: {\n clusterId: 1,\n contentTopics: ["/my-app/1/notifications/proto"]\n }\n});\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"After"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n networkConfig: {\n clusterId: 1,\n contentTopics: ["/my-app/1/notifications/proto"]\n }\n});\n'})}),"\n",(0,t.jsx)(n.h2,{id:"pubsub-topic-configuration",children:"Pubsub Topic Configuration"}),"\n",(0,t.jsx)(n.p,{children:"Named pubsub topics are no longer supported. You must use either Static Sharding or Auto Sharding to configure pubsub topics."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Before"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n pubsubTopics: ["/waku/2/default-waku/proto"]\n});\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"After"})}),"\n",(0,t.jsx)(n.p,{children:"Use Static Sharding:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n networkConfig: {\n clusterId: 1,\n shards: [0, 1, 2, 3, 4, 5, 6, 7]\n }\n});\n'})}),"\n",(0,t.jsx)(n.p,{children:"Or use Auto Sharding:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n networkConfig: {\n clusterId: 1,\n contentTopics: ["/your-app/1/default/proto"]\n }\n});\n'})}),"\n",(0,t.jsx)(n.h2,{id:"removed-apis",children:"Removed APIs"}),"\n",(0,t.jsx)(n.p,{children:"The following APIs have been removed:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["ApplicationInfo type: Use ",(0,t.jsx)(n.code,{children:"string"})," for application and version in ",(0,t.jsx)(n.code,{children:"NetworkConfig"})," instead."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"shardInfo"})," option in ",(0,t.jsx)(n.code,{children:"createLightNode"}),": Use ",(0,t.jsx)(n.code,{children:"networkConfig"})," instead."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"pubsubTopics"})," option in ",(0,t.jsx)(n.code,{children:"createLightNode"}),": Use ",(0,t.jsx)(n.code,{children:"networkConfig"})," with Static Sharding or Auto Sharding instead."]}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["If you were using ",(0,t.jsx)(n.code,{children:"ApplicationInfo"})," before, you should now use ",(0,t.jsx)(n.code,{children:"ContentTopicInfo"})," (Auto Sharding) and specify your application and version in the content topic ",(0,t.jsx)(n.code,{children:"string"}),"."]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Before"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n shardInfo: {\n clusterId: 1,\n application: "my-app",\n version: "1"\n }\n});\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"After"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { createLightNode } from "@waku/sdk";\n\nconst waku = await createLightNode({\n networkConfig: {\n clusterId: 1,\n contentTopics: ["/my-app/1/default/proto"]\n }\n});\n'})}),"\n",(0,t.jsx)(n.h2,{id:"type-changes",children:"Type Changes"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"ShardingParams"})," has been removed. Use ",(0,t.jsx)(n.code,{children:"NetworkConfig"})," instead."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"NetworkConfig"})," is now defined as ",(0,t.jsx)(n.code,{children:"StaticSharding"})," | ",(0,t.jsx)(n.code,{children:"AutoSharding"}),"."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"StaticSharding"})," is equivalent to the previous ",(0,t.jsx)(n.code,{children:"ShardInfo"}),"."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"AutoSharding"})," is equivalent to the previous ",(0,t.jsx)(n.code,{children:"ContentTopicInfo"}),"."]}),"\n"]}),"\n",(0,t.jsx)(n.h2,{id:"internalprivate-utility-function-changes",children:"Internal/Private Utility Function Changes"}),"\n",(0,t.jsx)(n.p,{children:"Several utility functions have been updated or added:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"ensureShardingConfigured"})," has been removed. Use ",(0,t.jsx)(n.code,{children:"derivePubsubTopicsFromNetworkConfig"})," instead."]}),"\n",(0,t.jsxs)(n.li,{children:["New function ",(0,t.jsx)(n.code,{children:"derivePubsubTopicsFromNetworkConfig"})," has been added to derive pubsub topics from the network configuration."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"shardInfoToPubsubTopics"})," now accepts ",(0,t.jsx)(n.code,{children:"Partial<NetworkConfig>"})," instead of ",(0,t.jsx)(n.code,{children:"Partial<ShardingParams>"}),"."]}),"\n",(0,t.jsxs)(n.li,{children:["New function ",(0,t.jsx)(n.code,{children:"pubsubTopicsToShardInfo"})," has been added to convert pubsub topics to a ShardInfo object."]}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"If you were using any of these utility functions directly, you'll need to update your code accordingly."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Before"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { ensureShardingConfigured } from "@waku/utils";\n\nconst result = ensureShardingConfigured(shardInfo);\n'})}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"After"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-typescript",children:'import { derivePubsubTopicsFromNetworkConfig } from "@waku/utils";\n\nconst pubsubTopics = derivePubsubTopicsFromNetworkConfig(networkConfig);\n'})}),"\n",(0,t.jsxs)(n.p,{children:["Note: The default ",(0,t.jsx)(n.code,{children:"NetworkConfig"})," for The Waku Network is now ",(0,t.jsx)(n.code,{children:"{ clusterId: 1, shards: [0,1,2,3,4,5,6,7] }."})]})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(l,{...e})}):l(e)}}}]); |