From 4322c1e8462cb3dde16435efc23303923bbc7d86 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Sat, 12 Feb 2022 07:49:23 +0200 Subject: [PATCH] fix: update to latest interfaces (#114) --- src/compat/querier.ts | 5 +++-- src/query.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compat/querier.ts b/src/compat/querier.ts index f443ebe..ebaef73 100644 --- a/src/compat/querier.ts +++ b/src/compat/querier.ts @@ -1,10 +1,11 @@ import { EventEmitter } from '@libp2p/interfaces' import MDNS from 'multicast-dns' import { Multiaddr } from '@multiformats/multiaddr' -import { PeerId } from '@libp2p/peer-id' +import type { PeerId } from '@libp2p/interfaces/peer-id' import { logger } from '@libp2p/logger' import { SERVICE_TAG_LOCAL, MULTICAST_IP, MULTICAST_PORT } from './constants.js' import { base58btc } from 'multiformats/bases/base58' +import { peerIdFromString } from '@libp2p/peer-id' import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery' import type { ResponsePacket } from 'multicast-dns' import type { RemoteInfo } from 'dgram' @@ -114,7 +115,7 @@ export class Querier extends EventEmitter implements PeerDi let peerId try { - peerId = PeerId.fromString(peerIdStr) + peerId = peerIdFromString(peerIdStr) } catch (err) { return log('failed to create peer ID from TXT record data', peerIdStr, err) } diff --git a/src/query.ts b/src/query.ts index 6f5de39..b5ef4d4 100644 --- a/src/query.ts +++ b/src/query.ts @@ -2,7 +2,8 @@ import os from 'os' import { logger } from '@libp2p/logger' import { Multiaddr, MultiaddrObject } from '@multiformats/multiaddr' import { base58btc } from 'multiformats/bases/base58' -import { PeerId } from '@libp2p/peer-id' +import { peerIdFromString } from '@libp2p/peer-id' +import type { PeerId } from '@libp2p/interfaces/peer-id' import type { PeerData } from '@libp2p/interfaces/peer-data' import type { MulticastDNS, ResponsePacket, QueryPacket } from 'multicast-dns' import type { SrvAnswer, StringAnswer, TxtAnswer, Answer } from 'dns-packet' @@ -88,7 +89,7 @@ export function gotResponse (rsp: ResponsePacket, localPeerId: PeerId, serviceTa log('peer found -', b58Id) return { - id: PeerId.fromString(b58Id), + id: peerIdFromString(b58Id), multiaddrs, protocols: [] }