Skip to content

Commit

Permalink
deps: update protons to 5.1.0 (#175)
Browse files Browse the repository at this point in the history
Remove some unused deps too.
  • Loading branch information
achingbrain authored Aug 11, 2022
1 parent 5200b95 commit 4c50ec9
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 21 deletions.
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,16 @@
"@libp2p/logger": "^2.0.0",
"@libp2p/peer-id": "^1.1.9",
"cborg": "^1.3.3",
"debug": "^4.2.0",
"err-code": "^3.0.1",
"interface-datastore": "^6.0.2",
"multiformats": "^9.4.5",
"protons-runtime": "^1.0.4",
"protons-runtime": "^3.1.0",
"timestamp-nano": "^1.0.0",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@libp2p/peer-id-factory": "^1.0.9",
"@types/debug": "^4.1.5",
"aegir": "^37.0.11",
"npm-run-all": "^4.1.5",
"protons": "3.0.4",
"rimraf": "^3.0.2",
"util": "^0.12.3"
"protons": "^5.1.0"
}
}
121 changes: 107 additions & 14 deletions src/pb/ipns.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable import/export */
/* eslint-disable @typescript-eslint/no-namespace */

import { enumeration, encodeMessage, decodeMessage, message, bytes, uint64 } from 'protons-runtime'
import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'
import type { Codec } from 'protons-runtime'

export interface IpnsEntry {
Expand All @@ -27,29 +28,121 @@ export namespace IpnsEntry {

export namespace ValidityType {
export const codec = () => {
return enumeration<typeof ValidityType>(__ValidityTypeValues)
return enumeration<ValidityType>(__ValidityTypeValues)
}
}

let _codec: Codec<IpnsEntry>

export const codec = (): Codec<IpnsEntry> => {
return message<IpnsEntry>({
1: { name: 'value', codec: bytes, optional: true },
2: { name: 'signature', codec: bytes, optional: true },
3: { name: 'validityType', codec: IpnsEntry.ValidityType.codec(), optional: true },
4: { name: 'validity', codec: bytes, optional: true },
5: { name: 'sequence', codec: uint64, optional: true },
6: { name: 'ttl', codec: uint64, optional: true },
7: { name: 'pubKey', codec: bytes, optional: true },
8: { name: 'signatureV2', codec: bytes, optional: true },
9: { name: 'data', codec: bytes, optional: true }
})
if (_codec == null) {
_codec = message<IpnsEntry>((obj, writer, opts = {}) => {
if (opts.lengthDelimited !== false) {
writer.fork()
}

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

if (obj.signature != null) {
writer.uint32(18)
writer.bytes(obj.signature)
}

if (obj.validityType != null) {
writer.uint32(24)
IpnsEntry.ValidityType.codec().encode(obj.validityType, writer)
}

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

if (obj.sequence != null) {
writer.uint32(40)
writer.uint64(obj.sequence)
}

if (obj.ttl != null) {
writer.uint32(48)
writer.uint64(obj.ttl)
}

if (obj.pubKey != null) {
writer.uint32(58)
writer.bytes(obj.pubKey)
}

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

if (obj.data != null) {
writer.uint32(74)
writer.bytes(obj.data)
}

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

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

while (reader.pos < end) {
const tag = reader.uint32()

switch (tag >>> 3) {
case 1:
obj.value = reader.bytes()
break
case 2:
obj.signature = reader.bytes()
break
case 3:
obj.validityType = IpnsEntry.ValidityType.codec().decode(reader)
break
case 4:
obj.validity = reader.bytes()
break
case 5:
obj.sequence = reader.uint64()
break
case 6:
obj.ttl = reader.uint64()
break
case 7:
obj.pubKey = reader.bytes()
break
case 8:
obj.signatureV2 = reader.bytes()
break
case 9:
obj.data = reader.bytes()
break
default:
reader.skipType(tag & 7)
break
}
}

return obj
})
}

return _codec
}

export const encode = (obj: IpnsEntry): Uint8Array => {
return encodeMessage(obj, IpnsEntry.codec())
}

export const decode = (buf: Uint8Array): IpnsEntry => {
export const decode = (buf: Uint8Array | Uint8ArrayList): IpnsEntry => {
return decodeMessage(buf, IpnsEntry.codec())
}
}

0 comments on commit 4c50ec9

Please sign in to comment.