u deps
This commit is contained in:
parent
68046a8c2e
commit
dc007d1285
|
@ -15,10 +15,6 @@
|
|||
"test": "wsrun -e -c -s --exclude-missing test",
|
||||
"clean": "wsrun -e -c -s clean && rimraf node_modules"
|
||||
},
|
||||
"resolutions": {
|
||||
"js-waku": "0.30.0",
|
||||
"protons-runtime": "3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"prettier": "^2.3.1",
|
||||
"wsrun": "^5.2.4"
|
||||
|
|
|
@ -17,15 +17,18 @@
|
|||
"clean": "rimraf dist node_modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"@status-im/js": "0.2.0",
|
||||
"@libp2p/bootstrap": "^9.0.10",
|
||||
"@status-im/js": "0.4.3",
|
||||
"@usedapp/core": "^1.2.8",
|
||||
"@waku/core": "^0.0.25",
|
||||
"@waku/message-encryption": "^0.0.23",
|
||||
"@waku/sdk": "^0.0.21",
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"eth-sig-util": "^3.0.1",
|
||||
"ethers": "5.4.1",
|
||||
"humanize-duration": "^3.27.0",
|
||||
"js-waku": "0.30.0",
|
||||
"protons": "^2.0.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
@ -54,6 +57,7 @@
|
|||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.26.0",
|
||||
"@typescript-eslint/parser": "^4.26.0",
|
||||
"@waku/interfaces": "^0.0.20",
|
||||
"babel-loader": "^8.2.2",
|
||||
"babel-preset-minify": "^0.5.1",
|
||||
"chai": "^4.3.4",
|
||||
|
@ -61,6 +65,8 @@
|
|||
"eslint": "^7.27.0",
|
||||
"eslint-plugin-hooks": "^0.2.0",
|
||||
"eslint-plugin-react": "^7.24.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.3.4",
|
||||
"ethereum-waffle": "^3.4.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"fork-ts-checker-webpack-plugin": "^6.2.10",
|
||||
|
@ -75,11 +81,6 @@
|
|||
"typescript": "^4.9.5",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^4.7.0",
|
||||
"webpack-dev-server": "^3.11.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.3.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"ethers": "5.4.1"
|
||||
"webpack-dev-server": "^3.11.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import lodash from 'lodash'
|
|||
import { BigNumber, utils } from 'ethers'
|
||||
import { recoverAddress } from './ethMessage'
|
||||
|
||||
import type { WakuLight } from 'js-waku/lib/interfaces'
|
||||
import type { LightNode } from '@waku/interfaces'
|
||||
import { FeaturedVoting } from '../models/smartContract'
|
||||
import { TypedFeature } from '../models/TypedData'
|
||||
import { WakuFeatureData } from '../models/waku'
|
||||
|
@ -43,7 +43,7 @@ function sumVotes(map: CommunitiesFeatureVotes) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function receiveWakuFeature(waku: WakuLight | undefined, topic: string, activeVoting: FeaturedVoting) {
|
||||
export async function receiveWakuFeature(waku: LightNode | undefined, topic: string, activeVoting: FeaturedVoting) {
|
||||
const messages = await receiveWakuFeatureMsg(waku, topic)
|
||||
const featureVotes: CommunitiesFeatureVotes = {}
|
||||
const validatedMessages = []
|
||||
|
|
|
@ -2,13 +2,13 @@ import { WakuFeatureData } from '../models/waku'
|
|||
import { utils, BigNumber } from 'ethers'
|
||||
import { JsonRpcSigner } from '@ethersproject/providers'
|
||||
import proto from './loadProtons'
|
||||
import { DecoderV0 } from 'js-waku/lib/waku_message/version_0'
|
||||
import { createDecoder } from '@waku/core'
|
||||
|
||||
import type { WakuLight } from 'js-waku/lib/interfaces'
|
||||
import type { MessageV0 as WakuMessage } from 'js-waku/lib/waku_message/version_0'
|
||||
import type { LightNode } from '@waku/interfaces'
|
||||
import type { DecodedMessage } from '@waku/core'
|
||||
import { getContractParameters } from './receiveWakuFeature'
|
||||
|
||||
function decodeWakuFeature(msg: WakuMessage): WakuFeatureData | undefined {
|
||||
function decodeWakuFeature(msg: DecodedMessage): WakuFeatureData | undefined {
|
||||
try {
|
||||
if (!msg.payload) {
|
||||
return undefined
|
||||
|
@ -29,11 +29,11 @@ export function decodeWakuFeatures(messages: any[] | null) {
|
|||
return messages?.map(decodeWakuFeature).filter((e): e is WakuFeatureData => !!e)
|
||||
}
|
||||
|
||||
export async function receiveWakuFeatureMsg(waku: WakuLight | undefined, topic: string) {
|
||||
export async function receiveWakuFeatureMsg(waku: LightNode | undefined, topic: string) {
|
||||
if (waku) {
|
||||
const messages: WakuMessage[] = []
|
||||
const messages: DecodedMessage[] = []
|
||||
// todo: init decoder once
|
||||
await waku.store.queryOrderedCallback([new DecoderV0(topic)], (wakuMessage: WakuMessage) => {
|
||||
await waku.store.queryWithOrderedCallback([createDecoder(topic)], (wakuMessage: DecodedMessage) => {
|
||||
messages.push(wakuMessage)
|
||||
})
|
||||
|
||||
|
|
|
@ -5,10 +5,10 @@ import { utils } from 'ethers'
|
|||
import proto from './loadProtons'
|
||||
import { WakuVoteData } from '../models/waku'
|
||||
import { TypedVote } from '../models/TypedData'
|
||||
import { DecoderV0 } from 'js-waku/lib/waku_message/version_0'
|
||||
import { createDecoder } from '@waku/core'
|
||||
|
||||
import type { WakuLight } from 'js-waku/lib/interfaces'
|
||||
import type { MessageV0 as WakuMessage } from 'js-waku/lib/waku_message/version_0'
|
||||
import type { DecodedMessage } from '@waku/core'
|
||||
import type { LightNode } from '@waku/interfaces'
|
||||
|
||||
function getContractParameters(
|
||||
address: string,
|
||||
|
@ -51,7 +51,7 @@ export function filterVerifiedVotes(
|
|||
return verified
|
||||
}
|
||||
|
||||
function decodeWakuVote(msg: WakuMessage): WakuVoteData | undefined {
|
||||
function decodeWakuVote(msg: DecodedMessage): WakuVoteData | undefined {
|
||||
try {
|
||||
if (!msg.payload) {
|
||||
return undefined
|
||||
|
@ -72,10 +72,10 @@ export function decodeWakuVotes(messages: any[] | null) {
|
|||
}
|
||||
|
||||
// todo?: pass complete topic
|
||||
export async function receiveWakuVotes(waku: WakuLight, topic: string, room: number) {
|
||||
const messages: WakuMessage[] = []
|
||||
export async function receiveWakuVotes(waku: LightNode, topic: string, room: number) {
|
||||
const messages: DecodedMessage[] = []
|
||||
// todo: init decoder once
|
||||
await waku.store.queryOrderedCallback([new DecoderV0(topic + room.toString())], (wakuMessage: WakuMessage) => {
|
||||
await waku.store.queryWithOrderedCallback([createDecoder(topic + room.toString())], (wakuMessage: DecodedMessage) => {
|
||||
messages.push(wakuMessage)
|
||||
})
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useWaku } from '../providers/waku/provider'
|
|||
import { useEthers, useSigner } from '@usedapp/core'
|
||||
import { config } from '../config'
|
||||
import { createWakuFeatureMsg } from '../helpers/wakuFeature'
|
||||
import { EncoderV0 } from 'js-waku/lib/waku_message/version_0'
|
||||
import { createEncoder } from '@waku/core'
|
||||
import { useTypedFeatureVote } from './useTypedFeatureVote'
|
||||
|
||||
export function useSendWakuFeature() {
|
||||
|
@ -18,7 +18,9 @@ export function useSendWakuFeature() {
|
|||
const msg = await createWakuFeatureMsg(account, signer, voteAmount, publicKey, timestamp, getTypedFeatureVote)
|
||||
if (msg) {
|
||||
if (waku) {
|
||||
await waku.lightPush.push(new EncoderV0(config.wakuConfig.wakuFeatureTopic), { payload: msg })
|
||||
await waku.lightPush.send(createEncoder({ contentTopic: config.wakuConfig.wakuFeatureTopic }), {
|
||||
payload: msg,
|
||||
})
|
||||
} else {
|
||||
alert('error sending feature vote please try again')
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useEthers, useSigner } from '@usedapp/core'
|
|||
import { config } from '../config'
|
||||
import { createWakuVote } from '../helpers/wakuVote'
|
||||
import { useTypedVote } from './useTypedVote'
|
||||
import { EncoderV0 } from 'js-waku/lib/waku_message/version_0'
|
||||
import { createEncoder } from '@waku/core'
|
||||
|
||||
export function useSendWakuVote() {
|
||||
const { waku } = useWaku()
|
||||
|
@ -18,7 +18,9 @@ export function useSendWakuVote() {
|
|||
const msg = await createWakuVote(account, signer, room, voteAmount, type, timestamp, getTypedVote)
|
||||
if (msg) {
|
||||
if (waku) {
|
||||
await waku.lightPush.push(new EncoderV0(config.wakuConfig.wakuTopic + room.toString()), { payload: msg })
|
||||
await waku.lightPush.send(createEncoder({ contentTopic: config.wakuConfig.wakuTopic + room.toString() }), {
|
||||
payload: msg,
|
||||
})
|
||||
} else {
|
||||
alert('error sending vote please try again')
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// note: !waku and waku && conditions to use isConnected when implementing detection of dicsonnections
|
||||
|
||||
import React, { ReactNode, createContext, useContext, useEffect, useState } from 'react'
|
||||
import { Protocols } from 'js-waku'
|
||||
import { createLightNode } from 'js-waku/lib/create_waku'
|
||||
import { PeerDiscoveryStaticPeers } from 'js-waku/lib/peer_discovery_static_list'
|
||||
import { waitForRemotePeer } from 'js-waku/lib/wait_for_remote_peer'
|
||||
import type { WakuLight } from 'js-waku/lib/interfaces'
|
||||
import { bootstrap } from '@libp2p/bootstrap'
|
||||
import { Protocols } from '@waku/interfaces'
|
||||
import { createLightNode, waitForRemotePeer } from '@waku/sdk'
|
||||
import type { LightNode } from '@waku/interfaces'
|
||||
import { config } from '../../config'
|
||||
|
||||
type Context = {
|
||||
waku: WakuLight | undefined
|
||||
waku: LightNode | undefined
|
||||
isLoading: boolean
|
||||
isConnected: boolean
|
||||
isError: boolean
|
||||
|
@ -24,7 +24,7 @@ type Props = {
|
|||
}
|
||||
|
||||
export function WakuProvider({ peers, children }: Props) {
|
||||
const [waku, setWaku] = useState<WakuLight>()
|
||||
const [waku, setWaku] = useState<LightNode>()
|
||||
const [isLoading, setIsLoading] = useState<boolean>(true)
|
||||
const [isConnected, setIsConnected] = useState<boolean>(false)
|
||||
const [isError, setIsError] = useState<boolean>(false)
|
||||
|
@ -39,7 +39,9 @@ export function WakuProvider({ peers, children }: Props) {
|
|||
// @ts-ignore
|
||||
emitSelf: true,
|
||||
libp2p: {
|
||||
peerDiscovery: [new PeerDiscoveryStaticPeers(peers, { maxPeers: 1 })],
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore icorrectly exported types from @libp2p/boostrap#package.json; patched only in @status-im/js for now
|
||||
peerDiscovery: [bootstrap({ list: peers[config.wakuConfig.environment] })],
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { JsonRpcSigner } from '@ethersproject/providers'
|
|||
import proto from '../../../src/helpers/loadProtons'
|
||||
import { BigNumber, utils } from 'ethers'
|
||||
import protons from 'protons'
|
||||
import { EncoderV0 } from 'js-waku/lib/waku_message/version_0'
|
||||
import { createEncoder } from '@waku/core'
|
||||
|
||||
const proto2 = protons(`
|
||||
message WakuVote {
|
||||
|
@ -22,7 +22,7 @@ describe('wakuMessage', () => {
|
|||
|
||||
describe('decode waku vote', () => {
|
||||
it('success', async () => {
|
||||
const encoder = new EncoderV0('/test2/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
|
||||
const payload = proto.WakuVote.encode({
|
||||
address: '0x0',
|
||||
|
@ -69,7 +69,7 @@ describe('wakuMessage', () => {
|
|||
})
|
||||
|
||||
it('wrong data', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
|
||||
const payload = proto2.WakuVote.encode({
|
||||
address: '0x0',
|
||||
|
@ -101,7 +101,7 @@ describe('wakuMessage', () => {
|
|||
|
||||
describe('decode waku feature', () => {
|
||||
it('success', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
|
||||
const payload = proto2.WakuFeature.encode({
|
||||
voter: '0x0',
|
||||
|
@ -136,7 +136,7 @@ describe('wakuMessage', () => {
|
|||
|
||||
describe('create', () => {
|
||||
it('success', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
const payload = await wakuMessage.create(
|
||||
alice.address,
|
||||
alice as unknown as JsonRpcSigner,
|
||||
|
@ -147,7 +147,7 @@ describe('wakuMessage', () => {
|
|||
() => [],
|
||||
'0x01'
|
||||
)
|
||||
const msg = await encoder.toProtoObj({ payload })
|
||||
const msg = await encoder.toProtoObj({ payload: payload! })
|
||||
|
||||
expect(msg?.payload).to.not.be.undefined
|
||||
if (msg?.payload) {
|
||||
|
@ -161,7 +161,7 @@ describe('wakuMessage', () => {
|
|||
})
|
||||
|
||||
it('different payload', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
const payload = await wakuMessage.create(
|
||||
alice.address,
|
||||
alice as unknown as JsonRpcSigner,
|
||||
|
@ -172,7 +172,7 @@ describe('wakuMessage', () => {
|
|||
() => [],
|
||||
'0x01'
|
||||
)
|
||||
const msg = await encoder.toProtoObj({ payload })
|
||||
const msg = await encoder.toProtoObj({ payload: payload! })
|
||||
|
||||
expect(msg?.payload).to.not.be.undefined
|
||||
if (msg?.payload) {
|
||||
|
@ -186,23 +186,23 @@ describe('wakuMessage', () => {
|
|||
})
|
||||
|
||||
it('no address', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
const payload = await wakuMessage.create(undefined, alice as unknown as JsonRpcSigner, 1, 100, 1, 1, () => [])
|
||||
const msg = await encoder.toProtoObj({ payload })
|
||||
const msg = await encoder.toProtoObj({ payload: payload! })
|
||||
expect(msg?.payload).to.be.undefined
|
||||
})
|
||||
|
||||
it('no signer', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
const payload = await wakuMessage.create(alice.address, undefined, 1, 100, 1, 1, () => [])
|
||||
const msg = await encoder.toProtoObj({ payload })
|
||||
const msg = await encoder.toProtoObj({ payload: payload! })
|
||||
expect(msg?.payload).to.be.undefined
|
||||
})
|
||||
|
||||
it('different signer', async () => {
|
||||
const encoder = new EncoderV0('/test/')
|
||||
const encoder = createEncoder({ contentTopic: '/test2/' })
|
||||
const payload = await wakuMessage.create(alice.address, bob as unknown as JsonRpcSigner, 1, 100, 1, 1, () => [])
|
||||
const msg = await encoder.toProtoObj({ payload })
|
||||
const msg = await encoder.toProtoObj({ payload: payload! })
|
||||
expect(msg?.payload).to.be.undefined
|
||||
})
|
||||
})
|
||||
|
|
|
@ -28,6 +28,7 @@ module.exports = () => {
|
|||
crypto: require.resolve('crypto-browserify'),
|
||||
stream: require.resolve('stream-browserify'),
|
||||
assert: require.resolve('assert'),
|
||||
zlib: false,
|
||||
},
|
||||
},
|
||||
module: {
|
||||
|
|
Loading…
Reference in New Issue