feat: added `I` prefix to message/codec interfaces

To make it easier to differentiate with their implementations.
This commit is contained in:
fryorcraken.eth 2022-12-05 17:07:03 +11:00
parent a7c4bb9cbf
commit cc691e26ce
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
19 changed files with 134 additions and 123 deletions

View File

@ -1,7 +1,7 @@
import { ProtoMessage } from "@waku/interfaces";
import { IProtoMessage } from "@waku/interfaces";
import { WakuMessage as WakuMessageProto } from "@waku/proto";
const EmptyMessage: ProtoMessage = {
const EmptyMessage: IProtoMessage = {
payload: undefined,
contentTopic: undefined,
version: undefined,
@ -10,6 +10,6 @@ const EmptyMessage: ProtoMessage = {
ephemeral: undefined,
};
export function toProtoMessage(wire: WakuMessageProto): ProtoMessage {
export function toProtoMessage(wire: WakuMessageProto): IProtoMessage {
return { ...EmptyMessage, ...wire };
}

View File

@ -7,10 +7,10 @@ import type { IncomingStreamData } from "@libp2p/interface-registrar";
import type { Registrar } from "@libp2p/interface-registrar";
import type {
Callback,
DecodedMessage,
Decoder,
Filter,
Message,
IDecodedMessage,
IDecoder,
IMessage,
ProtocolOptions,
} from "@waku/interfaces";
import {
@ -69,7 +69,7 @@ class WakuFilter implements Filter {
private subscriptions: Map<string, Callback<any>>;
private decoders: Map<
string, // content topic
Set<Decoder<any>>
Set<IDecoder<any>>
>;
constructor(public components: FilterComponents, options?: CreateOptions) {
@ -87,8 +87,8 @@ class WakuFilter implements Filter {
* @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to.
* @returns Unsubscribe function that can be used to end the subscription.
*/
async subscribe<T extends DecodedMessage>(
decoders: Decoder<T>[],
async subscribe<T extends IDecodedMessage>(
decoders: IDecoder<T>[],
callback: Callback<T>,
opts?: ProtocolOptions
): Promise<UnsubscribeFunction> {
@ -198,7 +198,7 @@ class WakuFilter implements Filter {
return;
}
let msg: Message | undefined;
let msg: IMessage | undefined;
// We don't want to wait for decoding failure, just attempt to decode
// all messages and do the call back on the one that works
// noinspection ES6MissingAwait
@ -225,8 +225,8 @@ class WakuFilter implements Filter {
this.subscriptions.delete(requestId);
}
private addDecoders<T extends DecodedMessage>(
decoders: Map<string, Array<Decoder<T>>>
private addDecoders<T extends IDecodedMessage>(
decoders: Map<string, Array<IDecoder<T>>>
): void {
decoders.forEach((decoders, contentTopic) => {
const currDecs = this.decoders.get(contentTopic);
@ -238,8 +238,8 @@ class WakuFilter implements Filter {
});
}
private deleteDecoders<T extends DecodedMessage>(
decoders: Map<string, Array<Decoder<T>>>
private deleteDecoders<T extends IDecodedMessage>(
decoders: Map<string, Array<IDecoder<T>>>
): void {
decoders.forEach((decoders, contentTopic) => {
const currDecs = this.decoders.get(contentTopic);

View File

@ -3,9 +3,9 @@ import type { PeerId } from "@libp2p/interface-peer-id";
import type { Peer } from "@libp2p/interface-peer-store";
import type { PeerStore } from "@libp2p/interface-peer-store";
import type {
Encoder,
IEncoder,
IMessage,
LightPush,
Message,
ProtocolOptions,
SendResult,
} from "@waku/interfaces";
@ -59,8 +59,8 @@ class WakuLightPush implements LightPush {
}
async push(
encoder: Encoder,
message: Message,
encoder: IEncoder,
message: IMessage,
opts?: ProtocolOptions
): Promise<SendResult> {
const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic;

View File

@ -1,10 +1,14 @@
import type { DecodedMessage, Decoder, ProtoMessage } from "@waku/interfaces";
import type {
IDecodedMessage,
IDecoder,
IProtoMessage,
} from "@waku/interfaces";
import { proto_topic_only_message as proto } from "@waku/proto";
import debug from "debug";
const log = debug("waku:message:topic-only");
export class TopicOnlyMessage implements DecodedMessage {
export class TopicOnlyMessage implements IDecodedMessage {
public payload: undefined;
public rateLimitProof: undefined;
public timestamp: undefined;
@ -17,10 +21,10 @@ export class TopicOnlyMessage implements DecodedMessage {
}
}
export class TopicOnlyDecoder implements Decoder<TopicOnlyMessage> {
export class TopicOnlyDecoder implements IDecoder<TopicOnlyMessage> {
public contentTopic = "";
fromWireToProtoObj(bytes: Uint8Array): Promise<ProtoMessage | undefined> {
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
const protoMessage = proto.TopicOnlyMessage.decode(bytes);
log("Message decoded", protoMessage);
return Promise.resolve({
@ -34,7 +38,7 @@ export class TopicOnlyDecoder implements Decoder<TopicOnlyMessage> {
}
async fromProtoObj(
proto: ProtoMessage
proto: IProtoMessage
): Promise<TopicOnlyMessage | undefined> {
return new TopicOnlyMessage(proto);
}

View File

@ -1,10 +1,10 @@
import type {
DecodedMessage as IDecodedMessage,
Decoder as IDecoder,
Encoder as IEncoder,
Message,
ProtoMessage,
RateLimitProof,
IDecodedMessage,
IDecoder,
IEncoder,
IMessage,
IProtoMessage,
IRateLimitProof,
} from "@waku/interfaces";
import { proto_message as proto } from "@waku/proto";
import debug from "debug";
@ -65,7 +65,7 @@ export class DecodedMessage implements IDecodedMessage {
return this.proto.version ?? 0;
}
get rateLimitProof(): RateLimitProof | undefined {
get rateLimitProof(): IRateLimitProof | undefined {
return this.proto.rateLimitProof;
}
}
@ -73,11 +73,11 @@ export class DecodedMessage implements IDecodedMessage {
export class Encoder implements IEncoder {
constructor(public contentTopic: string, public ephemeral: boolean = false) {}
async toWire(message: Message): Promise<Uint8Array> {
async toWire(message: IMessage): Promise<Uint8Array> {
return proto.WakuMessage.encode(await this.toProtoObj(message));
}
async toProtoObj(message: Message): Promise<ProtoMessage> {
async toProtoObj(message: IMessage): Promise<IProtoMessage> {
const timestamp = message.timestamp ?? new Date();
return {
@ -113,7 +113,7 @@ export function createEncoder(
export class Decoder implements IDecoder<DecodedMessage> {
constructor(public contentTopic: string) {}
fromWireToProtoObj(bytes: Uint8Array): Promise<ProtoMessage | undefined> {
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
const protoMessage = proto.WakuMessage.decode(bytes);
log("Message decoded", protoMessage);
return Promise.resolve({
@ -126,7 +126,9 @@ export class Decoder implements IDecoder<DecodedMessage> {
});
}
async fromProtoObj(proto: ProtoMessage): Promise<DecodedMessage | undefined> {
async fromProtoObj(
proto: IProtoMessage
): Promise<DecodedMessage | undefined> {
// https://github.com/status-im/js-waku/issues/921
if (proto.version === undefined) {
proto.version = 0;

View File

@ -8,13 +8,13 @@ import type { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/types";
import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types";
import type {
Callback,
Decoder,
Encoder,
Message,
IDecoder,
IEncoder,
IMessage,
Relay,
SendResult,
} from "@waku/interfaces";
import { DecodedMessage } from "@waku/interfaces";
import { IDecodedMessage } from "@waku/interfaces";
import debug from "debug";
import { DefaultPubSubTopic } from "../constants.js";
@ -25,8 +25,8 @@ import * as constants from "./constants.js";
const log = debug("waku:relay");
export type Observer<T extends DecodedMessage> = {
decoder: Decoder<T>;
export type Observer<T extends IDecodedMessage> = {
decoder: IDecoder<T>;
callback: Callback<T>;
};
@ -55,7 +55,7 @@ export type CreateOptions = {
*/
class WakuRelay extends GossipSub implements Relay {
pubSubTopic: string;
defaultDecoder: Decoder<DecodedMessage>;
defaultDecoder: IDecoder<IDecodedMessage>;
public static multicodec: string = constants.RelayCodecs[0];
/**
@ -99,7 +99,7 @@ class WakuRelay extends GossipSub implements Relay {
/**
* Send Waku message.
*/
public async send(encoder: Encoder, message: Message): Promise<SendResult> {
public async send(encoder: IEncoder, message: IMessage): Promise<SendResult> {
const msg = await encoder.toWire(message);
if (!msg) {
log("Failed to encode message, aborting publish");
@ -113,8 +113,8 @@ class WakuRelay extends GossipSub implements Relay {
*
* @returns Function to delete the observer
*/
addObserver<T extends DecodedMessage>(
decoder: Decoder<T>,
addObserver<T extends IDecodedMessage>(
decoder: IDecoder<T>,
callback: Callback<T>
): () => void {
const observer = {

View File

@ -6,8 +6,8 @@ import { sha256 } from "@noble/hashes/sha256";
import { concat, utf8ToBytes } from "@waku/byte-utils";
import {
Cursor,
DecodedMessage,
Decoder,
IDecodedMessage,
IDecoder,
Index,
Store,
} from "@waku/interfaces";
@ -128,8 +128,8 @@ class WakuStore implements Store {
* or if an error is encountered when processing the reply,
* or if two decoders with the same content topic are passed.
*/
async queryOrderedCallback<T extends DecodedMessage>(
decoders: Decoder<T>[],
async queryOrderedCallback<T extends IDecodedMessage>(
decoders: IDecoder<T>[],
callback: (message: T) => Promise<void | boolean> | boolean | void,
options?: QueryOptions
): Promise<void> {
@ -177,8 +177,8 @@ class WakuStore implements Store {
* or if an error is encountered when processing the reply,
* or if two decoders with the same content topic are passed.
*/
async queryCallbackOnPromise<T extends DecodedMessage>(
decoders: Decoder<T>[],
async queryCallbackOnPromise<T extends IDecodedMessage>(
decoders: IDecoder<T>[],
callback: (
message: Promise<T | undefined>
) => Promise<void | boolean> | boolean | void,
@ -215,8 +215,8 @@ class WakuStore implements Store {
* or if an error is encountered when processing the reply,
* or if two decoders with the same content topic are passed.
*/
async *queryGenerator<T extends DecodedMessage>(
decoders: Decoder<T>[],
async *queryGenerator<T extends IDecodedMessage>(
decoders: IDecoder<T>[],
options?: QueryOptions
): AsyncGenerator<Promise<T | undefined>[]> {
let startTime, endTime;
@ -295,11 +295,11 @@ class WakuStore implements Store {
}
}
async function* paginate<T extends DecodedMessage>(
async function* paginate<T extends IDecodedMessage>(
connection: Connection,
protocol: string,
queryOpts: Params,
decoders: Map<string, Decoder<T>>,
decoders: Map<string, IDecoder<T>>,
cursor?: Cursor
): AsyncGenerator<Promise<T | undefined>[]> {
if (
@ -404,7 +404,7 @@ export function isDefined<T>(msg: T | undefined): msg is T {
}
export async function createCursor(
message: DecodedMessage,
message: IDecodedMessage,
pubsubTopic: string = DefaultPubSubTopic
): Promise<Index> {
if (

View File

@ -1,4 +1,4 @@
import type { DecodedMessage, Decoder } from "./message.js";
import type { IDecodedMessage, IDecoder } from "./message.js";
import type {
Callback,
PointToPointProtocol,
@ -6,8 +6,8 @@ import type {
} from "./protocols.js";
export interface Filter extends PointToPointProtocol {
subscribe: <T extends DecodedMessage>(
decoders: Decoder<T>[],
subscribe: <T extends IDecodedMessage>(
decoders: IDecoder<T>[],
callback: Callback<T>,
opts?: ProtocolOptions
) => Promise<() => Promise<void>>;

View File

@ -1,4 +1,4 @@
import type { Encoder, Message } from "./message.js";
import type { IEncoder, IMessage } from "./message.js";
import type {
PointToPointProtocol,
ProtocolOptions,
@ -7,8 +7,8 @@ import type {
export interface LightPush extends PointToPointProtocol {
push: (
encoder: Encoder,
message: Message,
encoder: IEncoder,
message: IMessage,
opts?: ProtocolOptions
) => Promise<SendResult>;
}

View File

@ -1,4 +1,4 @@
export interface RateLimitProof {
export interface IRateLimitProof {
proof: Uint8Array;
merkleRoot: Uint8Array;
epoch: Uint8Array;
@ -12,41 +12,41 @@ export interface RateLimitProof {
* Interface matching the protobuf library.
* Field types matches the protobuf type over the wire
*/
export interface ProtoMessage {
export interface IProtoMessage {
payload: Uint8Array | undefined;
contentTopic: string | undefined;
version: number | undefined;
timestamp: bigint | undefined;
rateLimitProof: RateLimitProof | undefined;
rateLimitProof: IRateLimitProof | undefined;
ephemeral: boolean | undefined;
}
/**
* Interface for messages to encode and send.
*/
export interface Message {
export interface IMessage {
payload?: Uint8Array;
timestamp?: Date;
rateLimitProof?: RateLimitProof;
rateLimitProof?: IRateLimitProof;
}
export interface Encoder {
export interface IEncoder {
contentTopic: string;
ephemeral: boolean;
toWire: (message: Message) => Promise<Uint8Array | undefined>;
toProtoObj: (message: Message) => Promise<ProtoMessage | undefined>;
toWire: (message: IMessage) => Promise<Uint8Array | undefined>;
toProtoObj: (message: IMessage) => Promise<IProtoMessage | undefined>;
}
export interface DecodedMessage {
export interface IDecodedMessage {
payload: Uint8Array | undefined;
contentTopic: string | undefined;
timestamp: Date | undefined;
rateLimitProof: RateLimitProof | undefined;
rateLimitProof: IRateLimitProof | undefined;
ephemeral: boolean | undefined;
}
export interface Decoder<T extends DecodedMessage> {
export interface IDecoder<T extends IDecodedMessage> {
contentTopic: string;
fromWireToProtoObj: (bytes: Uint8Array) => Promise<ProtoMessage | undefined>;
fromProtoObj: (proto: ProtoMessage) => Promise<T | undefined>;
fromWireToProtoObj: (bytes: Uint8Array) => Promise<IProtoMessage | undefined>;
fromProtoObj: (proto: IProtoMessage) => Promise<T | undefined>;
}

View File

@ -1,7 +1,7 @@
import type { PeerId } from "@libp2p/interface-peer-id";
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
import type { Message } from "./message.js";
import type { IMessage } from "./message.js";
export enum Protocols {
Relay = "relay",
@ -24,7 +24,7 @@ export type ProtocolOptions = {
peerId?: PeerId;
};
export type Callback<T extends Message> = (msg: T) => void | Promise<void>;
export type Callback<T extends IMessage> = (msg: T) => void | Promise<void>;
export interface SendResult {
recipients: PeerId[];

View File

@ -1,12 +1,17 @@
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
import type { DecodedMessage, Decoder, Encoder, Message } from "./message.js";
import type {
IDecodedMessage,
IDecoder,
IEncoder,
IMessage,
} from "./message.js";
import type { Callback, SendResult } from "./protocols.js";
export interface Relay extends GossipSub {
send: (encoder: Encoder, message: Message) => Promise<SendResult>;
addObserver: <T extends DecodedMessage>(
decoder: Decoder<T>,
send: (encoder: IEncoder, message: IMessage) => Promise<SendResult>;
addObserver: <T extends IDecodedMessage>(
decoder: IDecoder<T>,
callback: Callback<T>
) => () => void;
getMeshPeers: () => string[];

View File

@ -1,4 +1,4 @@
import type { DecodedMessage, Decoder } from "./message.js";
import type { IDecodedMessage, IDecoder } from "./message.js";
import type { PointToPointProtocol, ProtocolOptions } from "./protocols.js";
export enum PageDirection {
@ -51,20 +51,20 @@ export type StoreQueryOptions = {
} & ProtocolOptions;
export interface Store extends PointToPointProtocol {
queryOrderedCallback: <T extends DecodedMessage>(
decoders: Decoder<T>[],
queryOrderedCallback: <T extends IDecodedMessage>(
decoders: IDecoder<T>[],
callback: (message: T) => Promise<void | boolean> | boolean | void,
options?: StoreQueryOptions
) => Promise<void>;
queryCallbackOnPromise: <T extends DecodedMessage>(
decoders: Decoder<T>[],
queryCallbackOnPromise: <T extends IDecodedMessage>(
decoders: IDecoder<T>[],
callback: (
message: Promise<T | undefined>
) => Promise<void | boolean> | boolean | void,
options?: StoreQueryOptions
) => Promise<void>;
queryGenerator: <T extends DecodedMessage>(
decoders: Decoder<T>[],
queryGenerator: <T extends IDecodedMessage>(
decoders: IDecoder<T>[],
options?: StoreQueryOptions
) => AsyncGenerator<Promise<T | undefined>[]>;
}

View File

@ -3,10 +3,10 @@ import {
proto,
} from "@waku/core/lib/waku_message/version_0";
import type {
Decoder as IDecoder,
Encoder as IEncoder,
Message,
ProtoMessage,
IDecoder,
IEncoder,
IMessage,
IProtoMessage,
} from "@waku/interfaces";
import debug from "debug";
@ -37,14 +37,14 @@ class Encoder implements IEncoder {
public ephemeral: boolean = false
) {}
async toWire(message: Message): Promise<Uint8Array | undefined> {
async toWire(message: IMessage): Promise<Uint8Array | undefined> {
const protoMessage = await this.toProtoObj(message);
if (!protoMessage) return;
return proto.WakuMessage.encode(protoMessage);
}
async toProtoObj(message: Message): Promise<ProtoMessage | undefined> {
async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
const timestamp = message.timestamp ?? new Date();
if (!message.payload) {
log("No payload to encrypt, skipping: ", message);
@ -98,7 +98,7 @@ class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
}
async fromProtoObj(
protoMessage: ProtoMessage
protoMessage: IProtoMessage
): Promise<DecodedMessage | undefined> {
const cipherPayload = protoMessage.payload;

View File

@ -2,7 +2,7 @@ import {
DecodedMessage as DecodedMessageV0,
proto,
} from "@waku/core/lib/waku_message/version_0";
import type { DecodedMessage as IDecodedMessage } from "@waku/interfaces";
import type { IDecodedMessage } from "@waku/interfaces";
import {
generatePrivateKey,

View File

@ -3,10 +3,10 @@ import {
proto,
} from "@waku/core/lib/waku_message/version_0";
import type {
Decoder as IDecoder,
Encoder as IEncoder,
Message,
ProtoMessage,
IDecoder,
IEncoder,
IMessage,
IProtoMessage,
} from "@waku/interfaces";
import debug from "debug";
@ -36,14 +36,14 @@ class Encoder implements IEncoder {
public ephemeral: boolean = false
) {}
async toWire(message: Message): Promise<Uint8Array | undefined> {
async toWire(message: IMessage): Promise<Uint8Array | undefined> {
const protoMessage = await this.toProtoObj(message);
if (!protoMessage) return;
return proto.WakuMessage.encode(protoMessage);
}
async toProtoObj(message: Message): Promise<ProtoMessage | undefined> {
async toProtoObj(message: IMessage): Promise<IProtoMessage | undefined> {
const timestamp = message.timestamp ?? new Date();
if (!message.payload) {
log("No payload to encrypt, skipping: ", message);
@ -96,7 +96,7 @@ class Decoder extends DecoderV0 implements IDecoder<DecodedMessage> {
}
async fromProtoObj(
protoMessage: ProtoMessage
protoMessage: IProtoMessage
): Promise<DecodedMessage | undefined> {
const cipherPayload = protoMessage.payload;

View File

@ -1,7 +1,7 @@
import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils";
import { createDecoder, createEncoder, waitForRemotePeer } from "@waku/core";
import { createLightNode } from "@waku/create";
import type { DecodedMessage, WakuLight } from "@waku/interfaces";
import type { IDecodedMessage, WakuLight } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import { expect } from "chai";
import debug from "debug";
@ -43,7 +43,7 @@ describe("Waku Filter", () => {
const messageText = "Filtering works!";
const message = { payload: utf8ToBytes(messageText) };
const callback = (msg: DecodedMessage): void => {
const callback = (msg: IDecodedMessage): void => {
log("Got a message");
messageCount++;
expect(msg.contentTopic).to.eq(TestContentTopic);
@ -67,7 +67,7 @@ describe("Waku Filter", () => {
this.timeout(10000);
let messageCount = 0;
const callback = (msg: DecodedMessage): void => {
const callback = (msg: IDecodedMessage): void => {
messageCount++;
expect(msg.contentTopic).to.eq(TestContentTopic);
};

View File

@ -7,7 +7,7 @@ import {
waitForRemotePeer,
} from "@waku/core";
import { createLightNode } from "@waku/create";
import type { DecodedMessage, Message, WakuLight } from "@waku/interfaces";
import type { IDecodedMessage, IMessage, WakuLight } from "@waku/interfaces";
import { Protocols } from "@waku/interfaces";
import {
createDecoder as createEciesDecoder,
@ -74,7 +74,7 @@ describe("Waku Store", () => {
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.Store]);
const messages: Message[] = [];
const messages: IMessage[] = [];
let promises: Promise<void>[] = [];
for await (const msgPromises of waku.store.queryGenerator([TestDecoder])) {
const _promises = msgPromises.map(async (promise) => {
@ -105,7 +105,7 @@ describe("Waku Store", () => {
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.Store]);
const messages: Message[] = [];
const messages: IMessage[] = [];
let promises: Promise<void>[] = [];
for await (const msgPromises of waku.store.queryGenerator([TestDecoder])) {
const _promises = msgPromises.map(async (promise) => {
@ -147,10 +147,10 @@ describe("Waku Store", () => {
const query = waku.store.queryGenerator([TestDecoder]);
// messages in reversed order (first message at last index)
const messages: DecodedMessage[] = [];
const messages: IDecodedMessage[] = [];
for await (const page of query) {
for await (const msg of page.reverse()) {
messages.push(msg as DecodedMessage);
messages.push(msg as IDecodedMessage);
}
}
@ -160,12 +160,12 @@ describe("Waku Store", () => {
// create cursor to extract messages after the 3rd index
const cursor = await createCursor(messages[cursorIndex]);
const messagesAfterCursor: DecodedMessage[] = [];
const messagesAfterCursor: IDecodedMessage[] = [];
for await (const page of waku.store.queryGenerator([TestDecoder], {
cursor,
})) {
for await (const msg of page.reverse()) {
messagesAfterCursor.push(msg as DecodedMessage);
messagesAfterCursor.push(msg as IDecodedMessage);
}
}
@ -201,7 +201,7 @@ describe("Waku Store", () => {
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.Store]);
const messages: Message[] = [];
const messages: IMessage[] = [];
await waku.store.queryCallbackOnPromise(
[TestDecoder],
async (msgPromise) => {
@ -243,7 +243,7 @@ describe("Waku Store", () => {
await waitForRemotePeer(waku, [Protocols.Store]);
const desiredMsgs = 14;
const messages: Message[] = [];
const messages: IMessage[] = [];
await waku.store.queryCallbackOnPromise(
[TestDecoder],
async (msgPromise) => {
@ -282,7 +282,7 @@ describe("Waku Store", () => {
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.Store]);
const messages: Message[] = [];
const messages: IMessage[] = [];
await waku.store.queryOrderedCallback(
[TestDecoder],
async (msg) => {
@ -321,7 +321,7 @@ describe("Waku Store", () => {
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.Store]);
let messages: Message[] = [];
let messages: IMessage[] = [];
await waku.store.queryOrderedCallback(
[TestDecoder],
async (msg) => {
@ -413,7 +413,7 @@ describe("Waku Store", () => {
await waitForRemotePeer(waku2, [Protocols.Store]);
const messages: DecodedMessage[] = [];
const messages: IDecodedMessage[] = [];
log("Retrieve messages from store");
for await (const msgPromises of waku2.store.queryGenerator([
@ -482,7 +482,7 @@ describe("Waku Store", () => {
const nwakuPeerId = await nwaku.getPeerId();
const firstMessages: Message[] = [];
const firstMessages: IMessage[] = [];
await waku.store.queryOrderedCallback(
[TestDecoder],
(msg) => {
@ -496,7 +496,7 @@ describe("Waku Store", () => {
}
);
const bothMessages: Message[] = [];
const bothMessages: IMessage[] = [];
await waku.store.queryOrderedCallback(
[TestDecoder],
async (msg) => {
@ -543,7 +543,7 @@ describe("Waku Store", () => {
await waitForRemotePeer(waku, [Protocols.Store]);
const desiredMsgs = 14;
const messages: Message[] = [];
const messages: IMessage[] = [];
await waku.store.queryOrderedCallback(
[TestDecoder],
async (msg) => {
@ -601,7 +601,7 @@ describe("Waku Store, custom pubsub topic", () => {
await waku.dial(await nwaku.getMultiaddrWithId());
await waitForRemotePeer(waku, [Protocols.Store]);
const messages: Message[] = [];
const messages: IMessage[] = [];
let promises: Promise<void>[] = [];
for await (const msgPromises of waku.store.queryGenerator([TestDecoder])) {
const _promises = msgPromises.map(async (promise) => {

View File

@ -4,7 +4,7 @@ import { bytesToUtf8, utf8ToBytes } from "@waku/byte-utils";
import { DefaultUserAgent, waitForRemotePeer } from "@waku/core";
import { createLightNode, createPrivacyNode } from "@waku/create";
import type {
DecodedMessage,
IDecodedMessage,
Waku,
WakuLight,
WakuPrivacy,
@ -180,7 +180,7 @@ describe("Decryption Keys", () => {
timestamp: messageTimestamp,
};
const receivedMsgPromise: Promise<DecodedMessage> = new Promise(
const receivedMsgPromise: Promise<IDecodedMessage> = new Promise(
(resolve) => {
waku2.relay.addObserver(decoder, resolve);
}