Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

deps: bump uint8arrays, protons and multiformats #29

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,19 @@
"it-foreach": "^0.1.1",
"it-map": "^1.0.6",
"it-pipe": "^2.0.3",
"multiformats": "^9.6.3",
"protons-runtime": "^3.1.0",
"multiformats": "^10.0.0",
"protons-runtime": "^4.0.1",
"uint8-varint": "^1.0.2",
"uint8arraylist": "^2.1.0",
"uint8arrays": "^3.0.0",
"uint8arrays": "^4.0.2",
"varint": "^6.0.0"
},
"devDependencies": {
"@libp2p/interface-record-compliance-tests": "^2.0.0",
"@libp2p/peer-id-factory": "^1.0.0",
"@types/varint": "^6.0.0",
"aegir": "^37.3.0",
"protons": "^5.1.0",
"protons": "^6.0.0",
"sinon": "^14.0.0"
}
}
56 changes: 17 additions & 39 deletions src/envelope/envelope.ts
Original file line number Diff line number Diff line change
@@ -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 @@ -17,41 +19,33 @@ export namespace Envelope {

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

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

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

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

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

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {
Expand Down Expand Up @@ -85,22 +79,6 @@ export namespace Envelope {
}
}

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

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

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

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

return obj
})
}
Expand Down
File renamed without changes.
58 changes: 21 additions & 37 deletions src/peer-record/peer-record.ts
Original file line number Diff line number Diff line change
@@ -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 @@ -21,20 +23,18 @@ export namespace PeerRecord {

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

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

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {
Expand All @@ -56,10 +56,6 @@ export namespace PeerRecord {
}
}

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

return obj
})
}
Expand All @@ -80,36 +76,32 @@ export namespace PeerRecord {

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

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

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

if (obj.addresses != null) {
for (const value of obj.addresses) {
writer.uint32(26)
PeerRecord.AddressInfo.codec().encode(value, writer)
w.uint32(26)
PeerRecord.AddressInfo.codec().encode(value, w, {
writeDefaults: true
})
}
} else {
throw new Error('Protocol error: required field "addresses" was not found in object')
}

if (opts.lengthDelimited !== false) {
writer.ldelim()
w.ldelim()
}
}, (reader, length) => {
const obj: any = {
Expand Down Expand Up @@ -139,14 +131,6 @@ export namespace PeerRecord {
}
}

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

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

return obj
})
}
Expand Down
4 changes: 0 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
"include": [
"src",
"test"
],
"exclude": [
"src/envelope/envelope.js",
"src/peer-record/peer-record.js"
]
}