Skip to content

Commit

Permalink
Merge branch 'master' of github.com:waku-org/js-waku into chore/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Jan 11, 2024
2 parents b1c98be + dc96074 commit a958eee
Show file tree
Hide file tree
Showing 49 changed files with 1,296 additions and 131 deletions.
22 changes: 11 additions & 11 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"packages/utils": "0.0.13",
"packages/proto": "0.0.5",
"packages/interfaces": "0.0.20",
"packages/message-hash": "0.1.9",
"packages/enr": "0.0.19",
"packages/peer-exchange": "0.0.18",
"packages/core": "0.0.25",
"packages/dns-discovery": "0.0.19",
"packages/message-encryption": "0.0.23",
"packages/relay": "0.0.8",
"packages/sdk": "0.0.21"
"packages/utils": "0.0.14",
"packages/proto": "0.0.6",
"packages/interfaces": "0.0.21",
"packages/message-hash": "0.1.10",
"packages/enr": "0.0.20",
"packages/peer-exchange": "0.0.19",
"packages/core": "0.0.26",
"packages/dns-discovery": "0.0.20",
"packages/message-encryption": "0.0.24",
"packages/relay": "0.0.9",
"packages/sdk": "0.0.22"
}
30 changes: 30 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.26](https://github.com/waku-org/js-waku/compare/core-v0.0.25...core-v0.0.26) (2024-01-10)


### ⚠ BREAKING CHANGES

* add support for sharded pubsub topics & remove support for named pubsub topics ([#1697](https://github.com/waku-org/js-waku/issues/1697))
* change all instances of `PubSubTopic` to `PubsubTopic` ([#1703](https://github.com/waku-org/js-waku/issues/1703))

### Features

* Add support for autosharded pubsub topics ([2bc3735](https://github.com/waku-org/js-waku/commit/2bc3735e4dcf85f06b3dee542024d7f20a40fac2))
* Add support for sharded pubsub topics & remove support for named pubsub topics ([#1697](https://github.com/waku-org/js-waku/issues/1697)) ([4cf2ffe](https://github.com/waku-org/js-waku/commit/4cf2ffefa75e0571805036b71644d2cdd4fe3192))
* Metadata protocol ([#1732](https://github.com/waku-org/js-waku/issues/1732)) ([9ac2a3f](https://github.com/waku-org/js-waku/commit/9ac2a3f36352523b79fcd8f8a94bd6e0e109fc30))
* Track node connection state ([#1719](https://github.com/waku-org/js-waku/issues/1719)) ([1d0e2ac](https://github.com/waku-org/js-waku/commit/1d0e2ace7fa5b44ab192505c7ebce01a7ce343e0))


### Miscellaneous Chores

* Change all instances of `PubSubTopic` to `PubsubTopic` ([#1703](https://github.com/waku-org/js-waku/issues/1703)) ([3166a51](https://github.com/waku-org/js-waku/commit/3166a5135e77583da4fa722ee2aa47c785854a38))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from ^0.0.19 to ^0.0.20
* @waku/interfaces bumped from 0.0.20 to 0.0.21
* @waku/proto bumped from 0.0.5 to 0.0.6
* @waku/utils bumped from 0.0.13 to 0.0.14

## [0.0.25](https://github.com/waku-org/js-waku/compare/core-v0.0.24...core-v0.0.25) (2023-11-01)


Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/core",
"version": "0.0.25",
"version": "0.0.26",
"description": "TypeScript implementation of the Waku v2 protocol",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -73,10 +73,10 @@
},
"dependencies": {
"@noble/hashes": "^1.3.2",
"@waku/enr": "^0.0.19",
"@waku/interfaces": "0.0.20",
"@waku/proto": "0.0.5",
"@waku/utils": "0.0.13",
"@waku/enr": "^0.0.20",
"@waku/interfaces": "0.0.21",
"@waku/proto": "0.0.6",
"@waku/utils": "0.0.14",
"debug": "^4.3.4",
"it-all": "^3.0.4",
"it-length-prefixed": "^9.0.1",
Expand Down
15 changes: 9 additions & 6 deletions packages/core/src/lib/base_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Peer, PeerStore } from "@libp2p/interface/peer-store";
import type {
IBaseProtocol,
Libp2pComponents,
PubsubTopic,
ShardingParams
ProtocolCreateOptions,
PubsubTopic
} from "@waku/interfaces";
import { DefaultPubsubTopic } from "@waku/interfaces";
import { Logger, shardInfoToPubsubTopics } from "@waku/utils";
Expand Down Expand Up @@ -113,9 +113,12 @@ export class BaseProtocol implements IBaseProtocol {
return sortedFilteredPeers;
}

initializePubsubTopic(shardInfo?: ShardingParams): PubsubTopic[] {
return shardInfo
? shardInfoToPubsubTopics(shardInfo)
: [DefaultPubsubTopic];
initializePubsubTopic(options?: ProtocolCreateOptions): PubsubTopic[] {
return (
options?.pubsubTopics ??
(options?.shardInfo
? shardInfoToPubsubTopics(options.shardInfo)
: [DefaultPubsubTopic])
);
}
}
11 changes: 6 additions & 5 deletions packages/core/src/lib/filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class Filter extends BaseProtocol implements IReceiver {
constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
super(FilterCodecs.SUBSCRIBE, libp2p.components, log);

this.pubsubTopics = this.initializePubsubTopic(options?.shardInfo);
this.pubsubTopics = this.initializePubsubTopic(options);

libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {
log.error("Failed to register ", FilterCodecs.PUSH, e);
Expand All @@ -291,11 +291,12 @@ class Filter extends BaseProtocol implements IReceiver {
}

async createSubscription(
pubsubTopicShardInfo?: SingleShardInfo
pubsubTopicShardInfo: SingleShardInfo | PubsubTopic = DefaultPubsubTopic
): Promise<Subscription> {
const pubsubTopic = pubsubTopicShardInfo
? singleShardInfoToPubsubTopic(pubsubTopicShardInfo)
: DefaultPubsubTopic;
const pubsubTopic =
typeof pubsubTopicShardInfo == "string"
? pubsubTopicShardInfo
: singleShardInfoToPubsubTopic(pubsubTopicShardInfo);

ensurePubsubTopicIsConfigured(pubsubTopic, this.pubsubTopics);

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/light_push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LightPush extends BaseProtocol implements ILightPush {

constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
super(LightPushCodec, libp2p.components, log);
this.pubsubTopics = this.initializePubsubTopic(options?.shardInfo);
this.pubsubTopics = this.initializePubsubTopic(options);
}

private async preparePushMessage(
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/lib/message/version_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class Encoder implements IEncoder {
* messages.
*/
export function createEncoder({
pubsubTopic,
pubsubTopicShardInfo,
contentTopic,
ephemeral,
Expand All @@ -126,7 +127,7 @@ export function createEncoder({
return new Encoder(
contentTopic,
ephemeral,
determinePubsubTopic(contentTopic, pubsubTopicShardInfo),
determinePubsubTopic(contentTopic, pubsubTopic ?? pubsubTopicShardInfo),
metaSetter
);
}
Expand Down Expand Up @@ -186,7 +187,7 @@ export class Decoder implements IDecoder<DecodedMessage> {
*/
export function createDecoder(
contentTopic: string,
pubsubTopicShardInfo?: SingleShardInfo
pubsubTopicShardInfo?: SingleShardInfo | PubsubTopic
): Decoder {
return new Decoder(
determinePubsubTopic(contentTopic, pubsubTopicShardInfo),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Store extends BaseProtocol implements IStore {

constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
super(StoreCodec, libp2p.components, log);
this.pubsubTopics = this.initializePubsubTopic(options?.shardInfo);
this.pubsubTopics = this.initializePubsubTopic(options);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/lib/waku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class WakuNode implements Waku {

constructor(
options: WakuOptions,
pubsubTopics: PubsubTopic[] = [],
libp2p: Libp2p,
pubsubShardInfo?: ShardingParams,
store?: (libp2p: Libp2p) => IStore,
Expand All @@ -63,7 +64,8 @@ export class WakuNode implements Waku {
relay?: (libp2p: Libp2p) => IRelay
) {
if (!pubsubShardInfo) {
this.pubsubTopics = [DefaultPubsubTopic];
this.pubsubTopics =
pubsubTopics.length > 0 ? pubsubTopics : [DefaultPubsubTopic];
} else {
this.pubsubTopics = shardInfoToPubsubTopics(pubsubShardInfo);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/dns-discovery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* devDependencies
* @waku/interfaces bumped from 0.0.13 to 0.0.14

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.19 to 0.0.20
* @waku/utils bumped from 0.0.13 to 0.0.14
* devDependencies
* @waku/interfaces bumped from 0.0.20 to 0.0.21

## [0.0.19](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.18...dns-discovery-v0.0.19) (2023-11-01)


Expand Down
8 changes: 4 additions & 4 deletions packages/dns-discovery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/dns-discovery",
"version": "0.0.19",
"version": "0.0.20",
"description": "DNS Peer Discovery (EIP-1459)",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -51,8 +51,8 @@
"node": ">=18"
},
"dependencies": {
"@waku/enr": "0.0.19",
"@waku/utils": "0.0.13",
"@waku/enr": "0.0.20",
"@waku/utils": "0.0.14",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
Expand All @@ -67,7 +67,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.11",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.20",
"@waku/interfaces": "0.0.21",
"chai": "^4.3.10",
"cspell": "^7.3.2",
"mocha": "^10.2.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/enr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* devDependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/utils bumped from 0.0.13 to 0.0.14
* devDependencies
* @waku/interfaces bumped from 0.0.20 to 0.0.21

## [0.0.19](https://github.com/waku-org/js-waku/compare/enr-v0.0.18...enr-v0.0.19) (2023-11-01)


Expand Down
6 changes: 3 additions & 3 deletions packages/enr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/enr",
"version": "0.0.19",
"version": "0.0.20",
"description": "ENR (EIP-778) for Waku",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -56,7 +56,7 @@
"@libp2p/peer-id": "^3.0.3",
"@multiformats/multiaddr": "^12.0.0",
"@noble/secp256k1": "^1.7.1",
"@waku/utils": "0.0.13",
"@waku/utils": "0.0.14",
"debug": "^4.3.4",
"js-sha3": "^0.9.2"
},
Expand All @@ -68,7 +68,7 @@
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.1",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.20",
"@waku/interfaces": "0.0.21",
"chai": "^4.3.10",
"cspell": "^7.3.2",
"fast-check": "^3.14.0",
Expand Down
20 changes: 20 additions & 0 deletions packages/interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.21](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.20...interfaces-v0.0.21) (2024-01-10)


### ⚠ BREAKING CHANGES

* add support for sharded pubsub topics & remove support for named pubsub topics ([#1697](https://github.com/waku-org/js-waku/issues/1697))
* change all instances of `PubSubTopic` to `PubsubTopic` ([#1703](https://github.com/waku-org/js-waku/issues/1703))

### Features

* Add support for autosharded pubsub topics ([2bc3735](https://github.com/waku-org/js-waku/commit/2bc3735e4dcf85f06b3dee542024d7f20a40fac2))
* Add support for sharded pubsub topics & remove support for named pubsub topics ([#1697](https://github.com/waku-org/js-waku/issues/1697)) ([4cf2ffe](https://github.com/waku-org/js-waku/commit/4cf2ffefa75e0571805036b71644d2cdd4fe3192))
* Metadata protocol ([#1732](https://github.com/waku-org/js-waku/issues/1732)) ([9ac2a3f](https://github.com/waku-org/js-waku/commit/9ac2a3f36352523b79fcd8f8a94bd6e0e109fc30))
* Track node connection state ([#1719](https://github.com/waku-org/js-waku/issues/1719)) ([1d0e2ac](https://github.com/waku-org/js-waku/commit/1d0e2ace7fa5b44ab192505c7ebce01a7ce343e0))


### Miscellaneous Chores

* Change all instances of `PubSubTopic` to `PubsubTopic` ([#1703](https://github.com/waku-org/js-waku/issues/1703)) ([3166a51](https://github.com/waku-org/js-waku/commit/3166a5135e77583da4fa722ee2aa47c785854a38))

## [0.0.20](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.19...interfaces-v0.0.20) (2023-11-01)


Expand Down
2 changes: 1 addition & 1 deletion packages/interfaces/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/interfaces",
"version": "0.0.20",
"version": "0.0.21",
"description": "Definition of Waku interfaces",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/interfaces/src/filter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PeerId } from "@libp2p/interface/peer-id";

import type { IDecodedMessage, IDecoder, SingleShardInfo } from "./message.js";
import type { ContentTopic } from "./misc.js";
import type { ContentTopic, PubsubTopic } from "./misc.js";
import type { Callback, IBaseProtocol } from "./protocols.js";
import type { IReceiver } from "./receiver.js";

Expand All @@ -25,7 +25,7 @@ export interface IFilterSubscription {
export type IFilter = IReceiver &
IBaseProtocol & {
createSubscription(
pubsubTopicShardInfo?: SingleShardInfo,
pubsubTopicShardInfo?: SingleShardInfo | PubsubTopic,
peerId?: PeerId
): Promise<IFilterSubscription>;
};
4 changes: 4 additions & 0 deletions packages/interfaces/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export interface IMetaSetter {
}

export interface EncoderOptions {
/**
* @deprecated
*/
pubsubTopic?: PubsubTopic;
pubsubTopicShardInfo?: SingleShardInfo;
/** The content topic to set on outgoing messages. */
contentTopic: string;
Expand Down
14 changes: 13 additions & 1 deletion packages/interfaces/src/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Peer, PeerStore } from "@libp2p/interface/peer-store";
import type { ShardInfo } from "./enr.js";
import type { CreateLibp2pOptions } from "./libp2p.js";
import type { IDecodedMessage } from "./message.js";
import { PubsubTopic } from "./misc.js";

export enum Protocols {
Relay = "relay",
Expand All @@ -26,9 +27,20 @@ export type ContentTopicInfo = {
contentTopics: string[];
};

export type ShardingParams = ShardInfo | ContentTopicInfo;
export type ApplicationInfo = {
clusterId: number;
application: string;
version: string;
};

export type ShardingParams = ShardInfo | ContentTopicInfo | ApplicationInfo;

export type ProtocolCreateOptions = {
/**
* @deprecated
* Waku will stop supporting named sharding. Only static sharding and autosharding will be supported moving forward.
*/
pubsubTopics?: PubsubTopic[];
/**
* Waku supports usage of multiple pubsub topics. This is achieved through static sharding for now, and auto-sharding in the future.
* The format to specify a shard is:
Expand Down
Loading

0 comments on commit a958eee

Please sign in to comment.