forked from Astrea-Payouts/astrea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstellar-network.ts
More file actions
30 lines (24 loc) · 1.02 KB
/
Copy pathstellar-network.ts
File metadata and controls
30 lines (24 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Networks } from "@stellar/stellar-sdk";
// Client-safe network config — NO secrets, safe to import from client
// components (unlike src/lib/env.ts, which validates server-only vars like
// TW_API_KEY and would break the client bundle if imported there).
//
// NEXT_PUBLIC_STELLAR_NETWORK is the single source of truth for which
// network the app targets — see src/lib/env.ts for why it's public.
export const STELLAR_ACCOUNT_ID = /^G[A-Z2-7]{55}$/;
export type StellarNetworkName = "testnet" | "mainnet";
export const STELLAR_NETWORK: StellarNetworkName =
process.env.NEXT_PUBLIC_STELLAR_NETWORK === "mainnet" ? "mainnet" : "testnet";
const NETWORK_CONFIG = {
testnet: {
passphrase: Networks.TESTNET,
horizonUrl: "https://horizon-testnet.stellar.org",
},
mainnet: {
passphrase: Networks.PUBLIC,
horizonUrl: "https://horizon.stellar.org",
},
} as const;
export const STELLAR_NETWORK_PASSPHRASE =
NETWORK_CONFIG[STELLAR_NETWORK].passphrase;
export const HORIZON_URL = NETWORK_CONFIG[STELLAR_NETWORK].horizonUrl;