refactor: simplify payment gateway, single evaluatePayment function, clean landing page pricing

This commit is contained in:
2026-03-19 09:42:03 +04:00
parent df638c94f1
commit 632f006988
5 changed files with 146 additions and 332 deletions
+1 -29
View File
@@ -15,8 +15,6 @@ export async function getAddressInfo(address: string): Promise<any> {
return res.json();
}
/** Bulk address lookup — POST /address with { terms: [...] }
* Normalizes response to { address: info } map regardless of API format. */
export async function getAddressInfoBulk(addresses: string[]): Promise<Record<string, any>> {
if (addresses.length === 0) return {};
const res = await fetch(`${API}/address`, {
@@ -24,39 +22,13 @@ export async function getAddressInfoBulk(addresses: string[]): Promise<Record<st
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ terms: addresses }),
});
const data = await res.json();
// Normalize: if response is already keyed by address, return as-is.
// If it's an array, index by address field.
if (Array.isArray(data)) {
const map: Record<string, any> = {};
for (const item of data) {
if (item?.address) map[item.address] = item;
}
return map;
}
// Check if it's keyed by address — verify first value has address-like fields
const firstKey = Object.keys(data)[0];
if (firstKey && data[firstKey]?.address) return data;
// If keyed by index (0, 1, 2...), map back to addresses
if (firstKey === "0" || firstKey === "1") {
const map: Record<string, any> = {};
for (let i = 0; i < addresses.length; i++) {
if (data[i]) map[addresses[i]] = data[i];
}
return map;
}
return data;
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)