Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/insights/src/config/isomorphic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable n/no-process-env */

import { getPythClusterApiUrl } from "@pythnetwork/client";

/**
* Indicates this is a production-optimized build. Note this does NOT
* necessarily indicate that we're running on a cloud machine or the live build
Expand All @@ -11,3 +13,9 @@
* with the optimized React build, etc.
*/
export const IS_PRODUCTION_BUILD = process.env.NODE_ENV === "production";

export const PYTHNET_RPC =
process.env.NEXT_PUBLIC_PYTHNET_RPC ?? getPythClusterApiUrl("pythnet");
export const PYTHTEST_CONFORMANCE_RPC =
process.env.NEXT_PUBLIC_PYTHTEST_CONFORMANCE_RPC ??
getPythClusterApiUrl("pythtest-conformance");
10 changes: 8 additions & 2 deletions apps/insights/src/services/pyth.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {
PythHttpClient,
PythConnection,
getPythClusterApiUrl,
getPythProgramKeyForCluster,
} from "@pythnetwork/client";
import type { PythPriceCallback } from "@pythnetwork/client/lib/PythConnection";
import { Connection, PublicKey } from "@solana/web3.js";
import { z } from "zod";

import { PYTHNET_RPC, PYTHTEST_CONFORMANCE_RPC } from "../config/isomorphic";

export enum Cluster {
Pythnet,
PythtestConformance,
Expand All @@ -18,6 +19,11 @@ export const ClusterToName = {
[Cluster.PythtestConformance]: "pythtest-conformance",
} as const;

const ClusterToRPC = {
[Cluster.Pythnet]: PYTHNET_RPC,
[Cluster.PythtestConformance]: PYTHTEST_CONFORMANCE_RPC,
} as const;

export const CLUSTER_NAMES = ["pythnet", "pythtest-conformance"] as const;

export const toCluster = (name: (typeof CLUSTER_NAMES)[number]): Cluster => {
Expand All @@ -37,7 +43,7 @@ export const parseCluster = (name: string): Cluster | undefined =>
: undefined;

const mkConnection = (cluster: Cluster) =>
new Connection(getPythClusterApiUrl(ClusterToName[cluster]));
new Connection(ClusterToRPC[cluster]);

const connections = {
[Cluster.Pythnet]: mkConnection(Cluster.Pythnet),
Expand Down
4 changes: 3 additions & 1 deletion apps/insights/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"CLICKHOUSE_USERNAME",
"CLICKHOUSE_PASSWORD",
"SOLANA_RPC",
"DISABLE_ACCESSIBILITY_REPORTING"
"DISABLE_ACCESSIBILITY_REPORTING",
"NEXT_PUBLIC_PYTHNET_RPC",
"NEXT_PUBLIC_PYTHTEST_CONFORMANCE_RPC"
]
},
"fix:lint": {
Expand Down
Loading