Skip to content

Commit db4a213

Browse files
committed
trying another approach of globals for the consts
1 parent 981d793 commit db4a213

File tree

5 files changed

+37
-33
lines changed

5 files changed

+37
-33
lines changed

docs/lit-pricing-constants.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Shared constants for Lit Protocol pricing components
2+
// This file is automatically included on every page by Mintlify
3+
4+
window.LitPricingConstants = {
5+
// LitActionPriceComponent enum values
6+
LitActionPriceComponent: {
7+
baseAmount: 0,
8+
runtimeLength: 1,
9+
memoryUsage: 2,
10+
codeLength: 3,
11+
responseLength: 4,
12+
signatures: 5,
13+
broadcasts: 6,
14+
contractCalls: 7,
15+
callDepth: 8,
16+
decrypts: 9,
17+
fetches: 10,
18+
},
19+
20+
// NodePriceMeasurement enum values
21+
NodePriceMeasurement: {
22+
perSecond: 0,
23+
perMegabyte: 1,
24+
perCount: 2,
25+
},
26+
};
27+

docs/snippets/CurrentPricesTable.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { weiToTokens, formatPrice, getNodePriceMeasurement } from './PriceProvider';
2-
3-
import { getLitActionPriceComponent } from './utils';
1+
import { weiToTokens, formatPrice } from './PriceProvider';
42

53
export const CurrentPricesTable = ({ priceData }) => {
4+
// Get constants from window (populated by lit-pricing-constants.js)
5+
const LitActionPriceComponent = window.LitPricingConstants?.LitActionPriceComponent || {};
6+
const NodePriceMeasurement = window.LitPricingConstants?.NodePriceMeasurement || {};
7+
68
// Product IDs
79
const ProductId = {
810
PkpSign: 0,
@@ -19,10 +21,6 @@ export const CurrentPricesTable = ({ priceData }) => {
1921
ProductId.SignSessionKey,
2022
];
2123

22-
// Get enum values from functions
23-
const LitActionPriceComponent = getLitActionPriceComponent();
24-
const NodePriceMeasurement = getNodePriceMeasurement();
25-
2624
const PRODUCT_NAMES = {
2725
[ProductId.PkpSign]: 'PKP Sign',
2826
[ProductId.EncSign]: 'Encrypted Sign',

docs/snippets/ExampleLitActionCosts.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { weiToTokens, formatPrice, getLitActionPriceComponent, getNodePriceMeasurement } from './PriceProvider';
1+
import { weiToTokens, formatPrice } from './PriceProvider';
22

33
export const ExampleLitActionCosts = ({ priceData }) => {
4-
// Get enum values from functions
5-
const LitActionPriceComponent = getLitActionPriceComponent();
6-
const NodePriceMeasurement = getNodePriceMeasurement();
4+
// Get constants from window (populated by lit-pricing-constants.js)
5+
const LitActionPriceComponent = window.LitPricingConstants?.LitActionPriceComponent || {};
6+
const NodePriceMeasurement = window.LitPricingConstants?.NodePriceMeasurement || {};
77
if (!priceData) {
88
return (
99
<div style={{ padding: '20px', textAlign: 'center' }}>

docs/snippets/PriceProvider.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ const PRODUCT_IDS = [
2121
ProductId.SignSessionKey,
2222
];
2323

24-
25-
26-
// NodePriceMeasurement enum values
27-
export const getNodePriceMeasurement = () => ({
28-
perSecond: 0,
29-
perMegabyte: 1,
30-
perCount: 2,
31-
});
24+
// Constants are now in lit-pricing-constants.js and available via window.LitPricingConstants
3225

3326
// PriceFeed ABI (minimal - only functions we need)
3427
const PRICE_FEED_ABI = [

docs/snippets/utils.jsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)