diff --git a/packages/interfaces/src/protocols.ts b/packages/interfaces/src/protocols.ts index 00d330152e..20cdcc77ee 100644 --- a/packages/interfaces/src/protocols.ts +++ b/packages/interfaces/src/protocols.ts @@ -24,17 +24,11 @@ export type NetworkConfig = StaticSharding | AutoSharding; export type ProtocolCreateOptions = { /** - * Configuration for determining the network in use. + * Set the user agent string to be used in identification of the node. * - * If using Static Sharding: - * Default value is configured for The Waku Network. - * The format to specify a shard is: clusterId: number, shards: number[] - * To learn more about the sharding specification, see [Relay Sharding](https://rfc.vac.dev/spec/51/). - * - * If using Auto Sharding: - * See [Waku v2 Topic Usage Recommendations](https://github.com/vacp2p/rfc-index/blob/main/waku/informational/23/topics.md#content-topics) for details. - * You cannot add or remove content topics after initialization of the node. + * @default "js-waku" */ + userAgent?: string; /** * Configuration for determining the network in use. diff --git a/packages/relay/src/create.ts b/packages/relay/src/create.ts index 448598162b..34e795b3f8 100644 --- a/packages/relay/src/create.ts +++ b/packages/relay/src/create.ts @@ -1,10 +1,5 @@ -import type { RelayNode } from "@waku/interfaces"; -import { - createLibp2pAndUpdateOptions, - CreateWakuNodeOptions, - WakuNode, - WakuOptions -} from "@waku/sdk"; +import type { ProtocolCreateOptions, RelayNode } from "@waku/interfaces"; +import { createLibp2pAndUpdateOptions, WakuNode } from "@waku/sdk"; import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "./relay.js"; @@ -19,7 +14,7 @@ import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "./relay.js"; * or use this function with caution. */ export async function createRelayNode( - options: CreateWakuNodeOptions & Partial + options: ProtocolCreateOptions & Partial ): Promise { options = { ...options, @@ -36,7 +31,7 @@ export async function createRelayNode( return new WakuNode( pubsubTopics, - options as WakuOptions, + options as ProtocolCreateOptions, libp2p, {}, relay diff --git a/packages/sdk/src/create/create.ts b/packages/sdk/src/create/create.ts index 155fee3403..331d1c2862 100644 --- a/packages/sdk/src/create/create.ts +++ b/packages/sdk/src/create/create.ts @@ -1,6 +1,6 @@ -import { type LightNode } from "@waku/interfaces"; +import type { LightNode, ProtocolCreateOptions } from "@waku/interfaces"; -import { CreateWakuNodeOptions, WakuNode } from "../waku/index.js"; +import { WakuNode } from "../waku/index.js"; import { createLibp2pAndUpdateOptions } from "./libp2p.js"; @@ -10,7 +10,7 @@ import { createLibp2pAndUpdateOptions } from "./libp2p.js"; * Uses Waku Filter V2 by default. */ export async function createLightNode( - options: CreateWakuNodeOptions = {} + options: ProtocolCreateOptions = {} ): Promise { const { libp2p, pubsubTopics } = await createLibp2pAndUpdateOptions(options); diff --git a/packages/sdk/src/create/libp2p.ts b/packages/sdk/src/create/libp2p.ts index e979487f9b..6efb17d1e7 100644 --- a/packages/sdk/src/create/libp2p.ts +++ b/packages/sdk/src/create/libp2p.ts @@ -12,17 +12,12 @@ import { type IMetadata, type Libp2p, type Libp2pComponents, + type ProtocolCreateOptions, PubsubTopic } from "@waku/interfaces"; import { derivePubsubTopicsFromNetworkConfig, Logger } from "@waku/utils"; import { createLibp2p } from "libp2p"; -import { - CreateWakuNodeOptions, - DefaultPingMaxInboundStreams, - DefaultUserAgent -} from "../waku/index.js"; - import { defaultPeerDiscoveries } from "./discovery.js"; type MetadataService = { @@ -31,6 +26,9 @@ type MetadataService = { const log = new Logger("sdk:create"); +const DefaultUserAgent = "js-waku"; +const DefaultPingMaxInboundStreams = 10; + export async function defaultLibp2p( pubsubTopics: PubsubTopic[], options?: Partial, @@ -78,7 +76,7 @@ export async function defaultLibp2p( } export async function createLibp2pAndUpdateOptions( - options: CreateWakuNodeOptions + options: ProtocolCreateOptions ): Promise<{ libp2p: Libp2p; pubsubTopics: PubsubTopic[] }> { const { networkConfig } = options; const pubsubTopics = derivePubsubTopicsFromNetworkConfig( diff --git a/packages/sdk/src/waku/waku.ts b/packages/sdk/src/waku/waku.ts index 96706e1a13..4700c372e9 100644 --- a/packages/sdk/src/waku/waku.ts +++ b/packages/sdk/src/waku/waku.ts @@ -24,22 +24,8 @@ import { ReliabilityMonitorManager } from "../reliability_monitor/index.js"; import { waitForRemotePeer } from "./wait_for_remote_peer.js"; -export const DefaultUserAgent = "js-waku"; -export const DefaultPingMaxInboundStreams = 10; - const log = new Logger("waku"); -export interface WakuOptions { - /** - * Set the user agent string to be used in identification of the node. - * @default {@link @waku/core.DefaultUserAgent} - */ - userAgent?: string; -} - -export type CreateWakuNodeOptions = ProtocolCreateOptions & - Partial; - type ProtocolsEnabled = { filter?: boolean; lightpush?: boolean; @@ -59,7 +45,7 @@ export class WakuNode implements IWaku { public constructor( public readonly pubsubTopics: PubsubTopic[], - options: CreateWakuNodeOptions, + options: ProtocolCreateOptions, libp2p: Libp2p, protocolsEnabled: ProtocolsEnabled, relay?: IRelay