chore: update @waku/react, remove old libp2p dep (#253)
* update @waku/react, remove old libp2p dep * add missing dep * fix prettier
This commit is contained in:
parent
ea2207abf4
commit
ff27ac060b
File diff suppressed because it is too large
Load Diff
|
@ -4,14 +4,13 @@
|
|||
"private": true,
|
||||
"homepage": "/web-chat",
|
||||
"dependencies": {
|
||||
"@libp2p/bootstrap": "^5.0.0",
|
||||
"@livechat/ui-kit": "^0.5.0-24",
|
||||
"@multiformats/multiaddr": "11.0.7",
|
||||
"@waku/react": "^0.0.2",
|
||||
"@waku/sdk": "^0.0.16",
|
||||
"@waku/dns-discovery": "^0.0.14",
|
||||
"@waku/interfaces": "^0.0.15",
|
||||
"@waku/peer-exchange": "^0.0.13",
|
||||
"@waku/dns-discovery": "^0.0.15",
|
||||
"@waku/interfaces": "^0.0.16",
|
||||
"@waku/peer-exchange": "^0.0.14",
|
||||
"@waku/react": "0.0.3-7aeb24a",
|
||||
"@waku/sdk": "^0.0.17",
|
||||
"process": "^0.11.10",
|
||||
"protons-runtime": "^3.1.0",
|
||||
"react": "^17.0.2",
|
||||
|
@ -20,6 +19,7 @@
|
|||
"uint8arraylist": "^2.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@libp2p/interface-peer-store": "^2.0.4",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^17.0.45",
|
||||
"@types/react": "^18.0.25",
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { generate } from "server-name-generator";
|
||||
import { Message } from "./Message";
|
||||
import type {
|
||||
Peer,
|
||||
PeerProtocolsChangeData,
|
||||
} from "@libp2p/interface-peer-store";
|
||||
import type { Peer } from "@libp2p/interface-peer-store";
|
||||
import type { LightNode, StoreQueryOptions, Waku } from "@waku/interfaces";
|
||||
import type { waku } from "@waku/sdk";
|
||||
|
||||
|
@ -70,8 +67,8 @@ export const useNodePeers = (node: undefined | LightNode) => {
|
|||
|
||||
const listener = async (evt: any) => {
|
||||
const { peerId } = evt.detail;
|
||||
const tags = (await node.libp2p.peerStore.getTags(peerId)).map(
|
||||
(t) => t.name
|
||||
const tags = Array.from(
|
||||
(await node.libp2p.peerStore.get(peerId)).tags.keys()
|
||||
);
|
||||
if (tags.includes("peer-exchange")) {
|
||||
setPeerExchangePeers((peers) => new Set(peers).add(peerId.toString()));
|
||||
|
@ -81,9 +78,9 @@ export const useNodePeers = (node: undefined | LightNode) => {
|
|||
};
|
||||
|
||||
// Update store peer when new peer connected & identified
|
||||
node.libp2p.peerStore.addEventListener("change:protocols", listener);
|
||||
node.libp2p.addEventListener("peer:identify", listener);
|
||||
return () => {
|
||||
node.libp2p.peerStore.removeEventListener("change:protocols", listener);
|
||||
node.libp2p.removeEventListener("peer:identify", listener);
|
||||
};
|
||||
}, [node]);
|
||||
|
||||
|
@ -128,7 +125,7 @@ export const usePeers = (params: UsePeersParams): UsePeersResults => {
|
|||
return;
|
||||
}
|
||||
|
||||
const listener = async (_event?: CustomEvent<PeerProtocolsChangeData>) => {
|
||||
const listener = async (_event?: any) => {
|
||||
const peers = await Promise.all([
|
||||
handleCatch(node?.store?.peers()),
|
||||
handleCatch(node?.filter?.peers()),
|
||||
|
@ -143,9 +140,9 @@ export const usePeers = (params: UsePeersParams): UsePeersResults => {
|
|||
};
|
||||
|
||||
listener(); // populate peers before event is invoked
|
||||
node.libp2p.peerStore.addEventListener("change:protocols", listener);
|
||||
node.libp2p.addEventListener("peer:identify", listener);
|
||||
return () => {
|
||||
node.libp2p.peerStore.removeEventListener("change:protocols", listener);
|
||||
node.libp2p.removeEventListener("peer:identify", listener);
|
||||
};
|
||||
}, [node, setPeers]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue