@defillama/sdk 5.0.182 → 5.0.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,7 +135,7 @@ const blockCacheSaveInterval = 1000 * 60 * 5; // 5 minutes
135
135
  const { data: blockTimeCache, saveCacheFile: saveBlockCacheFile } = (0, cache_1.getTempLocalCache)({ file: 'BlockCache.json', defaultData: {}, clearAfter: cache_1.ONE_WEEK, returnWithSaveFunction: true });
136
136
  function validateCurrentBlock(block, chain = 'ethereum') {
137
137
  // sometimes the chain is halted or facing issues, so we skip the validation for those chains
138
- if ((0, env_1.shouldSkipCurrentBlockValidation)(chain))
138
+ if ((0, env_1.shouldSkipBlockValidation)(chain))
139
139
  return;
140
140
  const provider = getExtraProvider(chain);
141
141
  const now = Math.floor(Date.now() / 1000);
@@ -232,8 +232,9 @@ async function _lookupBlock(timestamp, extraParams) {
232
232
  }
233
233
  if (i > 2 && env_1.ENV_CONSTANTS.GET_BLOCK_STATS)
234
234
  (0, debugLog_1.debugLog)(`chain: ${chain} block: ${block.number} #calls: ${i} imprecision: ${Number((imprecision) / 60).toFixed(2)} (min) Time Taken: ${Number((Date.now() - time) / 1000).toFixed(2)} (in sec)`);
235
- if (chain !== "bsc" && // this check is there because bsc halted the chain for few days
236
- Math.abs(block.timestamp - timestamp) > 3600) {
235
+ if (Math.abs(block.timestamp - timestamp) > 3600
236
+ && chain !== "bsc" // this check is there because bsc halted the chain for few days
237
+ && !(0, env_1.shouldSkipBlockValidation)(chain)) {
237
238
  throw new Error("Block selected is more than 1 hour away from the requested timestamp");
238
239
  }
239
240
  return {
@@ -14,5 +14,5 @@ export declare function getBatchMaxCount(chain: string): number;
14
14
  export declare function getArchivalRPCs(chain: string): string[];
15
15
  export declare function getChainRPCs(chain: string, defaultList?: string[]): string | undefined;
16
16
  export declare function getWhitelistedRPCs(chain: string): string[];
17
- export declare function shouldSkipCurrentBlockValidation(chain: string): boolean;
17
+ export declare function shouldSkipBlockValidation(chain: string): boolean;
18
18
  export declare function getBoolEnvValue(key: string, defaultValue?: boolean): boolean;
package/build/util/env.js CHANGED
@@ -15,7 +15,7 @@ exports.getBatchMaxCount = getBatchMaxCount;
15
15
  exports.getArchivalRPCs = getArchivalRPCs;
16
16
  exports.getChainRPCs = getChainRPCs;
17
17
  exports.getWhitelistedRPCs = getWhitelistedRPCs;
18
- exports.shouldSkipCurrentBlockValidation = shouldSkipCurrentBlockValidation;
18
+ exports.shouldSkipBlockValidation = shouldSkipBlockValidation;
19
19
  exports.getBoolEnvValue = getBoolEnvValue;
20
20
  const whitelistedEnvConstants = [
21
21
  'R2_ENDPOINT', 'R2_ACCESS_KEY_ID', 'R2_SECRET_ACCESS_KEY', 'TRON_PRO_API_KEY', 'COINS_API_KEY',
@@ -134,14 +134,14 @@ function getWhitelistedRPCs(chain) {
134
134
  return getEnvValue(key).split(',');
135
135
  return [];
136
136
  }
137
- let skipCurrentBlockValidationChainSet = null;
138
- function shouldSkipCurrentBlockValidation(chain) {
139
- if (!skipCurrentBlockValidationChainSet) {
140
- const envValue = getEnvValue('SKIP_CURRENT_BLOCK_VALIDATION_CHAINS', '');
137
+ let skipBlockValidationChainSet = null;
138
+ function shouldSkipBlockValidation(chain) {
139
+ if (!skipBlockValidationChainSet) {
140
+ const envValue = getEnvValue('SKIP_BLOCK_VALIDATION_CHAINS', '');
141
141
  const chainList = envValue ? envValue.split(',').map(c => c.trim()) : [];
142
- skipCurrentBlockValidationChainSet = new Set(chainList);
142
+ skipBlockValidationChainSet = new Set(chainList);
143
143
  }
144
- return skipCurrentBlockValidationChainSet.has(chain);
144
+ return skipBlockValidationChainSet.has(chain);
145
145
  }
146
146
  function getBoolEnvValue(key, defaultValue = false) {
147
147
  const envValue = getEnvValue(key);
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.182",
3
+ "version": "5.0.185",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
7
7
  "start": "npm run build && node build/index.js",
8
+ "pack-and-publish": "bash ./scripts/skipTestPatchAndPublish.sh",
8
9
  "build": "tsc",
9
10
  "watch": "tsc --watch",
10
- "load-providers": "wget https://unpkg.com/@defillama/sdk@latest/build/providers.json -O build/providers.json",
11
- "test": "npm run load-providers && TEST_MODE=true LLAMA_DEBUG_MODE='' SDK_DEBUG='' LLAMA_DEBUG_LEVEL2='' jest",
12
- "test-only": "echo 'skipped building providers.json' && TEST_MODE=true LLAMA_DEBUG_MODE='' SDK_DEBUG='' LLAMA_DEBUG_LEVEL2='' jest",
11
+ "load-providers": "mkdir -p build && wget https://unpkg.com/@defillama/sdk@latest/build/providers.json -O build/providers.json",
12
+ "test": "npm run load-providers && TEST_MODE=true LLAMA_DEBUG_MODE='' SDK_DEBUG='' LLAMA_DEBUG_LEVEL2='' LLAMA_DEBUG_LEVEL3='' jest",
13
+ "test-only": "echo 'skipped building providers.json' && TEST_MODE=true LLAMA_DEBUG_MODE='' SDK_DEBUG='' LLAMA_DEBUG_LEVEL2='' LLAMA_DEBUG_LEVEL3='' jest",
13
14
  "test-debug": "TEST_MODE=true jest",
14
15
  "update-providers": "ts-node src/util/updateProviderList.ts",
15
16
  "remove-rpcs": "ts-node src/util/removeRedundantRPCs.ts",