mirror of
https://github.com/status-im/dappconnect-voting-sdk.git
synced 2025-03-02 11:10:47 +00:00
Fix js waku (#36)
This commit is contained in:
parent
3de0037d8e
commit
085c4d28ba
@ -4,7 +4,7 @@ import { PollInitMsg } from './models/PollInitMsg'
|
|||||||
import { PollType } from './types/PollType'
|
import { PollType } from './types/PollType'
|
||||||
import { BigNumber, Wallet } from 'ethers'
|
import { BigNumber, Wallet } from 'ethers'
|
||||||
import PollInit from './utils/proto/PollInit'
|
import PollInit from './utils/proto/PollInit'
|
||||||
import { WakuMessage } from 'js-waku'
|
import { WakuMessage, StoreCodec } from 'js-waku'
|
||||||
import { TimedPollVoteMsg } from './models/TimedPollVoteMsg'
|
import { TimedPollVoteMsg } from './models/TimedPollVoteMsg'
|
||||||
import TimedPollVote from './utils/proto/TimedPollVote'
|
import TimedPollVote from './utils/proto/TimedPollVote'
|
||||||
import { DetailedTimedPoll } from './models/DetailedTimedPoll'
|
import { DetailedTimedPoll } from './models/DetailedTimedPoll'
|
||||||
@ -51,6 +51,13 @@ class WakuVoting {
|
|||||||
public static async create(appName: string, tokenAddress: string, waku?: Waku) {
|
public static async create(appName: string, tokenAddress: string, waku?: Waku) {
|
||||||
if (!waku) {
|
if (!waku) {
|
||||||
waku = await Waku.create({ bootstrap: true })
|
waku = await Waku.create({ bootstrap: true })
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
waku?.libp2p.peerStore.on('change:protocols', ({ protocols }) => {
|
||||||
|
if (protocols.includes(StoreCodec)) {
|
||||||
|
resolve('')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return new WakuVoting(appName, tokenAddress, waku)
|
return new WakuVoting(appName, tokenAddress, waku)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user