From 69e9ec1280439d4134e99bbbf52f05ea23acac45 Mon Sep 17 00:00:00 2001 From: Tyler Shipe Date: Sun, 25 Apr 2021 12:22:28 -0400 Subject: [PATCH] add env var to access devnet --- stores/useMangoStore.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/stores/useMangoStore.tsx b/stores/useMangoStore.tsx index 15217201..ab2a69cf 100644 --- a/stores/useMangoStore.tsx +++ b/stores/useMangoStore.tsx @@ -30,7 +30,10 @@ export const ENDPOINTS: EndpointInfo[] = [ }, ] -const CLUSTER = 'mainnet-beta' +type ClusterType = 'mainnet-beta' | 'devnet' + +const CLUSTER = + (process.env.NEXT_PUBLIC_CLUSTER as ClusterType) || 'mainnet-beta' const ENDPOINT = ENDPOINTS.find((e) => e.name === CLUSTER) const DEFAULT_CONNECTION = new Connection(ENDPOINT.url, 'recent') const WEBSOCKET_CONNECTION = new Connection(ENDPOINT.websocket, 'recent') @@ -63,7 +66,7 @@ interface MangoStore extends State { }> accountInfos: AccountInfoList connection: { - cluster: string + cluster: ClusterType current: Connection websocket: Connection endpoint: string @@ -114,7 +117,9 @@ interface MangoStore extends State { } tradeHistory: any[] set: (x: any) => void - actions: any + actions: { + [key: string]: () => void + } } const useMangoStore = create((set, get) => ({