From 12b8d1df64a69f1b302d619a3f5021fc8720683f Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Fri, 30 Sep 2022 15:25:26 +0100 Subject: [PATCH] Handle no opts for connect --- src/utils/Network.mjs | 4 ++-- src/utils/QueryClient.mjs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/Network.mjs b/src/utils/Network.mjs index 8b47b272..7be0eabc 100644 --- a/src/utils/Network.mjs +++ b/src/utils/Network.mjs @@ -102,9 +102,9 @@ class Network { this.txTimeout = this.data.txTimeout || 60_000 } - async connect({ timeout }) { + async connect(opts) { try { - this.queryClient = await QueryClient(this.chain.chainId, this.restUrl, { connectTimeout: timeout }) + this.queryClient = await QueryClient(this.chain.chainId, this.restUrl, { connectTimeout: opts?.timeout }) this.restUrl = this.queryClient.restUrl this.connected = this.queryClient.connected && (!this.usingDirectory || this.connectedDirectory()) } catch (error) { diff --git a/src/utils/QueryClient.mjs b/src/utils/QueryClient.mjs index c237e9e1..f645a0fc 100644 --- a/src/utils/QueryClient.mjs +++ b/src/utils/QueryClient.mjs @@ -212,7 +212,7 @@ const QueryClient = async (chainId, restUrls, opts) => { return pages; }; - async function findAvailableUrl(urls, type, { timeout }) { + async function findAvailableUrl(urls, type, opts) { if(!urls) return if (!Array.isArray(urls)) { @@ -223,6 +223,7 @@ const QueryClient = async (chainId, restUrls, opts) => { } } const path = type === "rest" ? "/blocks/latest" : "/block"; + const { timeout } = opts || {} return Promise.any(urls.map(async (url) => { url = url.replace(/\/$/, '') try {