mirror of https://github.com/waku-org/js-waku.git
Rename all `pubsubTopic` occurrences to `pubSubTopic`
This commit is contained in:
parent
026aaaf67e
commit
1d48dc4372
|
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Examples (eth-pm): Use sign typed data EIP-712 instead of personal sign.
|
- Examples (eth-pm): Use sign typed data EIP-712 instead of personal sign.
|
||||||
- Upgraded dependencies to remove warning at installation.
|
- Upgraded dependencies to remove warning at installation.
|
||||||
- **Breaking**: Moved `DefaultPubSubTopic` to `waku.ts` and fixed the casing.
|
- **Breaking**: Moved `DefaultPubSubTopic` to `waku.ts` and fixed the casing.
|
||||||
|
- **Breaking**: Rename all `pubsubTopic` occurrences to `pubSubTopic`, across all interfaces.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Examples (cli-chat): The focus of this library is Web environment;
|
- Examples (cli-chat): The focus of this library is Web environment;
|
||||||
|
|
|
@ -5,7 +5,7 @@ package waku.v2;
|
||||||
import "waku/v2/message.proto";
|
import "waku/v2/message.proto";
|
||||||
|
|
||||||
message PushRequest {
|
message PushRequest {
|
||||||
string pubsub_topic = 1;
|
string pub_sub_topic = 1;
|
||||||
WakuMessage message = 2;
|
WakuMessage message = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ message ContentFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryQuery {
|
message HistoryQuery {
|
||||||
optional string pubsub_topic = 2;
|
optional string pub_sub_topic = 2;
|
||||||
repeated ContentFilter content_filters = 3;
|
repeated ContentFilter content_filters = 3;
|
||||||
optional PagingInfo paging_info = 4;
|
optional PagingInfo paging_info = 4;
|
||||||
optional double start_time = 5;
|
optional double start_time = 5;
|
||||||
|
|
|
@ -50,7 +50,7 @@ export interface CreateOptions {
|
||||||
*
|
*
|
||||||
* @default {@link DefaultPubSubTopic}
|
* @default {@link DefaultPubSubTopic}
|
||||||
*/
|
*/
|
||||||
pubsubTopic?: string;
|
pubSubTopic?: string;
|
||||||
/**
|
/**
|
||||||
* Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0`
|
* Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0`
|
||||||
* request to each peer after the set number of seconds. Set to 0 to disable.
|
* request to each peer after the set number of seconds. Set to 0 to disable.
|
||||||
|
@ -158,9 +158,9 @@ export class Waku {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Pass pubsub topic to relay
|
// Pass pubsub topic to relay
|
||||||
if (options?.pubsubTopic) {
|
if (options?.pubSubTopic) {
|
||||||
libp2pOpts.config.pubsub = Object.assign(
|
libp2pOpts.config.pubsub = Object.assign(
|
||||||
{ pubsubTopic: options.pubsubTopic },
|
{ pubSubTopic: options.pubSubTopic },
|
||||||
libp2pOpts.config.pubsub
|
libp2pOpts.config.pubsub
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ export class Waku {
|
||||||
const libp2p = await Libp2p.create(libp2pOpts);
|
const libp2p = await Libp2p.create(libp2pOpts);
|
||||||
|
|
||||||
const wakuStore = new WakuStore(libp2p, {
|
const wakuStore = new WakuStore(libp2p, {
|
||||||
pubsubTopic: options?.pubsubTopic,
|
pubSubTopic: options?.pubSubTopic,
|
||||||
});
|
});
|
||||||
const wakuLightPush = new WakuLightPush(libp2p);
|
const wakuLightPush = new WakuLightPush(libp2p);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe('Waku Light Push', () => {
|
||||||
await nimWaku.start({ lightpush: true, topics: customPubSubTopic });
|
await nimWaku.start({ lightpush: true, topics: customPubSubTopic });
|
||||||
|
|
||||||
waku = await Waku.create({
|
waku = await Waku.create({
|
||||||
pubsubTopic: customPubSubTopic,
|
pubSubTopic: customPubSubTopic,
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
libp2p: { modules: { transport: [TCP] } },
|
libp2p: { modules: { transport: [TCP] } },
|
||||||
});
|
});
|
||||||
|
|
|
@ -66,10 +66,10 @@ export class WakuLightPush {
|
||||||
|
|
||||||
const { stream } = await connection.newStream(LightPushCodec);
|
const { stream } = await connection.newStream(LightPushCodec);
|
||||||
try {
|
try {
|
||||||
const pubsubTopic = opts?.pubSubTopic
|
const pubSubTopic = opts?.pubSubTopic
|
||||||
? opts.pubSubTopic
|
? opts.pubSubTopic
|
||||||
: this.pubSubTopic;
|
: this.pubSubTopic;
|
||||||
const query = PushRPC.createRequest(message, pubsubTopic);
|
const query = PushRPC.createRequest(message, pubSubTopic);
|
||||||
const res = await pipe(
|
const res = await pipe(
|
||||||
[query.encode()],
|
[query.encode()],
|
||||||
lp.encode(),
|
lp.encode(),
|
||||||
|
|
|
@ -7,12 +7,12 @@ import { WakuMessage } from '../waku_message';
|
||||||
export class PushRPC {
|
export class PushRPC {
|
||||||
public constructor(public proto: proto.PushRPC) {}
|
public constructor(public proto: proto.PushRPC) {}
|
||||||
|
|
||||||
static createRequest(message: WakuMessage, pubsubTopic: string): PushRPC {
|
static createRequest(message: WakuMessage, pubSubTopic: string): PushRPC {
|
||||||
return new PushRPC({
|
return new PushRPC({
|
||||||
requestId: uuid(),
|
requestId: uuid(),
|
||||||
request: {
|
request: {
|
||||||
message: message.proto,
|
message: message.proto,
|
||||||
pubsubTopic,
|
pubSubTopic: pubSubTopic,
|
||||||
},
|
},
|
||||||
response: undefined,
|
response: undefined,
|
||||||
});
|
});
|
||||||
|
|
|
@ -178,16 +178,16 @@ describe('Waku Relay', () => {
|
||||||
it('Publish', async function () {
|
it('Publish', async function () {
|
||||||
this.timeout(10000);
|
this.timeout(10000);
|
||||||
|
|
||||||
const pubsubTopic = '/some/pubsub/topic';
|
const pubSubTopic = '/some/pubsub/topic';
|
||||||
|
|
||||||
// 1 and 2 uses a custom pubsub
|
// 1 and 2 uses a custom pubsub
|
||||||
const [waku1, waku2, waku3] = await Promise.all([
|
const [waku1, waku2, waku3] = await Promise.all([
|
||||||
Waku.create({
|
Waku.create({
|
||||||
pubsubTopic,
|
pubSubTopic: pubSubTopic,
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
}),
|
}),
|
||||||
Waku.create({
|
Waku.create({
|
||||||
pubsubTopic,
|
pubSubTopic: pubSubTopic,
|
||||||
staticNoiseKey: NOISE_KEY_2,
|
staticNoiseKey: NOISE_KEY_2,
|
||||||
libp2p: { addresses: { listen: ['/ip4/0.0.0.0/tcp/0/ws'] } },
|
libp2p: { addresses: { listen: ['/ip4/0.0.0.0/tcp/0/ws'] } },
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -62,7 +62,7 @@ export interface GossipOptions {
|
||||||
*/
|
*/
|
||||||
export class WakuRelay extends Gossipsub {
|
export class WakuRelay extends Gossipsub {
|
||||||
heartbeat: RelayHeartbeat;
|
heartbeat: RelayHeartbeat;
|
||||||
pubsubTopic: string;
|
pubSubTopic: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decryption private keys to use to attempt decryption of incoming messages.
|
* Decryption private keys to use to attempt decryption of incoming messages.
|
||||||
|
@ -97,7 +97,7 @@ export class WakuRelay extends Gossipsub {
|
||||||
|
|
||||||
Object.assign(this, { multicodecs });
|
Object.assign(this, { multicodecs });
|
||||||
|
|
||||||
this.pubsubTopic = options?.pubsubTopic || DefaultPubSubTopic;
|
this.pubSubTopic = options?.pubSubTopic || DefaultPubSubTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +109,7 @@ export class WakuRelay extends Gossipsub {
|
||||||
*/
|
*/
|
||||||
public start(): void {
|
public start(): void {
|
||||||
super.start();
|
super.start();
|
||||||
this.subscribe(this.pubsubTopic);
|
this.subscribe(this.pubSubTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +120,7 @@ export class WakuRelay extends Gossipsub {
|
||||||
*/
|
*/
|
||||||
public async send(message: WakuMessage): Promise<void> {
|
public async send(message: WakuMessage): Promise<void> {
|
||||||
const msg = message.encode();
|
const msg = message.encode();
|
||||||
await super.publish(this.pubsubTopic, Buffer.from(msg));
|
await super.publish(this.pubSubTopic, Buffer.from(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,7 +194,7 @@ export class WakuRelay extends Gossipsub {
|
||||||
* Return the relay peers we are connected to and we would publish a message to
|
* Return the relay peers we are connected to and we would publish a message to
|
||||||
*/
|
*/
|
||||||
getPeers(): Set<string> {
|
getPeers(): Set<string> {
|
||||||
return getRelayPeers(this, this.pubsubTopic, this._options.D, (id) => {
|
return getRelayPeers(this, this.pubSubTopic, this._options.D, (id) => {
|
||||||
// Filter peers we would not publish to
|
// Filter peers we would not publish to
|
||||||
return (
|
return (
|
||||||
this.score.score(id) >= this._options.scoreThresholds.publishThreshold
|
this.score.score(id) >= this._options.scoreThresholds.publishThreshold
|
||||||
|
@ -207,9 +207,9 @@ export class WakuRelay extends Gossipsub {
|
||||||
*
|
*
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
subscribe(pubsubTopic: string): void {
|
subscribe(pubSubTopic: string): void {
|
||||||
this.on(pubsubTopic, (event) => {
|
this.on(pubSubTopic, (event) => {
|
||||||
dbg(`Message received on ${pubsubTopic}`);
|
dbg(`Message received on ${pubSubTopic}`);
|
||||||
WakuMessage.decode(event.data, Array.from(this.decryptionKeys))
|
WakuMessage.decode(event.data, Array.from(this.decryptionKeys))
|
||||||
.then((wakuMsg) => {
|
.then((wakuMsg) => {
|
||||||
if (!wakuMsg) {
|
if (!wakuMsg) {
|
||||||
|
@ -235,7 +235,7 @@ export class WakuRelay extends Gossipsub {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
super.subscribe(pubsubTopic);
|
super.subscribe(pubSubTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,7 +11,7 @@ export enum Direction {
|
||||||
export interface Params {
|
export interface Params {
|
||||||
contentTopics: string[];
|
contentTopics: string[];
|
||||||
cursor?: proto.Index;
|
cursor?: proto.Index;
|
||||||
pubsubTopic: string;
|
pubSubTopic: string;
|
||||||
direction: Direction;
|
direction: Direction;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ export class HistoryRPC {
|
||||||
return new HistoryRPC({
|
return new HistoryRPC({
|
||||||
requestId: uuid(),
|
requestId: uuid(),
|
||||||
query: {
|
query: {
|
||||||
pubsubTopic: params.pubsubTopic,
|
pubSubTopic: params.pubSubTopic,
|
||||||
contentFilters,
|
contentFilters,
|
||||||
pagingInfo,
|
pagingInfo,
|
||||||
startTime: undefined,
|
startTime: undefined,
|
||||||
|
|
|
@ -120,7 +120,7 @@ describe('Waku Store', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
waku = await Waku.create({
|
waku = await Waku.create({
|
||||||
pubsubTopic: customPubSubTopic,
|
pubSubTopic: customPubSubTopic,
|
||||||
staticNoiseKey: NOISE_KEY_1,
|
staticNoiseKey: NOISE_KEY_1,
|
||||||
libp2p: { modules: { transport: [TCP] } },
|
libp2p: { modules: { transport: [TCP] } },
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,12 +28,12 @@ export interface CreateOptions {
|
||||||
*
|
*
|
||||||
* @default {@link DefaultPubSubTopic}
|
* @default {@link DefaultPubSubTopic}
|
||||||
*/
|
*/
|
||||||
pubsubTopic?: string;
|
pubSubTopic?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryOptions {
|
export interface QueryOptions {
|
||||||
peerId?: PeerId;
|
peerId?: PeerId;
|
||||||
pubsubTopic?: string;
|
pubSubTopic?: string;
|
||||||
direction?: Direction;
|
direction?: Direction;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
callback?: (messages: WakuMessage[]) => void;
|
callback?: (messages: WakuMessage[]) => void;
|
||||||
|
@ -44,13 +44,13 @@ export interface QueryOptions {
|
||||||
* Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).
|
* Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).
|
||||||
*/
|
*/
|
||||||
export class WakuStore {
|
export class WakuStore {
|
||||||
pubsubTopic: string;
|
pubSubTopic: string;
|
||||||
|
|
||||||
constructor(public libp2p: Libp2p, options?: CreateOptions) {
|
constructor(public libp2p: Libp2p, options?: CreateOptions) {
|
||||||
if (options?.pubsubTopic) {
|
if (options?.pubSubTopic) {
|
||||||
this.pubsubTopic = options.pubsubTopic;
|
this.pubSubTopic = options.pubSubTopic;
|
||||||
} else {
|
} else {
|
||||||
this.pubsubTopic = DefaultPubSubTopic;
|
this.pubSubTopic = DefaultPubSubTopic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export class WakuStore {
|
||||||
* retrieve all messages.
|
* retrieve all messages.
|
||||||
* @param options
|
* @param options
|
||||||
* @param options.peerId The peer to query.Options
|
* @param options.peerId The peer to query.Options
|
||||||
* @param options.pubsubTopic The pubsub topic to pass to the query. Defaults
|
* @param options.pubSubTopic The pubsub topic to pass to the query. Defaults
|
||||||
* to the value set at creation. See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/).
|
* to the value set at creation. See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/).
|
||||||
* @param options.callback Callback called on page of stored messages as they are retrieved
|
* @param options.callback Callback called on page of stored messages as they are retrieved
|
||||||
* @param options.decryptionKeys Keys that will be used to decrypt messages.
|
* @param options.decryptionKeys Keys that will be used to decrypt messages.
|
||||||
|
@ -75,7 +75,7 @@ export class WakuStore {
|
||||||
): Promise<WakuMessage[]> {
|
): Promise<WakuMessage[]> {
|
||||||
const opts = Object.assign(
|
const opts = Object.assign(
|
||||||
{
|
{
|
||||||
pubsubTopic: this.pubsubTopic,
|
pubSubTopic: this.pubSubTopic,
|
||||||
direction: Direction.BACKWARD,
|
direction: Direction.BACKWARD,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
},
|
},
|
||||||
|
@ -131,7 +131,7 @@ export class WakuStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg(
|
dbg(
|
||||||
`${response.messages.length} messages retrieved for pubsub topic ${opts.pubsubTopic}`
|
`${response.messages.length} messages retrieved for pubsub topic ${opts.pubSubTopic}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const pageMessages: WakuMessage[] = [];
|
const pageMessages: WakuMessage[] = [];
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { WakuMessage } from '../../waku/v2/message';
|
||||||
export const protobufPackage = 'waku.v2';
|
export const protobufPackage = 'waku.v2';
|
||||||
|
|
||||||
export interface PushRequest {
|
export interface PushRequest {
|
||||||
pubsubTopic: string;
|
pubSubTopic: string;
|
||||||
message: WakuMessage | undefined;
|
message: WakuMessage | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,15 +21,15 @@ export interface PushRPC {
|
||||||
response: PushResponse | undefined;
|
response: PushResponse | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const basePushRequest: object = { pubsubTopic: '' };
|
const basePushRequest: object = { pubSubTopic: '' };
|
||||||
|
|
||||||
export const PushRequest = {
|
export const PushRequest = {
|
||||||
encode(
|
encode(
|
||||||
message: PushRequest,
|
message: PushRequest,
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
writer: _m0.Writer = _m0.Writer.create()
|
||||||
): _m0.Writer {
|
): _m0.Writer {
|
||||||
if (message.pubsubTopic !== '') {
|
if (message.pubSubTopic !== '') {
|
||||||
writer.uint32(10).string(message.pubsubTopic);
|
writer.uint32(10).string(message.pubSubTopic);
|
||||||
}
|
}
|
||||||
if (message.message !== undefined) {
|
if (message.message !== undefined) {
|
||||||
WakuMessage.encode(message.message, writer.uint32(18).fork()).ldelim();
|
WakuMessage.encode(message.message, writer.uint32(18).fork()).ldelim();
|
||||||
|
@ -45,7 +45,7 @@ export const PushRequest = {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 1:
|
case 1:
|
||||||
message.pubsubTopic = reader.string();
|
message.pubSubTopic = reader.string();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
message.message = WakuMessage.decode(reader, reader.uint32());
|
message.message = WakuMessage.decode(reader, reader.uint32());
|
||||||
|
@ -60,10 +60,10 @@ export const PushRequest = {
|
||||||
|
|
||||||
fromJSON(object: any): PushRequest {
|
fromJSON(object: any): PushRequest {
|
||||||
const message = { ...basePushRequest } as PushRequest;
|
const message = { ...basePushRequest } as PushRequest;
|
||||||
if (object.pubsubTopic !== undefined && object.pubsubTopic !== null) {
|
if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) {
|
||||||
message.pubsubTopic = String(object.pubsubTopic);
|
message.pubSubTopic = String(object.pubSubTopic);
|
||||||
} else {
|
} else {
|
||||||
message.pubsubTopic = '';
|
message.pubSubTopic = '';
|
||||||
}
|
}
|
||||||
if (object.message !== undefined && object.message !== null) {
|
if (object.message !== undefined && object.message !== null) {
|
||||||
message.message = WakuMessage.fromJSON(object.message);
|
message.message = WakuMessage.fromJSON(object.message);
|
||||||
|
@ -75,8 +75,8 @@ export const PushRequest = {
|
||||||
|
|
||||||
toJSON(message: PushRequest): unknown {
|
toJSON(message: PushRequest): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.pubsubTopic !== undefined &&
|
message.pubSubTopic !== undefined &&
|
||||||
(obj.pubsubTopic = message.pubsubTopic);
|
(obj.pubSubTopic = message.pubSubTopic);
|
||||||
message.message !== undefined &&
|
message.message !== undefined &&
|
||||||
(obj.message = message.message
|
(obj.message = message.message
|
||||||
? WakuMessage.toJSON(message.message)
|
? WakuMessage.toJSON(message.message)
|
||||||
|
@ -86,10 +86,10 @@ export const PushRequest = {
|
||||||
|
|
||||||
fromPartial(object: DeepPartial<PushRequest>): PushRequest {
|
fromPartial(object: DeepPartial<PushRequest>): PushRequest {
|
||||||
const message = { ...basePushRequest } as PushRequest;
|
const message = { ...basePushRequest } as PushRequest;
|
||||||
if (object.pubsubTopic !== undefined && object.pubsubTopic !== null) {
|
if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) {
|
||||||
message.pubsubTopic = object.pubsubTopic;
|
message.pubSubTopic = object.pubSubTopic;
|
||||||
} else {
|
} else {
|
||||||
message.pubsubTopic = '';
|
message.pubSubTopic = '';
|
||||||
}
|
}
|
||||||
if (object.message !== undefined && object.message !== null) {
|
if (object.message !== undefined && object.message !== null) {
|
||||||
message.message = WakuMessage.fromPartial(object.message);
|
message.message = WakuMessage.fromPartial(object.message);
|
||||||
|
|
|
@ -58,7 +58,7 @@ export interface ContentFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HistoryQuery {
|
export interface HistoryQuery {
|
||||||
pubsubTopic?: string | undefined;
|
pubSubTopic?: string | undefined;
|
||||||
contentFilters: ContentFilter[];
|
contentFilters: ContentFilter[];
|
||||||
pagingInfo?: PagingInfo | undefined;
|
pagingInfo?: PagingInfo | undefined;
|
||||||
startTime?: number | undefined;
|
startTime?: number | undefined;
|
||||||
|
@ -366,8 +366,8 @@ export const HistoryQuery = {
|
||||||
message: HistoryQuery,
|
message: HistoryQuery,
|
||||||
writer: _m0.Writer = _m0.Writer.create()
|
writer: _m0.Writer = _m0.Writer.create()
|
||||||
): _m0.Writer {
|
): _m0.Writer {
|
||||||
if (message.pubsubTopic !== undefined) {
|
if (message.pubSubTopic !== undefined) {
|
||||||
writer.uint32(18).string(message.pubsubTopic);
|
writer.uint32(18).string(message.pubSubTopic);
|
||||||
}
|
}
|
||||||
for (const v of message.contentFilters) {
|
for (const v of message.contentFilters) {
|
||||||
ContentFilter.encode(v!, writer.uint32(26).fork()).ldelim();
|
ContentFilter.encode(v!, writer.uint32(26).fork()).ldelim();
|
||||||
|
@ -393,7 +393,7 @@ export const HistoryQuery = {
|
||||||
const tag = reader.uint32();
|
const tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
case 2:
|
case 2:
|
||||||
message.pubsubTopic = reader.string();
|
message.pubSubTopic = reader.string();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
message.contentFilters.push(
|
message.contentFilters.push(
|
||||||
|
@ -420,10 +420,10 @@ export const HistoryQuery = {
|
||||||
fromJSON(object: any): HistoryQuery {
|
fromJSON(object: any): HistoryQuery {
|
||||||
const message = { ...baseHistoryQuery } as HistoryQuery;
|
const message = { ...baseHistoryQuery } as HistoryQuery;
|
||||||
message.contentFilters = [];
|
message.contentFilters = [];
|
||||||
if (object.pubsubTopic !== undefined && object.pubsubTopic !== null) {
|
if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) {
|
||||||
message.pubsubTopic = String(object.pubsubTopic);
|
message.pubSubTopic = String(object.pubSubTopic);
|
||||||
} else {
|
} else {
|
||||||
message.pubsubTopic = undefined;
|
message.pubSubTopic = undefined;
|
||||||
}
|
}
|
||||||
if (object.contentFilters !== undefined && object.contentFilters !== null) {
|
if (object.contentFilters !== undefined && object.contentFilters !== null) {
|
||||||
for (const e of object.contentFilters) {
|
for (const e of object.contentFilters) {
|
||||||
|
@ -450,8 +450,8 @@ export const HistoryQuery = {
|
||||||
|
|
||||||
toJSON(message: HistoryQuery): unknown {
|
toJSON(message: HistoryQuery): unknown {
|
||||||
const obj: any = {};
|
const obj: any = {};
|
||||||
message.pubsubTopic !== undefined &&
|
message.pubSubTopic !== undefined &&
|
||||||
(obj.pubsubTopic = message.pubsubTopic);
|
(obj.pubSubTopic = message.pubSubTopic);
|
||||||
if (message.contentFilters) {
|
if (message.contentFilters) {
|
||||||
obj.contentFilters = message.contentFilters.map((e) =>
|
obj.contentFilters = message.contentFilters.map((e) =>
|
||||||
e ? ContentFilter.toJSON(e) : undefined
|
e ? ContentFilter.toJSON(e) : undefined
|
||||||
|
@ -471,10 +471,10 @@ export const HistoryQuery = {
|
||||||
fromPartial(object: DeepPartial<HistoryQuery>): HistoryQuery {
|
fromPartial(object: DeepPartial<HistoryQuery>): HistoryQuery {
|
||||||
const message = { ...baseHistoryQuery } as HistoryQuery;
|
const message = { ...baseHistoryQuery } as HistoryQuery;
|
||||||
message.contentFilters = [];
|
message.contentFilters = [];
|
||||||
if (object.pubsubTopic !== undefined && object.pubsubTopic !== null) {
|
if (object.pubSubTopic !== undefined && object.pubSubTopic !== null) {
|
||||||
message.pubsubTopic = object.pubsubTopic;
|
message.pubSubTopic = object.pubSubTopic;
|
||||||
} else {
|
} else {
|
||||||
message.pubsubTopic = undefined;
|
message.pubSubTopic = undefined;
|
||||||
}
|
}
|
||||||
if (object.contentFilters !== undefined && object.contentFilters !== null) {
|
if (object.contentFilters !== undefined && object.contentFilters !== null) {
|
||||||
for (const e of object.contentFilters) {
|
for (const e of object.contentFilters) {
|
||||||
|
|
|
@ -171,7 +171,7 @@ export class NimWaku {
|
||||||
|
|
||||||
async sendMessage(
|
async sendMessage(
|
||||||
message: WakuMessage,
|
message: WakuMessage,
|
||||||
pubsubTopic?: string
|
pubSubTopic?: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
this.checkProcess();
|
this.checkProcess();
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ export class NimWaku {
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.rpcCall<boolean>('post_waku_v2_relay_v1_message', [
|
return this.rpcCall<boolean>('post_waku_v2_relay_v1_message', [
|
||||||
pubsubTopic ? pubsubTopic : DefaultPubSubTopic,
|
pubSubTopic ? pubSubTopic : DefaultPubSubTopic,
|
||||||
rpcMessage,
|
rpcMessage,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ export class NimWaku {
|
||||||
async postAsymmetricMessage(
|
async postAsymmetricMessage(
|
||||||
message: WakuRelayMessage,
|
message: WakuRelayMessage,
|
||||||
publicKey: Uint8Array,
|
publicKey: Uint8Array,
|
||||||
pubsubTopic?: string
|
pubSubTopic?: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
this.checkProcess();
|
this.checkProcess();
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ export class NimWaku {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.rpcCall<boolean>('post_waku_v2_private_v1_asymmetric_message', [
|
return this.rpcCall<boolean>('post_waku_v2_private_v1_asymmetric_message', [
|
||||||
pubsubTopic ? pubsubTopic : DefaultPubSubTopic,
|
pubSubTopic ? pubSubTopic : DefaultPubSubTopic,
|
||||||
message,
|
message,
|
||||||
'0x' + bufToHex(publicKey),
|
'0x' + bufToHex(publicKey),
|
||||||
]);
|
]);
|
||||||
|
@ -250,14 +250,14 @@ export class NimWaku {
|
||||||
|
|
||||||
async getAsymmetricMessages(
|
async getAsymmetricMessages(
|
||||||
privateKey: Uint8Array,
|
privateKey: Uint8Array,
|
||||||
pubsubTopic?: string
|
pubSubTopic?: string
|
||||||
): Promise<WakuRelayMessage[]> {
|
): Promise<WakuRelayMessage[]> {
|
||||||
this.checkProcess();
|
this.checkProcess();
|
||||||
|
|
||||||
return await this.rpcCall<WakuRelayMessage[]>(
|
return await this.rpcCall<WakuRelayMessage[]>(
|
||||||
'get_waku_v2_private_v1_asymmetric_messages',
|
'get_waku_v2_private_v1_asymmetric_messages',
|
||||||
[
|
[
|
||||||
pubsubTopic ? pubsubTopic : DefaultPubSubTopic,
|
pubSubTopic ? pubSubTopic : DefaultPubSubTopic,
|
||||||
'0x' + bufToHex(privateKey),
|
'0x' + bufToHex(privateKey),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -275,7 +275,7 @@ export class NimWaku {
|
||||||
async postSymmetricMessage(
|
async postSymmetricMessage(
|
||||||
message: WakuRelayMessage,
|
message: WakuRelayMessage,
|
||||||
symKey: Uint8Array,
|
symKey: Uint8Array,
|
||||||
pubsubTopic?: string
|
pubSubTopic?: string
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
this.checkProcess();
|
this.checkProcess();
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ export class NimWaku {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.rpcCall<boolean>('post_waku_v2_private_v1_symmetric_message', [
|
return this.rpcCall<boolean>('post_waku_v2_private_v1_symmetric_message', [
|
||||||
pubsubTopic ? pubsubTopic : DefaultPubSubTopic,
|
pubSubTopic ? pubSubTopic : DefaultPubSubTopic,
|
||||||
message,
|
message,
|
||||||
'0x' + bufToHex(symKey),
|
'0x' + bufToHex(symKey),
|
||||||
]);
|
]);
|
||||||
|
@ -292,13 +292,13 @@ export class NimWaku {
|
||||||
|
|
||||||
async getSymmetricMessages(
|
async getSymmetricMessages(
|
||||||
symKey: Uint8Array,
|
symKey: Uint8Array,
|
||||||
pubsubTopic?: string
|
pubSubTopic?: string
|
||||||
): Promise<WakuRelayMessage[]> {
|
): Promise<WakuRelayMessage[]> {
|
||||||
this.checkProcess();
|
this.checkProcess();
|
||||||
|
|
||||||
return await this.rpcCall<WakuRelayMessage[]>(
|
return await this.rpcCall<WakuRelayMessage[]>(
|
||||||
'get_waku_v2_private_v1_symmetric_messages',
|
'get_waku_v2_private_v1_symmetric_messages',
|
||||||
[pubsubTopic ? pubsubTopic : DefaultPubSubTopic, '0x' + bufToHex(symKey)]
|
[pubSubTopic ? pubSubTopic : DefaultPubSubTopic, '0x' + bufToHex(symKey)]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue