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 1 commit
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
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
Loading