mirror of https://github.com/waku-org/js-waku.git
No need for a wallet to send messages
This commit is contained in:
parent
a1218c1223
commit
6038007d40
|
@ -76,13 +76,6 @@ function App() {
|
||||||
);
|
);
|
||||||
const [messages, setMessages] = useState<Message[]>([]);
|
const [messages, setMessages] = useState<Message[]>([]);
|
||||||
const [address, setAddress] = useState<string>();
|
const [address, setAddress] = useState<string>();
|
||||||
const [peerStats, setPeerStats] = useState<{
|
|
||||||
relayPeers: number;
|
|
||||||
lightPushPeers: number;
|
|
||||||
}>({
|
|
||||||
relayPeers: 0,
|
|
||||||
lightPushPeers: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
@ -101,7 +94,6 @@ function App() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!waku) return;
|
if (!waku) return;
|
||||||
if (!address) return;
|
|
||||||
|
|
||||||
const observerPublicKeyMessage = handlePublicKeyMessage.bind(
|
const observerPublicKeyMessage = handlePublicKeyMessage.bind(
|
||||||
{},
|
{},
|
||||||
|
@ -155,17 +147,12 @@ function App() {
|
||||||
};
|
};
|
||||||
}, [waku, address, EncryptionKeyPair]);
|
}, [waku, address, EncryptionKeyPair]);
|
||||||
|
|
||||||
useEffect(() => {
|
let relayPeers = 0;
|
||||||
if (!waku) return;
|
let lightPushPeers = 0;
|
||||||
|
if (waku) {
|
||||||
const interval = setInterval(() => {
|
relayPeers = waku.relay.getPeers().size;
|
||||||
setPeerStats({
|
lightPushPeers = waku.lightPush.peers.length;
|
||||||
relayPeers: waku.relay.getPeers().size,
|
}
|
||||||
lightPushPeers: waku.lightPush.peers.length,
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, [waku]);
|
|
||||||
|
|
||||||
let addressDisplay = '';
|
let addressDisplay = '';
|
||||||
if (address) {
|
if (address) {
|
||||||
|
@ -189,8 +176,7 @@ function App() {
|
||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography className={classes.peers} aria-label="connected-peers">
|
<Typography className={classes.peers} aria-label="connected-peers">
|
||||||
Peers: {peerStats.relayPeers} relay, {peerStats.lightPushPeers}{' '}
|
Peers: {relayPeers} relay, {lightPushPeers} light push
|
||||||
light push
|
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="h6" className={classes.title}>
|
<Typography variant="h6" className={classes.title}>
|
||||||
Ethereum Direct Message
|
Ethereum Direct Message
|
||||||
|
|
|
@ -33,7 +33,7 @@ export async function initWaku(): Promise<Waku> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handlePublicKeyMessage(
|
export function handlePublicKeyMessage(
|
||||||
myAddress: string,
|
myAddress: string | undefined,
|
||||||
setter: Dispatch<SetStateAction<Map<string, Uint8Array>>>,
|
setter: Dispatch<SetStateAction<Map<string, Uint8Array>>>,
|
||||||
msg: WakuMessage
|
msg: WakuMessage
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Reference in New Issue