@libp2p/interop 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,8 @@
5
5
  /* eslint-disable @typescript-eslint/no-empty-interface */
6
6
 
7
7
  import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
8
- import type { Uint8ArrayList } from 'uint8arraylist'
9
8
  import type { Codec } from 'protons-runtime'
9
+ import type { Uint8ArrayList } from 'uint8arraylist'
10
10
 
11
11
  export interface HopMessage {
12
12
  type?: HopMessage.Type
@@ -51,23 +51,17 @@ export namespace HopMessage {
51
51
 
52
52
  if (obj.peer != null) {
53
53
  w.uint32(18)
54
- Peer.codec().encode(obj.peer, w, {
55
- writeDefaults: false
56
- })
54
+ Peer.codec().encode(obj.peer, w)
57
55
  }
58
56
 
59
57
  if (obj.reservation != null) {
60
58
  w.uint32(26)
61
- Reservation.codec().encode(obj.reservation, w, {
62
- writeDefaults: false
63
- })
59
+ Reservation.codec().encode(obj.reservation, w)
64
60
  }
65
61
 
66
62
  if (obj.limit != null) {
67
63
  w.uint32(34)
68
- Limit.codec().encode(obj.limit, w, {
69
- writeDefaults: false
70
- })
64
+ Limit.codec().encode(obj.limit, w)
71
65
  }
72
66
 
73
67
  if (obj.status != null) {
@@ -115,7 +109,7 @@ export namespace HopMessage {
115
109
  return _codec
116
110
  }
117
111
 
118
- export const encode = (obj: HopMessage): Uint8Array => {
112
+ export const encode = (obj: Partial<HopMessage>): Uint8Array => {
119
113
  return encodeMessage(obj, HopMessage.codec())
120
114
  }
121
115
 
@@ -164,16 +158,12 @@ export namespace StopMessage {
164
158
 
165
159
  if (obj.peer != null) {
166
160
  w.uint32(18)
167
- Peer.codec().encode(obj.peer, w, {
168
- writeDefaults: false
169
- })
161
+ Peer.codec().encode(obj.peer, w)
170
162
  }
171
163
 
172
164
  if (obj.limit != null) {
173
165
  w.uint32(26)
174
- Limit.codec().encode(obj.limit, w, {
175
- writeDefaults: false
176
- })
166
+ Limit.codec().encode(obj.limit, w)
177
167
  }
178
168
 
179
169
  if (obj.status != null) {
@@ -218,7 +208,7 @@ export namespace StopMessage {
218
208
  return _codec
219
209
  }
220
210
 
221
- export const encode = (obj: StopMessage): Uint8Array => {
211
+ export const encode = (obj: Partial<StopMessage>): Uint8Array => {
222
212
  return encodeMessage(obj, StopMessage.codec())
223
213
  }
224
214
 
@@ -242,7 +232,7 @@ export namespace Peer {
242
232
  w.fork()
243
233
  }
244
234
 
245
- if (opts.writeDefaults === true || (obj.id != null && obj.id.byteLength > 0)) {
235
+ if ((obj.id != null && obj.id.byteLength > 0)) {
246
236
  w.uint32(10)
247
237
  w.bytes(obj.id)
248
238
  }
@@ -288,7 +278,7 @@ export namespace Peer {
288
278
  return _codec
289
279
  }
290
280
 
291
- export const encode = (obj: Peer): Uint8Array => {
281
+ export const encode = (obj: Partial<Peer>): Uint8Array => {
292
282
  return encodeMessage(obj, Peer.codec())
293
283
  }
294
284
 
@@ -313,7 +303,7 @@ export namespace Reservation {
313
303
  w.fork()
314
304
  }
315
305
 
316
- if (opts.writeDefaults === true || obj.expire !== 0n) {
306
+ if ((obj.expire != null && obj.expire !== 0n)) {
317
307
  w.uint32(8)
318
308
  w.uint64(obj.expire)
319
309
  }
@@ -367,7 +357,7 @@ export namespace Reservation {
367
357
  return _codec
368
358
  }
369
359
 
370
- export const encode = (obj: Reservation): Uint8Array => {
360
+ export const encode = (obj: Partial<Reservation>): Uint8Array => {
371
361
  return encodeMessage(obj, Reservation.codec())
372
362
  }
373
363
 
@@ -432,7 +422,7 @@ export namespace Limit {
432
422
  return _codec
433
423
  }
434
424
 
435
- export const encode = (obj: Limit): Uint8Array => {
425
+ export const encode = (obj: Partial<Limit>): Uint8Array => {
436
426
  return encodeMessage(obj, Limit.codec())
437
427
  }
438
428
 
@@ -486,17 +476,17 @@ export namespace ReservationVoucher {
486
476
  w.fork()
487
477
  }
488
478
 
489
- if (opts.writeDefaults === true || (obj.relay != null && obj.relay.byteLength > 0)) {
479
+ if ((obj.relay != null && obj.relay.byteLength > 0)) {
490
480
  w.uint32(10)
491
481
  w.bytes(obj.relay)
492
482
  }
493
483
 
494
- if (opts.writeDefaults === true || (obj.peer != null && obj.peer.byteLength > 0)) {
484
+ if ((obj.peer != null && obj.peer.byteLength > 0)) {
495
485
  w.uint32(18)
496
486
  w.bytes(obj.peer)
497
487
  }
498
488
 
499
- if (opts.writeDefaults === true || obj.expiration !== 0n) {
489
+ if ((obj.expiration != null && obj.expiration !== 0n)) {
500
490
  w.uint32(24)
501
491
  w.uint64(obj.expiration)
502
492
  }
@@ -539,7 +529,7 @@ export namespace ReservationVoucher {
539
529
  return _codec
540
530
  }
541
531
 
542
- export const encode = (obj: ReservationVoucher): Uint8Array => {
532
+ export const encode = (obj: Partial<ReservationVoucher>): Uint8Array => {
543
533
  return encodeMessage(obj, ReservationVoucher.codec())
544
534
  }
545
535