chore: bump protons (#1898)

* regen lockfile

* commit new proto code

* chore: upgrade protons-runtime to 5.4.0

* chore: have src/generated as a dedicated directory for generated proto code

* chore: ignore unused vars in proto

* chore: update lockfile

* fix: eslint errors

* chore: handle flaky tests edge case

* chore: update playright docker image

* rm: only

* rm: console

* chore: regen lockfile

* chore: update playright docker image
This commit is contained in:
Danish Arora 2024-04-07 10:55:09 +03:00 committed by GitHub
parent 0b54d2e3d7
commit 8ec11b2cde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 7560 additions and 36145 deletions

View File

@ -20,7 +20,7 @@ jobs:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.40.1-jammy
image: mcr.microsoft.com/playwright:v1.43.0-jammy
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

42723
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@
"build": "run-s build:**",
"build:esm": "tsc",
"build:bundle": "rollup --config rollup.config.js",
"proto": "rimraf src/lib/*.ts; protons src/lib/*.proto",
"proto": "rimraf src/generated/*.ts && mkdir -p src/generated && protons src/lib/*.proto -o src/generated",
"check:tsc": "tsc -p tsconfig.dev.json",
"prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
@ -44,7 +44,7 @@
"node": ">=18"
},
"dependencies": {
"protons-runtime": "^5.0.2"
"protons-runtime": "^5.4.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",

View File

@ -4,8 +4,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface FilterRequest {
@ -37,7 +37,7 @@ export namespace FilterRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
contentTopic: ''
}
@ -48,14 +48,16 @@ export namespace FilterRequest {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.contentTopic = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -68,8 +70,8 @@ export namespace FilterRequest {
return encodeMessage(obj, ContentFilter.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): ContentFilter => {
return decodeMessage(buf, ContentFilter.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ContentFilter>): ContentFilter => {
return decodeMessage(buf, ContentFilter.codec(), opts)
}
}
@ -102,7 +104,7 @@ export namespace FilterRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
subscribe: false,
topic: '',
@ -115,20 +117,30 @@ export namespace FilterRequest {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.subscribe = reader.bool()
break
case 2:
}
case 2: {
obj.topic = reader.string()
break
case 3:
obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32()))
}
case 3: {
if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {
throw new CodeError('decode error - map field "contentFilters" had too many elements', 'ERR_MAX_LENGTH')
}
obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.contentFilters$
}))
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -141,8 +153,8 @@ export namespace FilterRequest {
return encodeMessage(obj, FilterRequest.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): FilterRequest => {
return decodeMessage(buf, FilterRequest.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<FilterRequest>): FilterRequest => {
return decodeMessage(buf, FilterRequest.codec(), opts)
}
}
@ -170,7 +182,7 @@ export namespace MessagePush {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
messages: []
}
@ -181,14 +193,22 @@ export namespace MessagePush {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()))
case 1: {
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
throw new CodeError('decode error - map field "messages" had too many elements', 'ERR_MAX_LENGTH')
}
obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.messages$
}))
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -201,8 +221,8 @@ export namespace MessagePush {
return encodeMessage(obj, MessagePush.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): MessagePush => {
return decodeMessage(buf, MessagePush.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<MessagePush>): MessagePush => {
return decodeMessage(buf, MessagePush.codec(), opts)
}
}
@ -240,7 +260,7 @@ export namespace FilterRpc {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
requestId: ''
}
@ -251,20 +271,28 @@ export namespace FilterRpc {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.requestId = reader.string()
break
case 2:
obj.request = FilterRequest.codec().decode(reader, reader.uint32())
}
case 2: {
obj.request = FilterRequest.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.request
})
break
case 3:
obj.push = MessagePush.codec().decode(reader, reader.uint32())
}
case 3: {
obj.push = MessagePush.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.push
})
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -277,8 +305,8 @@ export namespace FilterRpc {
return encodeMessage(obj, FilterRpc.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): FilterRpc => {
return decodeMessage(buf, FilterRpc.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<FilterRpc>): FilterRpc => {
return decodeMessage(buf, FilterRpc.codec(), opts)
}
}
@ -340,15 +368,15 @@ export namespace RateLimitProof {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
proof: new Uint8Array(0),
merkleRoot: new Uint8Array(0),
epoch: new Uint8Array(0),
shareX: new Uint8Array(0),
shareY: new Uint8Array(0),
nullifier: new Uint8Array(0),
rlnIdentifier: new Uint8Array(0)
proof: uint8ArrayAlloc(0),
merkleRoot: uint8ArrayAlloc(0),
epoch: uint8ArrayAlloc(0),
shareX: uint8ArrayAlloc(0),
shareY: uint8ArrayAlloc(0),
nullifier: uint8ArrayAlloc(0),
rlnIdentifier: uint8ArrayAlloc(0)
}
const end = length == null ? reader.len : reader.pos + length
@ -357,32 +385,40 @@ export namespace RateLimitProof {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.proof = reader.bytes()
break
case 2:
}
case 2: {
obj.merkleRoot = reader.bytes()
break
case 3:
}
case 3: {
obj.epoch = reader.bytes()
break
case 4:
}
case 4: {
obj.shareX = reader.bytes()
break
case 5:
}
case 5: {
obj.shareY = reader.bytes()
break
case 6:
}
case 6: {
obj.nullifier = reader.bytes()
break
case 7:
}
case 7: {
obj.rlnIdentifier = reader.bytes()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -395,8 +431,8 @@ export namespace RateLimitProof {
return encodeMessage(obj, RateLimitProof.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<RateLimitProof>): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec(), opts)
}
}
@ -458,9 +494,9 @@ export namespace WakuMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
payload: new Uint8Array(0),
payload: uint8ArrayAlloc(0),
contentTopic: ''
}
@ -470,32 +506,42 @@ export namespace WakuMessage {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.payload = reader.bytes()
break
case 2:
}
case 2: {
obj.contentTopic = reader.string()
break
case 3:
}
case 3: {
obj.version = reader.uint32()
break
case 10:
}
case 10: {
obj.timestamp = reader.sint64()
break
case 11:
}
case 11: {
obj.meta = reader.bytes()
break
case 21:
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32())
}
case 21: {
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.rateLimitProof
})
break
case 31:
}
case 31: {
obj.ephemeral = reader.bool()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -508,7 +554,7 @@ export namespace WakuMessage {
return encodeMessage(obj, WakuMessage.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMessage>): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec(), opts)
}
}

View File

@ -4,8 +4,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, enumeration, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface FilterSubscribeRequest {
@ -70,7 +70,7 @@ export namespace FilterSubscribeRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
requestId: '',
filterSubscribeType: FilterSubscribeType.SUBSCRIBER_PING,
@ -83,23 +83,32 @@ export namespace FilterSubscribeRequest {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.requestId = reader.string()
break
case 2:
}
case 2: {
obj.filterSubscribeType = FilterSubscribeRequest.FilterSubscribeType.codec().decode(reader)
break
case 10:
}
case 10: {
obj.pubsubTopic = reader.string()
break
case 11:
}
case 11: {
if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {
throw new CodeError('decode error - map field "contentTopics" had too many elements', 'ERR_MAX_LENGTH')
}
obj.contentTopics.push(reader.string())
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -112,8 +121,8 @@ export namespace FilterSubscribeRequest {
return encodeMessage(obj, FilterSubscribeRequest.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): FilterSubscribeRequest => {
return decodeMessage(buf, FilterSubscribeRequest.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<FilterSubscribeRequest>): FilterSubscribeRequest => {
return decodeMessage(buf, FilterSubscribeRequest.codec(), opts)
}
}
@ -151,7 +160,7 @@ export namespace FilterSubscribeResponse {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
requestId: '',
statusCode: 0
@ -163,20 +172,24 @@ export namespace FilterSubscribeResponse {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.requestId = reader.string()
break
case 10:
}
case 10: {
obj.statusCode = reader.uint32()
break
case 11:
}
case 11: {
obj.statusDesc = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -189,8 +202,8 @@ export namespace FilterSubscribeResponse {
return encodeMessage(obj, FilterSubscribeResponse.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): FilterSubscribeResponse => {
return decodeMessage(buf, FilterSubscribeResponse.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<FilterSubscribeResponse>): FilterSubscribeResponse => {
return decodeMessage(buf, FilterSubscribeResponse.codec(), opts)
}
}
@ -222,7 +235,7 @@ export namespace MessagePush {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {}
const end = length == null ? reader.len : reader.pos + length
@ -231,17 +244,22 @@ export namespace MessagePush {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32())
case 1: {
obj.wakuMessage = WakuMessage.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.wakuMessage
})
break
case 2:
}
case 2: {
obj.pubsubTopic = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -254,8 +272,8 @@ export namespace MessagePush {
return encodeMessage(obj, MessagePush.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): MessagePush => {
return decodeMessage(buf, MessagePush.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<MessagePush>): MessagePush => {
return decodeMessage(buf, MessagePush.codec(), opts)
}
}
@ -317,15 +335,15 @@ export namespace RateLimitProof {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
proof: new Uint8Array(0),
merkleRoot: new Uint8Array(0),
epoch: new Uint8Array(0),
shareX: new Uint8Array(0),
shareY: new Uint8Array(0),
nullifier: new Uint8Array(0),
rlnIdentifier: new Uint8Array(0)
proof: uint8ArrayAlloc(0),
merkleRoot: uint8ArrayAlloc(0),
epoch: uint8ArrayAlloc(0),
shareX: uint8ArrayAlloc(0),
shareY: uint8ArrayAlloc(0),
nullifier: uint8ArrayAlloc(0),
rlnIdentifier: uint8ArrayAlloc(0)
}
const end = length == null ? reader.len : reader.pos + length
@ -334,32 +352,40 @@ export namespace RateLimitProof {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.proof = reader.bytes()
break
case 2:
}
case 2: {
obj.merkleRoot = reader.bytes()
break
case 3:
}
case 3: {
obj.epoch = reader.bytes()
break
case 4:
}
case 4: {
obj.shareX = reader.bytes()
break
case 5:
}
case 5: {
obj.shareY = reader.bytes()
break
case 6:
}
case 6: {
obj.nullifier = reader.bytes()
break
case 7:
}
case 7: {
obj.rlnIdentifier = reader.bytes()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -372,8 +398,8 @@ export namespace RateLimitProof {
return encodeMessage(obj, RateLimitProof.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<RateLimitProof>): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec(), opts)
}
}
@ -435,9 +461,9 @@ export namespace WakuMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
payload: new Uint8Array(0),
payload: uint8ArrayAlloc(0),
contentTopic: ''
}
@ -447,32 +473,42 @@ export namespace WakuMessage {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.payload = reader.bytes()
break
case 2:
}
case 2: {
obj.contentTopic = reader.string()
break
case 3:
}
case 3: {
obj.version = reader.uint32()
break
case 10:
}
case 10: {
obj.timestamp = reader.sint64()
break
case 11:
}
case 11: {
obj.meta = reader.bytes()
break
case 21:
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32())
}
case 21: {
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.rateLimitProof
})
break
case 31:
}
case 31: {
obj.ephemeral = reader.bool()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -485,7 +521,7 @@ export namespace WakuMessage {
return encodeMessage(obj, WakuMessage.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMessage>): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec(), opts)
}
}

View File

@ -4,8 +4,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface PushRequest {
@ -36,7 +36,7 @@ export namespace PushRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
pubsubTopic: ''
}
@ -47,17 +47,22 @@ export namespace PushRequest {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.pubsubTopic = reader.string()
break
case 2:
obj.message = WakuMessage.codec().decode(reader, reader.uint32())
}
case 2: {
obj.message = WakuMessage.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.message
})
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -70,8 +75,8 @@ export namespace PushRequest {
return encodeMessage(obj, PushRequest.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PushRequest => {
return decodeMessage(buf, PushRequest.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PushRequest>): PushRequest => {
return decodeMessage(buf, PushRequest.codec(), opts)
}
}
@ -103,7 +108,7 @@ export namespace PushResponse {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
isSuccess: false
}
@ -114,17 +119,20 @@ export namespace PushResponse {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.isSuccess = reader.bool()
break
case 2:
}
case 2: {
obj.info = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -137,8 +145,8 @@ export namespace PushResponse {
return encodeMessage(obj, PushResponse.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PushResponse => {
return decodeMessage(buf, PushResponse.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PushResponse>): PushResponse => {
return decodeMessage(buf, PushResponse.codec(), opts)
}
}
@ -176,7 +184,7 @@ export namespace PushRpc {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
requestId: ''
}
@ -187,20 +195,28 @@ export namespace PushRpc {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.requestId = reader.string()
break
case 2:
obj.request = PushRequest.codec().decode(reader, reader.uint32())
}
case 2: {
obj.request = PushRequest.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.request
})
break
case 3:
obj.response = PushResponse.codec().decode(reader, reader.uint32())
}
case 3: {
obj.response = PushResponse.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.response
})
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -213,8 +229,8 @@ export namespace PushRpc {
return encodeMessage(obj, PushRpc.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PushRpc => {
return decodeMessage(buf, PushRpc.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PushRpc>): PushRpc => {
return decodeMessage(buf, PushRpc.codec(), opts)
}
}
@ -276,15 +292,15 @@ export namespace RateLimitProof {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
proof: new Uint8Array(0),
merkleRoot: new Uint8Array(0),
epoch: new Uint8Array(0),
shareX: new Uint8Array(0),
shareY: new Uint8Array(0),
nullifier: new Uint8Array(0),
rlnIdentifier: new Uint8Array(0)
proof: uint8ArrayAlloc(0),
merkleRoot: uint8ArrayAlloc(0),
epoch: uint8ArrayAlloc(0),
shareX: uint8ArrayAlloc(0),
shareY: uint8ArrayAlloc(0),
nullifier: uint8ArrayAlloc(0),
rlnIdentifier: uint8ArrayAlloc(0)
}
const end = length == null ? reader.len : reader.pos + length
@ -293,32 +309,40 @@ export namespace RateLimitProof {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.proof = reader.bytes()
break
case 2:
}
case 2: {
obj.merkleRoot = reader.bytes()
break
case 3:
}
case 3: {
obj.epoch = reader.bytes()
break
case 4:
}
case 4: {
obj.shareX = reader.bytes()
break
case 5:
}
case 5: {
obj.shareY = reader.bytes()
break
case 6:
}
case 6: {
obj.nullifier = reader.bytes()
break
case 7:
}
case 7: {
obj.rlnIdentifier = reader.bytes()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -331,8 +355,8 @@ export namespace RateLimitProof {
return encodeMessage(obj, RateLimitProof.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<RateLimitProof>): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec(), opts)
}
}
@ -394,9 +418,9 @@ export namespace WakuMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
payload: new Uint8Array(0),
payload: uint8ArrayAlloc(0),
contentTopic: ''
}
@ -406,32 +430,42 @@ export namespace WakuMessage {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.payload = reader.bytes()
break
case 2:
}
case 2: {
obj.contentTopic = reader.string()
break
case 3:
}
case 3: {
obj.version = reader.uint32()
break
case 10:
}
case 10: {
obj.timestamp = reader.sint64()
break
case 11:
}
case 11: {
obj.meta = reader.bytes()
break
case 21:
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32())
}
case 21: {
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.rateLimitProof
})
break
case 31:
}
case 31: {
obj.ephemeral = reader.bool()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -444,7 +478,7 @@ export namespace WakuMessage {
return encodeMessage(obj, WakuMessage.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMessage>): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec(), opts)
}
}

View File

@ -4,8 +4,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface RateLimitProof {
@ -66,15 +66,15 @@ export namespace RateLimitProof {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
proof: new Uint8Array(0),
merkleRoot: new Uint8Array(0),
epoch: new Uint8Array(0),
shareX: new Uint8Array(0),
shareY: new Uint8Array(0),
nullifier: new Uint8Array(0),
rlnIdentifier: new Uint8Array(0)
proof: uint8ArrayAlloc(0),
merkleRoot: uint8ArrayAlloc(0),
epoch: uint8ArrayAlloc(0),
shareX: uint8ArrayAlloc(0),
shareY: uint8ArrayAlloc(0),
nullifier: uint8ArrayAlloc(0),
rlnIdentifier: uint8ArrayAlloc(0)
}
const end = length == null ? reader.len : reader.pos + length
@ -83,32 +83,40 @@ export namespace RateLimitProof {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.proof = reader.bytes()
break
case 2:
}
case 2: {
obj.merkleRoot = reader.bytes()
break
case 3:
}
case 3: {
obj.epoch = reader.bytes()
break
case 4:
}
case 4: {
obj.shareX = reader.bytes()
break
case 5:
}
case 5: {
obj.shareY = reader.bytes()
break
case 6:
}
case 6: {
obj.nullifier = reader.bytes()
break
case 7:
}
case 7: {
obj.rlnIdentifier = reader.bytes()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -121,8 +129,8 @@ export namespace RateLimitProof {
return encodeMessage(obj, RateLimitProof.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<RateLimitProof>): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec(), opts)
}
}
@ -184,9 +192,9 @@ export namespace WakuMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
payload: new Uint8Array(0),
payload: uint8ArrayAlloc(0),
contentTopic: ''
}
@ -196,32 +204,42 @@ export namespace WakuMessage {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.payload = reader.bytes()
break
case 2:
}
case 2: {
obj.contentTopic = reader.string()
break
case 3:
}
case 3: {
obj.version = reader.uint32()
break
case 10:
}
case 10: {
obj.timestamp = reader.sint64()
break
case 11:
}
case 11: {
obj.meta = reader.bytes()
break
case 21:
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32())
}
case 21: {
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.rateLimitProof
})
break
case 31:
}
case 31: {
obj.ephemeral = reader.bool()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -234,7 +252,7 @@ export namespace WakuMessage {
return encodeMessage(obj, WakuMessage.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMessage>): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec(), opts)
}
}

View File

@ -4,8 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface WakuMetadataRequest {
@ -38,7 +37,7 @@ export namespace WakuMetadataRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
shards: []
}
@ -49,17 +48,24 @@ export namespace WakuMetadataRequest {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.clusterId = reader.uint32()
break
case 2:
}
case 2: {
if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {
throw new CodeError('decode error - map field "shards" had too many elements', 'ERR_MAX_LENGTH')
}
obj.shards.push(reader.uint32())
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -72,8 +78,8 @@ export namespace WakuMetadataRequest {
return encodeMessage(obj, WakuMetadataRequest.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMetadataRequest => {
return decodeMessage(buf, WakuMetadataRequest.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMetadataRequest>): WakuMetadataRequest => {
return decodeMessage(buf, WakuMetadataRequest.codec(), opts)
}
}
@ -107,7 +113,7 @@ export namespace WakuMetadataResponse {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
shards: []
}
@ -118,17 +124,24 @@ export namespace WakuMetadataResponse {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.clusterId = reader.uint32()
break
case 2:
}
case 2: {
if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {
throw new CodeError('decode error - map field "shards" had too many elements', 'ERR_MAX_LENGTH')
}
obj.shards.push(reader.uint32())
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -141,7 +154,7 @@ export namespace WakuMetadataResponse {
return encodeMessage(obj, WakuMetadataResponse.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMetadataResponse => {
return decodeMessage(buf, WakuMetadataResponse.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMetadataResponse>): WakuMetadataResponse => {
return decodeMessage(buf, WakuMetadataResponse.codec(), opts)
}
}

View File

@ -4,8 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface PeerInfo {
@ -30,7 +29,7 @@ export namespace PeerInfo {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {}
const end = length == null ? reader.len : reader.pos + length
@ -39,14 +38,16 @@ export namespace PeerInfo {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.enr = reader.bytes()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -59,8 +60,8 @@ export namespace PeerInfo {
return encodeMessage(obj, PeerInfo.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerInfo => {
return decodeMessage(buf, PeerInfo.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerInfo>): PeerInfo => {
return decodeMessage(buf, PeerInfo.codec(), opts)
}
}
@ -86,7 +87,7 @@ export namespace PeerExchangeQuery {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {}
const end = length == null ? reader.len : reader.pos + length
@ -95,14 +96,16 @@ export namespace PeerExchangeQuery {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.numPeers = reader.uint64()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -115,8 +118,8 @@ export namespace PeerExchangeQuery {
return encodeMessage(obj, PeerExchangeQuery.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerExchangeQuery => {
return decodeMessage(buf, PeerExchangeQuery.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerExchangeQuery>): PeerExchangeQuery => {
return decodeMessage(buf, PeerExchangeQuery.codec(), opts)
}
}
@ -144,7 +147,7 @@ export namespace PeerExchangeResponse {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
peerInfos: []
}
@ -155,14 +158,22 @@ export namespace PeerExchangeResponse {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32()))
case 1: {
if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) {
throw new CodeError('decode error - map field "peerInfos" had too many elements', 'ERR_MAX_LENGTH')
}
obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.peerInfos$
}))
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -175,8 +186,8 @@ export namespace PeerExchangeResponse {
return encodeMessage(obj, PeerExchangeResponse.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerExchangeResponse => {
return decodeMessage(buf, PeerExchangeResponse.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerExchangeResponse>): PeerExchangeResponse => {
return decodeMessage(buf, PeerExchangeResponse.codec(), opts)
}
}
@ -208,7 +219,7 @@ export namespace PeerExchangeRPC {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {}
const end = length == null ? reader.len : reader.pos + length
@ -217,17 +228,24 @@ export namespace PeerExchangeRPC {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32())
case 1: {
obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.query
})
break
case 2:
obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32())
}
case 2: {
obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.response
})
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -240,7 +258,7 @@ export namespace PeerExchangeRPC {
return encodeMessage(obj, PeerExchangeRPC.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PeerExchangeRPC => {
return decodeMessage(buf, PeerExchangeRPC.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PeerExchangeRPC>): PeerExchangeRPC => {
return decodeMessage(buf, PeerExchangeRPC.codec(), opts)
}
}

View File

@ -4,8 +4,8 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message, enumeration } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, enumeration, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface Index {
@ -48,9 +48,9 @@ export namespace Index {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
digest: new Uint8Array(0),
digest: uint8ArrayAlloc(0),
receiverTime: 0n,
senderTime: 0n,
pubsubTopic: ''
@ -62,23 +62,28 @@ export namespace Index {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.digest = reader.bytes()
break
case 2:
}
case 2: {
obj.receiverTime = reader.sint64()
break
case 3:
}
case 3: {
obj.senderTime = reader.sint64()
break
case 4:
}
case 4: {
obj.pubsubTopic = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -91,8 +96,8 @@ export namespace Index {
return encodeMessage(obj, Index.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): Index => {
return decodeMessage(buf, Index.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Index>): Index => {
return decodeMessage(buf, Index.codec(), opts)
}
}
@ -146,7 +151,7 @@ export namespace PagingInfo {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {}
const end = length == null ? reader.len : reader.pos + length
@ -155,20 +160,26 @@ export namespace PagingInfo {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.pageSize = reader.uint64()
break
case 2:
obj.cursor = Index.codec().decode(reader, reader.uint32())
}
case 2: {
obj.cursor = Index.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.cursor
})
break
case 3:
}
case 3: {
obj.direction = PagingInfo.Direction.codec().decode(reader)
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -181,8 +192,8 @@ export namespace PagingInfo {
return encodeMessage(obj, PagingInfo.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): PagingInfo => {
return decodeMessage(buf, PagingInfo.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PagingInfo>): PagingInfo => {
return decodeMessage(buf, PagingInfo.codec(), opts)
}
}
@ -208,7 +219,7 @@ export namespace ContentFilter {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
contentTopic: ''
}
@ -219,14 +230,16 @@ export namespace ContentFilter {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.contentTopic = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -239,8 +252,8 @@ export namespace ContentFilter {
return encodeMessage(obj, ContentFilter.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): ContentFilter => {
return decodeMessage(buf, ContentFilter.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<ContentFilter>): ContentFilter => {
return decodeMessage(buf, ContentFilter.codec(), opts)
}
}
@ -292,7 +305,7 @@ export namespace HistoryQuery {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
contentFilters: []
}
@ -303,26 +316,40 @@ export namespace HistoryQuery {
const tag = reader.uint32()
switch (tag >>> 3) {
case 2:
case 2: {
obj.pubsubTopic = reader.string()
break
case 3:
obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32()))
}
case 3: {
if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {
throw new CodeError('decode error - map field "contentFilters" had too many elements', 'ERR_MAX_LENGTH')
}
obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.contentFilters$
}))
break
case 4:
obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32())
}
case 4: {
obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.pagingInfo
})
break
case 5:
}
case 5: {
obj.startTime = reader.sint64()
break
case 6:
}
case 6: {
obj.endTime = reader.sint64()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -335,8 +362,8 @@ export namespace HistoryQuery {
return encodeMessage(obj, HistoryQuery.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): HistoryQuery => {
return decodeMessage(buf, HistoryQuery.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HistoryQuery>): HistoryQuery => {
return decodeMessage(buf, HistoryQuery.codec(), opts)
}
}
@ -392,7 +419,7 @@ export namespace HistoryResponse {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
messages: [],
error: HistoryError.NONE
@ -404,20 +431,32 @@ export namespace HistoryResponse {
const tag = reader.uint32()
switch (tag >>> 3) {
case 2:
obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()))
case 2: {
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
throw new CodeError('decode error - map field "messages" had too many elements', 'ERR_MAX_LENGTH')
}
obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.messages$
}))
break
case 3:
obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32())
}
case 3: {
obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.pagingInfo
})
break
case 4:
}
case 4: {
obj.error = HistoryResponse.HistoryError.codec().decode(reader)
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -430,8 +469,8 @@ export namespace HistoryResponse {
return encodeMessage(obj, HistoryResponse.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): HistoryResponse => {
return decodeMessage(buf, HistoryResponse.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HistoryResponse>): HistoryResponse => {
return decodeMessage(buf, HistoryResponse.codec(), opts)
}
}
@ -469,7 +508,7 @@ export namespace HistoryRpc {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
requestId: ''
}
@ -480,20 +519,28 @@ export namespace HistoryRpc {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.requestId = reader.string()
break
case 2:
obj.query = HistoryQuery.codec().decode(reader, reader.uint32())
}
case 2: {
obj.query = HistoryQuery.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.query
})
break
case 3:
obj.response = HistoryResponse.codec().decode(reader, reader.uint32())
}
case 3: {
obj.response = HistoryResponse.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.response
})
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -506,8 +553,8 @@ export namespace HistoryRpc {
return encodeMessage(obj, HistoryRpc.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): HistoryRpc => {
return decodeMessage(buf, HistoryRpc.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<HistoryRpc>): HistoryRpc => {
return decodeMessage(buf, HistoryRpc.codec(), opts)
}
}
@ -569,15 +616,15 @@ export namespace RateLimitProof {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
proof: new Uint8Array(0),
merkleRoot: new Uint8Array(0),
epoch: new Uint8Array(0),
shareX: new Uint8Array(0),
shareY: new Uint8Array(0),
nullifier: new Uint8Array(0),
rlnIdentifier: new Uint8Array(0)
proof: uint8ArrayAlloc(0),
merkleRoot: uint8ArrayAlloc(0),
epoch: uint8ArrayAlloc(0),
shareX: uint8ArrayAlloc(0),
shareY: uint8ArrayAlloc(0),
nullifier: uint8ArrayAlloc(0),
rlnIdentifier: uint8ArrayAlloc(0)
}
const end = length == null ? reader.len : reader.pos + length
@ -586,32 +633,40 @@ export namespace RateLimitProof {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.proof = reader.bytes()
break
case 2:
}
case 2: {
obj.merkleRoot = reader.bytes()
break
case 3:
}
case 3: {
obj.epoch = reader.bytes()
break
case 4:
}
case 4: {
obj.shareX = reader.bytes()
break
case 5:
}
case 5: {
obj.shareY = reader.bytes()
break
case 6:
}
case 6: {
obj.nullifier = reader.bytes()
break
case 7:
}
case 7: {
obj.rlnIdentifier = reader.bytes()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -624,8 +679,8 @@ export namespace RateLimitProof {
return encodeMessage(obj, RateLimitProof.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<RateLimitProof>): RateLimitProof => {
return decodeMessage(buf, RateLimitProof.codec(), opts)
}
}
@ -687,9 +742,9 @@ export namespace WakuMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
payload: new Uint8Array(0),
payload: uint8ArrayAlloc(0),
contentTopic: ''
}
@ -699,32 +754,42 @@ export namespace WakuMessage {
const tag = reader.uint32()
switch (tag >>> 3) {
case 1:
case 1: {
obj.payload = reader.bytes()
break
case 2:
}
case 2: {
obj.contentTopic = reader.string()
break
case 3:
}
case 3: {
obj.version = reader.uint32()
break
case 10:
}
case 10: {
obj.timestamp = reader.sint64()
break
case 11:
}
case 11: {
obj.meta = reader.bytes()
break
case 21:
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32())
}
case 21: {
obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32(), {
limits: opts.limits?.rateLimitProof
})
break
case 31:
}
case 31: {
obj.ephemeral = reader.bool()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -737,7 +802,7 @@ export namespace WakuMessage {
return encodeMessage(obj, WakuMessage.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<WakuMessage>): WakuMessage => {
return decodeMessage(buf, WakuMessage.codec(), opts)
}
}

View File

@ -4,8 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
export interface TopicOnlyMessage {
@ -30,7 +29,7 @@ export namespace TopicOnlyMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
contentTopic: ''
}
@ -41,14 +40,16 @@ export namespace TopicOnlyMessage {
const tag = reader.uint32()
switch (tag >>> 3) {
case 2:
case 2: {
obj.contentTopic = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}
return obj
})
@ -61,7 +62,7 @@ export namespace TopicOnlyMessage {
return encodeMessage(obj, TopicOnlyMessage.codec())
}
export const decode = (buf: Uint8Array | Uint8ArrayList): TopicOnlyMessage => {
return decodeMessage(buf, TopicOnlyMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<TopicOnlyMessage>): TopicOnlyMessage => {
return decodeMessage(buf, TopicOnlyMessage.codec(), opts)
}
}

View File

@ -1,17 +1,17 @@
export * as proto_message from "./lib/message.js";
export { WakuMessage } from "./lib/filter.js";
export * as proto_message from "./generated/message.js";
export { WakuMessage } from "./generated/filter.js";
export * as proto_topic_only_message from "./lib/topic_only_message.js";
export { TopicOnlyMessage } from "./lib/topic_only_message.js";
export * as proto_topic_only_message from "./generated/topic_only_message.js";
export { TopicOnlyMessage } from "./generated/topic_only_message.js";
export * as proto_filter from "./lib/filter.js";
export * as proto_filter_v2 from "./lib/filter_v2.js";
export * as proto_filter from "./generated/filter.js";
export * as proto_filter_v2 from "./generated/filter_v2.js";
export * as proto_lightpush from "./lib/light_push.js";
export { PushResponse } from "./lib/light_push.js";
export * as proto_lightpush from "./generated/light_push.js";
export { PushResponse } from "./generated/light_push.js";
export * as proto_store from "./lib/store.js";
export * as proto_store from "./generated/store.js";
export * as proto_peer_exchange from "./lib/peer_exchange.js";
export * as proto_peer_exchange from "./generated/peer_exchange.js";
export * as proto_metadata from './lib/metadata.js'
export * as proto_metadata from './generated/metadata.js'

View File

@ -1,3 +0,0 @@
{
"extends": "../../tsconfig.dev"
}

View File

@ -3,8 +3,11 @@
"compilerOptions": {
"outDir": "dist/",
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo"
"tsBuildInfoFile": "dist/.tsbuildinfo",
"skipLibCheck": true,
"noUnusedLocals": false,
"noUnusedParameters": false
},
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/test_utils"]
"include": ["src/index.ts", "src/lib/**/*.proto"],
"exclude": ["src/generated/**/*.ts"]
}

View File

@ -145,11 +145,17 @@ describe("Metadata Protocol", function () {
await waku.start();
await waku.libp2p.dialProtocol(nwaku1Ma, MetadataCodec);
// add a delay to make sure the connection is closed from the other side
// ensure the connection is closed from the other side
let counter = 0;
while (waku.libp2p.getConnections().length !== 0) {
if (counter > 10) {
break;
}
await delay(100);
counter++;
}
const activeConnections = waku.libp2p.getConnections();
expect(activeConnections.length).to.equal(0);
expect(waku.libp2p.getConnections().length).to.equal(0);
});
it("different cluster, different shard: nodes don't connect", async function () {
@ -177,11 +183,18 @@ describe("Metadata Protocol", function () {
await waku.start();
await waku.libp2p.dialProtocol(nwaku1Ma, MetadataCodec);
// add a delay to make sure the connection is closed from the other side
// ensure the connection is closed from the other side
let counter = 0;
while (waku.libp2p.getConnections().length !== 0) {
if (counter > 10) {
console.error("Connection was not closed");
break;
}
await delay(100);
counter++;
}
const activeConnections = waku.libp2p.getConnections();
expect(activeConnections.length).to.equal(0);
expect(waku.libp2p.getConnections().length).to.equal(0);
});
});

View File

@ -191,7 +191,7 @@ describe("Waku Store, cursor", function () {
for await (const page of waku.store.queryGenerator([TestDecoder], {
cursor
})) {
page;
void page;
}
throw new Error("Cursor with wrong pubsubtopic was accepted");
} catch (err) {

View File

@ -39,7 +39,7 @@ describe("Waku Store, error handling", function () {
for await (const msgPromises of waku.store.queryGenerator([
customDecoder1
])) {
msgPromises;
void msgPromises;
}
throw new Error("QueryGenerator was successful but was expected to fail");
} catch (err) {
@ -60,7 +60,7 @@ describe("Waku Store, error handling", function () {
TestDecoder,
customDecoder1
])) {
msgPromises;
void msgPromises;
}
throw new Error("QueryGenerator was successful but was expected to fail");
} catch (err) {
@ -78,7 +78,7 @@ describe("Waku Store, error handling", function () {
it("Query Generator, No Decoder", async function () {
try {
for await (const msgPromises of waku.store.queryGenerator([])) {
msgPromises;
void msgPromises;
}
throw new Error("QueryGenerator was successful but was expected to fail");
} catch (err) {