From 88a5ff3c5c19b592726babb0c3b422faa7541af3 Mon Sep 17 00:00:00 2001 From: Danut Date: Thu, 28 Nov 2024 11:41:22 +0200 Subject: [PATCH 1/2] Added custom websocket url support --- .../initApp/websocket/initializeWebsocketConnection.ts | 7 +++++-- src/types/network.types.ts | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/methods/initApp/websocket/initializeWebsocketConnection.ts b/src/core/methods/initApp/websocket/initializeWebsocketConnection.ts index ddc931b..9b8a39a 100644 --- a/src/core/methods/initApp/websocket/initializeWebsocketConnection.ts +++ b/src/core/methods/initApp/websocket/initializeWebsocketConnection.ts @@ -27,7 +27,9 @@ type TimeoutType = NodeJS.Timeout | null; export async function initializeWebsocketConnection() { const { address } = getAccount(); - const { apiAddress } = networkSelector(getStore().getState()); + const { apiAddress, websocketUrl: customWebsocketUrl } = networkSelector( + getStore().getState() + ); let messageTimeout: TimeoutType = null; let batchTimeout: TimeoutType = null; @@ -55,7 +57,8 @@ export async function initializeWebsocketConnection() { // To avoid multiple connections to the same endpoint websocketConnection.status = WebsocketConnectionStatusEnum.PENDING; - const websocketUrl = await getWebsocketUrl(apiAddress); + const websocketUrl = + customWebsocketUrl ?? (await getWebsocketUrl(apiAddress)); if (!websocketUrl) { console.warn('Cannot get websocket URL'); diff --git a/src/types/network.types.ts b/src/types/network.types.ts index 1b4d892..d51ebe7 100644 --- a/src/types/network.types.ts +++ b/src/types/network.types.ts @@ -16,6 +16,7 @@ export interface BaseNetworkType { xAliasAddress?: string; roundDuration: number; metamaskSnapWalletAddress?: string; + websocketUrl?: string; } export interface CurrentNetworkType extends BaseNetworkType { @@ -40,13 +41,14 @@ export interface CustomNetworkType { walletConnectDeepLink?: string; walletConnectBridgeAddresses?: string[]; walletAddress?: string; - metamaskSnapWalletAddress?: string; apiAddress?: string; explorerAddress?: string; skipFetchFromServer?: boolean; apiTimeout?: string; walletConnectV2ProjectId?: string; walletConnectV2Options?: any; + metamaskSnapWalletAddress?: string; + websocketUrl?: string; } export interface ApiNetworkConfigType { From 700d344a85c2a0dfbc8dcec74b0e52fa2916a9e1 Mon Sep 17 00:00:00 2001 From: Danut Date: Thu, 28 Nov 2024 11:59:03 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e1e6e..0bc0405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- [Added custom web socket url support](https://github.com/multiversx/mx-sdk-dapp-core/pull/35) - [Metamask integration](https://github.com/multiversx/mx-sdk-dapp-core/pull/27) - [Extension integration](https://github.com/multiversx/mx-sdk-dapp-core/pull/26) - [Ledger integration](https://github.com/multiversx/mx-sdk-dapp-core/pull/22) @@ -15,9 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Added signMessage](https://github.com/multiversx/mx-sdk-dapp-core/pull/18) ## [[0.0.0-alpha.9]](https://github.com/multiversx/mx-sdk-dapp-core)] - 2024-08-29 + - [CrossWindow login](https://github.com/multiversx/mx-sdk-dapp-core/pull/13) ## [[v0.0.0-alpha.8]](https://github.com/multiversx/mx-sdk-dapp-core/pull/16) - 2024-08-27 + - [Added sdk-web-wallet-cross-window-provider as peer dependency](https://github.com/multiversx/mx-sdk-dapp-core/pull/14) - [Generic login + ExtensionProvider login](https://github.com/multiversx/mx-sdk-dapp-core/pull/12) - [Make middlewares registration more scalable](https://github.com/multiversx/mx-sdk-dapp-core/pull/11)