diff --git a/package-lock.json b/package-lock.json index cb1a193..c63f139 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@ethersproject/hdnode": "^5.7.0", "@ethersproject/providers": "^5.5.3", "@ibm/plex": "^5.1.3", + "@streamr/config": "^5.4.0", "@streamr/sdk": "^101.1.2", "@streamr/utils": "^101.1.2", "@tanstack/react-query": "^5.28.4", diff --git a/package.json b/package.json index 1a0d67e..c1cb004 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@ethersproject/hdnode": "^5.7.0", "@ethersproject/providers": "^5.5.3", "@ibm/plex": "^5.1.3", + "@streamr/config": "^5.4.0", "@streamr/sdk": "^101.1.2", "@streamr/utils": "^101.1.2", "@tanstack/react-query": "^5.28.4", diff --git a/src/components/StreamrClientProvider.tsx b/src/components/StreamrClientProvider.tsx index 75fd316..febfc74 100644 --- a/src/components/StreamrClientProvider.tsx +++ b/src/components/StreamrClientProvider.tsx @@ -1,12 +1,15 @@ -import React from 'react' +import React, { useState } from 'react' import Provider from 'streamr-client-react' +import { getStreamrClientConfig } from '../utils/streams' interface Props { children: React.ReactNode } const StreamrClientProvider = ({ children }: Props) => { - return {children} + const [config] = useState(getStreamrClientConfig()) + + return {children} } export default StreamrClientProvider diff --git a/src/utils/streams.ts b/src/utils/streams.ts index e159543..1dd1ef6 100644 --- a/src/utils/streams.ts +++ b/src/utils/streams.ts @@ -1,4 +1,4 @@ -import { ResendOptions, StreamDefinition, StreamMessage } from '@streamr/sdk' +import { ResendOptions, StreamDefinition, StreamMessage, StreamrClientConfig } from '@streamr/sdk' import { keyToArrayIndex } from '@streamr/utils' import { useQuery } from '@tanstack/react-query' import { useEffect, useMemo, useRef, useState } from 'react' @@ -13,6 +13,7 @@ import { GetStreamsQueryVariables, } from '../generated/gql/indexer' import { getIndexerClient } from './queries' +import { config } from '@streamr/config' function getLimitedStreamsQueryKey(phrase: string, limit: number) { return ['useLimitedStreamsQuery', phrase, limit] @@ -191,10 +192,22 @@ export function useRecentOperatorNodeMetricEntry(nodeId: string) { return recent } +export function getStreamrClientConfig(): StreamrClientConfig { + return { + metrics: false, + contracts: { + ethereumNetwork: { + chainId: config.polygon.id, + }, + rpcs: config.polygon.rpcEndpoints.slice(0, 1) + }, + } +} + async function getStreamrClientInstance() { const StreamrClient = (await import('@streamr/sdk')).default - return new StreamrClient() + return new StreamrClient(getStreamrClientConfig()) } export function useStreamFromClient(streamId: string) {