Skip to content

Commit

Permalink
feat(constant): add PRODUCT_IDS constant for price feed products
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansonhkg committed Dec 20, 2024
1 parent b532c39 commit 741761a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
19 changes: 16 additions & 3 deletions packages/constants/src/lib/constants/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const deprecated = depd('lit-js-sdk:constants:mappers');
*/
export const NETWORK_CONTEXT_BY_NETWORK: {
[key in LIT_NETWORK_VALUES]:
| typeof datilDev
| typeof datilTest
| typeof datil;
| typeof datilDev
| typeof datilTest
| typeof datil;
} = {
'datil-dev': datilDev,
'datil-test': datilTest,
Expand All @@ -31,3 +31,16 @@ export const GLOBAL_OVERWRITE_IPFS_CODE_BY_NETWORK: {
datil: false,
custom: false,
};

/**
* Product IDs used for price feed and node selection
*
* - DECRYPTION (0): Used for decryption operations
* - SIGN (1): Used for signing operations
* - LA (2): Used for Lit Actions execution
*/
export const PRODUCT_IDS = {
DECRYPTION: 0, // For decryption operations
SIGN: 1, // For signing operations
LA: 2, // For Lit Actions execution
} as const;
9 changes: 6 additions & 3 deletions packages/contracts-sdk/src/lib/contracts-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
ParamsMissingError,
InvalidArgumentException,
TransactionError,
PRODUCT_IDS,
} from '@lit-protocol/constants';
import { LogManager, Logger } from '@lit-protocol/logger';
import { TokenInfo } from '@lit-protocol/types';
Expand Down Expand Up @@ -1254,9 +1255,11 @@ export class LitContracts {
}) => {
if (!productIds || productIds.length === 0) {
log('No product IDs provided. Defaulting to 0');

// 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
productIds = [0, 1, 2];
productIds = [
PRODUCT_IDS.DECRYPTION,
PRODUCT_IDS.LA,
PRODUCT_IDS.SIGN,
]
}

const priceFeedContract = await LitContracts.getPriceFeedContract(
Expand Down

0 comments on commit 741761a

Please sign in to comment.