diff --git a/packages/interop/package.json b/packages/interop/package.json index bb898f02..d13a4f44 100644 --- a/packages/interop/package.json +++ b/packages/interop/package.json @@ -69,7 +69,6 @@ "@helia/mfs": "^3.0.8", "@helia/routers": "^1.1.1", "@helia/strings": "^3.0.6", - "@helia/utils": "^0.3.3", "@helia/unixfs": "^3.0.7", "@ipld/car": "^5.3.0", "@ipld/dag-cbor": "^9.2.0", diff --git a/packages/interop/src/ipns-pubsub.spec.ts b/packages/interop/src/ipns-pubsub.spec.ts index bcbdbd42..43e7c9e4 100644 --- a/packages/interop/src/ipns-pubsub.spec.ts +++ b/packages/interop/src/ipns-pubsub.spec.ts @@ -4,7 +4,6 @@ import { gossipsub } from '@chainsafe/libp2p-gossipsub' import { ipns } from '@helia/ipns' import { pubsub } from '@helia/ipns/routing' -import { hasCode } from '@helia/utils' import { generateKeyPair } from '@libp2p/crypto/keys' import { peerIdFromCID } from '@libp2p/peer-id' import { expect } from 'aegir/chai' @@ -12,6 +11,8 @@ import last from 'it-last' import { base36 } from 'multiformats/bases/base36' import { CID } from 'multiformats/cid' import * as raw from 'multiformats/codecs/raw' +import { hasCode } from 'multiformats/hashes/digest' +import { identity } from 'multiformats/hashes/identity' import { sha256 } from 'multiformats/hashes/sha2' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' @@ -129,7 +130,7 @@ keyTypes.filter(keyType => keyType !== 'RSA').forEach(keyType => { const peerCid = CID.parse(result.id, base36) const peerId = peerIdFromCID(peerCid) - if (!hasCode(peerCid.multihash, 0)) { + if (!hasCode(peerCid.multihash, identity.code)) { throw new Error('Incorrect hash type') } diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index b48d5733..79d69cbf 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -38,7 +38,7 @@ import type { Blockstore } from 'interface-blockstore' import type { Datastore } from 'interface-datastore' import type { BlockCodec } from 'multiformats' import type { CID } from 'multiformats/cid' -import type { MultihashDigest, MultihashHasher } from 'multiformats/hashes/interface' +import type { MultihashHasher } from 'multiformats/hashes/interface' export { AbstractSession, type AbstractCreateSessionOptions } from './abstract-session.js' export { BloomFilter } from './bloom-filter.js' @@ -280,12 +280,3 @@ export class Helia implements HeliaInterface { this.log('gc finished') } } - -/** - * Used to check that the passed multihash has the passed code - * - * Remove after https://github.com/multiformats/js-multiformats/pull/308 - */ -export function hasCode (digest: MultihashDigest, code: T): digest is MultihashDigest { - return digest.code === code -}