Skip to content

Commit 0f7a88e

Browse files
committed
fix: circular reference with PRODUCT_IDS
1 parent b04daad commit 0f7a88e

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

local-tests/setup/tinny-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import {
44
CENTRALISATION_BY_NETWORK,
55
LIT_NETWORK,
66
LIT_NETWORK_VALUES,
7+
PRODUCT_IDS,
78
RPC_URL_BY_NETWORK,
89
} from '@lit-protocol/constants';
910
import { LitContracts } from '@lit-protocol/contracts-sdk';
1011
import { LitNodeClient } from '@lit-protocol/lit-node-client';
1112
import {
1213
AuthSig,
13-
PRODUCT_IDS,
1414
LitContractContext,
1515
LitContractResolverContext,
1616
} from '@lit-protocol/types';

packages/constants/src/lib/constants/mappers.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ export const GLOBAL_OVERWRITE_IPFS_CODE_BY_NETWORK: {
2323
'naga-dev': false,
2424
custom: false,
2525
} as const;
26+
27+
/**
28+
* Product IDs used for price feed and node selection
29+
*
30+
* - DECRYPTION (0): Used for decryption operations
31+
* - SIGN (1): Used for signing operations
32+
* - LA (2): Used for Lit Actions execution
33+
*/
34+
export const PRODUCT_IDS = {
35+
DECRYPTION: 0, // For decryption operations
36+
SIGN: 1, // For signing operations
37+
LIT_ACTION: 2, // For Lit Actions execution
38+
} as const;
39+
export type PRODUCT_IDS_TYPE = keyof typeof PRODUCT_IDS;
40+
export type PRODUCT_IDS_VALUES = (typeof PRODUCT_IDS)[keyof typeof PRODUCT_IDS];

packages/contracts-sdk/src/lib/price-feed-info-manager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// import * as util from 'node:util'; // For inspecting bigInt payloads for pricing data
22

3-
import { HTTP, HTTPS } from '@lit-protocol/constants';
3+
import { HTTP, HTTPS, PRODUCT_IDS } from '@lit-protocol/constants';
44
import {
55
LIT_NETWORKS_KEYS,
66
LitContractContext,
77
LitContractResolverContext,
8-
PRODUCT_IDS,
98
} from '@lit-protocol/types';
109

1110
import { LitContracts } from './contracts-sdk';

packages/lit-node-client-nodejs/src/lib/helpers/get-max-prices-for-node-product.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { MaxPriceTooLow } from '@lit-protocol/constants';
2-
import { PRODUCT_IDS } from '@lit-protocol/types';
1+
import { MaxPriceTooLow, PRODUCT_IDS } from '@lit-protocol/constants';
32

43
interface MaxPricesForNodes {
54
nodePrices: { url: string; prices: bigint[] }[];

packages/lit-node-client-nodejs/src/lib/helpers/get-max-prices-for-nodes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PRODUCT_IDS } from '@lit-protocol/types';
1+
import { PRODUCT_IDS } from '@lit-protocol/constants';
22

33
import { getMaxPricesForNodeProduct } from './get-max-prices-for-node-product';
44

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
LOCAL_STORAGE_KEYS,
3434
ParamNullError,
3535
ParamsMissingError,
36+
PRODUCT_IDS,
37+
PRODUCT_IDS_TYPE,
3638
SIWE_URI_PREFIX,
3739
UnknownError,
3840
UnsupportedMethodError,
@@ -71,7 +73,6 @@ import { nacl } from '@lit-protocol/nacl';
7173
import {
7274
AuthMethod,
7375
ExecuteJsValueResponse,
74-
PRODUCT_IDS,
7576
LitNodeSignature,
7677
} from '@lit-protocol/types';
7778
import {
@@ -144,7 +145,7 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
144145
*
145146
* If the user never sets a max price, it means 'unlimited'
146147
*/
147-
defaultMaxPriceByProduct: Record<keyof typeof PRODUCT_IDS, bigint> = {
148+
defaultMaxPriceByProduct: Record<PRODUCT_IDS_TYPE, bigint> = {
148149
DECRYPTION: BigInt(-1),
149150
SIGN: BigInt(-1),
150151
LIT_ACTION: BigInt(-1),
@@ -1536,7 +1537,7 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
15361537
product,
15371538
}: {
15381539
userMaxPrice?: bigint;
1539-
product: keyof typeof PRODUCT_IDS;
1540+
product: PRODUCT_IDS_TYPE;
15401541
}) => {
15411542
log('getMaxPricesForNodeProduct()', { product });
15421543
const getUserMaxPrice = () => {

packages/types/src/lib/ILitNodeClient.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,9 @@ import {
1616
} from './interfaces';
1717
import { ClaimProcessor, ClaimRequest } from './types';
1818

19-
/**
20-
* Product IDs used for price feed and node selection
21-
*
22-
* - DECRYPTION (0): Used for decryption operations
23-
* - SIGN (1): Used for signing operations
24-
* - LA (2): Used for Lit Actions execution
25-
*/
26-
export const PRODUCT_IDS = {
27-
DECRYPTION: 0, // For decryption operations
28-
SIGN: 1, // For signing operations
29-
LIT_ACTION: 2, // For Lit Actions execution
30-
} as const;
19+
// keyof typeof @lit-protocol/constants -> PRODUCT_IDS. Importing creates a circular reference
20+
export type PRODUCT_IDS_TYPE = 'DECRYPTION' | 'SIGN' | 'LIT_ACTION';
21+
export type PRODUCT_IDS_VALUES = 0 | 1 | 2;
3122

3223
export interface ILitNodeClient {
3324
config: LitNodeClientConfig;
@@ -53,7 +44,7 @@ export interface ILitNodeClient {
5344
* @param product - The product type to set the max price for
5445
* @param price - The max price to set
5546
*/
56-
setDefaultMaxPrice(product: keyof typeof PRODUCT_IDS, price: bigint): void;
47+
setDefaultMaxPrice(product: PRODUCT_IDS_TYPE, price: bigint): void;
5748

5849
/**
5950
* Get PKP authentication context
@@ -68,7 +59,7 @@ export interface ILitNodeClient {
6859
*/
6960
getMaxPricesForNodeProduct(params: {
7061
userMaxPrice?: bigint;
71-
product: keyof typeof PRODUCT_IDS;
62+
product: PRODUCT_IDS_TYPE;
7263
}): Promise<{ url: string; price: bigint }[]>;
7364

7465
/**
@@ -96,7 +87,7 @@ export interface ILitNodeClient {
9687

9788
/**
9889
* Execute JS on the nodes and combine and return any resulting signatures
99-
* @param { ExecuteJsRequest } params
90+
* @param { JsonExecutionSdkParams } params
10091
* @returns { ExecuteJsResponse }
10192
*/
10293
executeJs(

0 commit comments

Comments
 (0)