From b618a703dc56de6988e50d14d0af281e5fd402a9 Mon Sep 17 00:00:00 2001 From: Pierre Gee Date: Wed, 11 Sep 2024 12:23:47 +0800 Subject: [PATCH] chore(ui-ux): make ocean endpoint configurable via env (#1938) * chore(ui-ux): make ocean endpoint configurable via env * change all ocean endpointss * change all ocean endpointss * fix naming * fix naming --- src/layouts/contexts/WhaleContext.tsx | 28 ++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/layouts/contexts/WhaleContext.tsx b/src/layouts/contexts/WhaleContext.tsx index d461b4c65..12f2cac72 100644 --- a/src/layouts/contexts/WhaleContext.tsx +++ b/src/layouts/contexts/WhaleContext.tsx @@ -33,7 +33,12 @@ export function getWhaleApiClient( ): WhaleApiClient { const network = context.query.network?.toString() ?? getEnvironment().networks[0]; - return newWhaleClient(newOceanOptions(network as EnvironmentNetwork)); + return newWhaleClient( + newOceanOptions( + network as EnvironmentNetwork, + process.env.NEXT_PUBLIC_API_CLIENT_ENDPOINT, + ), + ); } export function getWhaleRpcClient( @@ -41,7 +46,12 @@ export function getWhaleRpcClient( ): WhaleRpcClient { const network = context.query.network?.toString() ?? getEnvironment().networks[0]; - return newRpcClient(newOceanOptions(network as EnvironmentNetwork)); + return newRpcClient( + newOceanOptions( + network as EnvironmentNetwork, + process.env.NEXT_PUBLIC_RPC_CLIENT_ENDPOINT, + ), + ); } export function newPlaygroundRpcClient( @@ -66,10 +76,18 @@ export function WhaleProvider( const connection = useNetwork().connection; const memo = useMemo(() => { - const options = newOceanOptions(connection); + const apiClientOptions = newOceanOptions( + connection, + process.env.NEXT_PUBLIC_API_CLIENT_ENDPOINT, + ); + const rpcClientOptions = newOceanOptions( + connection, + process.env.NEXT_PUBLIC_RPC_CLIENT_ENDPOINT, + ); + return { - api: newWhaleClient(options), - rpc: newRpcClient(options), + api: newWhaleClient(apiClientOptions), + rpc: newRpcClient(rpcClientOptions), }; }, [connection]);