forked from SmartDropLabs/smartdrop-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
76 lines (66 loc) · 2.74 KB
/
Copy pathindex.ts
File metadata and controls
76 lines (66 loc) · 2.74 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
export type StellarNetworkPreset = "PUBLIC" | "TESTNET" | "FUTURENET";
const PRESETS: Record<
StellarNetworkPreset,
{ horizon: string; passphrase: string }
> = {
PUBLIC: {
horizon: "https://horizon.stellar.org",
passphrase: "Public Global Stellar Network ; September 2015",
},
TESTNET: {
horizon: "https://horizon-testnet.stellar.org",
passphrase: "Test SDF Network ; September 2015",
},
FUTURENET: {
horizon: "https://horizon-futurenet.stellar.org",
passphrase: "Test SDF Future Network ; October 2022",
},
};
function presetFromEnv(): StellarNetworkPreset {
const n = (process.env.NEXT_PUBLIC_STELLAR_NETWORK || "TESTNET").toUpperCase();
if (n === "PUBLIC" || n === "MAINNET") return "PUBLIC";
if (n === "FUTURENET") return "FUTURENET";
return "TESTNET";
}
const preset = presetFromEnv();
export const stellarNetwork = preset;
export const horizonUrl =
process.env.NEXT_PUBLIC_HORIZON_URL || PRESETS[preset].horizon;
export const networkPassphrase =
process.env.NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE ||
PRESETS[preset].passphrase;
export const sorobanRpcUrl =
process.env.NEXT_PUBLIC_SOROBAN_RPC_URL ||
(preset === "TESTNET"
? "https://soroban-testnet.stellar.org"
: preset === "FUTURENET"
? "https://rpc-futurenet.stellar.org"
: "https://soroban-mainnet.stellar.org");
/** Soroban factory contract id (starts with C…) after you deploy */
export const factoryContractId =
process.env.NEXT_PUBLIC_FACTORY_CONTRACT_ID ?? "";
/** Soroban pool contract id (starts with C…) holding locked positions */
export const poolContractId = process.env.NEXT_PUBLIC_POOL_CONTRACT_ID ?? "";
/**
* Stellar account used as the source for read-only Soroban simulation calls
* (getFactoryPools, getUserPosition, calculateUserCredits). Must be funded on
* the configured network. No hardcoded fallback — must be set explicitly per
* environment to avoid silent failures when switching networks.
*/
export const simulationAccount = process.env.NEXT_PUBLIC_SIMULATION_ACCOUNT ?? "";
/**
* Minimum lock period (in seconds) enforced by the pool contract before a
* position can be unlocked. Mirrors the on-chain `unlock_assets` time-lock so
* the UI can disable the action and show an accurate countdown. Defaults to 7
* days when the env var is unset or invalid.
*/
export const minLockPeriodSeconds = (() => {
const raw = Number(process.env.NEXT_PUBLIC_MIN_LOCK_PERIOD_SECONDS);
return Number.isFinite(raw) && raw > 0 ? raw : 7 * 24 * 60 * 60;
})();
/**
* Base URL for the smartdrop-backend API (price oracle, airdrops, webhooks,
* alerts). Defaults to the local dev server from that repo's README.
*/
export const backendApiUrl =
process.env.NEXT_PUBLIC_BACKEND_API_URL ?? "http://localhost:4000/api/v1";