Skip to content

Commit 3bc9140

Browse files
fix cases where metadata service needs to be undefined
1 parent e711edf commit 3bc9140

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/sdk/src/create.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { enrTree, wakuDnsDiscovery } from "@waku/dns-discovery";
1717
import type {
1818
CreateLibp2pOptions,
1919
FullNode,
20+
IMetadata,
2021
Libp2p,
2122
Libp2pComponents,
2223
LightNode,
@@ -174,6 +175,10 @@ type PubsubService = {
174175
pubsub?: (components: Libp2pComponents) => GossipSub;
175176
};
176177

178+
type MetadataService = {
179+
metadata?: (components: Libp2pComponents) => IMetadata;
180+
};
181+
177182
export async function defaultLibp2p(
178183
shardInfo?: ShardInfo,
179184
wakuGossipSub?: PubsubService["pubsub"],
@@ -197,7 +202,9 @@ export async function defaultLibp2p(
197202
? { pubsub: wakuGossipSub }
198203
: {};
199204

200-
const metadataService = shardInfo && wakuMetadata(shardInfo);
205+
const metadataService: MetadataService = shardInfo
206+
? { metadata: wakuMetadata(shardInfo) }
207+
: {};
201208

202209
return createLibp2p({
203210
connectionManager: {
@@ -212,7 +219,7 @@ export async function defaultLibp2p(
212219
agentVersion: userAgent ?? DefaultUserAgent
213220
}),
214221
ping: pingService(),
215-
metadata: metadataService,
222+
...metadataService,
216223
...pubsubService,
217224
...options?.services
218225
}

0 commit comments

Comments
 (0)