Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/typink/src/hooks/internal/useInitializeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ export function useInitializeClient(network?: NetworkInfo, options?: UseClientOp
useAsync(async () => {
if (client) {
try {
setClient(undefined);
// TODO check this again if the network is not available
await client.disconnect();
} catch (e) {
console.error(e);
}

setClient(undefined);
}

if (!network) {
Expand All @@ -61,7 +62,7 @@ export function useInitializeClient(network?: NetworkInfo, options?: UseClientOp
setReady(false);

// TODO support light-client
const provider: JsonRpcProvider = new WsProvider(network.providers[0]);
const provider: JsonRpcProvider = new WsProvider(network.providers);

if (network.jsonRpcApi === JsonRpcApi.LEGACY) {
setClient(await LegacyClient.new({ provider, cacheMetadata }));
Expand Down