diff --git a/examples/web-chat/src/command.ts b/examples/web-chat/src/command.ts index c1e5b98823..cd7b1beb41 100644 --- a/examples/web-chat/src/command.ts +++ b/examples/web-chat/src/command.ts @@ -26,7 +26,7 @@ function info(waku: Waku | undefined): string[] { if (!waku) { return ["Waku node is starting"]; } - return [`PeerId: ${waku.libp2p.peerId.toB58String()}`]; + return [`PeerId: ${waku.libp2p.peerId.toString()}`]; } function connect(peer: string | undefined, waku: Waku | undefined): string[] { @@ -64,7 +64,7 @@ async function peers(waku: Waku | undefined): Promise { peers.push(peer); } Array.from(peers).forEach((peer) => { - response.push(peer.id.toB58String() + ":"); + response.push(peer.id.toString() + ":"); let addresses = " addresses: ["; peer.addresses.forEach(({ multiaddr }) => { addresses += " " + multiaddr.toString() + ","; diff --git a/src/lib/discovery/dns.spec.ts b/src/lib/discovery/dns.spec.ts index 2db676f514..93c28cf10b 100644 --- a/src/lib/discovery/dns.spec.ts +++ b/src/lib/discovery/dns.spec.ts @@ -171,7 +171,7 @@ describe("DNS Node Discovery w/ capabilities", () => { }); expect(peers.length).to.eq(1); - expect(peers[0].peerId?.toB58String()).to.eq( + expect(peers[0].peerId?.toString()).to.eq( "16Uiu2HAmPsYLvfKafxgRsb6tioYyGnSvGXS2iuMigptHrqHPNPzx" ); }); @@ -186,7 +186,7 @@ describe("DNS Node Discovery w/ capabilities", () => { }); expect(peers.length).to.eq(1); - expect(peers[0].peerId?.toB58String()).to.eq( + expect(peers[0].peerId?.toString()).to.eq( "16Uiu2HAm2HyS6brcCspSbszG9i36re2bWBVjMe3tMdnFp1Hua34F" ); }); @@ -200,7 +200,7 @@ describe("DNS Node Discovery w/ capabilities", () => { }); expect(peers.length).to.eq(1); - expect(peers[0].peerId?.toB58String()).to.eq( + expect(peers[0].peerId?.toString()).to.eq( "16Uiu2HAkv3La3ECgQpdYeEJfrX36EWdhkUDv4C9wvXM8TFZ9dNgd" ); }); @@ -220,7 +220,7 @@ describe("DNS Node Discovery w/ capabilities", () => { }); expect(peers.length).to.eq(2); - const peerIds = peers.map((p) => p.peerId?.toB58String()); + const peerIds = peers.map((p) => p.peerId?.toString()); expect(peerIds).to.contain( "16Uiu2HAm2HyS6brcCspSbszG9i36re2bWBVjMe3tMdnFp1Hua34F" ); @@ -246,7 +246,7 @@ describe("DNS Node Discovery w/ capabilities", () => { }); expect(peers.length).to.eq(3); - const peerIds = peers.map((p) => p.peerId?.toB58String()); + const peerIds = peers.map((p) => p.peerId?.toString()); expect(peerIds).to.contain( "16Uiu2HAm2HyS6brcCspSbszG9i36re2bWBVjMe3tMdnFp1Hua34F" ); diff --git a/src/lib/discovery/fetch_nodes.spec.ts b/src/lib/discovery/fetch_nodes.spec.ts index c6040332a9..91adb96915 100644 --- a/src/lib/discovery/fetch_nodes.spec.ts +++ b/src/lib/discovery/fetch_nodes.spec.ts @@ -42,7 +42,7 @@ describe("Fetch nodes until capabilities are fulfilled", function () { ); expect(res.length).to.eq(1); - expect(res[0].peerId!.toB58String()).to.eq(relayNode.peerId?.toB58String()); + expect(res[0].peerId!.toString()).to.eq(relayNode.peerId?.toString()); }); it("1 Store, 2 fetches", async function () { @@ -65,7 +65,7 @@ describe("Fetch nodes until capabilities are fulfilled", function () { ); expect(res.length).to.eq(1); - expect(res[0].peerId!.toB58String()).to.eq(storeNode.peerId?.toB58String()); + expect(res[0].peerId!.toString()).to.eq(storeNode.peerId?.toString()); }); it("1 Store, 2 relays, 2 fetches", async function () { @@ -94,15 +94,9 @@ describe("Fetch nodes until capabilities are fulfilled", function () { ); expect(res.length).to.eq(3); - expect(res[0].peerId!.toB58String()).to.eq( - relayNode1.peerId?.toB58String() - ); - expect(res[1].peerId!.toB58String()).to.eq( - relayNode2.peerId?.toB58String() - ); - expect(res[2].peerId!.toB58String()).to.eq( - relayStoreNode.peerId?.toB58String() - ); + expect(res[0].peerId!.toString()).to.eq(relayNode1.peerId?.toString()); + expect(res[1].peerId!.toString()).to.eq(relayNode2.peerId?.toString()); + expect(res[2].peerId!.toString()).to.eq(relayStoreNode.peerId?.toString()); }); it("1 Relay, 1 Filter, gives up", async function () { @@ -117,6 +111,6 @@ describe("Fetch nodes until capabilities are fulfilled", function () { ); expect(res.length).to.eq(1); - expect(res[0].peerId!.toB58String()).to.eq(relayNode.peerId?.toB58String()); + expect(res[0].peerId!.toString()).to.eq(relayNode.peerId?.toString()); }); }); diff --git a/src/lib/enr/enr.node.spec.ts b/src/lib/enr/enr.node.spec.ts index b918fa22da..db1b43f94e 100644 --- a/src/lib/enr/enr.node.spec.ts +++ b/src/lib/enr/enr.node.spec.ts @@ -36,7 +36,7 @@ describe("ENR Interop: nwaku", function () { expect(nwakuInfo.enrUri).to.not.be.undefined; const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? ""); - expect(dec.peerId?.toB58String()).to.eq(nimPeerId.toB58String()); + expect(dec.peerId?.toString()).to.eq(nimPeerId.toString()); expect(dec.waku2).to.deep.eq({ relay: true, store: false, @@ -67,7 +67,7 @@ describe("ENR Interop: nwaku", function () { expect(nwakuInfo.enrUri).to.not.be.undefined; const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? ""); - expect(dec.peerId?.toB58String()).to.eq(nimPeerId.toB58String()); + expect(dec.peerId?.toString()).to.eq(nimPeerId.toString()); expect(dec.waku2).to.deep.eq({ relay: true, store: true, @@ -98,7 +98,7 @@ describe("ENR Interop: nwaku", function () { expect(nwakuInfo.enrUri).to.not.be.undefined; const dec = await ENR.decodeTxt(nwakuInfo.enrUri ?? ""); - expect(dec.peerId?.toB58String()).to.eq(nimPeerId.toB58String()); + expect(dec.peerId?.toString()).to.eq(nimPeerId.toString()); expect(dec.waku2).to.deep.eq({ relay: true, store: true, diff --git a/src/lib/enr/enr.spec.ts b/src/lib/enr/enr.spec.ts index c4ec51b474..c1775cdf13 100644 --- a/src/lib/enr/enr.spec.ts +++ b/src/lib/enr/enr.spec.ts @@ -102,7 +102,7 @@ describe("ENR", function () { expect(enr.ip).to.not.be.undefined; expect(enr.ip).to.be.equal("134.209.139.210"); expect(enr.publicKey).to.not.be.undefined; - expect(enr.peerId?.toB58String()).to.be.equal( + expect(enr.peerId?.toString()).to.be.equal( "16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ" ); }); diff --git a/src/lib/enr/enr.ts b/src/lib/enr/enr.ts index 519c4dbcd3..5e7e308405 100644 --- a/src/lib/enr/enr.ts +++ b/src/lib/enr/enr.ts @@ -422,9 +422,7 @@ export class ENR extends Map { if (this.peerId) { const locationMultiaddr = this.getLocationMultiaddr(protocol); if (locationMultiaddr) { - return locationMultiaddr.encapsulate( - `/p2p/${this.peerId.toB58String()}` - ); + return locationMultiaddr.encapsulate(`/p2p/${this.peerId.toString()}`); } } return; @@ -437,7 +435,7 @@ export class ENR extends Map { if (this.peerId && this.multiaddrs) { const peerId = this.peerId; return this.multiaddrs.map((ma) => { - return ma.encapsulate(`/p2p/${peerId.toB58String()}`); + return ma.encapsulate(`/p2p/${peerId.toString()}`); }); } return []; diff --git a/src/lib/waku.node.spec.ts b/src/lib/waku.node.spec.ts index 134235dc0e..ef0ec9afbd 100644 --- a/src/lib/waku.node.spec.ts +++ b/src/lib/waku.node.spec.ts @@ -69,7 +69,7 @@ describe("Waku Dial [node only]", function () { }); }); - expect(connectedPeerID.toB58String()).to.eq(multiAddrWithId.getPeerId()); + expect(connectedPeerID.toString()).to.eq(multiAddrWithId.getPeerId()); }); it("Passing a function", async function () { @@ -94,7 +94,7 @@ describe("Waku Dial [node only]", function () { }); const multiAddrWithId = await nwaku.getMultiaddrWithId(); - expect(connectedPeerID.toB58String()).to.eq(multiAddrWithId.getPeerId()); + expect(connectedPeerID.toString()).to.eq(multiAddrWithId.getPeerId()); }); }); }); @@ -249,7 +249,7 @@ describe("Wait for remote peer / get peers", function () { const peers = []; for await (const peer of waku.store.peers) { - peers.push(peer.id.toB58String()); + peers.push(peer.id.toString()); } const nimPeerId = multiAddrWithId.getPeerId(); @@ -274,7 +274,7 @@ describe("Wait for remote peer / get peers", function () { const peers = []; for await (const peer of waku.store.peers) { - peers.push(peer.id.toB58String()); + peers.push(peer.id.toString()); } const nimPeerId = multiAddrWithId.getPeerId(); @@ -297,7 +297,7 @@ describe("Wait for remote peer / get peers", function () { const peers = []; for await (const peer of waku.lightPush.peers) { - peers.push(peer.id.toB58String()); + peers.push(peer.id.toString()); } const nimPeerId = multiAddrWithId.getPeerId(); @@ -320,7 +320,7 @@ describe("Wait for remote peer / get peers", function () { const peers = []; for await (const peer of waku.filter.peers) { - peers.push(peer.id.toB58String()); + peers.push(peer.id.toString()); } const nimPeerId = multiAddrWithId.getPeerId(); diff --git a/src/lib/waku.ts b/src/lib/waku.ts index fd1e09493e..21c465fb1e 100644 --- a/src/lib/waku.ts +++ b/src/lib/waku.ts @@ -346,7 +346,7 @@ export class Waku { if (!localMultiaddr || localMultiaddr.toString() === "") { throw "Not listening on localhost"; } - return localMultiaddr + "/p2p/" + this.libp2p.peerId.toB58String(); + return localMultiaddr + "/p2p/" + this.libp2p.peerId.toString(); } /** @@ -388,7 +388,7 @@ export class Waku { if (protocols.includes(Protocols.Store)) { const storePromise = (async (): Promise => { for await (const peer of this.store.peers) { - dbg("Store peer found", peer.id.toB58String()); + dbg("Store peer found", peer.id.toString()); break; } })(); @@ -398,7 +398,7 @@ export class Waku { if (protocols.includes(Protocols.LightPush)) { const lightPushPromise = (async (): Promise => { for await (const peer of this.lightPush.peers) { - dbg("Light Push peer found", peer.id.toB58String()); + dbg("Light Push peer found", peer.id.toString()); break; } })(); @@ -408,7 +408,7 @@ export class Waku { if (protocols.includes(Protocols.Filter)) { const filterPromise = (async (): Promise => { for await (const peer of this.filter.peers) { - dbg("Filter peer found", peer.id.toB58String()); + dbg("Filter peer found", peer.id.toString()); break; } })(); @@ -434,7 +434,7 @@ export class Waku { // Just in case a timer already exist for this peer this.stopKeepAlive(peerId); - const peerIdStr = peerId.toB58String(); + const peerIdStr = peerId.toString(); if (pingPeriodSecs !== 0) { const pingService = new PingService(this.libp2p); @@ -455,7 +455,7 @@ export class Waku { } private stopKeepAlive(peerId: PeerId): void { - const peerIdStr = peerId.toB58String(); + const peerIdStr = peerId.toString(); if (this.pingKeepAliveTimers[peerIdStr]) { clearInterval(this.pingKeepAliveTimers[peerIdStr]); diff --git a/src/lib/waku_filter/index.ts b/src/lib/waku_filter/index.ts index a2f12933d5..f176a249dd 100644 --- a/src/lib/waku_filter/index.ts +++ b/src/lib/waku_filter/index.ts @@ -87,7 +87,7 @@ export class WakuFilter { } catch (e) { log( "Error subscribing to peer ", - peer.id.toB58String(), + peer.id.toString(), "for content topics", contentTopics, ": ", @@ -200,7 +200,7 @@ export class WakuFilter { peer = await this.libp2p.peerStore.get(peerId); if (!peer) { throw new Error( - `Failed to retrieve connection details for provided peer in peer store: ${peerId.toB58String()}` + `Failed to retrieve connection details for provided peer in peer store: ${peerId.toString()}` ); } } else { diff --git a/src/lib/waku_relay/index.node.spec.ts b/src/lib/waku_relay/index.node.spec.ts index 764de39cb2..73ffee624b 100644 --- a/src/lib/waku_relay/index.node.spec.ts +++ b/src/lib/waku_relay/index.node.spec.ts @@ -70,8 +70,8 @@ describe("Waku Relay [node only]", () => { waku2.libp2p.pubsub.getSubscribers(DefaultPubSubTopic); log("Asserting mutual subscription"); - expect(subscribers1).to.contain(waku2.libp2p.peerId.toB58String()); - expect(subscribers2).to.contain(waku1.libp2p.peerId.toB58String()); + expect(subscribers1).to.contain(waku2.libp2p.peerId.toString()); + expect(subscribers2).to.contain(waku1.libp2p.peerId.toString()); }); it("Register correct protocols", async function () { @@ -338,7 +338,7 @@ describe("Waku Relay [node only]", () => { } const nimPeerId = await nwaku.getPeerId(); - expect(subscribers).to.contain(nimPeerId.toB58String()); + expect(subscribers).to.contain(nimPeerId.toString()); }); it("Publishes to nwaku", async function () { diff --git a/src/lib/waku_relay/index.ts b/src/lib/waku_relay/index.ts index 1011088903..239b9142fe 100644 --- a/src/lib/waku_relay/index.ts +++ b/src/lib/waku_relay/index.ts @@ -326,7 +326,7 @@ export class WakuRelay extends Gossipsub { */ async _publish(msg: InMessage): Promise { const msgIdStr = await this.getCanonicalMsgIdStr(msg); - if (msg.receivedFrom !== this.peerId.toB58String()) { + if (msg.receivedFrom !== this.peerId.toString()) { this.score.deliverMessage(msg, msgIdStr); this.gossipTracer.deliverMessage(msgIdStr); } diff --git a/src/lib/waku_store/index.ts b/src/lib/waku_store/index.ts index 3cad6bb492..8a0b59b43c 100644 --- a/src/lib/waku_store/index.ts +++ b/src/lib/waku_store/index.ts @@ -146,7 +146,7 @@ export class WakuStore { ); dbg("Querying history with the following options", { - peerId: options?.peerId?.toB58String(), + peerId: options?.peerId?.toString(), ...options, }); @@ -154,7 +154,7 @@ export class WakuStore { if (opts.peerId) { peer = await this.libp2p.peerStore.get(opts.peerId); if (!peer) - throw `Failed to retrieve connection details for provided peer in peer store: ${opts.peerId.toB58String()}`; + throw `Failed to retrieve connection details for provided peer in peer store: ${opts.peerId.toString()}`; } else { peer = await this.randomPeer; if (!peer) @@ -170,7 +170,7 @@ export class WakuStore { } dbg(`Use store codec ${storeCodec}`); if (!storeCodec) - throw `Peer does not register waku store protocol: ${peer.id.toB58String()}`; + throw `Peer does not register waku store protocol: ${peer.id.toString()}`; Object.assign(opts, { storeCodec }); const connection = this.libp2p.connectionManager.get(peer.id);