Merge pull request #108 from waku-org/js-waku-0.28.0

This commit is contained in:
fryorcraken.eth 2022-09-20 10:21:22 +10:00 committed by GitHub
commit a895f2cc4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 201 additions and 148 deletions

View File

@ -8,9 +8,9 @@
"@ethersproject/providers": "5.7.0", "@ethersproject/providers": "5.7.0",
"@material-ui/core": "^4.12.3", "@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2", "@material-ui/icons": "^4.11.2",
"ethers": "5.7.0", "ethers": "5.7.1",
"fontsource-roboto": "^4.0.0", "fontsource-roboto": "^4.0.0",
"js-waku": "0.27.0", "js-waku": "0.28.0",
"protobufjs": "^7.1.0", "protobufjs": "^7.1.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",

70
eth-pm/pnpm-lock.yaml generated
View File

@ -12,9 +12,9 @@ specifiers:
'@types/react-dom': ^18.0.6 '@types/react-dom': ^18.0.6
cspell: ^6.0.0 cspell: ^6.0.0
eslint: ^8.9.0 eslint: ^8.9.0
ethers: 5.7.0 ethers: 5.7.1
fontsource-roboto: ^4.0.0 fontsource-roboto: ^4.0.0
js-waku: 0.27.0 js-waku: 0.28.0
npm-run-all: ^4.1.5 npm-run-all: ^4.1.5
prettier: ^2.5.1 prettier: ^2.5.1
protobufjs: ^7.1.0 protobufjs: ^7.1.0
@ -29,9 +29,9 @@ dependencies:
'@ethersproject/providers': 5.7.0 '@ethersproject/providers': 5.7.0
'@material-ui/core': 4.12.4_zxljzmqdrxwnuenbkrz77w74uy '@material-ui/core': 4.12.4_zxljzmqdrxwnuenbkrz77w74uy
'@material-ui/icons': 4.11.3_upnjamd3tbaukgopcqqdlc7jbm '@material-ui/icons': 4.11.3_upnjamd3tbaukgopcqqdlc7jbm
ethers: 5.7.0 ethers: 5.7.1
fontsource-roboto: 4.0.0 fontsource-roboto: 4.0.0
js-waku: 0.27.0_undici@5.10.0 js-waku: 0.28.0_undici@5.10.0
protobufjs: 7.1.0 protobufjs: 7.1.0
react: 18.2.0 react: 18.2.0
react-dom: 18.2.0_react@18.2.0 react-dom: 18.2.0_react@18.2.0
@ -2099,10 +2099,10 @@ packages:
'@ethersproject/bignumber': 5.7.0 '@ethersproject/bignumber': 5.7.0
'@ethersproject/bytes': 5.7.0 '@ethersproject/bytes': 5.7.0
'@ethersproject/logger': 5.7.0 '@ethersproject/logger': 5.7.0
'@ethersproject/networks': 5.7.0 '@ethersproject/networks': 5.7.1
'@ethersproject/properties': 5.7.0 '@ethersproject/properties': 5.7.0
'@ethersproject/transactions': 5.7.0 '@ethersproject/transactions': 5.7.0
'@ethersproject/web': 5.7.0 '@ethersproject/web': 5.7.1
dev: false dev: false
/@ethersproject/abstract-signer/5.7.0: /@ethersproject/abstract-signer/5.7.0:
@ -2239,6 +2239,12 @@ packages:
'@ethersproject/logger': 5.7.0 '@ethersproject/logger': 5.7.0
dev: false dev: false
/@ethersproject/networks/5.7.1:
resolution: {integrity: sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==}
dependencies:
'@ethersproject/logger': 5.7.0
dev: false
/@ethersproject/pbkdf2/5.7.0: /@ethersproject/pbkdf2/5.7.0:
resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==} resolution: {integrity: sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==}
dependencies: dependencies:
@ -2280,6 +2286,34 @@ packages:
- utf-8-validate - utf-8-validate
dev: false dev: false
/@ethersproject/providers/5.7.1:
resolution: {integrity: sha512-vZveG/DLyo+wk4Ga1yx6jSEHrLPgmTt+dFv0dv8URpVCRf0jVhalps1jq/emN/oXnMRsC7cQgAF32DcXLL7BPQ==}
dependencies:
'@ethersproject/abstract-provider': 5.7.0
'@ethersproject/abstract-signer': 5.7.0
'@ethersproject/address': 5.7.0
'@ethersproject/base64': 5.7.0
'@ethersproject/basex': 5.7.0
'@ethersproject/bignumber': 5.7.0
'@ethersproject/bytes': 5.7.0
'@ethersproject/constants': 5.7.0
'@ethersproject/hash': 5.7.0
'@ethersproject/logger': 5.7.0
'@ethersproject/networks': 5.7.1
'@ethersproject/properties': 5.7.0
'@ethersproject/random': 5.7.0
'@ethersproject/rlp': 5.7.0
'@ethersproject/sha2': 5.7.0
'@ethersproject/strings': 5.7.0
'@ethersproject/transactions': 5.7.0
'@ethersproject/web': 5.7.1
bech32: 1.1.4
ws: 7.4.6
transitivePeerDependencies:
- bufferutil
- utf-8-validate
dev: false
/@ethersproject/random/5.7.0: /@ethersproject/random/5.7.0:
resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==} resolution: {integrity: sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==}
dependencies: dependencies:
@ -2388,6 +2422,16 @@ packages:
'@ethersproject/strings': 5.7.0 '@ethersproject/strings': 5.7.0
dev: false dev: false
/@ethersproject/web/5.7.1:
resolution: {integrity: sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==}
dependencies:
'@ethersproject/base64': 5.7.0
'@ethersproject/bytes': 5.7.0
'@ethersproject/logger': 5.7.0
'@ethersproject/properties': 5.7.0
'@ethersproject/strings': 5.7.0
dev: false
/@ethersproject/wordlists/5.7.0: /@ethersproject/wordlists/5.7.0:
resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==} resolution: {integrity: sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==}
dependencies: dependencies:
@ -6559,8 +6603,8 @@ packages:
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: true dev: true
/ethers/5.7.0: /ethers/5.7.1:
resolution: {integrity: sha512-5Xhzp2ZQRi0Em+0OkOcRHxPzCfoBfgtOQA+RUylSkuHbhTEaQklnYi2hsWbRgs3ztJsXVXd9VKBcO1ScWL8YfA==} resolution: {integrity: sha512-5krze4dRLITX7FpU8J4WscXqADiKmyeNlylmmDLbS95DaZpBhDe2YSwRQwKXWNyXcox7a3gBgm/MkGXV1O1S/Q==}
dependencies: dependencies:
'@ethersproject/abi': 5.7.0 '@ethersproject/abi': 5.7.0
'@ethersproject/abstract-provider': 5.7.0 '@ethersproject/abstract-provider': 5.7.0
@ -6577,10 +6621,10 @@ packages:
'@ethersproject/json-wallets': 5.7.0 '@ethersproject/json-wallets': 5.7.0
'@ethersproject/keccak256': 5.7.0 '@ethersproject/keccak256': 5.7.0
'@ethersproject/logger': 5.7.0 '@ethersproject/logger': 5.7.0
'@ethersproject/networks': 5.7.0 '@ethersproject/networks': 5.7.1
'@ethersproject/pbkdf2': 5.7.0 '@ethersproject/pbkdf2': 5.7.0
'@ethersproject/properties': 5.7.0 '@ethersproject/properties': 5.7.0
'@ethersproject/providers': 5.7.0 '@ethersproject/providers': 5.7.1
'@ethersproject/random': 5.7.0 '@ethersproject/random': 5.7.0
'@ethersproject/rlp': 5.7.0 '@ethersproject/rlp': 5.7.0
'@ethersproject/sha2': 5.7.0 '@ethersproject/sha2': 5.7.0
@ -6590,7 +6634,7 @@ packages:
'@ethersproject/transactions': 5.7.0 '@ethersproject/transactions': 5.7.0
'@ethersproject/units': 5.7.0 '@ethersproject/units': 5.7.0
'@ethersproject/wallet': 5.7.0 '@ethersproject/wallet': 5.7.0
'@ethersproject/web': 5.7.0 '@ethersproject/web': 5.7.1
'@ethersproject/wordlists': 5.7.0 '@ethersproject/wordlists': 5.7.0
transitivePeerDependencies: transitivePeerDependencies:
- bufferutil - bufferutil
@ -8443,8 +8487,8 @@ packages:
/js-tokens/4.0.0: /js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
/js-waku/0.27.0_undici@5.10.0: /js-waku/0.28.0_undici@5.10.0:
resolution: {integrity: sha512-uIh1h2Gu+aEyrGb4qmyk2Sc91in3fMfOil0kdtrps9HnA7ESbC5c6d148LeJaxqH5rfOkrfXXIhw1zwA3hlauw==} resolution: {integrity: sha512-MEIFugvio2IaQMQT+g+bn24BvlJ5S4PdSKD0AGVZlR7q1BhECwlpRoytyz0A/hC1+EJWhrZB8cpIAmxwtYWTBw==}
engines: {node: '>=16'} engines: {node: '>=16'}
dependencies: dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1_undici@5.10.0 '@chainsafe/libp2p-gossipsub': 4.1.1_undici@5.10.0

View File

@ -18,16 +18,18 @@
<div><h2>Remote Peer Id</h2></div> <div><h2>Remote Peer Id</h2></div>
<div id='remote-peer-id'></div> <div id='remote-peer-id'></div>
<label for='remote-multiaddr'>Remote peer's multiaddr</label>
<input id='remote-multiaddr' <input id='remote-multiaddr'
type='text' type='text'
value="/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm"> value="/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm">
<button id='dial' type='button'>Dial</button> <button id='dial' type='button'>Dial</button>
<br/> <br/>
<button id='subscribe' type='button'>Subscribe</button> <button id='subscribe' type='button'>Subscribe with Filter</button>
<button id='unsubscribe' type='button'>Unsubscribe</button> <button id='unsubscribe' type='button'>Unsubscribe with Filter</button>
<br/> <br/>
<label for='textInput'>Message text</label>
<input id='textInput' placeholder='Type your message here' type='text'> <input id='textInput' placeholder='Type your message here' type='text'>
<button id='sendButton' type='button'>Send Message</button> <button id='sendButton' type='button'>Send message using Light Push</button>
<br/> <br/>
<div id="messages"></div> <div id="messages"></div>
@ -35,13 +37,13 @@
import { import {
utils, utils,
WakuMessage WakuMessage
} from 'https://unpkg.com/js-waku@0.27.0/bundle/index.js'; } from 'https://unpkg.com/js-waku@0.28.0/bundle/index.js';
import { import {
createLightNode createLightNode
} from 'https://unpkg.com/js-waku@0.27.0/bundle/lib/create_waku.js' } from 'https://unpkg.com/js-waku@0.28.0/bundle/lib/create_waku.js'
import { import {
waitForRemotePeer waitForRemotePeer
} from 'https://unpkg.com/js-waku@0.27.0/bundle/lib/wait_for_remote_peer.js' } from 'https://unpkg.com/js-waku@0.28.0/bundle/lib/wait_for_remote_peer.js'
const peerIdDiv = document.getElementById('peer-id'); const peerIdDiv = document.getElementById('peer-id');
const remotePeerIdDiv = document.getElementById('remote-peer-id'); const remotePeerIdDiv = document.getElementById('remote-peer-id');

View File

@ -21,7 +21,7 @@
"@angular/platform-browser": "~14.2.0", "@angular/platform-browser": "~14.2.0",
"@angular/platform-browser-dynamic": "~14.2.0", "@angular/platform-browser-dynamic": "~14.2.0",
"@angular/router": "~14.2.0", "@angular/router": "~14.2.0",
"js-waku": "0.27.0", "js-waku": "0.28.0",
"protobufjs": "^7.1.0", "protobufjs": "^7.1.0",
"rxjs": "~7.5.0", "rxjs": "~7.5.0",
"tslib": "^2.3.0", "tslib": "^2.3.0",

View File

@ -16,7 +16,7 @@ specifiers:
'@types/node': ^17.0.21 '@types/node': ^17.0.21
is-ci-cli: ^2.2.0 is-ci-cli: ^2.2.0
jasmine-core: ~4.3.0 jasmine-core: ~4.3.0
js-waku: 0.27.0 js-waku: 0.28.0
karma: ~6.4.0 karma: ~6.4.0
karma-chrome-launcher: ~3.1.0 karma-chrome-launcher: ~3.1.0
karma-coverage: ~2.2.0 karma-coverage: ~2.2.0
@ -37,7 +37,7 @@ dependencies:
'@angular/platform-browser': 14.2.0_afytwol7hs4qio34buyx2grhfa '@angular/platform-browser': 14.2.0_afytwol7hs4qio34buyx2grhfa
'@angular/platform-browser-dynamic': 14.2.0_owch6soaoexeadly32xw5vendq '@angular/platform-browser-dynamic': 14.2.0_owch6soaoexeadly32xw5vendq
'@angular/router': 14.2.0_6lk4yxyxfaqzosenawf2bqx6vy '@angular/router': 14.2.0_6lk4yxyxfaqzosenawf2bqx6vy
js-waku: 0.27.0 js-waku: 0.28.0
protobufjs: 7.1.0 protobufjs: 7.1.0
rxjs: 7.5.6 rxjs: 7.5.6
tslib: 2.4.0 tslib: 2.4.0
@ -5440,8 +5440,8 @@ packages:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
dev: true dev: true
/js-waku/0.27.0: /js-waku/0.28.0:
resolution: {integrity: sha512-uIh1h2Gu+aEyrGb4qmyk2Sc91in3fMfOil0kdtrps9HnA7ESbC5c6d148LeJaxqH5rfOkrfXXIhw1zwA3hlauw==} resolution: {integrity: sha512-MEIFugvio2IaQMQT+g+bn24BvlJ5S4PdSKD0AGVZlR7q1BhECwlpRoytyz0A/hC1+EJWhrZB8cpIAmxwtYWTBw==}
engines: {node: '>=16'} engines: {node: '>=16'}
dependencies: dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1 '@chainsafe/libp2p-gossipsub': 4.1.1

View File

@ -12,9 +12,9 @@
<div><h1>Waku Node Status</h1></div> <div><h1>Waku Node Status</h1></div>
<div id='status'></div> <div id='status'></div>
<label for='textInput'>Message text</label>
<input id='textInput' placeholder='Type your message here' type='text'> <input id='textInput' placeholder='Type your message here' type='text'>
<button id='sendButton' type='button'>Send Message <button id='sendButton' type='button'>Send Message using Relay</button>
</button>
<div><h1>Messages</h1></div> <div><h1>Messages</h1></div>
<div id='messages'></div> <div id='messages'></div>
@ -28,13 +28,13 @@
import { import {
WakuMessage WakuMessage
} from 'https://unpkg.com/js-waku@0.27.0/bundle/index.js'; } from 'https://unpkg.com/js-waku@0.28.0/bundle/index.js';
import { import {
createWaku createPrivacyNode
} from 'https://unpkg.com/js-waku@0.27.0/bundle/lib/create_waku.js' } from 'https://unpkg.com/js-waku@0.28.0/bundle/lib/create_waku.js'
import { import {
waitForRemotePeer waitForRemotePeer
} from 'https://unpkg.com/js-waku@0.27.0/bundle/lib/wait_for_remote_peer.js' } from 'https://unpkg.com/js-waku@0.28.0/bundle/lib/wait_for_remote_peer.js'
const statusDiv = document.getElementById('status'); const statusDiv = document.getElementById('status');
const messagesDiv = document.getElementById('messages'); const messagesDiv = document.getElementById('messages');
@ -60,7 +60,7 @@
// We are currently working on migrating this method to DNS Discovery. // We are currently working on migrating this method to DNS Discovery.
// //
// https://js-waku.wakuconnect.dev/classes/waku.Waku.html#create // https://js-waku.wakuconnect.dev/classes/waku.Waku.html#create
const waku = await createWaku({defaultBootstrap: true}); const waku = await createPrivacyNode({defaultBootstrap: true});
await waku.start(); await waku.start();
// Had a hook to process all incoming messages on a specified content topic. // Had a hook to process all incoming messages on a specified content topic.

View File

@ -7,7 +7,7 @@
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0", "@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"js-waku": "0.27.0", "js-waku": "0.28.0",
"protobufjs": "^7.0.0", "protobufjs": "^7.0.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",

View File

@ -6,7 +6,7 @@ specifiers:
'@testing-library/react': ^13.3.0 '@testing-library/react': ^13.3.0
'@testing-library/user-event': ^13.5.0 '@testing-library/user-event': ^13.5.0
eslint: ^8.22.0 eslint: ^8.22.0
js-waku: 0.27.0 js-waku: 0.28.0
protobufjs: ^7.0.0 protobufjs: ^7.0.0
react: ^18.2.0 react: ^18.2.0
react-dom: ^18.2.0 react-dom: ^18.2.0
@ -17,7 +17,7 @@ dependencies:
'@testing-library/jest-dom': 5.16.5 '@testing-library/jest-dom': 5.16.5
'@testing-library/react': 13.3.0_biqbaboplfbrettd7655fr4n2y '@testing-library/react': 13.3.0_biqbaboplfbrettd7655fr4n2y
'@testing-library/user-event': 13.5.0_wl4iynrlixafokvgqnhzlvigei '@testing-library/user-event': 13.5.0_wl4iynrlixafokvgqnhzlvigei
js-waku: 0.27.0_undici@5.10.0 js-waku: 0.28.0_undici@5.10.0
protobufjs: 7.0.0 protobufjs: 7.0.0
react: 18.2.0 react: 18.2.0
react-dom: 18.2.0_react@18.2.0 react-dom: 18.2.0_react@18.2.0
@ -7001,8 +7001,8 @@ packages:
/js-tokens/4.0.0: /js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
/js-waku/0.27.0_undici@5.10.0: /js-waku/0.28.0_undici@5.10.0:
resolution: {integrity: sha512-uIh1h2Gu+aEyrGb4qmyk2Sc91in3fMfOil0kdtrps9HnA7ESbC5c6d148LeJaxqH5rfOkrfXXIhw1zwA3hlauw==} resolution: {integrity: sha512-MEIFugvio2IaQMQT+g+bn24BvlJ5S4PdSKD0AGVZlR7q1BhECwlpRoytyz0A/hC1+EJWhrZB8cpIAmxwtYWTBw==}
engines: {node: '>=16'} engines: {node: '>=16'}
dependencies: dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1_undici@5.10.0 '@chainsafe/libp2p-gossipsub': 4.1.1_undici@5.10.0

View File

@ -1,7 +1,7 @@
import { WakuMessage } from "js-waku"; import { WakuMessage } from "js-waku";
import * as React from "react"; import * as React from "react";
import protobuf from "protobufjs"; import protobuf from "protobufjs";
import { createWaku } from "js-waku/lib/create_waku"; import { createPrivacyNode } from "js-waku/lib/create_waku";
import { waitForRemotePeer } from "js-waku/lib/wait_for_remote_peer"; import { waitForRemotePeer } from "js-waku/lib/wait_for_remote_peer";
const ContentTopic = `/relay-reactjs-chat/1/chat/proto`; const ContentTopic = `/relay-reactjs-chat/1/chat/proto`;
@ -23,7 +23,7 @@ function App() {
setWakuStatus("Starting"); setWakuStatus("Starting");
(async () => { (async () => {
const waku = await createWaku({ defaultBootstrap: true }); const waku = await createPrivacyNode({ defaultBootstrap: true });
setWaku(waku); setWaku(waku);
await waku.start(); await waku.start();

View File

@ -2,39 +2,38 @@
<html lang='en'> <html lang='en'>
<head> <head>
<meta charset='UTF-8' /> <meta charset='UTF-8'/>
<meta content='width=device-width, initial-scale=1.0' name='viewport' /> <meta content='width=device-width, initial-scale=1.0' name='viewport'/>
<title>JS-Waku store script tag example</title> <title>JS-Waku store script tag example</title>
</head> </head>
<body> <body>
<div><h1>Timestamp of latest message seen in store</h1></div> <div><h1>Timestamp of the latest message seen in store</h1></div>
<div id='timestamp'></div> <div id='timestamp'></div>
<script type='module'> <script type='module'>
import { import {
Protocols Protocols
} from 'https://unpkg.com/js-waku@0.27.0/bundle/index.js'; } from 'https://unpkg.com/js-waku@0.28.0/bundle/index.js';
import { import {
createWaku createWaku
} from 'https://unpkg.com/js-waku@0.27.0/bundle/lib/create_waku.js' } from 'https://unpkg.com/js-waku@0.28.0/bundle/lib/create_waku.js'
import { import {
waitForRemotePeer waitForRemotePeer
} from 'https://unpkg.com/js-waku@0.27.0/bundle/lib/wait_for_remote_peer.js' } from 'https://unpkg.com/js-waku@0.28.0/bundle/lib/wait_for_remote_peer.js'
/** /**
* This example demonstrates how to use the js-waku minified bundle * This example demonstrates how to use the js-waku minified bundle
* available on unpkg.com. * available on unpkg.com.
* *
* It is a simple script that uses Waku Store to retrieve ping relay messages * It is a simple script that uses Waku Store to retrieve ping relay messages
* and displays the timestamp of the most recent ping relay message. * and displays the timestamp of the most recent ping relay message.
*/ */
const timestampDiv = document.getElementById('timestamp'); const timestampDiv = document.getElementById('timestamp');
try {
timestampDiv.innerHTML = '<p>Creating waku.</p>'; timestampDiv.innerHTML = '<p>Creating waku.</p>';
const node = await createWaku({ defaultBootstrap: true }); const node = await createWaku({defaultBootstrap: true});
timestampDiv.innerHTML = '<p>Starting waku.</p>'; timestampDiv.innerHTML = '<p>Starting waku.</p>';
await node.start(); await node.start();
@ -43,40 +42,34 @@
await waitForRemotePeer(node, [Protocols.Store]); await waitForRemotePeer(node, [Protocols.Store]);
timestampDiv.innerHTML = '<p>Retrieving messages.</p>'; timestampDiv.innerHTML = '<p>Retrieving messages.</p>';
const callback = (wakuMessages) => { const callback = (wakuMessage) => {
// Messages are ordered with oldest first // When `backward` direction is passed, first message is the most recent
// even with page direction `backward` timestampDiv.innerHTML = wakuMessage.timestamp;
const latestFirst = wakuMessages.reverse();
const latestMessage = latestFirst[0];
if (latestMessage) {
timestampDiv.innerHTML = latestMessage.timestamp;
} else {
timestampDiv.innerHTML = '<p>No message available, go to <a href="https://js-waku.wakuconnect.dev/examples/web-chat/">web-chat</a> to send a message</p>';
}
// When returning true, `queryHistory` stops retrieving pages // When returning true, `queryHistory` stops retrieving pages
// In our case, we only want one message, hence one page. // In our case, we only want one message, hence one page.
return true; return true;
}; };
const startTime = new Date(); const startTime = new Date();
// Only retrieve a week of messages // Only retrieve a week of messages
startTime.setTime(Date.now() - 7 * 24 * 60 * 60 * 1000); startTime.setTime(Date.now() - 7 * 24 * 60 * 60 * 1000);
try {
await node.store
await node.store .queryOrderedCallback([],
.queryHistory([], { callback,
callback, {
pageDirection: 'backward', pageDirection: 'backward',
pageSize: 1, pageSize: 1,
timeFilter: { timeFilter: {
startTime, startTime,
endTime: new Date() endTime: new Date()
} }
}); });
} catch (e) { } catch (e) {
timestampDiv.innerHTML = 'Error encountered: ' + e.toString(); // Known issue: https://github.com/status-im/nwaku/issues/1157
} console.log(e)
}
</script> </script>
</body> </body>

View File

@ -7,7 +7,7 @@
"@testing-library/jest-dom": "^5.16.4", "@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0", "@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^14.1.1", "@testing-library/user-event": "^14.1.1",
"js-waku": "0.27.0", "js-waku": "0.28.0",
"protobufjs": "^7.1.0", "protobufjs": "^7.1.0",
"react": "^18.1.0", "react": "^18.1.0",
"react-dom": "^18.1.0", "react-dom": "^18.1.0",

View File

@ -5,7 +5,7 @@ specifiers:
'@testing-library/jest-dom': ^5.16.4 '@testing-library/jest-dom': ^5.16.4
'@testing-library/react': ^13.2.0 '@testing-library/react': ^13.2.0
'@testing-library/user-event': ^14.1.1 '@testing-library/user-event': ^14.1.1
js-waku: 0.27.0 js-waku: 0.28.0
protobufjs: ^7.1.0 protobufjs: ^7.1.0
react: ^18.1.0 react: ^18.1.0
react-dom: ^18.1.0 react-dom: ^18.1.0
@ -17,7 +17,7 @@ dependencies:
'@testing-library/jest-dom': 5.16.5 '@testing-library/jest-dom': 5.16.5
'@testing-library/react': 13.3.0_biqbaboplfbrettd7655fr4n2y '@testing-library/react': 13.3.0_biqbaboplfbrettd7655fr4n2y
'@testing-library/user-event': 14.4.2_znfriv3ismgf3ybh2woqwlpfea '@testing-library/user-event': 14.4.2_znfriv3ismgf3ybh2woqwlpfea
js-waku: 0.27.0 js-waku: 0.28.0
protobufjs: 7.1.0 protobufjs: 7.1.0
react: 18.2.0 react: 18.2.0
react-dom: 18.2.0_react@18.2.0 react-dom: 18.2.0_react@18.2.0
@ -7375,8 +7375,8 @@ packages:
/js-tokens/4.0.0: /js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
/js-waku/0.27.0: /js-waku/0.28.0:
resolution: {integrity: sha512-uIh1h2Gu+aEyrGb4qmyk2Sc91in3fMfOil0kdtrps9HnA7ESbC5c6d148LeJaxqH5rfOkrfXXIhw1zwA3hlauw==} resolution: {integrity: sha512-MEIFugvio2IaQMQT+g+bn24BvlJ5S4PdSKD0AGVZlR7q1BhECwlpRoytyz0A/hC1+EJWhrZB8cpIAmxwtYWTBw==}
engines: {node: '>=16'} engines: {node: '>=16'}
dependencies: dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1 '@chainsafe/libp2p-gossipsub': 4.1.1

View File

@ -55,32 +55,40 @@ function App() {
React.useEffect(() => { React.useEffect(() => {
if (wakuStatus !== "Connected") return; if (wakuStatus !== "Connected") return;
const processMessages = (retrievedMessages) => { (async () => {
const messages = retrievedMessages.map(decodeMessage).filter(Boolean); const startTime = new Date();
// 7 days/week, 24 hours/day, 60min/hour, 60secs/min, 100ms/sec
startTime.setTime(startTime.getTime() - 7 * 24 * 60 * 60 * 1000);
setMessages((currentMessages) => { // TODO: Remove this timeout once https://github.com/status-im/js-waku/issues/913 is done
return currentMessages.concat(messages.reverse()); await new Promise((resolve) => setTimeout(resolve, 200));
});
};
const startTime = new Date(); try {
// 7 days/week, 24 hours/day, 60min/hour, 60secs/min, 100ms/sec for await (const messagesPromises of waku.store.queryGenerator(
startTime.setTime(startTime.getTime() - 7 * 24 * 60 * 60 * 1000); [ContentTopic],
{
// TODO: Remove this timeout once https://github.com/status-im/js-waku/issues/913 is done
setTimeout(
() =>
waku.store
.queryHistory([ContentTopic], {
callback: processMessages,
timeFilter: { startTime, endTime: new Date() }, timeFilter: { startTime, endTime: new Date() },
}) pageDirection: "forward",
.catch((e) => { }
console.log("Failed to retrieve messages", e); )) {
setWakuStatus("Error Encountered"); const messages = await Promise.all(
}), messagesPromises
200 .map(async (p) => {
); const msg = await p;
return decodeMessage(msg);
})
.filter(Boolean)
);
setMessages((currentMessages) => {
return currentMessages.concat(messages.reverse());
});
}
} catch (e) {
console.log("Failed to retrieve messages", e);
setWakuStatus("Error Encountered");
}
})();
}, [waku, wakuStatus]); }, [waku, wakuStatus]);
return ( return (

View File

@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"@livechat/ui-kit": "^0.5.0-20", "@livechat/ui-kit": "^0.5.0-20",
"@multiformats/multiaddr": "^10.4.0", "@multiformats/multiaddr": "^10.4.0",
"js-waku": "0.27.0", "js-waku": "0.28.0",
"process": "^0.11.10", "process": "^0.11.10",
"protons-runtime": "^3.1.0", "protons-runtime": "^3.1.0",
"react": "^17.0.2", "react": "^17.0.2",

View File

@ -9,7 +9,7 @@ specifiers:
'@types/react-dom': ^17.0.11 '@types/react-dom': ^17.0.11
cspell: ^6.0.0 cspell: ^6.0.0
gh-pages: ^4.0.0 gh-pages: ^4.0.0
js-waku: 0.27.0 js-waku: 0.28.0
npm-run-all: ^4.1.5 npm-run-all: ^4.1.5
prettier: ^2.6.2 prettier: ^2.6.2
process: ^0.11.10 process: ^0.11.10
@ -26,7 +26,7 @@ specifiers:
dependencies: dependencies:
'@livechat/ui-kit': 0.5.0-20_ibvs32p3vr2bbtbo3dwziny444 '@livechat/ui-kit': 0.5.0-20_ibvs32p3vr2bbtbo3dwziny444
'@multiformats/multiaddr': 10.4.0 '@multiformats/multiaddr': 10.4.0
js-waku: 0.27.0 js-waku: 0.28.0
process: 0.11.10 process: 0.11.10
protons-runtime: 3.1.0_uint8arraylist@2.3.2 protons-runtime: 3.1.0_uint8arraylist@2.3.2
react: 17.0.2 react: 17.0.2
@ -8382,8 +8382,8 @@ packages:
/js-tokens/4.0.0: /js-tokens/4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
/js-waku/0.27.0: /js-waku/0.28.0:
resolution: {integrity: sha512-uIh1h2Gu+aEyrGb4qmyk2Sc91in3fMfOil0kdtrps9HnA7ESbC5c6d148LeJaxqH5rfOkrfXXIhw1zwA3hlauw==} resolution: {integrity: sha512-MEIFugvio2IaQMQT+g+bn24BvlJ5S4PdSKD0AGVZlR7q1BhECwlpRoytyz0A/hC1+EJWhrZB8cpIAmxwtYWTBw==}
engines: {node: '>=16'} engines: {node: '>=16'}
dependencies: dependencies:
'@chainsafe/libp2p-gossipsub': 4.1.1 '@chainsafe/libp2p-gossipsub': 4.1.1

View File

@ -51,19 +51,7 @@ export const ChatContentTopic = "/toy-chat/2/huilong/proto";
async function retrieveStoreMessages( async function retrieveStoreMessages(
waku: WakuLight, waku: WakuLight,
setArchivedMessages: (value: Message[]) => void setArchivedMessages: (value: Message[]) => void
): Promise<number> { ): Promise<void> {
const callback = (wakuMessages: WakuMessage[]): void => {
const messages: Message[] = [];
wakuMessages
.map((wakuMsg) => Message.fromWakuMessage(wakuMsg))
.forEach((message) => {
if (message) {
messages.push(message);
}
});
setArchivedMessages(messages);
};
const startTime = new Date(); const startTime = new Date();
// Only retrieve a week of history // Only retrieve a week of history
startTime.setTime(Date.now() - 1000 * 60 * 60 * 24 * 7); startTime.setTime(Date.now() - 1000 * 60 * 60 * 24 * 7);
@ -71,20 +59,32 @@ async function retrieveStoreMessages(
const endTime = new Date(); const endTime = new Date();
try { try {
const res = await waku.store.queryHistory([ChatContentTopic], { for await (const messagesPromises of waku.store.queryGenerator(
pageSize: 5, [ChatContentTopic],
pageDirection: PageDirection.FORWARD, {
timeFilter: { pageSize: 5,
startTime, pageDirection: PageDirection.FORWARD,
endTime, timeFilter: {
}, startTime,
callback, endTime,
}); },
}
)) {
const messages: Message[] = [];
const wakuMessages = await Promise.all(messagesPromises);
return res.length; wakuMessages
.filter(isWakuMessageDefined)
.map((wakuMsg) => Message.fromWakuMessage(wakuMsg))
.forEach((message) => {
if (message) {
messages.push(message);
}
});
setArchivedMessages(messages);
}
} catch (e) { } catch (e) {
console.log("Failed to retrieve messages", e); console.log("Failed to retrieve messages", e);
return 0;
} }
} }
@ -228,3 +228,9 @@ function selectFleetEnv() {
function reduceMessages(state: Message[], newMessages: Message[]) { function reduceMessages(state: Message[], newMessages: Message[]) {
return state.concat(newMessages); return state.concat(newMessages);
} }
const isWakuMessageDefined = (
msg: WakuMessage | undefined
): msg is WakuMessage => {
return !!msg;
};