Skip to content

Commit 89805ae

Browse files
committed
fix mainnet wss
1 parent 069b3a2 commit 89805ae

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

services/api/socket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** Services */
2-
import { Server } from "../config"
2+
import { useSocketURL } from "../config"
33

44
/** Store */
55
import { useAppStore } from "@/store/app"
@@ -9,7 +9,7 @@ export let socket = null
99
export const init = () => {
1010
const appStore = useAppStore()
1111

12-
socket = new WebSocket(Server.WSS)
12+
socket = new WebSocket(useSocketURL())
1313

1414
socket.addEventListener("open", (e) => {
1515
/** Head Subscription */

services/api/stats.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/** Services */
2+
import { useServerURL } from "@/services/config"
3+
4+
export const fetchHistogram = async ({ table, func, period }) => {
5+
try {
6+
const url = new URL(`${useServerURL()}/stats/histogram/${table}/${func}/${period}`)
7+
8+
const data = await useFetch(url.href)
9+
return data
10+
} catch (error) {
11+
console.error(error)
12+
}
13+
}
14+
15+
export const fetchSummary = async ({ table, func }) => {
16+
try {
17+
const url = new URL(`${useServerURL()}/stats/summary/${table}/${func}`)
18+
19+
const data = await useFetch(url.href)
20+
return data
21+
} catch (error) {
22+
console.error(error)
23+
}
24+
}

services/config.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ export const Server = {
44
mocha: "https://api-mocha-4.celenium.io/v1",
55
dev: "https://api-dev.celenium.io/v1",
66
},
7-
WSS: "wss://api-dev.celenium.io/v1/ws",
7+
WSS: {
8+
mainnet: "wss://api.celenium.io/v1/ws",
9+
mocha: "wss://api-dev.celenium.io/v1/ws",
10+
dev: "wss://api-dev.celenium.io/v1/ws",
11+
},
812
}
913

1014
export const useServerURL = () => {
@@ -24,3 +28,21 @@ export const useServerURL = () => {
2428
return Server.API.dev
2529
}
2630
}
31+
32+
export const useSocketURL = () => {
33+
const requestURL = useRequestURL()
34+
35+
switch (requestURL.hostname) {
36+
case "celenium.io":
37+
return Server.WSS.mainnet
38+
39+
case "mocha-4.celenium.io":
40+
return Server.WSS.mocha
41+
42+
case "dev.celenium.io":
43+
return Server.WSS.dev
44+
45+
default:
46+
return Server.WSS.dev
47+
}
48+
}

0 commit comments

Comments
 (0)