From b76d07f07e7de5f65bd00a3c3c4a106fcca99f57 Mon Sep 17 00:00:00 2001 From: tabcat Date: Fri, 13 Jan 2023 13:57:09 -0600 Subject: [PATCH] chore: replace err-code with CodeError (#42) Replaces [err-code](https://github.com/IndigoUnited/js-err-code/blob/master/index.js) with [CodeError](https://github.com/libp2p/js-libp2p-interfaces/pull/314) Related: [js-libp2p#1269](https://github.com/libp2p/js-libp2p/issues/1269) Changes - removes err-code from dependencies - adds @libp2p/interfaces@3.2.0 to dependencies - uses CodeError in place of err-code --- package.json | 2 +- src/envelope/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0cbfa4bd4a..bfad34aa74 100644 --- a/package.json +++ b/package.json @@ -149,11 +149,11 @@ "@libp2p/crypto": "^1.0.11", "@libp2p/interface-peer-id": "^2.0.0", "@libp2p/interface-record": "^2.0.1", + "@libp2p/interfaces": "^3.2.0", "@libp2p/logger": "^2.0.5", "@libp2p/peer-id": "^2.0.0", "@libp2p/utils": "^3.0.0", "@multiformats/multiaddr": "^11.0.0", - "err-code": "^3.0.1", "interface-datastore": "^7.0.0", "it-all": "^2.0.0", "it-filter": "^2.0.0", diff --git a/src/envelope/index.ts b/src/envelope/index.ts index ffa6051b1a..630f86b314 100644 --- a/src/envelope/index.ts +++ b/src/envelope/index.ts @@ -1,4 +1,4 @@ -import errCode from 'err-code' +import { CodeError } from '@libp2p/interfaces/errors' import { fromString as uint8arraysFromString } from 'uint8arrays/from-string' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { unmarshalPrivateKey, unmarshalPublicKey } from '@libp2p/crypto/keys' @@ -66,7 +66,7 @@ export class RecordEnvelope implements Envelope { const valid = await envelope.validate(domain) if (!valid) { - throw errCode(new Error('envelope signature is not valid for the given domain'), codes.ERR_SIGNATURE_NOT_VALID) + throw new CodeError('envelope signature is not valid for the given domain', codes.ERR_SIGNATURE_NOT_VALID) } return envelope