Skip to content

Commit

Permalink
Move endpoint to env file
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinred committed Sep 9, 2024
1 parent 088ac22 commit 8db6e1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ NEXT_PUBLIC_BUILDER_NEWS_SETTINGS_ID=
AIRTABLE_TOKEN=
# River
RIVER_KEY=
# RPC Endpoint
NEXT_PUBLIC_RPC_ENDPOINT=
17 changes: 5 additions & 12 deletions src/hooks/useTransactionStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export const MAINNET_ENDPOINT = "https://explorer-api.mainnet-beta.solana.com";
*
* @type {string}
*/
export const INTERNAL_MAINNET_ENDPOINT = "";

const isDevelopment = process?.env?.NODE_ENV === "development" || false;
const rpcNodeURL = isDevelopment ? INTERNAL_MAINNET_ENDPOINT : MAINNET_ENDPOINT;
const rpcNodeURL = process.env.NEXT_PUBLIC_RPC_ENDPOINT || "";
if (!rpcNodeURL) {
console.warn("Warning: RPC_ENDPOINT is not set.");
}

// Test for AbortController support.
const isAbortControllerSupported =
Expand Down Expand Up @@ -77,12 +78,6 @@ export const useTransactionStats = ({

const getRPCData = useCallback(
async (getValidatorNodes, getTransactionCount, abortSignal) => {
if (!visible) {
if (isDevelopment) {
console.debug("not visible, or homepage exit");
}
return;
}
try {
// Do *not* batch these queries.
// Batching has been disabled on the homepage's API endpoint.
Expand Down Expand Up @@ -143,11 +138,9 @@ export const useTransactionStats = ({
if (error.name === "AbortError" || error.name === "TypeError") {
return;
}

isDevelopment && console.error("error: ", error);
}
},
[sampleHistoryHours, visible],
[sampleHistoryHours],
);

// Load dynamic statistics only when the component is visible.
Expand Down

0 comments on commit 8db6e1e

Please sign in to comment.