Skip to content

Commit 7a9ce0a

Browse files
committed
cleanup
1 parent e6a86a6 commit 7a9ce0a

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

docs/snippets/CurrentPricesTable.jsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ const ProductId = {
3838
SignSessionKey: 3,
3939
};
4040

41+
// Product IDs array used for fetching prices
42+
const PRODUCT_IDS = [
43+
ProductId.PkpSign,
44+
ProductId.EncSign,
45+
ProductId.LitAction,
46+
ProductId.SignSessionKey,
47+
];
48+
4149
// LitActionPriceComponent enum values
4250
const LitActionPriceComponent = {
4351
baseAmount: 0,
@@ -247,28 +255,20 @@ export function CurrentPricesTable() {
247255
const priceUSD = await getLitKeyPrice();
248256
setLitKeyPriceUSD(priceUSD);
249257

250-
// Get product IDs
251-
const productIds = [
252-
ProductId.PkpSign,
253-
ProductId.EncSign,
254-
ProductId.LitAction,
255-
ProductId.SignSessionKey,
256-
];
257-
258258
// Fetch base prices
259259
const basePricesResult = await publicClient.readContract({
260260
address: NAGA_PROD_PRICE_FEED_ADDRESS,
261261
abi: PRICE_FEED_ABI,
262262
functionName: 'baseNetworkPrices',
263-
args: [productIds],
263+
args: [PRODUCT_IDS],
264264
});
265265

266266
// Fetch max prices
267267
const maxPricesResult = await publicClient.readContract({
268268
address: NAGA_PROD_PRICE_FEED_ADDRESS,
269269
abi: PRICE_FEED_ABI,
270270
functionName: 'maxNetworkPrices',
271-
args: [productIds],
271+
args: [PRODUCT_IDS],
272272
});
273273

274274
// Fetch current prices (we'll estimate at 50% usage for now)
@@ -279,7 +279,7 @@ export function CurrentPricesTable() {
279279
address: NAGA_PROD_PRICE_FEED_ADDRESS,
280280
abi: PRICE_FEED_ABI,
281281
functionName: 'usagePercentToPrices',
282-
args: [estimatedUsage, productIds],
282+
args: [estimatedUsage, PRODUCT_IDS],
283283
});
284284

285285
// Fetch LitAction price configs
@@ -317,19 +317,12 @@ export function CurrentPricesTable() {
317317
<div style={{ padding: '20px', color: 'red' }}>
318318
<p>Error loading prices: {error}</p>
319319
<p style={{ fontSize: '0.9em', marginTop: '10px' }}>
320-
Please ensure you have an internet connection and try refreshing the page.
320+
Unable to fetch pricing data. Please check your connection or try again later.
321321
</p>
322322
</div>
323323
);
324324
}
325325

326-
const productIds = [
327-
ProductId.PkpSign,
328-
ProductId.EncSign,
329-
ProductId.LitAction,
330-
ProductId.SignSessionKey,
331-
];
332-
333326
return (
334327
<div style={{ marginTop: '20px', marginBottom: '20px' }}>
335328
{litKeyPriceUSD && (
@@ -392,7 +385,7 @@ export function CurrentPricesTable() {
392385
</tr>
393386
</thead>
394387
<tbody>
395-
{productIds.map((productId, index) => {
388+
{PRODUCT_IDS.map((productId, index) => {
396389
const basePriceInTokens = weiToTokens(basePrices[index]);
397390
const maxPriceInTokens = weiToTokens(maxPrices[index]);
398391
const currentPriceInTokens = weiToTokens(currentPrices[index]);
@@ -534,5 +527,4 @@ export function CurrentPricesTable() {
534527
</div>
535528
</div>
536529
);
537-
}
538-
530+
}

0 commit comments

Comments
 (0)