From 94788d0dfc616a4321ec6ec73121ead8cc1808b7 Mon Sep 17 00:00:00 2001 From: Arseniy Klempner Date: Tue, 1 Jul 2025 21:32:29 -0700 Subject: [PATCH] feat(proto): add light push v3 definition --- packages/proto/src/generated/light_push.ts | 203 +++++++++++++++++++++ packages/proto/src/lib/light_push.proto | 24 ++- 2 files changed, 225 insertions(+), 2 deletions(-) diff --git a/packages/proto/src/generated/light_push.ts b/packages/proto/src/generated/light_push.ts index 40baf36082..c8083f08ad 100644 --- a/packages/proto/src/generated/light_push.ts +++ b/packages/proto/src/generated/light_push.ts @@ -86,6 +86,9 @@ export namespace PushRequest { export interface PushResponse { isSuccess: boolean info?: string + statusCode?: number + statusDesc?: string + relayPeerCount?: number } export namespace PushResponse { @@ -108,6 +111,21 @@ export namespace PushResponse { w.string(obj.info) } + if (obj.statusCode != null) { + w.uint32(80) + w.uint32(obj.statusCode) + } + + if (obj.statusDesc != null) { + w.uint32(90) + w.string(obj.statusDesc) + } + + if (obj.relayPeerCount != null) { + w.uint32(96) + w.uint32(obj.relayPeerCount) + } + if (opts.lengthDelimited !== false) { w.ldelim() } @@ -130,6 +148,18 @@ export namespace PushResponse { obj.info = reader.string() break } + case 10: { + obj.statusCode = reader.uint32() + break + } + case 11: { + obj.statusDesc = reader.string() + break + } + case 12: { + obj.relayPeerCount = reader.uint32() + break + } default: { reader.skipType(tag & 7) break @@ -237,6 +267,179 @@ export namespace PushRpc { } } +export interface LightPushRequestV3 { + requestId: string + pubsubTopic?: string + message?: WakuMessage +} + +export namespace LightPushRequestV3 { + let _codec: Codec + + export const codec = (): Codec => { + if (_codec == null) { + _codec = message((obj, w, opts = {}) => { + if (opts.lengthDelimited !== false) { + w.fork() + } + + if ((obj.requestId != null && obj.requestId !== '')) { + w.uint32(10) + w.string(obj.requestId) + } + + if (obj.pubsubTopic != null) { + w.uint32(162) + w.string(obj.pubsubTopic) + } + + if (obj.message != null) { + w.uint32(170) + WakuMessage.codec().encode(obj.message, w) + } + + if (opts.lengthDelimited !== false) { + w.ldelim() + } + }, (reader, length, opts = {}) => { + const obj: any = { + requestId: '' + } + + const end = length == null ? reader.len : reader.pos + length + + while (reader.pos < end) { + const tag = reader.uint32() + + switch (tag >>> 3) { + case 1: { + obj.requestId = reader.string() + break + } + case 20: { + obj.pubsubTopic = reader.string() + break + } + case 21: { + obj.message = WakuMessage.codec().decode(reader, reader.uint32(), { + limits: opts.limits?.message + }) + break + } + default: { + reader.skipType(tag & 7) + break + } + } + } + + return obj + }) + } + + return _codec + } + + export const encode = (obj: Partial): Uint8Array => { + return encodeMessage(obj, LightPushRequestV3.codec()) + } + + export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions): LightPushRequestV3 => { + return decodeMessage(buf, LightPushRequestV3.codec(), opts) + } +} + +export interface LightPushResponseV3 { + requestId: string + statusCode: number + statusDesc?: string + relayPeerCount?: number +} + +export namespace LightPushResponseV3 { + let _codec: Codec + + export const codec = (): Codec => { + if (_codec == null) { + _codec = message((obj, w, opts = {}) => { + if (opts.lengthDelimited !== false) { + w.fork() + } + + if ((obj.requestId != null && obj.requestId !== '')) { + w.uint32(10) + w.string(obj.requestId) + } + + if ((obj.statusCode != null && obj.statusCode !== 0)) { + w.uint32(80) + w.uint32(obj.statusCode) + } + + if (obj.statusDesc != null) { + w.uint32(90) + w.string(obj.statusDesc) + } + + if (obj.relayPeerCount != null) { + w.uint32(96) + w.uint32(obj.relayPeerCount) + } + + if (opts.lengthDelimited !== false) { + w.ldelim() + } + }, (reader, length, opts = {}) => { + const obj: any = { + requestId: '', + statusCode: 0 + } + + const end = length == null ? reader.len : reader.pos + length + + while (reader.pos < end) { + const tag = reader.uint32() + + switch (tag >>> 3) { + case 1: { + obj.requestId = reader.string() + break + } + case 10: { + obj.statusCode = reader.uint32() + break + } + case 11: { + obj.statusDesc = reader.string() + break + } + case 12: { + obj.relayPeerCount = reader.uint32() + break + } + default: { + reader.skipType(tag & 7) + break + } + } + } + + return obj + }) + } + + return _codec + } + + export const encode = (obj: Partial): Uint8Array => { + return encodeMessage(obj, LightPushResponseV3.codec()) + } + + export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions): LightPushResponseV3 => { + return decodeMessage(buf, LightPushResponseV3.codec(), opts) + } +} + export interface RateLimitProof { proof: Uint8Array merkleRoot: Uint8Array diff --git a/packages/proto/src/lib/light_push.proto b/packages/proto/src/lib/light_push.proto index 26e121ae42..b980115ab9 100644 --- a/packages/proto/src/lib/light_push.proto +++ b/packages/proto/src/lib/light_push.proto @@ -1,5 +1,6 @@ -// 19/WAKU2-LIGHTPUSH rfc: https://rfc.vac.dev/spec/19/ -// Protocol identifier: /vac/waku/lightpush/2.0.0-beta1 +// LightPush protocol definition supporting v1, v2, and v3 +// V1/V2: /vac/waku/lightpush/2.0.0-beta1 +// V3: /vac/waku/lightpush/3.0.0 syntax = "proto3"; @@ -13,6 +14,11 @@ message PushRequest { message PushResponse { bool is_success = 1; optional string info = 2; + + // V3 extended fields + optional uint32 status_code = 10; + optional string status_desc = 11; + optional uint32 relay_peer_count = 12; } message PushRpc { @@ -20,3 +26,17 @@ message PushRpc { optional PushRequest request = 2; optional PushResponse response = 3; } + +// V3 specific messages with different field numbering +message LightPushRequestV3 { + string request_id = 1; + optional string pubsub_topic = 20; + WakuMessage message = 21; +} + +message LightPushResponseV3 { + string request_id = 1; + uint32 status_code = 10; + optional string status_desc = 11; + optional uint32 relay_peer_count = 12; +} \ No newline at end of file