Skip to content

Commit

Permalink
fix: regenerate protobuf defs (#1439)
Browse files Browse the repository at this point in the history
The new protons needs the protobuf files regenerating.
  • Loading branch information
achingbrain committed Oct 14, 2022
1 parent a3847f2 commit e10eea2
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 148 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -171,8 +171,8 @@
"@chainsafe/libp2p-noise": "^9.0.0",
"@chainsafe/libp2p-yamux": "^3.0.0",
"@libp2p/bootstrap": "^5.0.0",
"@libp2p/daemon-client": "^3.0.1",
"@libp2p/daemon-server": "^3.0.1",
"@libp2p/daemon-client": "^3.0.5",
"@libp2p/daemon-server": "^3.0.4",
"@libp2p/floodsub": "^5.0.0",
"@libp2p/interface-compliance-tests": "^3.0.2",
"@libp2p/interface-connection-encrypter-compliance-tests": "^3.0.0",
Expand Down Expand Up @@ -205,7 +205,7 @@
"protons": "^6.0.0",
"rimraf": "^3.0.2",
"sinon": "^14.0.0",
"ts-sinon": "^2.0.2"
"sinon-ts": "^1.0.0"
},
"browser": {
"nat-api": false
Expand Down
64 changes: 29 additions & 35 deletions src/circuit/pb/index.ts
@@ -1,5 +1,7 @@
/* eslint-disable import/export */
/* eslint-disable complexity */
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */

import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
Expand Down Expand Up @@ -87,32 +89,31 @@ export namespace CircuitRelay {

export const codec = (): Codec<Peer> => {
if (_codec == null) {
_codec = message<Peer>((obj, writer, opts = {}) => {
_codec = message<Peer>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.id != null) {
writer.uint32(10)
writer.bytes(obj.id)
} else {
throw new Error('Protocol error: required field "id" was not found in object')
if (opts.writeDefaults === true || (obj.id != null && obj.id.byteLength > 0)) {
w.uint32(10)
w.bytes(obj.id)
}

if (obj.addrs != null) {
for (const value of obj.addrs) {
writer.uint32(18)
writer.bytes(value)
w.uint32(18)
w.bytes(value)
}
} else {
throw new Error('Protocol error: required field "addrs" was not found in object')
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {}
const obj: any = {
id: new Uint8Array(0),
addrs: []
}

const end = length == null ? reader.len : reader.pos + length

Expand All @@ -124,7 +125,6 @@ export namespace CircuitRelay {
obj.id = reader.bytes()
break
case 2:
obj.addrs = obj.addrs ?? []
obj.addrs.push(reader.bytes())
break
default:
Expand All @@ -133,16 +133,6 @@ export namespace CircuitRelay {
}
}

obj.addrs = obj.addrs ?? []

if (obj.id == null) {
throw new Error('Protocol error: value for required field "id" was not found in protobuf')
}

if (obj.addrs == null) {
throw new Error('Protocol error: value for required field "addrs" was not found in protobuf')
}

return obj
})
}
Expand All @@ -163,33 +153,37 @@ export namespace CircuitRelay {

export const codec = (): Codec<CircuitRelay> => {
if (_codec == null) {
_codec = message<CircuitRelay>((obj, writer, opts = {}) => {
_codec = message<CircuitRelay>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.type != null) {
writer.uint32(8)
CircuitRelay.Type.codec().encode(obj.type, writer)
w.uint32(8)
CircuitRelay.Type.codec().encode(obj.type, w)
}

if (obj.srcPeer != null) {
writer.uint32(18)
CircuitRelay.Peer.codec().encode(obj.srcPeer, writer)
w.uint32(18)
CircuitRelay.Peer.codec().encode(obj.srcPeer, w, {
writeDefaults: false
})
}

if (obj.dstPeer != null) {
writer.uint32(26)
CircuitRelay.Peer.codec().encode(obj.dstPeer, writer)
w.uint32(26)
CircuitRelay.Peer.codec().encode(obj.dstPeer, w, {
writeDefaults: false
})
}

if (obj.code != null) {
writer.uint32(32)
CircuitRelay.Status.codec().encode(obj.code, writer)
w.uint32(32)
CircuitRelay.Status.codec().encode(obj.code, w)
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {}
Expand Down
59 changes: 24 additions & 35 deletions src/fetch/pb/proto.ts
@@ -1,5 +1,7 @@
/* eslint-disable import/export */
/* eslint-disable complexity */
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */

import { encodeMessage, decodeMessage, message, enumeration } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
Expand All @@ -14,23 +16,23 @@ export namespace FetchRequest {

export const codec = (): Codec<FetchRequest> => {
if (_codec == null) {
_codec = message<FetchRequest>((obj, writer, opts = {}) => {
_codec = message<FetchRequest>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.identifier != null) {
writer.uint32(10)
writer.string(obj.identifier)
} else {
throw new Error('Protocol error: required field "identifier" was not found in object')
if (opts.writeDefaults === true || obj.identifier !== '') {
w.uint32(10)
w.string(obj.identifier)
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {}
const obj: any = {
identifier: ''
}

const end = length == null ? reader.len : reader.pos + length

Expand All @@ -47,10 +49,6 @@ export namespace FetchRequest {
}
}

if (obj.identifier == null) {
throw new Error('Protocol error: value for required field "identifier" was not found in protobuf')
}

return obj
})
}
Expand Down Expand Up @@ -95,30 +93,29 @@ export namespace FetchResponse {

export const codec = (): Codec<FetchResponse> => {
if (_codec == null) {
_codec = message<FetchResponse>((obj, writer, opts = {}) => {
_codec = message<FetchResponse>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.status != null) {
writer.uint32(8)
FetchResponse.StatusCode.codec().encode(obj.status, writer)
} else {
throw new Error('Protocol error: required field "status" was not found in object')
if (opts.writeDefaults === true || (obj.status != null && __StatusCodeValues[obj.status] !== 0)) {
w.uint32(8)
FetchResponse.StatusCode.codec().encode(obj.status, w)
}

if (obj.data != null) {
writer.uint32(18)
writer.bytes(obj.data)
} else {
throw new Error('Protocol error: required field "data" was not found in object')
if (opts.writeDefaults === true || (obj.data != null && obj.data.byteLength > 0)) {
w.uint32(18)
w.bytes(obj.data)
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {}
const obj: any = {
status: StatusCode.OK,
data: new Uint8Array(0)
}

const end = length == null ? reader.len : reader.pos + length

Expand All @@ -138,14 +135,6 @@ export namespace FetchResponse {
}
}

if (obj.status == null) {
throw new Error('Protocol error: value for required field "status" was not found in protobuf')
}

if (obj.data == null) {
throw new Error('Protocol error: value for required field "data" was not found in protobuf')
}

return obj
})
}
Expand Down
58 changes: 23 additions & 35 deletions src/identify/pb/message.ts
@@ -1,5 +1,7 @@
/* eslint-disable import/export */
/* eslint-disable complexity */
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */

import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
Expand All @@ -20,59 +22,58 @@ export namespace Identify {

export const codec = (): Codec<Identify> => {
if (_codec == null) {
_codec = message<Identify>((obj, writer, opts = {}) => {
_codec = message<Identify>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
w.fork()
}

if (obj.protocolVersion != null) {
writer.uint32(42)
writer.string(obj.protocolVersion)
w.uint32(42)
w.string(obj.protocolVersion)
}

if (obj.agentVersion != null) {
writer.uint32(50)
writer.string(obj.agentVersion)
w.uint32(50)
w.string(obj.agentVersion)
}

if (obj.publicKey != null) {
writer.uint32(10)
writer.bytes(obj.publicKey)
w.uint32(10)
w.bytes(obj.publicKey)
}

if (obj.listenAddrs != null) {
for (const value of obj.listenAddrs) {
writer.uint32(18)
writer.bytes(value)
w.uint32(18)
w.bytes(value)
}
} else {
throw new Error('Protocol error: required field "listenAddrs" was not found in object')
}

if (obj.observedAddr != null) {
writer.uint32(34)
writer.bytes(obj.observedAddr)
w.uint32(34)
w.bytes(obj.observedAddr)
}

if (obj.protocols != null) {
for (const value of obj.protocols) {
writer.uint32(26)
writer.string(value)
w.uint32(26)
w.string(value)
}
} else {
throw new Error('Protocol error: required field "protocols" was not found in object')
}

if (obj.signedPeerRecord != null) {
writer.uint32(66)
writer.bytes(obj.signedPeerRecord)
w.uint32(66)
w.bytes(obj.signedPeerRecord)
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {}
const obj: any = {
listenAddrs: [],
protocols: []
}

const end = length == null ? reader.len : reader.pos + length

Expand All @@ -90,14 +91,12 @@ export namespace Identify {
obj.publicKey = reader.bytes()
break
case 2:
obj.listenAddrs = obj.listenAddrs ?? []
obj.listenAddrs.push(reader.bytes())
break
case 4:
obj.observedAddr = reader.bytes()
break
case 3:
obj.protocols = obj.protocols ?? []
obj.protocols.push(reader.string())
break
case 8:
Expand All @@ -109,17 +108,6 @@ export namespace Identify {
}
}

obj.listenAddrs = obj.listenAddrs ?? []
obj.protocols = obj.protocols ?? []

if (obj.listenAddrs == null) {
throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf')
}

if (obj.protocols == null) {
throw new Error('Protocol error: value for required field "protocols" was not found in protobuf')
}

return obj
})
}
Expand Down

0 comments on commit e10eea2

Please sign in to comment.