2022-12-05 17:07:03 +11:00
|
|
|
export interface IRateLimitProof {
|
2022-12-05 17:00:24 +11:00
|
|
|
proof: Uint8Array;
|
|
|
|
merkleRoot: Uint8Array;
|
|
|
|
epoch: Uint8Array;
|
|
|
|
shareX: Uint8Array;
|
|
|
|
shareY: Uint8Array;
|
|
|
|
nullifier: Uint8Array;
|
|
|
|
rlnIdentifier: Uint8Array;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface matching the protobuf library.
|
|
|
|
* Field types matches the protobuf type over the wire
|
|
|
|
*/
|
2022-12-05 17:07:03 +11:00
|
|
|
export interface IProtoMessage {
|
2023-02-24 23:22:04 +11:00
|
|
|
payload: Uint8Array;
|
|
|
|
contentTopic: string;
|
2022-12-05 17:00:24 +11:00
|
|
|
version: number | undefined;
|
|
|
|
timestamp: bigint | undefined;
|
2022-12-05 17:07:03 +11:00
|
|
|
rateLimitProof: IRateLimitProof | undefined;
|
2022-12-05 17:00:24 +11:00
|
|
|
ephemeral: boolean | undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for messages to encode and send.
|
|
|
|
*/
|
2022-12-05 17:07:03 +11:00
|
|
|
export interface IMessage {
|
2023-02-24 23:22:04 +11:00
|
|
|
payload: Uint8Array;
|
2022-12-05 17:00:24 +11:00
|
|
|
timestamp?: Date;
|
2022-12-05 17:07:03 +11:00
|
|
|
rateLimitProof?: IRateLimitProof;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|
|
|
|
|
2023-02-02 11:37:28 +05:30
|
|
|
export interface EncoderOptions {
|
|
|
|
/** 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;
|
|
|
|
}
|
|
|
|
|
2022-12-05 17:07:03 +11:00
|
|
|
export interface IEncoder {
|
2022-12-05 17:00:24 +11:00
|
|
|
contentTopic: string;
|
|
|
|
ephemeral: boolean;
|
2022-12-05 17:07:03 +11:00
|
|
|
toWire: (message: IMessage) => Promise<Uint8Array | undefined>;
|
|
|
|
toProtoObj: (message: IMessage) => Promise<IProtoMessage | undefined>;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|
|
|
|
|
2022-12-05 17:07:03 +11:00
|
|
|
export interface IDecodedMessage {
|
2023-02-24 23:22:04 +11:00
|
|
|
payload: Uint8Array;
|
|
|
|
contentTopic: string;
|
2022-12-05 17:00:24 +11:00
|
|
|
timestamp: Date | undefined;
|
2022-12-05 17:07:03 +11:00
|
|
|
rateLimitProof: IRateLimitProof | undefined;
|
2022-12-05 17:00:24 +11:00
|
|
|
ephemeral: boolean | undefined;
|
|
|
|
}
|
|
|
|
|
2022-12-05 17:07:03 +11:00
|
|
|
export interface IDecoder<T extends IDecodedMessage> {
|
2022-12-05 17:00:24 +11:00
|
|
|
contentTopic: string;
|
2022-12-05 17:07:03 +11:00
|
|
|
fromWireToProtoObj: (bytes: Uint8Array) => Promise<IProtoMessage | undefined>;
|
|
|
|
fromProtoObj: (proto: IProtoMessage) => Promise<T | undefined>;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|