From 0b25379bd4d391747a1712c55b3b0456e38f8764 Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Tue, 26 Mar 2024 15:42:44 +0900 Subject: [PATCH] update dependencies (#112) * update dependencies * f --- packages/DApp/package.json | 2 +- packages/DApp/src/hooks/useCommunities.ts | 5 +++-- packages/DApp/src/lib/request-client.ts | 14 ++++++++++++++ yarn.lock | 8 ++++---- 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 packages/DApp/src/lib/request-client.ts diff --git a/packages/DApp/package.json b/packages/DApp/package.json index 23c6595..f623bc8 100644 --- a/packages/DApp/package.json +++ b/packages/DApp/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@libp2p/bootstrap": "^9.0.10", - "@status-im/js": "0.5.1", + "@status-im/js": "0.6.1", "@usedapp/core": "^1.2.8", "@waku/core": "^0.0.27", "@waku/sdk": "^0.0.22", diff --git a/packages/DApp/src/hooks/useCommunities.ts b/packages/DApp/src/hooks/useCommunities.ts index b7802dd..8295f98 100644 --- a/packages/DApp/src/hooks/useCommunities.ts +++ b/packages/DApp/src/hooks/useCommunities.ts @@ -4,9 +4,10 @@ import { useEffect } from 'react' import { useContractCalls } from '@usedapp/core' import { useContracts } from './useContracts' import { useWaku } from '../providers/waku/provider' -import { deserializePublicKey, RequestClient } from '@status-im/js' +import { deserializePublicKey } from '@status-im/js' import { BigNumber } from 'ethers' import { useFeaturedVotes } from './useFeaturedVotes' +import { getRequestClient } from '../lib/request-client' export function useCommunities(publicKeys: string[]): CommunityDetail[] { const { communitiesDetails, dispatch } = useCommunitiesProvider() @@ -39,7 +40,7 @@ export function useCommunities(publicKeys: string[]): CommunityDetail[] { return } - const requestClient = new RequestClient(waku) + const requestClient = getRequestClient(waku) const community = await requestClient.fetchCommunityDescription(deserializedPublicKey) if (!community) { diff --git a/packages/DApp/src/lib/request-client.ts b/packages/DApp/src/lib/request-client.ts new file mode 100644 index 0000000..8ed2523 --- /dev/null +++ b/packages/DApp/src/lib/request-client.ts @@ -0,0 +1,14 @@ +import { RequestClient } from '@status-im/js' +import { LightNode } from '@waku/interfaces' + +let client: RequestClient + +export function getRequestClient(waku: LightNode): RequestClient { + if (!client) { + client = new RequestClient(waku, { environment: process.env.ENV, ethProviderApiKey: process.env.INFURA_API_KEY! }) + + return client + } + + return client +} diff --git a/yarn.lock b/yarn.lock index 1995ed1..31dd9f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2570,10 +2570,10 @@ dependencies: antlr4ts "^0.5.0-alpha.4" -"@status-im/js@0.5.1": - version "0.5.1" - resolved "https://registry.yarnpkg.com/@status-im/js/-/js-0.5.1.tgz#cca1c2637a21ec23094cde965f864e8204818af1" - integrity sha512-a8/EsuMY+aTExSuVN7DGZXaSQaUeY20z44iJC4oR20l1GRlBXTt1H6BDVPULZSi4agmPuoVwcAKbIorzTg3iIw== +"@status-im/js@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@status-im/js/-/js-0.6.1.tgz#0e6ad504b79d661e1b5f93b3f7b68d9487ad8bad" + integrity sha512-VTWu/vv8Rp3N/j7Q66EAnxMz1dg3e1XFu/9DaFbM/5t+rT818Fu/0etqu46UlPv0XAyvodxPrM0RxvPfSUb0Vw== dependencies: "@bufbuild/protobuf" "1.4.2" "@libp2p/bootstrap" "^9.0.10"