Skip to content

Commit 741761a

Browse files
committed
feat(constant): add PRODUCT_IDS constant for price feed products
1 parent b532c39 commit 741761a

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const deprecated = depd('lit-js-sdk:constants:mappers');
1111
*/
1212
export const NETWORK_CONTEXT_BY_NETWORK: {
1313
[key in LIT_NETWORK_VALUES]:
14-
| typeof datilDev
15-
| typeof datilTest
16-
| typeof datil;
14+
| typeof datilDev
15+
| typeof datilTest
16+
| typeof datil;
1717
} = {
1818
'datil-dev': datilDev,
1919
'datil-test': datilTest,
@@ -31,3 +31,16 @@ export const GLOBAL_OVERWRITE_IPFS_CODE_BY_NETWORK: {
3131
datil: false,
3232
custom: false,
3333
};
34+
35+
/**
36+
* Product IDs used for price feed and node selection
37+
*
38+
* - DECRYPTION (0): Used for decryption operations
39+
* - SIGN (1): Used for signing operations
40+
* - LA (2): Used for Lit Actions execution
41+
*/
42+
export const PRODUCT_IDS = {
43+
DECRYPTION: 0, // For decryption operations
44+
SIGN: 1, // For signing operations
45+
LA: 2, // For Lit Actions execution
46+
} as const;

packages/contracts-sdk/src/lib/contracts-sdk.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
ParamsMissingError,
6666
InvalidArgumentException,
6767
TransactionError,
68+
PRODUCT_IDS,
6869
} from '@lit-protocol/constants';
6970
import { LogManager, Logger } from '@lit-protocol/logger';
7071
import { TokenInfo } from '@lit-protocol/types';
@@ -1254,9 +1255,11 @@ export class LitContracts {
12541255
}) => {
12551256
if (!productIds || productIds.length === 0) {
12561257
log('No product IDs provided. Defaulting to 0');
1257-
1258-
// You should use all [0,1,2] because we fetch the price first to connect to the cheapest node. And after that the user calls the actual function
1259-
productIds = [0, 1, 2];
1258+
productIds = [
1259+
PRODUCT_IDS.DECRYPTION,
1260+
PRODUCT_IDS.LA,
1261+
PRODUCT_IDS.SIGN,
1262+
]
12601263
}
12611264

12621265
const priceFeedContract = await LitContracts.getPriceFeedContract(

0 commit comments

Comments
 (0)