From 085c4d28ba3fb02a54405ccc586b17cc3e1ac4e5 Mon Sep 17 00:00:00 2001 From: Szymon Szlachtowicz <38212223+Szymx95@users.noreply.github.com> Date: Wed, 1 Sep 2021 13:16:39 +0200 Subject: [PATCH] Fix js waku (#36) --- packages/core/src/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 7144c71..2dc574b 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -4,7 +4,7 @@ import { PollInitMsg } from './models/PollInitMsg' import { PollType } from './types/PollType' import { BigNumber, Wallet } from 'ethers' import PollInit from './utils/proto/PollInit' -import { WakuMessage } from 'js-waku' +import { WakuMessage, StoreCodec } from 'js-waku' import { TimedPollVoteMsg } from './models/TimedPollVoteMsg' import TimedPollVote from './utils/proto/TimedPollVote' import { DetailedTimedPoll } from './models/DetailedTimedPoll' @@ -51,6 +51,13 @@ class WakuVoting { public static async create(appName: string, tokenAddress: string, waku?: Waku) { if (!waku) { 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) }