feat(proto): add light push v3 definition

This commit is contained in:
Arseniy Klempner 2025-07-01 21:32:29 -07:00
parent 9b0c5e8311
commit 94788d0dfc
No known key found for this signature in database
GPG Key ID: 51653F18863BD24B
2 changed files with 225 additions and 2 deletions

View File

@ -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<LightPushRequestV3>
export const codec = (): Codec<LightPushRequestV3> => {
if (_codec == null) {
_codec = message<LightPushRequestV3>((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<LightPushRequestV3>): Uint8Array => {
return encodeMessage(obj, LightPushRequestV3.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<LightPushRequestV3>): LightPushRequestV3 => {
return decodeMessage(buf, LightPushRequestV3.codec(), opts)
}
}
export interface LightPushResponseV3 {
requestId: string
statusCode: number
statusDesc?: string
relayPeerCount?: number
}
export namespace LightPushResponseV3 {
let _codec: Codec<LightPushResponseV3>
export const codec = (): Codec<LightPushResponseV3> => {
if (_codec == null) {
_codec = message<LightPushResponseV3>((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<LightPushResponseV3>): Uint8Array => {
return encodeMessage(obj, LightPushResponseV3.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<LightPushResponseV3>): LightPushResponseV3 => {
return decodeMessage(buf, LightPushResponseV3.codec(), opts)
}
}
export interface RateLimitProof {
proof: Uint8Array
merkleRoot: Uint8Array

View File

@ -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;
}