diff --git a/package.json b/package.json index 5d94ded59a..4339458222 100644 --- a/package.json +++ b/package.json @@ -161,7 +161,7 @@ "it-map": "^2.0.0", "it-pipe": "^2.0.3", "multiformats": "^11.0.0", - "protons-runtime": "^4.0.1", + "protons-runtime": "^5.0.0", "uint8-varint": "^1.0.2", "uint8arraylist": "^2.1.0", "uint8arrays": "^4.0.2", @@ -172,7 +172,7 @@ "@libp2p/peer-id-factory": "^2.0.0", "@types/varint": "^6.0.0", "aegir": "^38.1.2", - "protons": "^6.0.0", + "protons": "^7.0.2", "sinon": "^15.0.0" } } diff --git a/src/envelope/envelope.ts b/src/envelope/envelope.ts index fdd22ad0e8..5a5d6e640a 100644 --- a/src/envelope/envelope.ts +++ b/src/envelope/envelope.ts @@ -2,10 +2,11 @@ /* eslint-disable complexity */ /* eslint-disable @typescript-eslint/no-namespace */ /* 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 { Uint8ArrayList } from 'uint8arraylist' import type { Codec } from 'protons-runtime' +import type { Uint8ArrayList } from 'uint8arraylist' export interface Envelope { publicKey: Uint8Array @@ -24,22 +25,22 @@ export namespace Envelope { w.fork() } - if (opts.writeDefaults === true || (obj.publicKey != null && obj.publicKey.byteLength > 0)) { + if ((obj.publicKey != null && obj.publicKey.byteLength > 0)) { w.uint32(10) w.bytes(obj.publicKey) } - if (opts.writeDefaults === true || (obj.payloadType != null && obj.payloadType.byteLength > 0)) { + if ((obj.payloadType != null && obj.payloadType.byteLength > 0)) { w.uint32(18) w.bytes(obj.payloadType) } - if (opts.writeDefaults === true || (obj.payload != null && obj.payload.byteLength > 0)) { + if ((obj.payload != null && obj.payload.byteLength > 0)) { w.uint32(26) w.bytes(obj.payload) } - if (opts.writeDefaults === true || (obj.signature != null && obj.signature.byteLength > 0)) { + if ((obj.signature != null && obj.signature.byteLength > 0)) { w.uint32(42) w.bytes(obj.signature) } @@ -86,7 +87,7 @@ export namespace Envelope { return _codec } - export const encode = (obj: Envelope): Uint8Array => { + export const encode = (obj: Partial): Uint8Array => { return encodeMessage(obj, Envelope.codec()) } diff --git a/src/peer-record/peer-record.ts b/src/peer-record/peer-record.ts index 5ff83fe2ad..0e3e9814fa 100644 --- a/src/peer-record/peer-record.ts +++ b/src/peer-record/peer-record.ts @@ -2,10 +2,11 @@ /* eslint-disable complexity */ /* eslint-disable @typescript-eslint/no-namespace */ /* 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 { Uint8ArrayList } from 'uint8arraylist' import type { Codec } from 'protons-runtime' +import type { Uint8ArrayList } from 'uint8arraylist' export interface PeerRecord { peerId: Uint8Array @@ -28,7 +29,7 @@ export namespace PeerRecord { w.fork() } - if (opts.writeDefaults === true || (obj.multiaddr != null && obj.multiaddr.byteLength > 0)) { + if ((obj.multiaddr != null && obj.multiaddr.byteLength > 0)) { w.uint32(10) w.bytes(obj.multiaddr) } @@ -63,7 +64,7 @@ export namespace PeerRecord { return _codec } - export const encode = (obj: AddressInfo): Uint8Array => { + export const encode = (obj: Partial): Uint8Array => { return encodeMessage(obj, AddressInfo.codec()) } @@ -81,12 +82,12 @@ export namespace PeerRecord { w.fork() } - if (opts.writeDefaults === true || (obj.peerId != null && obj.peerId.byteLength > 0)) { + if ((obj.peerId != null && obj.peerId.byteLength > 0)) { w.uint32(10) w.bytes(obj.peerId) } - if (opts.writeDefaults === true || obj.seq !== 0n) { + if ((obj.seq != null && obj.seq !== 0n)) { w.uint32(16) w.uint64(obj.seq) } @@ -94,9 +95,7 @@ export namespace PeerRecord { if (obj.addresses != null) { for (const value of obj.addresses) { w.uint32(26) - PeerRecord.AddressInfo.codec().encode(value, w, { - writeDefaults: true - }) + PeerRecord.AddressInfo.codec().encode(value, w) } } @@ -138,7 +137,7 @@ export namespace PeerRecord { return _codec } - export const encode = (obj: PeerRecord): Uint8Array => { + export const encode = (obj: Partial): Uint8Array => { return encodeMessage(obj, PeerRecord.codec()) }