Skip to content

Commit e10eea2

Browse files
authored
fix: regenerate protobuf defs (#1439)
The new protons needs the protobuf files regenerating.
1 parent a3847f2 commit e10eea2

File tree

16 files changed

+114
-148
lines changed

16 files changed

+114
-148
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@
171171
"@chainsafe/libp2p-noise": "^9.0.0",
172172
"@chainsafe/libp2p-yamux": "^3.0.0",
173173
"@libp2p/bootstrap": "^5.0.0",
174-
"@libp2p/daemon-client": "^3.0.1",
175-
"@libp2p/daemon-server": "^3.0.1",
174+
"@libp2p/daemon-client": "^3.0.5",
175+
"@libp2p/daemon-server": "^3.0.4",
176176
"@libp2p/floodsub": "^5.0.0",
177177
"@libp2p/interface-compliance-tests": "^3.0.2",
178178
"@libp2p/interface-connection-encrypter-compliance-tests": "^3.0.0",
@@ -205,7 +205,7 @@
205205
"protons": "^6.0.0",
206206
"rimraf": "^3.0.2",
207207
"sinon": "^14.0.0",
208-
"ts-sinon": "^2.0.2"
208+
"sinon-ts": "^1.0.0"
209209
},
210210
"browser": {
211211
"nat-api": false

src/circuit/pb/index.ts

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable import/export */
2+
/* eslint-disable complexity */
23
/* eslint-disable @typescript-eslint/no-namespace */
4+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
35

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

8890
export const codec = (): Codec<Peer> => {
8991
if (_codec == null) {
90-
_codec = message<Peer>((obj, writer, opts = {}) => {
92+
_codec = message<Peer>((obj, w, opts = {}) => {
9193
if (opts.lengthDelimited !== false) {
92-
writer.fork()
94+
w.fork()
9395
}
9496

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

102102
if (obj.addrs != null) {
103103
for (const value of obj.addrs) {
104-
writer.uint32(18)
105-
writer.bytes(value)
104+
w.uint32(18)
105+
w.bytes(value)
106106
}
107-
} else {
108-
throw new Error('Protocol error: required field "addrs" was not found in object')
109107
}
110108

111109
if (opts.lengthDelimited !== false) {
112-
writer.ldelim()
110+
w.ldelim()
113111
}
114112
}, (reader, length) => {
115-
const obj: any = {}
113+
const obj: any = {
114+
id: new Uint8Array(0),
115+
addrs: []
116+
}
116117

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

@@ -124,7 +125,6 @@ export namespace CircuitRelay {
124125
obj.id = reader.bytes()
125126
break
126127
case 2:
127-
obj.addrs = obj.addrs ?? []
128128
obj.addrs.push(reader.bytes())
129129
break
130130
default:
@@ -133,16 +133,6 @@ export namespace CircuitRelay {
133133
}
134134
}
135135

136-
obj.addrs = obj.addrs ?? []
137-
138-
if (obj.id == null) {
139-
throw new Error('Protocol error: value for required field "id" was not found in protobuf')
140-
}
141-
142-
if (obj.addrs == null) {
143-
throw new Error('Protocol error: value for required field "addrs" was not found in protobuf')
144-
}
145-
146136
return obj
147137
})
148138
}
@@ -163,33 +153,37 @@ export namespace CircuitRelay {
163153

164154
export const codec = (): Codec<CircuitRelay> => {
165155
if (_codec == null) {
166-
_codec = message<CircuitRelay>((obj, writer, opts = {}) => {
156+
_codec = message<CircuitRelay>((obj, w, opts = {}) => {
167157
if (opts.lengthDelimited !== false) {
168-
writer.fork()
158+
w.fork()
169159
}
170160

171161
if (obj.type != null) {
172-
writer.uint32(8)
173-
CircuitRelay.Type.codec().encode(obj.type, writer)
162+
w.uint32(8)
163+
CircuitRelay.Type.codec().encode(obj.type, w)
174164
}
175165

176166
if (obj.srcPeer != null) {
177-
writer.uint32(18)
178-
CircuitRelay.Peer.codec().encode(obj.srcPeer, writer)
167+
w.uint32(18)
168+
CircuitRelay.Peer.codec().encode(obj.srcPeer, w, {
169+
writeDefaults: false
170+
})
179171
}
180172

181173
if (obj.dstPeer != null) {
182-
writer.uint32(26)
183-
CircuitRelay.Peer.codec().encode(obj.dstPeer, writer)
174+
w.uint32(26)
175+
CircuitRelay.Peer.codec().encode(obj.dstPeer, w, {
176+
writeDefaults: false
177+
})
184178
}
185179

186180
if (obj.code != null) {
187-
writer.uint32(32)
188-
CircuitRelay.Status.codec().encode(obj.code, writer)
181+
w.uint32(32)
182+
CircuitRelay.Status.codec().encode(obj.code, w)
189183
}
190184

191185
if (opts.lengthDelimited !== false) {
192-
writer.ldelim()
186+
w.ldelim()
193187
}
194188
}, (reader, length) => {
195189
const obj: any = {}

src/fetch/pb/proto.ts

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable import/export */
2+
/* eslint-disable complexity */
23
/* eslint-disable @typescript-eslint/no-namespace */
4+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
35

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

1517
export const codec = (): Codec<FetchRequest> => {
1618
if (_codec == null) {
17-
_codec = message<FetchRequest>((obj, writer, opts = {}) => {
19+
_codec = message<FetchRequest>((obj, w, opts = {}) => {
1820
if (opts.lengthDelimited !== false) {
19-
writer.fork()
21+
w.fork()
2022
}
2123

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

2929
if (opts.lengthDelimited !== false) {
30-
writer.ldelim()
30+
w.ldelim()
3131
}
3232
}, (reader, length) => {
33-
const obj: any = {}
33+
const obj: any = {
34+
identifier: ''
35+
}
3436

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

@@ -47,10 +49,6 @@ export namespace FetchRequest {
4749
}
4850
}
4951

50-
if (obj.identifier == null) {
51-
throw new Error('Protocol error: value for required field "identifier" was not found in protobuf')
52-
}
53-
5452
return obj
5553
})
5654
}
@@ -95,30 +93,29 @@ export namespace FetchResponse {
9593

9694
export const codec = (): Codec<FetchResponse> => {
9795
if (_codec == null) {
98-
_codec = message<FetchResponse>((obj, writer, opts = {}) => {
96+
_codec = message<FetchResponse>((obj, w, opts = {}) => {
9997
if (opts.lengthDelimited !== false) {
100-
writer.fork()
98+
w.fork()
10199
}
102100

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

110-
if (obj.data != null) {
111-
writer.uint32(18)
112-
writer.bytes(obj.data)
113-
} else {
114-
throw new Error('Protocol error: required field "data" was not found in object')
106+
if (opts.writeDefaults === true || (obj.data != null && obj.data.byteLength > 0)) {
107+
w.uint32(18)
108+
w.bytes(obj.data)
115109
}
116110

117111
if (opts.lengthDelimited !== false) {
118-
writer.ldelim()
112+
w.ldelim()
119113
}
120114
}, (reader, length) => {
121-
const obj: any = {}
115+
const obj: any = {
116+
status: StatusCode.OK,
117+
data: new Uint8Array(0)
118+
}
122119

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

@@ -138,14 +135,6 @@ export namespace FetchResponse {
138135
}
139136
}
140137

141-
if (obj.status == null) {
142-
throw new Error('Protocol error: value for required field "status" was not found in protobuf')
143-
}
144-
145-
if (obj.data == null) {
146-
throw new Error('Protocol error: value for required field "data" was not found in protobuf')
147-
}
148-
149138
return obj
150139
})
151140
}

src/identify/pb/message.ts

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable import/export */
2+
/* eslint-disable complexity */
23
/* eslint-disable @typescript-eslint/no-namespace */
4+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
35

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

2123
export const codec = (): Codec<Identify> => {
2224
if (_codec == null) {
23-
_codec = message<Identify>((obj, writer, opts = {}) => {
25+
_codec = message<Identify>((obj, w, opts = {}) => {
2426
if (opts.lengthDelimited !== false) {
25-
writer.fork()
27+
w.fork()
2628
}
2729

2830
if (obj.protocolVersion != null) {
29-
writer.uint32(42)
30-
writer.string(obj.protocolVersion)
31+
w.uint32(42)
32+
w.string(obj.protocolVersion)
3133
}
3234

3335
if (obj.agentVersion != null) {
34-
writer.uint32(50)
35-
writer.string(obj.agentVersion)
36+
w.uint32(50)
37+
w.string(obj.agentVersion)
3638
}
3739

3840
if (obj.publicKey != null) {
39-
writer.uint32(10)
40-
writer.bytes(obj.publicKey)
41+
w.uint32(10)
42+
w.bytes(obj.publicKey)
4143
}
4244

4345
if (obj.listenAddrs != null) {
4446
for (const value of obj.listenAddrs) {
45-
writer.uint32(18)
46-
writer.bytes(value)
47+
w.uint32(18)
48+
w.bytes(value)
4749
}
48-
} else {
49-
throw new Error('Protocol error: required field "listenAddrs" was not found in object')
5050
}
5151

5252
if (obj.observedAddr != null) {
53-
writer.uint32(34)
54-
writer.bytes(obj.observedAddr)
53+
w.uint32(34)
54+
w.bytes(obj.observedAddr)
5555
}
5656

5757
if (obj.protocols != null) {
5858
for (const value of obj.protocols) {
59-
writer.uint32(26)
60-
writer.string(value)
59+
w.uint32(26)
60+
w.string(value)
6161
}
62-
} else {
63-
throw new Error('Protocol error: required field "protocols" was not found in object')
6462
}
6563

6664
if (obj.signedPeerRecord != null) {
67-
writer.uint32(66)
68-
writer.bytes(obj.signedPeerRecord)
65+
w.uint32(66)
66+
w.bytes(obj.signedPeerRecord)
6967
}
7068

7169
if (opts.lengthDelimited !== false) {
72-
writer.ldelim()
70+
w.ldelim()
7371
}
7472
}, (reader, length) => {
75-
const obj: any = {}
73+
const obj: any = {
74+
listenAddrs: [],
75+
protocols: []
76+
}
7677

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

@@ -90,14 +91,12 @@ export namespace Identify {
9091
obj.publicKey = reader.bytes()
9192
break
9293
case 2:
93-
obj.listenAddrs = obj.listenAddrs ?? []
9494
obj.listenAddrs.push(reader.bytes())
9595
break
9696
case 4:
9797
obj.observedAddr = reader.bytes()
9898
break
9999
case 3:
100-
obj.protocols = obj.protocols ?? []
101100
obj.protocols.push(reader.string())
102101
break
103102
case 8:
@@ -109,17 +108,6 @@ export namespace Identify {
109108
}
110109
}
111110

112-
obj.listenAddrs = obj.listenAddrs ?? []
113-
obj.protocols = obj.protocols ?? []
114-
115-
if (obj.listenAddrs == null) {
116-
throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf')
117-
}
118-
119-
if (obj.protocols == null) {
120-
throw new Error('Protocol error: value for required field "protocols" was not found in protobuf')
121-
}
122-
123111
return obj
124112
})
125113
}

0 commit comments

Comments
 (0)