chore: update filter.proto

Ref: https://github.com/vacp2p/waku
This commit is contained in:
fryorcraken.eth 2023-02-24 15:57:50 +11:00
parent 31740e7a3d
commit 5f0e8b72f5
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 39 additions and 30 deletions

View File

@ -9,7 +9,7 @@ export type ContentFilter = {
* FilterRPC represents a message conforming to the Waku Filter protocol
*/
export class FilterRPC {
public constructor(public proto: proto.FilterRPC) {}
public constructor(public proto: proto.FilterRpc) {}
static createRequest(
topic: string,
@ -34,7 +34,7 @@ export class FilterRPC {
* @returns FilterRPC
*/
static decode(bytes: Uint8Array): FilterRPC {
const res = proto.FilterRPC.decode(bytes);
const res = proto.FilterRpc.decode(bytes);
return new FilterRPC(res);
}
@ -43,14 +43,14 @@ export class FilterRPC {
* @returns Uint8Array
*/
encode(): Uint8Array {
return proto.FilterRPC.encode(this.proto);
return proto.FilterRpc.encode(this.proto);
}
get push(): proto.MessagePush | undefined {
return this.proto.push;
}
get requestId(): string | undefined {
get requestId(): string {
return this.proto.requestId;
}
}

View File

@ -1,23 +1,26 @@
// 12/WAKU2-FILTER rfc: https://rfc.vac.dev/spec/12/
// Protocol identifier: /vac/waku/filter/2.0.0-beta1
syntax = "proto3";
import "message.proto";
message FilterRequest {
optional bool subscribe = 1;
optional string topic = 2;
repeated ContentFilter content_filters = 3;
message ContentFilter {
optional string content_topic = 1;
string content_topic = 1;
}
bool subscribe = 1;
string topic = 2;
repeated ContentFilter content_filters = 3;
}
message MessagePush {
repeated WakuMessage messages = 1;
}
message FilterRPC {
optional string request_id = 1;
message FilterRpc {
string request_id = 1;
optional FilterRequest request = 2;
optional MessagePush push = 3;
}

View File

@ -9,14 +9,14 @@ import type { Codec } from "protons-runtime";
import type { Uint8ArrayList } from "uint8arraylist";
export interface FilterRequest {
subscribe?: boolean;
topic?: string;
subscribe: boolean;
topic: string;
contentFilters: FilterRequest.ContentFilter[];
}
export namespace FilterRequest {
export interface ContentFilter {
contentTopic?: string;
contentTopic: string;
}
export namespace ContentFilter {
@ -30,7 +30,7 @@ export namespace FilterRequest {
w.fork();
}
if (obj.contentTopic != null) {
if (obj.contentTopic != null && obj.contentTopic !== "") {
w.uint32(10);
w.string(obj.contentTopic);
}
@ -40,7 +40,9 @@ export namespace FilterRequest {
}
},
(reader, length) => {
const obj: any = {};
const obj: any = {
contentTopic: "",
};
const end = length == null ? reader.len : reader.pos + length;
@ -84,12 +86,12 @@ export namespace FilterRequest {
w.fork();
}
if (obj.subscribe != null) {
if (obj.subscribe != null && obj.subscribe !== false) {
w.uint32(8);
w.bool(obj.subscribe);
}
if (obj.topic != null) {
if (obj.topic != null && obj.topic !== "") {
w.uint32(18);
w.string(obj.topic);
}
@ -107,6 +109,8 @@ export namespace FilterRequest {
},
(reader, length) => {
const obj: any = {
subscribe: false,
topic: "",
contentFilters: [],
};
@ -218,24 +222,24 @@ export namespace MessagePush {
};
}
export interface FilterRPC {
requestId?: string;
export interface FilterRpc {
requestId: string;
request?: FilterRequest;
push?: MessagePush;
}
export namespace FilterRPC {
let _codec: Codec<FilterRPC>;
export namespace FilterRpc {
let _codec: Codec<FilterRpc>;
export const codec = (): Codec<FilterRPC> => {
export const codec = (): Codec<FilterRpc> => {
if (_codec == null) {
_codec = message<FilterRPC>(
_codec = message<FilterRpc>(
(obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
w.fork();
}
if (obj.requestId != null) {
if (obj.requestId != null && obj.requestId !== "") {
w.uint32(10);
w.string(obj.requestId);
}
@ -255,7 +259,9 @@ export namespace FilterRPC {
}
},
(reader, length) => {
const obj: any = {};
const obj: any = {
requestId: "",
};
const end = length == null ? reader.len : reader.pos + length;
@ -289,12 +295,12 @@ export namespace FilterRPC {
return _codec;
};
export const encode = (obj: Partial<FilterRPC>): Uint8Array => {
return encodeMessage(obj, FilterRPC.codec());
export const encode = (obj: Partial<FilterRpc>): Uint8Array => {
return encodeMessage(obj, FilterRpc.codec());
};
export const decode = (buf: Uint8Array | Uint8ArrayList): FilterRPC => {
return decodeMessage(buf, FilterRPC.codec());
export const decode = (buf: Uint8Array | Uint8ArrayList): FilterRpc => {
return decodeMessage(buf, FilterRpc.codec());
};
}