Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade protons + commit new proto code #1898

Merged
merged 13 commits into from
Apr 7, 2024
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42,939 changes: 7,055 additions & 35,884 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,7 +44,7 @@
"node": ">=18"
},
"dependencies": {
"protons-runtime": "^5.0.2"
"protons-runtime": "^5.4.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -37,7 +37,7 @@ export namespace FilterRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
contentTopic: ''
}
Expand All @@ -48,12 +48,14 @@ 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
}
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -102,7 +104,7 @@ export namespace FilterRequest {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
subscribe: false,
topic: '',
Expand All @@ -115,18 +117,28 @@ 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) {
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
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$
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
}))
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -170,7 +182,7 @@ export namespace MessagePush {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
messages: []
}
Expand All @@ -181,12 +193,20 @@ 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) {
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
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$
danisharora099 marked this conversation as resolved.
Show resolved Hide resolved
}))
break
default:
}
default: {
reader.skipType(tag & 7)
break
}
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -240,7 +260,7 @@ export namespace FilterRpc {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
requestId: ''
}
Expand All @@ -251,18 +271,26 @@ 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
}
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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
Expand All @@ -357,30 +385,38 @@ 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
}
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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: ''
}

Expand All @@ -470,30 +506,40 @@ 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
}
}
}

Expand All @@ -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)
}
}
Loading
Loading