forked from Astrea-Payouts/astrea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkit.ts
More file actions
38 lines (33 loc) · 1.45 KB
/
Copy pathkit.ts
File metadata and controls
38 lines (33 loc) · 1.45 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
"use client";
import { AlbedoModule } from "@creit.tech/stellar-wallets-kit/modules/albedo";
import {
FREIGHTER_ID,
FreighterModule,
} from "@creit.tech/stellar-wallets-kit/modules/freighter";
import { LobstrModule } from "@creit.tech/stellar-wallets-kit/modules/lobstr";
import { xBullModule } from "@creit.tech/stellar-wallets-kit/modules/xbull";
import { StellarWalletsKit } from "@creit.tech/stellar-wallets-kit/sdk";
import { Networks } from "@creit.tech/stellar-wallets-kit/types";
import { STELLAR_NETWORK } from "../stellar-network";
// StellarWalletsKit is a static/global class (v2.5.0 API — verified against
// the installed package's own .d.ts files, not the README, which documents
// an unreleased JSR-only rewrite under a different package name that isn't
// on npm). init() must run exactly once, and only in the browser — this
// module is "use client", but Next.js still executes "use client" module
// top-level code during SSR, so the actual init() call is guarded and
// triggered from a useEffect in the provider, never at import time here.
let initialized = false;
export function initWalletKit() {
if (initialized || typeof window === "undefined") return;
initialized = true;
StellarWalletsKit.init({
network: STELLAR_NETWORK === "mainnet" ? Networks.PUBLIC : Networks.TESTNET,
modules: [
new FreighterModule(),
new AlbedoModule(),
new xBullModule(),
new LobstrModule(),
],
});
}
export { FREIGHTER_ID, StellarWalletsKit };