mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-22 09:53:08 +00:00
* changing default pubsub topic to its static sharding version * keeping RFC's Waku Message test vectors * reverting change in changelog * setting pubsub topic when creating nwaku node * adding shardInfo to runMultipleNodes call * adding shardInfo to runMultipleNodes call in lightpush tests * add pubsub topics to nwaku.start * get rid of it.only that remained * fixing compliance tests * setting clusterId to 0 * removing unnecessary fix * adding shardInfo when creating nodes * fixing wait for remote peer tests * fixing peer exchange test * refactor * removing unnecessary variable * feat: create default shard info, update tests (#2085) * feat: create default shard info, update tests * add link * fix tests * remoe only * up tests * up test --------- Co-authored-by: Sasha <118575614+weboko@users.noreply.github.com>
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import type {
|
|
IDecodedMessage,
|
|
IDecoder,
|
|
IProtoMessage,
|
|
PubsubTopic
|
|
} from "@waku/interfaces";
|
|
import { TopicOnlyMessage as ProtoTopicOnlyMessage } from "@waku/proto";
|
|
|
|
export class TopicOnlyMessage implements IDecodedMessage {
|
|
public payload: Uint8Array = new Uint8Array();
|
|
public rateLimitProof: undefined;
|
|
public timestamp: undefined;
|
|
public meta: undefined;
|
|
public ephemeral: undefined;
|
|
|
|
public constructor(
|
|
public pubsubTopic: string,
|
|
private proto: ProtoTopicOnlyMessage
|
|
) {}
|
|
|
|
public get contentTopic(): string {
|
|
return this.proto.contentTopic;
|
|
}
|
|
}
|
|
|
|
// This decoder is used only for reading `contentTopic` from the WakuMessage
|
|
export class TopicOnlyDecoder implements IDecoder<TopicOnlyMessage> {
|
|
public contentTopic = "";
|
|
|
|
// pubsubTopic is ignored
|
|
public constructor(public pubsubTopic: PubsubTopic) {}
|
|
|
|
public fromWireToProtoObj(
|
|
bytes: Uint8Array
|
|
): Promise<IProtoMessage | undefined> {
|
|
const protoMessage = ProtoTopicOnlyMessage.decode(bytes);
|
|
return Promise.resolve({
|
|
contentTopic: protoMessage.contentTopic,
|
|
payload: new Uint8Array(),
|
|
rateLimitProof: undefined,
|
|
timestamp: undefined,
|
|
meta: undefined,
|
|
version: undefined,
|
|
ephemeral: undefined
|
|
});
|
|
}
|
|
|
|
public async fromProtoObj(
|
|
pubsubTopic: string,
|
|
proto: IProtoMessage
|
|
): Promise<TopicOnlyMessage | undefined> {
|
|
return new TopicOnlyMessage(pubsubTopic, proto);
|
|
}
|
|
}
|