-
-
Notifications
You must be signed in to change notification settings - Fork 361
/
websocket.ts
23 lines (19 loc) · 653 Bytes
/
websocket.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { INDEXERS } from '@kodadot1/static'
import { apolloClientConfig } from './constants'
const wssConfig = {
[INDEXERS.ahk]: 'wss://squid.subsquid.io/stick/graphql',
[INDEXERS.ahp]: 'wss://squid.subsquid.io/speck/graphql',
[INDEXERS.ksm]: 'wss://squid.subsquid.io/marck/v/v2/graphql',
}
export const getWSUrlByClient = (client: string): string | null => {
const endPoint = apolloClientConfig[client]
if (!endPoint) {
return null
}
const { httpEndpoint } = endPoint
const oldWss = wssConfig[httpEndpoint]
if (oldWss) {
return oldWss
}
return httpEndpoint.replace('https://', 'wss://').replace('http://', 'wss://')
}