@jaw.id/ui 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -54649,15 +54649,13 @@ async function gz(e) {
|
|
|
54649
54649
|
let t = e.replace(/[₮]/g, "T").toUpperCase(), n = mz.get(t);
|
|
54650
54650
|
if (n && Date.now() - n.timestamp < hz) return n.price;
|
|
54651
54651
|
try {
|
|
54652
|
-
let e = await fetch(`https://
|
|
54653
|
-
if (!e.ok) throw Error(`
|
|
54654
|
-
let
|
|
54655
|
-
if (r.Response === "Error") return console.warn(`CryptoCompare error for ${t}:`, r.Message), n?.price ?? 0;
|
|
54656
|
-
let i = r.USD ?? 0;
|
|
54652
|
+
let e = await fetch(`https://data-api.binance.vision/api/v3/ticker/price?symbol=${t}USD`);
|
|
54653
|
+
if (!e.ok) throw Error(`Binance API error: ${e.status}`);
|
|
54654
|
+
let n = await e.json(), r = Number(n.price) || 0;
|
|
54657
54655
|
return mz.set(t, {
|
|
54658
|
-
price:
|
|
54656
|
+
price: r,
|
|
54659
54657
|
timestamp: Date.now()
|
|
54660
|
-
}),
|
|
54658
|
+
}), r;
|
|
54661
54659
|
} catch (e) {
|
|
54662
54660
|
return console.warn(`Failed to fetch ${t} price:`, e), n?.price ?? 0;
|
|
54663
54661
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Fetches the current price in USD for a token by its symbol from
|
|
2
|
+
* Fetches the current price in USD for a token by its symbol from Binance API
|
|
3
3
|
* Results are cached for 5 minutes per symbol to reduce API calls
|
|
4
4
|
* @param symbol - The token symbol (ETH, AVAX, BNB, USDC, etc.)
|
|
5
5
|
* @returns Promise<number> - The token price in USD, or 0 if fetch fails
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenPrice.d.ts","sourceRoot":"","sources":["../../src/utils/tokenPrice.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"tokenPrice.d.ts","sourceRoot":"","sources":["../../src/utils/tokenPrice.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6BrE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|