Skip to content

Commit

Permalink
Merge pull request #101 from WalletConnect/feat/disable-provider-test…
Browse files Browse the repository at this point in the history
…-ping

feat: disable provider test ping
  • Loading branch information
ganchoradkov authored May 22, 2023
2 parents 137e338 + 9d18e71 commit 0ad9f76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jsonrpc/http-connection/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@walletconnect/jsonrpc-http-connection",
"description": "HTTP Connection for JSON-RPC",
"version": "1.0.6",
"version": "1.0.7",
"author": "WalletConnect, Inc. <walletconnect.com>",
"license": "MIT",
"homepage": "https://github.com/WalletConnect/walletconnect-utils/",
Expand Down
9 changes: 6 additions & 3 deletions jsonrpc/http-connection/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export class HttpConnection implements IJsonRpcConnection {

private registering = false;

constructor(public url: string) {
constructor(public url: string, public disableProviderPing = false) {
if (!isHttpUrl(url)) {
throw new Error(`Provided URL is not compatible with HTTP connection: ${url}`);
}
this.url = url;
this.disableProviderPing = disableProviderPing;
}

get connected(): boolean {
Expand Down Expand Up @@ -118,8 +119,10 @@ export class HttpConnection implements IJsonRpcConnection {
this.url = url;
this.registering = true;
try {
const body = safeJsonStringify({ id: 1, jsonrpc: "2.0", method: "test", params: [] });
await fetch(url, { ...DEFAULT_FETCH_OPTS, body });
if (!this.disableProviderPing) {
const body = safeJsonStringify({ id: 1, jsonrpc: "2.0", method: "test", params: [] });
await fetch(url, { ...DEFAULT_FETCH_OPTS, body });
}
this.onOpen();
} catch (e) {
const error = this.parseError(e as any);
Expand Down

0 comments on commit 0ad9f76

Please sign in to comment.