From 53af8994bd12a3a13245b920c6018377450dd99d Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 6 Dec 2022 12:36:29 +1100 Subject: [PATCH 1/6] feat: added `I` prefix to protocols interfaces This will enable the remove of `Waku` prefix on all protocol implementations, which is redundant due to the context. --- packages/core/src/lib/wait_for_remote_peer.ts | 4 +- packages/core/src/lib/waku.ts | 30 +++++++------- packages/core/src/lib/waku_filter/index.ts | 6 +-- .../core/src/lib/waku_light_push/index.ts | 6 +-- packages/core/src/lib/waku_relay/index.ts | 6 +-- packages/core/src/lib/waku_store/index.ts | 6 +-- packages/create/src/index.ts | 9 ++++- packages/interfaces/src/filter.ts | 2 +- packages/interfaces/src/light_push.ts | 2 +- packages/interfaces/src/peer_exchange.ts | 2 +- packages/interfaces/src/relay.ts | 2 +- packages/interfaces/src/store.ts | 2 +- packages/interfaces/src/waku.ts | 40 +++++++++---------- .../peer-exchange/src/waku_peer_exchange.ts | 4 +- 14 files changed, 63 insertions(+), 58 deletions(-) diff --git a/packages/core/src/lib/wait_for_remote_peer.ts b/packages/core/src/lib/wait_for_remote_peer.ts index 785e0dd370..85c312c12e 100644 --- a/packages/core/src/lib/wait_for_remote_peer.ts +++ b/packages/core/src/lib/wait_for_remote_peer.ts @@ -1,5 +1,5 @@ import { PeerProtocolsChangeData } from "@libp2p/interface-peer-store"; -import type { PointToPointProtocol, Relay, Waku } from "@waku/interfaces"; +import type { IRelay, PointToPointProtocol, Waku } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { PeerExchangeCodec } from "@waku/peer-exchange"; import debug from "debug"; @@ -117,7 +117,7 @@ async function waitForConnectedPeer( * Wait for a peer with the given protocol to be connected and in the gossipsub * mesh. */ -async function waitForGossipSubPeerInMesh(waku: Relay): Promise { +async function waitForGossipSubPeerInMesh(waku: IRelay): Promise { let peers = waku.getMeshPeers(); while (peers.length == 0) { diff --git a/packages/core/src/lib/waku.ts b/packages/core/src/lib/waku.ts index cac155d88a..ba6969f3fe 100644 --- a/packages/core/src/lib/waku.ts +++ b/packages/core/src/lib/waku.ts @@ -3,12 +3,12 @@ import type { PeerId } from "@libp2p/interface-peer-id"; import type { PubSub } from "@libp2p/interface-pubsub"; import type { Multiaddr } from "@multiformats/multiaddr"; import type { - Filter, - LightPush, - PeerExchange, + IFilter, + ILightPush, + IPeerExchange, + IRelay, + IStore, PeerExchangeComponents, - Relay, - Store, Waku, } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; @@ -56,11 +56,11 @@ export interface WakuOptions { export class WakuNode implements Waku { public libp2p: Libp2p; - public relay?: Relay; - public store?: Store; - public filter?: Filter; - public lightPush?: LightPush; - public peerExchange?: PeerExchange; + public relay?: IRelay; + public store?: IStore; + public filter?: IFilter; + public lightPush?: ILightPush; + public peerExchange?: IPeerExchange; private pingKeepAliveTimers: { [peer: string]: ReturnType; @@ -72,10 +72,10 @@ export class WakuNode implements Waku { constructor( options: WakuOptions, libp2p: Libp2p, - store?: (components: StoreComponents) => Store, - lightPush?: (components: LightPushComponents) => LightPush, - filter?: (components: FilterComponents) => Filter, - peerExchange?: (components: PeerExchangeComponents) => PeerExchange + store?: (components: StoreComponents) => IStore, + lightPush?: (components: LightPushComponents) => ILightPush, + filter?: (components: FilterComponents) => IFilter, + peerExchange?: (components: PeerExchangeComponents) => IPeerExchange ) { this.libp2p = libp2p; @@ -274,7 +274,7 @@ export class WakuNode implements Waku { } } -function isRelay(pubsub: PubSub): pubsub is Relay { +function isRelay(pubsub: PubSub): pubsub is IRelay { if (pubsub) { try { return pubsub.multicodecs.includes( diff --git a/packages/core/src/lib/waku_filter/index.ts b/packages/core/src/lib/waku_filter/index.ts index c8b2ab2b51..d7e3dae673 100644 --- a/packages/core/src/lib/waku_filter/index.ts +++ b/packages/core/src/lib/waku_filter/index.ts @@ -7,9 +7,9 @@ import type { IncomingStreamData } from "@libp2p/interface-registrar"; import type { Registrar } from "@libp2p/interface-registrar"; import type { Callback, - Filter, IDecodedMessage, IDecoder, + IFilter, IMessage, ProtocolOptions, } from "@waku/interfaces"; @@ -64,7 +64,7 @@ export type UnsubscribeFunction = () => Promise; * - https://github.com/status-im/go-waku/issues/245 * - https://github.com/status-im/nwaku/issues/948 */ -class WakuFilter implements Filter { +class WakuFilter implements IFilter { pubSubTopic: string; private subscriptions: Map>; private decoders: Map< @@ -308,6 +308,6 @@ class WakuFilter implements Filter { export function wakuFilter( init: Partial = {} -): (components: FilterComponents) => Filter { +): (components: FilterComponents) => IFilter { return (components: FilterComponents) => new WakuFilter(components, init); } diff --git a/packages/core/src/lib/waku_light_push/index.ts b/packages/core/src/lib/waku_light_push/index.ts index 54c8db3afb..9e934ccbfd 100644 --- a/packages/core/src/lib/waku_light_push/index.ts +++ b/packages/core/src/lib/waku_light_push/index.ts @@ -4,8 +4,8 @@ import type { Peer } from "@libp2p/interface-peer-store"; import type { PeerStore } from "@libp2p/interface-peer-store"; import type { IEncoder, + ILightPush, IMessage, - LightPush, ProtocolOptions, SendResult, } from "@waku/interfaces"; @@ -51,7 +51,7 @@ export interface CreateOptions { /** * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/). */ -class WakuLightPush implements LightPush { +class WakuLightPush implements ILightPush { pubSubTopic: string; constructor(public components: LightPushComponents, options?: CreateOptions) { @@ -151,7 +151,7 @@ class WakuLightPush implements LightPush { export function wakuLightPush( init: Partial = {} -): (components: LightPushComponents) => LightPush { +): (components: LightPushComponents) => ILightPush { return (components: LightPushComponents) => new WakuLightPush(components, init); } diff --git a/packages/core/src/lib/waku_relay/index.ts b/packages/core/src/lib/waku_relay/index.ts index d3a4861ffe..9492e09bec 100644 --- a/packages/core/src/lib/waku_relay/index.ts +++ b/packages/core/src/lib/waku_relay/index.ts @@ -11,7 +11,7 @@ import type { IDecoder, IEncoder, IMessage, - Relay, + IRelay, SendResult, } from "@waku/interfaces"; import { IDecodedMessage } from "@waku/interfaces"; @@ -53,7 +53,7 @@ export type CreateOptions = { * * @implements {require('libp2p-interfaces/src/pubsub')} */ -class WakuRelay extends GossipSub implements Relay { +class WakuRelay extends GossipSub implements IRelay { pubSubTopic: string; defaultDecoder: IDecoder; public static multicodec: string = constants.RelayCodecs[0]; @@ -189,6 +189,6 @@ WakuRelay.multicodec = constants.RelayCodecs[constants.RelayCodecs.length - 1]; export function wakuRelay( init: Partial = {} -): (components: GossipSubComponents) => Relay { +): (components: GossipSubComponents) => IRelay { return (components: GossipSubComponents) => new WakuRelay(components, init); } diff --git a/packages/core/src/lib/waku_store/index.ts b/packages/core/src/lib/waku_store/index.ts index 78c890164d..7bf80fecc8 100644 --- a/packages/core/src/lib/waku_store/index.ts +++ b/packages/core/src/lib/waku_store/index.ts @@ -9,7 +9,7 @@ import { IDecodedMessage, IDecoder, Index, - Store, + IStore, } from "@waku/interfaces"; import { getPeersForProtocol, @@ -104,7 +104,7 @@ export interface QueryOptions { * * The Waku Store protocol can be used to retrieved historical messages. */ -class WakuStore implements Store { +class WakuStore implements IStore { pubSubTopic: string; constructor(public components: StoreComponents, options?: CreateOptions) { @@ -432,6 +432,6 @@ export async function createCursor( export function wakuStore( init: Partial = {} -): (components: StoreComponents) => Store { +): (components: StoreComponents) => IStore { return (components: StoreComponents) => new WakuStore(components, init); } diff --git a/packages/create/src/index.ts b/packages/create/src/index.ts index ae1af85f44..756b1bbbf3 100644 --- a/packages/create/src/index.ts +++ b/packages/create/src/index.ts @@ -15,7 +15,12 @@ import { } from "@waku/core"; import { DefaultUserAgent } from "@waku/core"; import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap_nodes"; -import type { Relay, WakuFull, WakuLight, WakuPrivacy } from "@waku/interfaces"; +import type { + IRelay, + WakuFull, + WakuLight, + WakuPrivacy, +} from "@waku/interfaces"; import { wakuPeerExchange } from "@waku/peer-exchange"; import type { Libp2p } from "libp2p"; import { createLibp2p, Libp2pOptions } from "libp2p"; @@ -172,7 +177,7 @@ export function defaultPeerDiscovery(): ( } export async function defaultLibp2p( - wakuRelay?: (components: Libp2pComponents) => Relay, + wakuRelay?: (components: Libp2pComponents) => IRelay, options?: Partial, userAgent?: string ): Promise { diff --git a/packages/interfaces/src/filter.ts b/packages/interfaces/src/filter.ts index 74c8e9c4fd..526b493421 100644 --- a/packages/interfaces/src/filter.ts +++ b/packages/interfaces/src/filter.ts @@ -5,7 +5,7 @@ import type { ProtocolOptions, } from "./protocols.js"; -export interface Filter extends PointToPointProtocol { +export interface IFilter extends PointToPointProtocol { subscribe: ( decoders: IDecoder[], callback: Callback, diff --git a/packages/interfaces/src/light_push.ts b/packages/interfaces/src/light_push.ts index 2afb674ae9..ad217b60de 100644 --- a/packages/interfaces/src/light_push.ts +++ b/packages/interfaces/src/light_push.ts @@ -5,7 +5,7 @@ import type { SendResult, } from "./protocols.js"; -export interface LightPush extends PointToPointProtocol { +export interface ILightPush extends PointToPointProtocol { push: ( encoder: IEncoder, message: IMessage, diff --git a/packages/interfaces/src/peer_exchange.ts b/packages/interfaces/src/peer_exchange.ts index 05359e25da..c74415c4d9 100644 --- a/packages/interfaces/src/peer_exchange.ts +++ b/packages/interfaces/src/peer_exchange.ts @@ -5,7 +5,7 @@ import { ENR } from "@waku/enr"; import { PointToPointProtocol } from "./protocols.js"; -export interface PeerExchange extends PointToPointProtocol { +export interface IPeerExchange extends PointToPointProtocol { query( params: PeerExchangeQueryParams, callback: (response: PeerExchangeResponse) => Promise | void diff --git a/packages/interfaces/src/relay.ts b/packages/interfaces/src/relay.ts index 76d1a76958..f88e4ca676 100644 --- a/packages/interfaces/src/relay.ts +++ b/packages/interfaces/src/relay.ts @@ -8,7 +8,7 @@ import type { } from "./message.js"; import type { Callback, SendResult } from "./protocols.js"; -export interface Relay extends GossipSub { +export interface IRelay extends GossipSub { send: (encoder: IEncoder, message: IMessage) => Promise; addObserver: ( decoder: IDecoder, diff --git a/packages/interfaces/src/store.ts b/packages/interfaces/src/store.ts index b7d7b355ce..77dd9467df 100644 --- a/packages/interfaces/src/store.ts +++ b/packages/interfaces/src/store.ts @@ -50,7 +50,7 @@ export type StoreQueryOptions = { cursor?: Cursor; } & ProtocolOptions; -export interface Store extends PointToPointProtocol { +export interface IStore extends PointToPointProtocol { queryOrderedCallback: ( decoders: IDecoder[], callback: (message: T) => Promise | boolean | void, diff --git a/packages/interfaces/src/waku.ts b/packages/interfaces/src/waku.ts index 19e0e429ff..21f5007438 100644 --- a/packages/interfaces/src/waku.ts +++ b/packages/interfaces/src/waku.ts @@ -3,20 +3,20 @@ import type { PeerId } from "@libp2p/interface-peer-id"; import type { Multiaddr } from "@multiformats/multiaddr"; import type { Libp2p } from "libp2p"; -import type { Filter } from "./filter.js"; -import type { LightPush } from "./light_push.js"; -import type { PeerExchange } from "./peer_exchange.js"; +import type { IFilter } from "./filter.js"; +import type { ILightPush } from "./light_push.js"; +import type { IPeerExchange } from "./peer_exchange.js"; import { Protocols } from "./protocols.js"; -import type { Relay } from "./relay.js"; -import type { Store } from "./store.js"; +import type { IRelay } from "./relay.js"; +import type { IStore } from "./store.js"; export interface Waku { libp2p: Libp2p; - relay?: Relay; - store?: Store; - filter?: Filter; - lightPush?: LightPush; - peerExchange?: PeerExchange; + relay?: IRelay; + store?: IStore; + filter?: IFilter; + lightPush?: ILightPush; + peerExchange?: IPeerExchange; dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise; @@ -29,14 +29,14 @@ export interface Waku { export interface WakuLight extends Waku { relay: undefined; - store: Store; - filter: Filter; - lightPush: LightPush; - peerExchange: PeerExchange; + store: IStore; + filter: IFilter; + lightPush: ILightPush; + peerExchange: IPeerExchange; } export interface WakuPrivacy extends Waku { - relay: Relay; + relay: IRelay; store: undefined; filter: undefined; lightPush: undefined; @@ -44,9 +44,9 @@ export interface WakuPrivacy extends Waku { } export interface WakuFull extends Waku { - relay: Relay; - store: Store; - filter: Filter; - lightPush: LightPush; - peerExchange: PeerExchange; + relay: IRelay; + store: IStore; + filter: IFilter; + lightPush: ILightPush; + peerExchange: IPeerExchange; } diff --git a/packages/peer-exchange/src/waku_peer_exchange.ts b/packages/peer-exchange/src/waku_peer_exchange.ts index c4adf2ecb7..99379bfc9c 100644 --- a/packages/peer-exchange/src/waku_peer_exchange.ts +++ b/packages/peer-exchange/src/waku_peer_exchange.ts @@ -4,7 +4,7 @@ import type { Peer, PeerStore } from "@libp2p/interface-peer-store"; import type { IncomingStreamData } from "@libp2p/interface-registrar"; import { ENR } from "@waku/enr"; import type { - PeerExchange, + IPeerExchange, PeerExchangeComponents, PeerExchangeQueryParams, PeerExchangeResponse, @@ -26,7 +26,7 @@ export const PeerExchangeCodec = "/vac/waku/peer-exchange/2.0.0-alpha1"; const log = debug("waku:peer-exchange"); -export class WakuPeerExchange implements PeerExchange { +export class WakuPeerExchange implements IPeerExchange { private callback: | ((response: PeerExchangeResponse) => Promise) | undefined; From 574f3ee80f6a6a728d4f49019fb004c5ed77c0ec Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 6 Dec 2022 12:49:02 +1100 Subject: [PATCH 2/6] refactor: remove `waku_` from module names This is redundant with the context (waku package). --- packages/core/package.json | 12 ++++++------ packages/core/rollup.config.js | 5 ++--- packages/core/src/index.ts | 18 +++++++++--------- .../lib/{waku_filter => filter}/filter_rpc.ts | 0 .../src/lib/{waku_filter => filter}/index.ts | 0 .../{waku_light_push => light_push}/index.ts | 0 .../push_rpc.ts | 0 .../topic_only_message.ts | 0 .../version_0.spec.ts | 0 .../lib/{waku_message => message}/version_0.ts | 0 .../src/lib/{waku_relay => relay}/constants.ts | 0 .../src/lib/{waku_relay => relay}/index.ts | 2 +- .../lib/{waku_store => store}/history_rpc.ts | 0 .../src/lib/{waku_store => store}/index.ts | 0 packages/core/src/lib/wait_for_remote_peer.ts | 6 +++--- packages/core/src/lib/waku.ts | 15 ++++++--------- packages/message-encryption/src/ecies.ts | 5 +---- packages/message-encryption/src/index.ts | 2 +- packages/message-encryption/src/symmetric.ts | 5 +---- 19 files changed, 30 insertions(+), 40 deletions(-) rename packages/core/src/lib/{waku_filter => filter}/filter_rpc.ts (100%) rename packages/core/src/lib/{waku_filter => filter}/index.ts (100%) rename packages/core/src/lib/{waku_light_push => light_push}/index.ts (100%) rename packages/core/src/lib/{waku_light_push => light_push}/push_rpc.ts (100%) rename packages/core/src/lib/{waku_message => message}/topic_only_message.ts (100%) rename packages/core/src/lib/{waku_message => message}/version_0.spec.ts (100%) rename packages/core/src/lib/{waku_message => message}/version_0.ts (100%) rename packages/core/src/lib/{waku_relay => relay}/constants.ts (100%) rename packages/core/src/lib/{waku_relay => relay}/index.ts (98%) rename packages/core/src/lib/{waku_store => store}/history_rpc.ts (100%) rename packages/core/src/lib/{waku_store => store}/index.ts (100%) diff --git a/packages/core/package.json b/packages/core/package.json index e8322db6ec..7776c92ba6 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -13,13 +13,13 @@ "types": "./dist/lib/predefined_bootstrap_nodes.d.ts", "import": "./dist/lib/predefined_bootstrap_nodes.js" }, - "./lib/waku_message/version_0": { - "types": "./dist/lib/waku_message/version_0.d.ts", - "import": "./dist/lib/waku_message/version_0.js" + "./lib/message/version_0": { + "types": "./dist/lib/message/version_0.d.ts", + "import": "./dist/lib/message/version_0.js" }, - "./lib/waku_message/topic_only_message": { - "types": "./dist/lib/waku_message/topic_only_message.d.ts", - "import": "./dist/lib/waku_message/topic_only_message.js" + "./lib/message/topic_only_message": { + "types": "./dist/lib/message/topic_only_message.d.ts", + "import": "./dist/lib/message/topic_only_message.js" } }, "typesVersions": { diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.js index 1a9240bbe7..4896be37cb 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.js @@ -6,9 +6,8 @@ export default { input: { index: "dist/index.js", "lib/predefined_bootstrap_nodes": "dist/lib/predefined_bootstrap_nodes.js", - "lib/waku_message/version_0": "dist/lib/waku_message/version_0.js", - "lib/waku_message/topic_only_message": - "dist/lib/waku_message/topic_only_message.js", + "lib/message/version_0": "dist/lib/message/version_0.js", + "lib/message/topic_only_message": "dist/lib/message/topic_only_message.js", }, output: { dir: "bundle", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index da0e7012b7..427dac0d4e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -5,30 +5,30 @@ export { createEncoder, createDecoder, DecodedMessage, -} from "./lib/waku_message/version_0.js"; +} from "./lib/message/version_0.js"; export * as waku from "./lib/waku.js"; export { WakuNode } from "./lib/waku.js"; -export * as waku_filter from "./lib/waku_filter/index.js"; -export { wakuFilter } from "./lib/waku_filter/index.js"; +export * as waku_filter from "./lib/filter/index.js"; +export { wakuFilter } from "./lib/filter/index.js"; -export * as waku_light_push from "./lib/waku_light_push/index.js"; +export * as waku_light_push from "./lib/light_push/index.js"; export { wakuLightPush, LightPushCodec, PushResponse, -} from "./lib/waku_light_push/index.js"; +} from "./lib/light_push/index.js"; -export * as waku_relay from "./lib/waku_relay/index.js"; -export { wakuRelay } from "./lib/waku_relay/index.js"; +export * as waku_relay from "./lib/relay/index.js"; +export { wakuRelay } from "./lib/relay/index.js"; -export * as waku_store from "./lib/waku_store/index.js"; +export * as waku_store from "./lib/store/index.js"; export { PageDirection, wakuStore, StoreCodec, createCursor, -} from "./lib/waku_store/index.js"; +} from "./lib/store/index.js"; export { waitForRemotePeer } from "./lib/wait_for_remote_peer.js"; diff --git a/packages/core/src/lib/waku_filter/filter_rpc.ts b/packages/core/src/lib/filter/filter_rpc.ts similarity index 100% rename from packages/core/src/lib/waku_filter/filter_rpc.ts rename to packages/core/src/lib/filter/filter_rpc.ts diff --git a/packages/core/src/lib/waku_filter/index.ts b/packages/core/src/lib/filter/index.ts similarity index 100% rename from packages/core/src/lib/waku_filter/index.ts rename to packages/core/src/lib/filter/index.ts diff --git a/packages/core/src/lib/waku_light_push/index.ts b/packages/core/src/lib/light_push/index.ts similarity index 100% rename from packages/core/src/lib/waku_light_push/index.ts rename to packages/core/src/lib/light_push/index.ts diff --git a/packages/core/src/lib/waku_light_push/push_rpc.ts b/packages/core/src/lib/light_push/push_rpc.ts similarity index 100% rename from packages/core/src/lib/waku_light_push/push_rpc.ts rename to packages/core/src/lib/light_push/push_rpc.ts diff --git a/packages/core/src/lib/waku_message/topic_only_message.ts b/packages/core/src/lib/message/topic_only_message.ts similarity index 100% rename from packages/core/src/lib/waku_message/topic_only_message.ts rename to packages/core/src/lib/message/topic_only_message.ts diff --git a/packages/core/src/lib/waku_message/version_0.spec.ts b/packages/core/src/lib/message/version_0.spec.ts similarity index 100% rename from packages/core/src/lib/waku_message/version_0.spec.ts rename to packages/core/src/lib/message/version_0.spec.ts diff --git a/packages/core/src/lib/waku_message/version_0.ts b/packages/core/src/lib/message/version_0.ts similarity index 100% rename from packages/core/src/lib/waku_message/version_0.ts rename to packages/core/src/lib/message/version_0.ts diff --git a/packages/core/src/lib/waku_relay/constants.ts b/packages/core/src/lib/relay/constants.ts similarity index 100% rename from packages/core/src/lib/waku_relay/constants.ts rename to packages/core/src/lib/relay/constants.ts diff --git a/packages/core/src/lib/waku_relay/index.ts b/packages/core/src/lib/relay/index.ts similarity index 98% rename from packages/core/src/lib/waku_relay/index.ts rename to packages/core/src/lib/relay/index.ts index 9492e09bec..96ea47a355 100644 --- a/packages/core/src/lib/waku_relay/index.ts +++ b/packages/core/src/lib/relay/index.ts @@ -18,8 +18,8 @@ import { IDecodedMessage } from "@waku/interfaces"; import debug from "debug"; import { DefaultPubSubTopic } from "../constants.js"; +import { TopicOnlyDecoder } from "../message/topic_only_message.js"; import { pushOrInitMapSet } from "../push_or_init_map.js"; -import { TopicOnlyDecoder } from "../waku_message/topic_only_message.js"; import * as constants from "./constants.js"; diff --git a/packages/core/src/lib/waku_store/history_rpc.ts b/packages/core/src/lib/store/history_rpc.ts similarity index 100% rename from packages/core/src/lib/waku_store/history_rpc.ts rename to packages/core/src/lib/store/history_rpc.ts diff --git a/packages/core/src/lib/waku_store/index.ts b/packages/core/src/lib/store/index.ts similarity index 100% rename from packages/core/src/lib/waku_store/index.ts rename to packages/core/src/lib/store/index.ts diff --git a/packages/core/src/lib/wait_for_remote_peer.ts b/packages/core/src/lib/wait_for_remote_peer.ts index 85c312c12e..4e15b5d7e5 100644 --- a/packages/core/src/lib/wait_for_remote_peer.ts +++ b/packages/core/src/lib/wait_for_remote_peer.ts @@ -5,9 +5,9 @@ import { PeerExchangeCodec } from "@waku/peer-exchange"; import debug from "debug"; import { pEvent } from "p-event"; -import { FilterCodec } from "./waku_filter/index.js"; -import { LightPushCodec } from "./waku_light_push/index.js"; -import { StoreCodec } from "./waku_store/index.js"; +import { FilterCodec } from "./filter/index.js"; +import { LightPushCodec } from "./light_push/index.js"; +import { StoreCodec } from "./store/index.js"; const log = debug("waku:wait-for-remote-peer"); diff --git a/packages/core/src/lib/waku.ts b/packages/core/src/lib/waku.ts index ba6969f3fe..94184f8cd4 100644 --- a/packages/core/src/lib/waku.ts +++ b/packages/core/src/lib/waku.ts @@ -16,15 +16,12 @@ import { PeerExchangeCodec } from "@waku/peer-exchange"; import debug from "debug"; import type { Libp2p } from "libp2p"; -import { FilterCodec, FilterComponents } from "./waku_filter/index.js"; -import { - LightPushCodec, - LightPushComponents, -} from "./waku_light_push/index.js"; -import { createEncoder } from "./waku_message/version_0.js"; -import * as relayConstants from "./waku_relay/constants.js"; -import { RelayCodecs, RelayPingContentTopic } from "./waku_relay/constants.js"; -import { StoreCodec, StoreComponents } from "./waku_store/index.js"; +import { FilterCodec, FilterComponents } from "./filter/index.js"; +import { LightPushCodec, LightPushComponents } from "./light_push/index.js"; +import { createEncoder } from "./message/version_0.js"; +import * as relayConstants from "./relay/constants.js"; +import { RelayCodecs, RelayPingContentTopic } from "./relay/constants.js"; +import { StoreCodec, StoreComponents } from "./store/index.js"; export const DefaultPingKeepAliveValueSecs = 0; export const DefaultRelayKeepAliveValueSecs = 5 * 60; diff --git a/packages/message-encryption/src/ecies.ts b/packages/message-encryption/src/ecies.ts index f55b7ca0f0..1d0ac45a8e 100644 --- a/packages/message-encryption/src/ecies.ts +++ b/packages/message-encryption/src/ecies.ts @@ -1,7 +1,4 @@ -import { - Decoder as DecoderV0, - proto, -} from "@waku/core/lib/waku_message/version_0"; +import { Decoder as DecoderV0, proto } from "@waku/core/lib/message/version_0"; import type { IDecoder, IEncoder, diff --git a/packages/message-encryption/src/index.ts b/packages/message-encryption/src/index.ts index 118e0ade9f..677f4197c8 100644 --- a/packages/message-encryption/src/index.ts +++ b/packages/message-encryption/src/index.ts @@ -1,7 +1,7 @@ import { DecodedMessage as DecodedMessageV0, proto, -} from "@waku/core/lib/waku_message/version_0"; +} from "@waku/core/lib/message/version_0"; import type { IDecodedMessage } from "@waku/interfaces"; import { diff --git a/packages/message-encryption/src/symmetric.ts b/packages/message-encryption/src/symmetric.ts index b177813a5e..e52d0a1273 100644 --- a/packages/message-encryption/src/symmetric.ts +++ b/packages/message-encryption/src/symmetric.ts @@ -1,7 +1,4 @@ -import { - Decoder as DecoderV0, - proto, -} from "@waku/core/lib/waku_message/version_0"; +import { Decoder as DecoderV0, proto } from "@waku/core/lib/message/version_0"; import type { IDecoder, IEncoder, From d946e443ad1e6a5039095c17e3b8ab11444278c8 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 6 Dec 2022 12:51:02 +1100 Subject: [PATCH 3/6] refactor: remove `Waku` from protocol names This is redundant with the context (waku package). --- packages/core/src/lib/filter/index.ts | 4 ++-- packages/core/src/lib/light_push/index.ts | 5 ++--- packages/core/src/lib/relay/index.ts | 6 +++--- packages/core/src/lib/store/index.ts | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/core/src/lib/filter/index.ts b/packages/core/src/lib/filter/index.ts index d7e3dae673..1497ef0a52 100644 --- a/packages/core/src/lib/filter/index.ts +++ b/packages/core/src/lib/filter/index.ts @@ -64,7 +64,7 @@ export type UnsubscribeFunction = () => Promise; * - https://github.com/status-im/go-waku/issues/245 * - https://github.com/status-im/nwaku/issues/948 */ -class WakuFilter implements IFilter { +class Filter implements IFilter { pubSubTopic: string; private subscriptions: Map>; private decoders: Map< @@ -309,5 +309,5 @@ class WakuFilter implements IFilter { export function wakuFilter( init: Partial = {} ): (components: FilterComponents) => IFilter { - return (components: FilterComponents) => new WakuFilter(components, init); + return (components: FilterComponents) => new Filter(components, init); } diff --git a/packages/core/src/lib/light_push/index.ts b/packages/core/src/lib/light_push/index.ts index 9e934ccbfd..d3517c9a90 100644 --- a/packages/core/src/lib/light_push/index.ts +++ b/packages/core/src/lib/light_push/index.ts @@ -51,7 +51,7 @@ export interface CreateOptions { /** * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/). */ -class WakuLightPush implements ILightPush { +class LightPush implements ILightPush { pubSubTopic: string; constructor(public components: LightPushComponents, options?: CreateOptions) { @@ -152,6 +152,5 @@ class WakuLightPush implements ILightPush { export function wakuLightPush( init: Partial = {} ): (components: LightPushComponents) => ILightPush { - return (components: LightPushComponents) => - new WakuLightPush(components, init); + return (components: LightPushComponents) => new LightPush(components, init); } diff --git a/packages/core/src/lib/relay/index.ts b/packages/core/src/lib/relay/index.ts index 96ea47a355..dda5664ab6 100644 --- a/packages/core/src/lib/relay/index.ts +++ b/packages/core/src/lib/relay/index.ts @@ -53,7 +53,7 @@ export type CreateOptions = { * * @implements {require('libp2p-interfaces/src/pubsub')} */ -class WakuRelay extends GossipSub implements IRelay { +class Relay extends GossipSub implements IRelay { pubSubTopic: string; defaultDecoder: IDecoder; public static multicodec: string = constants.RelayCodecs[0]; @@ -185,10 +185,10 @@ class WakuRelay extends GossipSub implements IRelay { } } -WakuRelay.multicodec = constants.RelayCodecs[constants.RelayCodecs.length - 1]; +Relay.multicodec = constants.RelayCodecs[constants.RelayCodecs.length - 1]; export function wakuRelay( init: Partial = {} ): (components: GossipSubComponents) => IRelay { - return (components: GossipSubComponents) => new WakuRelay(components, init); + return (components: GossipSubComponents) => new Relay(components, init); } diff --git a/packages/core/src/lib/store/index.ts b/packages/core/src/lib/store/index.ts index 7bf80fecc8..ac3897490a 100644 --- a/packages/core/src/lib/store/index.ts +++ b/packages/core/src/lib/store/index.ts @@ -104,7 +104,7 @@ export interface QueryOptions { * * The Waku Store protocol can be used to retrieved historical messages. */ -class WakuStore implements IStore { +class Store implements IStore { pubSubTopic: string; constructor(public components: StoreComponents, options?: CreateOptions) { @@ -433,5 +433,5 @@ export async function createCursor( export function wakuStore( init: Partial = {} ): (components: StoreComponents) => IStore { - return (components: StoreComponents) => new WakuStore(components, init); + return (components: StoreComponents) => new Store(components, init); } From f743cfd1ca8ff11a611764cb7b98594bf9ef8b4d Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 6 Dec 2022 13:18:32 +1100 Subject: [PATCH 4/6] chore: rename node interfaces to include `Node` in name Also rename node with only relay to `RelayNode`. --- packages/create/src/index.ts | 21 +++++------ packages/interfaces/src/waku.ts | 6 ++-- packages/tests/tests/enr.node.spec.ts | 12 +++---- packages/tests/tests/ephemeral.node.spec.ts | 4 +-- packages/tests/tests/filter.node.spec.ts | 4 +-- packages/tests/tests/light_push.node.spec.ts | 4 +-- packages/tests/tests/relay.node.spec.ts | 36 +++++++++---------- packages/tests/tests/store.node.spec.ts | 6 ++-- .../tests/wait_for_remote_peer.node.spec.ts | 16 ++++----- packages/tests/tests/waku.node.spec.ts | 18 +++++----- 10 files changed, 61 insertions(+), 66 deletions(-) diff --git a/packages/create/src/index.ts b/packages/create/src/index.ts index 756b1bbbf3..22b38d55a4 100644 --- a/packages/create/src/index.ts +++ b/packages/create/src/index.ts @@ -15,12 +15,7 @@ import { } from "@waku/core"; import { DefaultUserAgent } from "@waku/core"; import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap_nodes"; -import type { - IRelay, - WakuFull, - WakuLight, - WakuPrivacy, -} from "@waku/interfaces"; +import type { FullNode, IRelay, LightNode, RelayNode } from "@waku/interfaces"; import { wakuPeerExchange } from "@waku/peer-exchange"; import type { Libp2p } from "libp2p"; import { createLibp2p, Libp2pOptions } from "libp2p"; @@ -74,7 +69,7 @@ export interface CreateOptions { */ export async function createLightNode( options?: CreateOptions & WakuOptions -): Promise { +): Promise { const libp2pOptions = options?.libp2p ?? {}; const peerDiscovery = libp2pOptions.peerDiscovery ?? []; if (options?.defaultBootstrap) { @@ -100,16 +95,16 @@ export async function createLightNode( lightPush, filter, peerExchange - ) as WakuLight; + ) as LightNode; } /** * Create a Waku node that uses Waku Relay to send and receive messages, * enabling some privacy preserving properties. */ -export async function createPrivacyNode( +export async function createRelayNode( options?: CreateOptions & WakuOptions & Partial -): Promise { +): Promise { const libp2pOptions = options?.libp2p ?? {}; const peerDiscovery = libp2pOptions.peerDiscovery ?? []; if (options?.defaultBootstrap) { @@ -123,7 +118,7 @@ export async function createPrivacyNode( options?.userAgent ); - return new WakuNode(options ?? {}, libp2p) as WakuPrivacy; + return new WakuNode(options ?? {}, libp2p) as RelayNode; } /** @@ -141,7 +136,7 @@ export async function createPrivacyNode( */ export async function createFullNode( options?: CreateOptions & WakuOptions & Partial -): Promise { +): Promise { const libp2pOptions = options?.libp2p ?? {}; const peerDiscovery = libp2pOptions.peerDiscovery ?? []; if (options?.defaultBootstrap) { @@ -167,7 +162,7 @@ export async function createFullNode( lightPush, filter, peerExchange - ) as WakuFull; + ) as FullNode; } export function defaultPeerDiscovery(): ( diff --git a/packages/interfaces/src/waku.ts b/packages/interfaces/src/waku.ts index 21f5007438..2af825a5fe 100644 --- a/packages/interfaces/src/waku.ts +++ b/packages/interfaces/src/waku.ts @@ -27,7 +27,7 @@ export interface Waku { isStarted(): boolean; } -export interface WakuLight extends Waku { +export interface LightNode extends Waku { relay: undefined; store: IStore; filter: IFilter; @@ -35,7 +35,7 @@ export interface WakuLight extends Waku { peerExchange: IPeerExchange; } -export interface WakuPrivacy extends Waku { +export interface RelayNode extends Waku { relay: IRelay; store: undefined; filter: undefined; @@ -43,7 +43,7 @@ export interface WakuPrivacy extends Waku { peerExchange: undefined; } -export interface WakuFull extends Waku { +export interface FullNode extends Waku { relay: IRelay; store: IStore; filter: IFilter; diff --git a/packages/tests/tests/enr.node.spec.ts b/packages/tests/tests/enr.node.spec.ts index 517007d44b..415e91aaa5 100644 --- a/packages/tests/tests/enr.node.spec.ts +++ b/packages/tests/tests/enr.node.spec.ts @@ -1,14 +1,14 @@ import { waitForRemotePeer } from "@waku/core"; -import { createPrivacyNode } from "@waku/create"; +import { createRelayNode } from "@waku/create"; import { ENR } from "@waku/enr"; -import type { WakuPrivacy } from "@waku/interfaces"; +import type { RelayNode } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../src/index.js"; describe("ENR Interop: nwaku", function () { - let waku: WakuPrivacy; + let waku: RelayNode; let nwaku: Nwaku; afterEach(async function () { @@ -27,7 +27,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createPrivacyNode({ + waku = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); @@ -59,7 +59,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createPrivacyNode({ + waku = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); @@ -91,7 +91,7 @@ describe("ENR Interop: nwaku", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku = await createPrivacyNode({ + waku = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); diff --git a/packages/tests/tests/ephemeral.node.spec.ts b/packages/tests/tests/ephemeral.node.spec.ts index 2a7a7ee94e..2284d39e17 100644 --- a/packages/tests/tests/ephemeral.node.spec.ts +++ b/packages/tests/tests/ephemeral.node.spec.ts @@ -7,7 +7,7 @@ import { } from "@waku/core"; import { createLightNode } from "@waku/create"; import { Protocols } from "@waku/interfaces"; -import type { WakuLight } from "@waku/interfaces"; +import type { LightNode } from "@waku/interfaces"; import { createDecoder as eciesDecoder, createEncoder as eciesEncoder, @@ -37,7 +37,7 @@ const TestEncoder = createEncoder(TestContentTopic); const TestDecoder = createDecoder(TestContentTopic); describe("Waku Message Ephemeral field", () => { - let waku: WakuLight; + let waku: LightNode; let nwaku: Nwaku; afterEach(async function () { diff --git a/packages/tests/tests/filter.node.spec.ts b/packages/tests/tests/filter.node.spec.ts index 543a122bd4..98ae599e83 100644 --- a/packages/tests/tests/filter.node.spec.ts +++ b/packages/tests/tests/filter.node.spec.ts @@ -6,7 +6,7 @@ import { waitForRemotePeer, } from "@waku/core"; import { createLightNode } from "@waku/create"; -import type { WakuLight } from "@waku/interfaces"; +import type { LightNode } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; @@ -20,7 +20,7 @@ const TestEncoder = createEncoder(TestContentTopic); const TestDecoder = createDecoder(TestContentTopic); describe("Waku Filter", () => { - let waku: WakuLight; + let waku: LightNode; let nwaku: Nwaku; afterEach(async function () { diff --git a/packages/tests/tests/light_push.node.spec.ts b/packages/tests/tests/light_push.node.spec.ts index fd530ce043..cd16d7606e 100644 --- a/packages/tests/tests/light_push.node.spec.ts +++ b/packages/tests/tests/light_push.node.spec.ts @@ -1,7 +1,7 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils"; import { createEncoder, waitForRemotePeer } from "@waku/core"; import { createLightNode } from "@waku/create"; -import type { WakuLight } from "@waku/interfaces"; +import type { LightNode } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import debug from "debug"; @@ -20,7 +20,7 @@ const TestContentTopic = "/test/1/waku-light-push/utf8"; const TestEncoder = createEncoder(TestContentTopic); describe("Waku Light Push [node only]", () => { - let waku: WakuLight; + let waku: LightNode; let nwaku: Nwaku; afterEach(async function () { diff --git a/packages/tests/tests/relay.node.spec.ts b/packages/tests/tests/relay.node.spec.ts index 955d4aebc7..4c03cb247c 100644 --- a/packages/tests/tests/relay.node.spec.ts +++ b/packages/tests/tests/relay.node.spec.ts @@ -7,8 +7,8 @@ import { DefaultPubSubTopic, waitForRemotePeer, } from "@waku/core"; -import { createPrivacyNode } from "@waku/create"; -import type { WakuPrivacy } from "@waku/interfaces"; +import { createRelayNode } from "@waku/create"; +import type { RelayNode } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { createDecoder as createEciesDecoder, @@ -50,17 +50,17 @@ describe("Waku Relay [node only]", () => { } }); - let waku1: WakuPrivacy; - let waku2: WakuPrivacy; + let waku1: RelayNode; + let waku2: RelayNode; beforeEach(async function () { this.timeout(10000); log("Starting JS Waku instances"); [waku1, waku2] = await Promise.all([ - createPrivacyNode({ staticNoiseKey: NOISE_KEY_1 }).then((waku) => + createRelayNode({ staticNoiseKey: NOISE_KEY_1 }).then((waku) => waku.start().then(() => waku) ), - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_2, libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } }, }).then((waku) => waku.start().then(() => waku)), @@ -250,9 +250,9 @@ describe("Waku Relay [node only]", () => { }); describe("Custom pubsub topic", () => { - let waku1: WakuPrivacy; - let waku2: WakuPrivacy; - let waku3: WakuPrivacy; + let waku1: RelayNode; + let waku2: RelayNode; + let waku3: RelayNode; afterEach(async function () { !!waku1 && waku1.stop().catch((e) => console.log("Waku failed to stop", e)); @@ -270,16 +270,16 @@ describe("Waku Relay [node only]", () => { // 1 and 2 uses a custom pubsub // 3 uses the default pubsub [waku1, waku2, waku3] = await Promise.all([ - createPrivacyNode({ + createRelayNode({ pubSubTopic: pubSubTopic, staticNoiseKey: NOISE_KEY_1, }).then((waku) => waku.start().then(() => waku)), - createPrivacyNode({ + createRelayNode({ pubSubTopic: pubSubTopic, staticNoiseKey: NOISE_KEY_2, libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } }, }).then((waku) => waku.start().then(() => waku)), - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_3, }).then((waku) => waku.start().then(() => waku)), ]); @@ -331,12 +331,12 @@ describe("Waku Relay [node only]", () => { }); describe("Interop: nwaku", function () { - let waku: WakuPrivacy; + let waku: RelayNode; let nwaku: Nwaku; beforeEach(async function () { this.timeout(30_000); - waku = await createPrivacyNode({ + waku = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku.start(); @@ -416,8 +416,8 @@ describe("Waku Relay [node only]", () => { }); describe.skip("Two nodes connected to nwaku", function () { - let waku1: WakuPrivacy; - let waku2: WakuPrivacy; + let waku1: RelayNode; + let waku2: RelayNode; let nwaku: Nwaku; afterEach(async function () { @@ -431,11 +431,11 @@ describe("Waku Relay [node only]", () => { it("Js publishes, other Js receives", async function () { this.timeout(60_000); [waku1, waku2] = await Promise.all([ - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_1, emitSelf: true, }).then((waku) => waku.start().then(() => waku)), - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_2, }).then((waku) => waku.start().then(() => waku)), ]); diff --git a/packages/tests/tests/store.node.spec.ts b/packages/tests/tests/store.node.spec.ts index 1f49ec3633..acef44762a 100644 --- a/packages/tests/tests/store.node.spec.ts +++ b/packages/tests/tests/store.node.spec.ts @@ -7,7 +7,7 @@ import { waitForRemotePeer, } from "@waku/core"; import { createLightNode } from "@waku/create"; -import type { IDecodedMessage, IMessage, WakuLight } from "@waku/interfaces"; +import type { IDecodedMessage, IMessage, LightNode } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { createDecoder as createEciesDecoder, @@ -38,7 +38,7 @@ const TestEncoder = createEncoder(TestContentTopic); const TestDecoder = createDecoder(TestContentTopic); describe("Waku Store", () => { - let waku: WakuLight; + let waku: LightNode; let nwaku: Nwaku; beforeEach(async function () { @@ -559,7 +559,7 @@ describe("Waku Store", () => { describe("Waku Store, custom pubsub topic", () => { const customPubSubTopic = "/waku/2/custom-dapp/proto"; - let waku: WakuLight; + let waku: LightNode; let nwaku: Nwaku; beforeEach(async function () { diff --git a/packages/tests/tests/wait_for_remote_peer.node.spec.ts b/packages/tests/tests/wait_for_remote_peer.node.spec.ts index ac476e7c94..52375d73b6 100644 --- a/packages/tests/tests/wait_for_remote_peer.node.spec.ts +++ b/packages/tests/tests/wait_for_remote_peer.node.spec.ts @@ -1,14 +1,14 @@ import { waitForRemotePeer } from "@waku/core"; -import { createLightNode, createPrivacyNode } from "@waku/create"; -import type { WakuLight, WakuPrivacy } from "@waku/interfaces"; +import { createLightNode, createRelayNode } from "@waku/create"; +import type { LightNode, RelayNode } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; import { delay, makeLogFileName, NOISE_KEY_1, Nwaku } from "../src/index.js"; describe("Wait for remote peer", function () { - let waku1: WakuPrivacy; - let waku2: WakuLight; + let waku1: RelayNode; + let waku2: LightNode; let nwaku: Nwaku | undefined; afterEach(async function () { @@ -31,7 +31,7 @@ describe("Wait for remote peer", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku1 = await createPrivacyNode({ + waku1 = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); @@ -56,7 +56,7 @@ describe("Wait for remote peer", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku1 = await createPrivacyNode({ + waku1 = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); @@ -75,7 +75,7 @@ describe("Wait for remote peer", function () { it("Relay - times out", function (done) { this.timeout(5000); - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_1, }) .then((waku1) => waku1.start().then(() => waku1)) @@ -253,7 +253,7 @@ describe("Wait for remote peer", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - waku1 = await createPrivacyNode({ + waku1 = await createRelayNode({ staticNoiseKey: NOISE_KEY_1, }); await waku1.start(); diff --git a/packages/tests/tests/waku.node.spec.ts b/packages/tests/tests/waku.node.spec.ts index e873107f35..ddc3b0abbb 100644 --- a/packages/tests/tests/waku.node.spec.ts +++ b/packages/tests/tests/waku.node.spec.ts @@ -6,8 +6,8 @@ import { DefaultUserAgent, waitForRemotePeer, } from "@waku/core"; -import { createLightNode, createPrivacyNode } from "@waku/create"; -import type { Waku, WakuLight, WakuPrivacy } from "@waku/interfaces"; +import { createLightNode, createRelayNode } from "@waku/create"; +import type { LightNode, RelayNode, Waku } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { createDecoder, @@ -62,7 +62,7 @@ describe("Waku Dial [node only]", function () { }); describe("Bootstrap", function () { - let waku: WakuLight; + let waku: LightNode; let nwaku: Nwaku; afterEach(async function () { @@ -134,15 +134,15 @@ describe("Decryption Keys", () => { } }); - let waku1: WakuPrivacy; - let waku2: WakuPrivacy; + let waku1: RelayNode; + let waku2: RelayNode; beforeEach(async function () { this.timeout(5000); [waku1, waku2] = await Promise.all([ - createPrivacyNode({ staticNoiseKey: NOISE_KEY_1 }).then((waku) => + createRelayNode({ staticNoiseKey: NOISE_KEY_1 }).then((waku) => waku.start().then(() => waku) ), - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_2, libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } }, }).then((waku) => waku.start().then(() => waku)), @@ -210,11 +210,11 @@ describe("User Agent", () => { const waku1UserAgent = "test-user-agent"; [waku1, waku2] = await Promise.all([ - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_1, userAgent: waku1UserAgent, }).then((waku) => waku.start().then(() => waku)), - createPrivacyNode({ + createRelayNode({ staticNoiseKey: NOISE_KEY_2, libp2p: { addresses: { listen: ["/ip4/0.0.0.0/tcp/0/ws"] } }, }).then((waku) => waku.start().then(() => waku)), From c6b86a33bcd15d27895cf4ca8bc2cb33377713c5 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 6 Dec 2022 13:37:26 +1100 Subject: [PATCH 5/6] doc: update changelogs --- packages/core/CHANGELOG.md | 1 + packages/create/CHANGELOG.md | 24 ++++++++++++++++++++++++ packages/interfaces/CHANGELOG.md | 27 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 packages/create/CHANGELOG.md create mode 100644 packages/interfaces/CHANGELOG.md diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index d664636735..9295354a21 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `waitForRemotePeer` must now be directly imported from `@waku/core`. - `V0` suffix removed from the version 0 objects. - `createEncoder`/`createDecoder`/`DecodedMessage` for Waku Message Version 0 (no Waku level encryption) can now be imported directly from `@waku/core`. +- Removed `Waku` and `waku_` prefixed on protocol implementations. ## [@waku/core@0.0.6] - 2022-11-18 diff --git a/packages/create/CHANGELOG.md b/packages/create/CHANGELOG.md new file mode 100644 index 0000000000..1272da8ea0 --- /dev/null +++ b/packages/create/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Changed + +- Renamed `createPrivacyNode` to `createRelayNode`. + +## [0.0.4] - 2022-11-18 + +### Added + +- Alpha version of `@waku/create`. + +[unreleased]: https://github.com/waku-org/js-waku/compare/@waku/create@0.0.4...HEAD +[0.0.4]: https://github.com/waku-org/js-waku/compare/@waku/create@0.0.3...@waku/create@0.0.4 +[0.0.3]: https://github.com/waku-org/js-waku/compare/@waku/create@0.0.2...%40waku/create@0.0.3 +[0.0.2]: https://github.com/waku-org/js-waku/compare/@waku/create@0.0.1...%40waku/create@0.0.2 +[0.0.1]: https://github.com/status-im/js-waku/compare/a20b7809d61ff9a9732aba82b99bbe99f229b935...%40waku/create%400.0.2 diff --git a/packages/interfaces/CHANGELOG.md b/packages/interfaces/CHANGELOG.md new file mode 100644 index 0000000000..6a771d7bf9 --- /dev/null +++ b/packages/interfaces/CHANGELOG.md @@ -0,0 +1,27 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Changed + +- Add `I` prefix to protocol and messages interfaces. +- Renamed node interfaces to include `Node`. +- Renamed `WakuPrivacy` to `RelayNode`. + +## [0.0.5] - 2022-11-18 + +### Added + +- Alpha version of `@waku/interfaces`. + +[unreleased]: https://github.com/waku-org/js-waku/compare/@waku/interfaces@0.0.5...HEAD +[0.0.5]: https://github.com/waku-org/js-waku/compare/@waku/interfaces@0.0.4...@waku/interfaces@0.0.5 +[0.0.4]: https://github.com/waku-org/js-waku/compare/@waku/interfaces@0.0.3...@waku/interfaces@0.0.4 +[0.0.3]: https://github.com/waku-org/js-waku/compare/@waku/interfaces@0.0.2...%40waku/create@0.0.3 +[0.0.2]: https://github.com/waku-org/js-waku/compare/@waku/interfaces@0.0.1...%40waku/create@0.0.2 +[0.0.1]: https://github.com/status-im/js-waku/compare/a20b7809d61ff9a9732aba82b99bbe99f229b935...%40waku/create%400.0.2 From 9ac92ef99d33ee8aa83a4c604ab1e57646a9c531 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Tue, 13 Dec 2022 10:58:07 +1100 Subject: [PATCH 6/6] test: use LightNode interface --- packages/tests/tests/peer_exchange.node.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tests/tests/peer_exchange.node.spec.ts b/packages/tests/tests/peer_exchange.node.spec.ts index e4b2b5423f..95869b066d 100644 --- a/packages/tests/tests/peer_exchange.node.spec.ts +++ b/packages/tests/tests/peer_exchange.node.spec.ts @@ -5,12 +5,12 @@ import { getPredefinedBootstrapNodes, } from "@waku/core/lib/predefined_bootstrap_nodes"; import { createLightNode } from "@waku/create"; -import type { PeerExchangeResponse, WakuFull } from "@waku/interfaces"; +import type { LightNode, PeerExchangeResponse } from "@waku/interfaces"; import { Protocols } from "@waku/interfaces"; import { expect } from "chai"; describe("Peer Exchange: Node", () => { - let waku: WakuFull; + let waku: LightNode; afterEach(async function () { !!waku && waku.stop().catch((e) => console.log("Waku failed to stop", e)); });