diff --git a/package-lock.json b/package-lock.json index 1323395b8..79e6f91d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6739,10 +6739,11 @@ "license": "0BSD" }, "node_modules/@walletconnect/jsonrpc-provider": { - "version": "1.0.6", - "license": "MIT", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-provider/-/jsonrpc-provider-1.0.9.tgz", + "integrity": "sha512-8CwmiDW42F+F8Qct13lX2x4lJOsi0mNBtUln3VS6TpWioTaL1VfforC/8ULc3tHXv+SNWwAXn2lCZbDcYhdRcA==", "dependencies": { - "@walletconnect/jsonrpc-utils": "^1.0.4", + "@walletconnect/jsonrpc-utils": "^1.0.6", "@walletconnect/safe-json": "^1.0.1", "tslib": "1.14.1" } @@ -6764,8 +6765,9 @@ "license": "0BSD" }, "node_modules/@walletconnect/jsonrpc-utils": { - "version": "1.0.4", - "license": "MIT", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.6.tgz", + "integrity": "sha512-snp0tfkjPiDLQp/jrBewI+9SM33GPV4+Gjgldod6XQ7rFyQ5FZjnBxUkY4xWH0+arNxzQSi6v5iDXjCjSaorpg==", "dependencies": { "@walletconnect/environment": "^1.0.1", "@walletconnect/jsonrpc-types": "^1.0.2", @@ -6777,15 +6779,22 @@ "license": "0BSD" }, "node_modules/@walletconnect/jsonrpc-ws-connection": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.7.tgz", - "integrity": "sha512-iEIWUAIQih0TDF+RRjExZL3jd84UWX/rvzAmQ6fZWhyBP/qSlxGrMuAwNhpk2zj6P8dZuf8sSaaNuWgXFJIa5A==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.10.tgz", + "integrity": "sha512-/tidvjfCXZuYugjF5fOswsNDPoMo9QRML3DFQ0dfNUarL4f5HGqu8NDGerr2n0+4MOX23GsT6Vv2POSwFbvgGw==", "dependencies": { - "@walletconnect/jsonrpc-utils": "^1.0.4", + "@walletconnect/jsonrpc-utils": "^1.0.6", "@walletconnect/safe-json": "^1.0.1", + "events": "^3.3.0", + "tslib": "1.14.1", "ws": "^7.5.1" } }, + "node_modules/@walletconnect/jsonrpc-ws-connection/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + }, "node_modules/@walletconnect/keyvaluestorage": { "version": "1.0.2", "license": "MIT", @@ -25363,9 +25372,9 @@ "license": "Apache-2.0", "dependencies": { "@walletconnect/heartbeat": "1.2.0", - "@walletconnect/jsonrpc-provider": "^1.0.6", + "@walletconnect/jsonrpc-provider": "1.0.9", "@walletconnect/jsonrpc-utils": "^1.0.4", - "@walletconnect/jsonrpc-ws-connection": "^1.0.7", + "@walletconnect/jsonrpc-ws-connection": "1.0.10", "@walletconnect/keyvaluestorage": "^1.0.2", "@walletconnect/logger": "^2.0.1", "@walletconnect/relay-api": "^1.0.9", @@ -25404,7 +25413,6 @@ "@walletconnect/core": "2.4.9", "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.0", - "@walletconnect/jsonrpc-provider": "^1.0.6", "@walletconnect/jsonrpc-utils": "^1.0.4", "@walletconnect/logger": "^2.0.1", "@walletconnect/time": "^1.0.2", @@ -25414,7 +25422,8 @@ "pino": "7.11.0" }, "devDependencies": { - "@walletconnect/jsonrpc-ws-connection": "^1.0.7", + "@walletconnect/jsonrpc-provider": "1.0.9", + "@walletconnect/jsonrpc-ws-connection": "1.0.10", "@walletconnect/relay-api": "^1.0.9", "aws-sdk": "2.1194.0", "lokijs": "^1.5.12" @@ -30293,9 +30302,9 @@ "requires": { "@types/lodash.isequal": "4.5.6", "@walletconnect/heartbeat": "1.2.0", - "@walletconnect/jsonrpc-provider": "^1.0.6", + "@walletconnect/jsonrpc-provider": "1.0.9", "@walletconnect/jsonrpc-utils": "^1.0.4", - "@walletconnect/jsonrpc-ws-connection": "^1.0.7", + "@walletconnect/jsonrpc-ws-connection": "1.0.10", "@walletconnect/keyvaluestorage": "^1.0.2", "@walletconnect/logger": "^2.0.1", "@walletconnect/relay-api": "^1.0.9", @@ -30385,9 +30394,11 @@ } }, "@walletconnect/jsonrpc-provider": { - "version": "1.0.6", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-provider/-/jsonrpc-provider-1.0.9.tgz", + "integrity": "sha512-8CwmiDW42F+F8Qct13lX2x4lJOsi0mNBtUln3VS6TpWioTaL1VfforC/8ULc3tHXv+SNWwAXn2lCZbDcYhdRcA==", "requires": { - "@walletconnect/jsonrpc-utils": "^1.0.4", + "@walletconnect/jsonrpc-utils": "^1.0.6", "@walletconnect/safe-json": "^1.0.1", "tslib": "1.14.1" }, @@ -30410,7 +30421,9 @@ } }, "@walletconnect/jsonrpc-utils": { - "version": "1.0.4", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.6.tgz", + "integrity": "sha512-snp0tfkjPiDLQp/jrBewI+9SM33GPV4+Gjgldod6XQ7rFyQ5FZjnBxUkY4xWH0+arNxzQSi6v5iDXjCjSaorpg==", "requires": { "@walletconnect/environment": "^1.0.1", "@walletconnect/jsonrpc-types": "^1.0.2", @@ -30423,13 +30436,22 @@ } }, "@walletconnect/jsonrpc-ws-connection": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.7.tgz", - "integrity": "sha512-iEIWUAIQih0TDF+RRjExZL3jd84UWX/rvzAmQ6fZWhyBP/qSlxGrMuAwNhpk2zj6P8dZuf8sSaaNuWgXFJIa5A==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.10.tgz", + "integrity": "sha512-/tidvjfCXZuYugjF5fOswsNDPoMo9QRML3DFQ0dfNUarL4f5HGqu8NDGerr2n0+4MOX23GsT6Vv2POSwFbvgGw==", "requires": { - "@walletconnect/jsonrpc-utils": "^1.0.4", + "@walletconnect/jsonrpc-utils": "^1.0.6", "@walletconnect/safe-json": "^1.0.1", + "events": "^3.3.0", + "tslib": "1.14.1", "ws": "^7.5.1" + }, + "dependencies": { + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + } } }, "@walletconnect/keyvaluestorage": { @@ -30510,9 +30532,9 @@ "@walletconnect/core": "2.4.9", "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.0", - "@walletconnect/jsonrpc-provider": "^1.0.6", + "@walletconnect/jsonrpc-provider": "1.0.9", "@walletconnect/jsonrpc-utils": "^1.0.4", - "@walletconnect/jsonrpc-ws-connection": "^1.0.7", + "@walletconnect/jsonrpc-ws-connection": "1.0.10", "@walletconnect/logger": "^2.0.1", "@walletconnect/relay-api": "^1.0.9", "@walletconnect/time": "^1.0.2", diff --git a/packages/core/package.json b/packages/core/package.json index 8d3cc9a32..f81fd23e0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -31,9 +31,9 @@ }, "dependencies": { "@walletconnect/heartbeat": "1.2.0", - "@walletconnect/jsonrpc-provider": "^1.0.6", + "@walletconnect/jsonrpc-provider": "1.0.9", "@walletconnect/jsonrpc-utils": "^1.0.4", - "@walletconnect/jsonrpc-ws-connection": "^1.0.7", + "@walletconnect/jsonrpc-ws-connection": "1.0.10", "@walletconnect/keyvaluestorage": "^1.0.2", "@walletconnect/logger": "^2.0.1", "@walletconnect/relay-api": "^1.0.9", diff --git a/packages/core/src/controllers/relayer.ts b/packages/core/src/controllers/relayer.ts index 1caa61d2d..07359c77a 100644 --- a/packages/core/src/controllers/relayer.ts +++ b/packages/core/src/controllers/relayer.ts @@ -226,6 +226,7 @@ export class Relayer extends IRelayer { relayUrl: this.relayUrl, projectId: this.projectId, auth, + useOnCloseEvent: true, }), ), ); @@ -282,9 +283,10 @@ export class Relayer extends IRelayer { this.attemptToReconnect(); }); - this.provider.on(RELAYER_PROVIDER_EVENTS.error, (err: unknown) => - this.events.emit(RELAYER_EVENTS.error, err), - ); + this.provider.on(RELAYER_PROVIDER_EVENTS.error, (err: unknown) => { + this.logger.error(err); + this.events.emit(RELAYER_EVENTS.error, err); + }); this.events.on(RELAYER_EVENTS.connection_stalled, async () => { await this.restartTransport(); diff --git a/packages/sign-client/package.json b/packages/sign-client/package.json index 27cbe2fbd..3083a61ce 100644 --- a/packages/sign-client/package.json +++ b/packages/sign-client/package.json @@ -40,7 +40,6 @@ "@walletconnect/core": "2.4.9", "@walletconnect/events": "^1.0.1", "@walletconnect/heartbeat": "1.2.0", - "@walletconnect/jsonrpc-provider": "^1.0.6", "@walletconnect/jsonrpc-utils": "^1.0.4", "@walletconnect/logger": "^2.0.1", "@walletconnect/time": "^1.0.2", @@ -50,7 +49,8 @@ "pino": "7.11.0" }, "devDependencies": { - "@walletconnect/jsonrpc-ws-connection": "^1.0.7", + "@walletconnect/jsonrpc-provider": "1.0.9", + "@walletconnect/jsonrpc-ws-connection": "1.0.10", "@walletconnect/relay-api": "^1.0.9", "aws-sdk": "2.1194.0", "lokijs": "^1.5.12" diff --git a/packages/types/src/core/relayer.ts b/packages/types/src/core/relayer.ts index 0db28612b..35488612b 100644 --- a/packages/types/src/core/relayer.ts +++ b/packages/types/src/core/relayer.ts @@ -49,6 +49,7 @@ export declare namespace RelayerTypes { relayUrl: string; sdkVersion: string; projectId?: string; + useOnCloseEvent?: boolean; } } diff --git a/packages/utils/src/misc.ts b/packages/utils/src/misc.ts index aca1c43ad..efa19d5ba 100644 --- a/packages/utils/src/misc.ts +++ b/packages/utils/src/misc.ts @@ -125,10 +125,11 @@ export function formatRelayRpcUrl({ sdkVersion, auth, projectId, + useOnCloseEvent, }: RelayerTypes.RpcUrlParams) { const splitUrl = relayUrl.split("?"); const ua = formatUA(protocol, version, sdkVersion); - const params = { auth, ua, projectId }; + const params = { auth, ua, projectId, useOnCloseEvent: useOnCloseEvent || undefined }; const queryString = appendToQueryString(splitUrl[1] || "", params); return splitUrl[0] + "?" + queryString; } diff --git a/packages/utils/test/misc.spec.ts b/packages/utils/test/misc.spec.ts index 87f4a667f..6bf81e450 100644 --- a/packages/utils/test/misc.spec.ts +++ b/packages/utils/test/misc.spec.ts @@ -22,6 +22,12 @@ const EXPECTED_RPC_URL_2 = formatUA(PROTOCOL, VERSION, SDK_VERSION), )}`; +const EXPECTED_RPC_URL_3 = + RELAY_URL + + `?auth=${AUTH}&projectId=${PROJECT_ID}&ua=${encodeURIComponent( + formatUA(PROTOCOL, VERSION, SDK_VERSION), + )}&useOnCloseEvent=true`; + const SEVEN_DAYS_IN_SECONDS = 604800; describe("Misc", () => { @@ -45,6 +51,17 @@ describe("Misc", () => { auth: AUTH, }), ).to.eql(EXPECTED_RPC_URL_2); + expect( + formatRelayRpcUrl({ + protocol: PROTOCOL, + version: VERSION, + sdkVersion: SDK_VERSION, + relayUrl: RELAY_URL, + projectId: PROJECT_ID, + auth: AUTH, + useOnCloseEvent: true, + }), + ).to.eql(EXPECTED_RPC_URL_3); }); it("hasOverlap", () => { expect(hasOverlap([], [])).to.be.true;