Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom web socket url support #35

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion src/types/network.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface BaseNetworkType {
xAliasAddress?: string;
roundDuration: number;
metamaskSnapWalletAddress?: string;
websocketUrl?: string;
}

export interface CurrentNetworkType extends BaseNetworkType {
Expand All @@ -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 {
Expand Down