feat: crypto payment system with HD wallets, Freedom.st integration, and checkout UI
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const API = process.env.FREEDOM_API ?? "https://api-v1.freedom.st";
|
||||
|
||||
export async function getChainInfo(): Promise<Record<string, any>> {
|
||||
const res = await fetch(`${API}/rpc/info`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function getExchangeRates(): Promise<Record<string, number>> {
|
||||
const res = await fetch(`${API}/invoice/rates`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function getAddressInfo(address: string): Promise<any> {
|
||||
const res = await fetch(`${API}/address/${address}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function getQrUrl(text: string): string {
|
||||
return `${API}/invoice/qr/${encodeURIComponent(text)}`;
|
||||
}
|
||||
|
||||
/** Returns coin keys where the chain is online (no null uptime field). */
|
||||
export async function getAvailableCoins(): Promise<string[]> {
|
||||
const info = await getChainInfo();
|
||||
return Object.entries(info)
|
||||
.filter(([_, v]) => v && v.uptime != null)
|
||||
.map(([k]) => k);
|
||||
}
|
||||
Reference in New Issue
Block a user