diff --git a/packages/core/src/lib/message/version_0.ts b/packages/core/src/lib/message/version_0.ts index 60748bb4e0..bb7e48fc36 100644 --- a/packages/core/src/lib/message/version_0.ts +++ b/packages/core/src/lib/message/version_0.ts @@ -1,4 +1,5 @@ import type { + EncoderOptions, IDecodedMessage, IDecoder, IEncoder, @@ -65,26 +66,6 @@ export class DecodedMessage implements IDecodedMessage { } } -export type EncoderOptions = { - /** - * The routing information for messages to encode. - */ - routingInfo: IRoutingInfo; - /** The content topic to set on outgoing messages. */ - contentTopic: string; - /** - * An optional flag to mark message as ephemeral, i.e., not to be stored by Waku Store nodes. - * @defaultValue `false` - */ - ephemeral?: boolean; - /** - * A function called when encoding messages to set the meta field. - * @param IProtoMessage The message encoded for wire, without the meta field. - * If encryption is used, `metaSetter` only accesses _encrypted_ payload. - */ - metaSetter?: IMetaSetter; -}; - export class Encoder implements IEncoder { public constructor( public contentTopic: string, diff --git a/packages/core/src/lib/store/store.spec.ts b/packages/core/src/lib/store/store.spec.ts index 5677b24b74..fbe340ab90 100644 --- a/packages/core/src/lib/store/store.spec.ts +++ b/packages/core/src/lib/store/store.spec.ts @@ -82,9 +82,7 @@ describe("StoreCore", () => { const routingInfo: IRoutingInfo = { pubsubTopic: "test-topic", shardId: 1, - networkConfig: { clusterId: 0 }, - isAutoSharding: false, - isStaticSharding: false + clusterId: 0 }; beforeEach(() => { diff --git a/packages/interfaces/src/message.ts b/packages/interfaces/src/message.ts index fda16fb160..0e076f0b3e 100644 --- a/packages/interfaces/src/message.ts +++ b/packages/interfaces/src/message.ts @@ -71,6 +71,26 @@ export interface IMetaSetter { (message: IProtoMessage & { meta: undefined }): Uint8Array; } +export interface EncoderOptions { + /** + * The routing information for the message (cluster id, shard id, pubsubTopic) + */ + routingInfo: IRoutingInfo; + /** The content topic to set on outgoing messages. */ + contentTopic: string; + /** + * An optional flag to mark message as ephemeral, i.e., not to be stored by Waku Store nodes. + * @defaultValue `false` + */ + ephemeral?: boolean; + /** + * A function called when encoding messages to set the meta field. + * @param IProtoMessage The message encoded for wire, without the meta field. + * If encryption is used, `metaSetter` only accesses _encrypted_ payload. + */ + metaSetter?: IMetaSetter; +} + export interface IEncoder { contentTopic: string; ephemeral: boolean; diff --git a/packages/message-encryption/src/ecies.ts b/packages/message-encryption/src/ecies.ts index bb7f1ded23..1628b2481f 100644 --- a/packages/message-encryption/src/ecies.ts +++ b/packages/message-encryption/src/ecies.ts @@ -1,5 +1,6 @@ import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0"; import { + type EncoderOptions as BaseEncoderOptions, type IDecoder, type IEncoder, type IEncryptedMessage, @@ -79,24 +80,7 @@ class Encoder implements IEncoder { } } -export interface EncoderOptions { - /** - * The routing information for messages to encode. - */ - routingInfo: IRoutingInfo; - /** The content topic to set on outgoing messages. */ - contentTopic: string; - /** - * An optional flag to mark message as ephemeral, i.e., not to be stored by Waku Store nodes. - * @defaultValue `false` - */ - ephemeral?: boolean; - /** - * A function called when encoding messages to set the meta field. - * @param IProtoMessage The message encoded for wire, without the meta field. - * If encryption is used, `metaSetter` only accesses _encrypted_ payload. - */ - metaSetter?: IMetaSetter; +export interface EncoderOptions extends BaseEncoderOptions { /** The public key to encrypt the payload for. */ publicKey: Uint8Array; /** An optional private key to be used to sign the payload before encryption. */ diff --git a/packages/message-encryption/src/symmetric.ts b/packages/message-encryption/src/symmetric.ts index d6f0ebfe41..2261e01751 100644 --- a/packages/message-encryption/src/symmetric.ts +++ b/packages/message-encryption/src/symmetric.ts @@ -1,5 +1,6 @@ import { Decoder as DecoderV0 } from "@waku/core/lib/message/version_0"; import type { + EncoderOptions as BaseEncoderOptions, IDecoder, IEncoder, IEncryptedMessage, @@ -79,24 +80,7 @@ class Encoder implements IEncoder { } } -export interface EncoderOptions { - /** - * The routing information for messages to encode. - */ - routingInfo: IRoutingInfo; - /** The content topic to set on outgoing messages. */ - contentTopic: string; - /** - * An optional flag to mark message as ephemeral, i.e., not to be stored by Waku Store nodes. - * @defaultValue `false` - */ - ephemeral?: boolean; - /** - * A function called when encoding messages to set the meta field. - * @param IProtoMessage The message encoded for wire, without the meta field. - * If encryption is used, `metaSetter` only accesses _encrypted_ payload. - */ - metaSetter?: IMetaSetter; +export interface EncoderOptions extends BaseEncoderOptions { /** The symmetric key to encrypt the payload with. */ symKey: Uint8Array; /** An optional private key to be used to sign the payload before encryption. */ diff --git a/packages/rln/src/rln.ts b/packages/rln/src/rln.ts index 2c9f6f653d..c677ad9d0a 100644 --- a/packages/rln/src/rln.ts +++ b/packages/rln/src/rln.ts @@ -2,8 +2,8 @@ import { createDecoder, createEncoder } from "@waku/core"; import type { ContentTopic, IDecodedMessage, - IMetaSetter, - IRoutingInfo + IRoutingInfo, + EncoderOptions as WakuEncoderOptions } from "@waku/interfaces"; import { Logger } from "@waku/utils"; import init from "@waku/zerokit-rln-wasm"; @@ -28,27 +28,7 @@ import { Zerokit } from "./zerokit.js"; const log = new Logger("waku:rln"); -type WakuRLNEncoderOptions = { - /** - * The routing information for messages to encode. - */ - routingInfo: IRoutingInfo; - /** The content topic to set on outgoing messages. */ - contentTopic: string; - /** - * An optional flag to mark message as ephemeral, i.e., not to be stored by Waku Store nodes. - * @defaultValue `false` - */ - ephemeral?: boolean; - /** - * A function called when encoding messages to set the meta field. - * @param IProtoMessage The message encoded for wire, without the meta field. - * If encryption is used, `metaSetter` only accesses _encrypted_ payload. - */ - metaSetter?: IMetaSetter; - /** - * RLN Credentials - */ +type WakuRLNEncoderOptions = WakuEncoderOptions & { credentials: EncryptedCredentials | DecryptedCredentials; }; diff --git a/packages/tests/src/lib/message_collector.ts b/packages/tests/src/lib/message_collector.ts index 456d1f881f..a5f1cf8263 100644 --- a/packages/tests/src/lib/message_collector.ts +++ b/packages/tests/src/lib/message_collector.ts @@ -66,7 +66,6 @@ export class MessageCollector { public async waitForMessages( numMessages: number, options?: { - // pubsubTopic?: string; timeoutDuration?: number; exact?: boolean; }