@defillama/sdk 5.0.130 → 5.0.133

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.
@@ -106,12 +106,12 @@ class LlamaProvider extends ethers_1.FallbackProvider {
106
106
  runners.splice(1, 0, primaryRunner);
107
107
  }
108
108
  runners = runners.slice(0, attempts);
109
- if (this.chainName === 'rsk' && method === 'getLogs') {
110
- const hostString = (0, env_1.getEnvValue)('RSK_ARCHIVAL_RPC');
111
- if (!hostString)
112
- throw new Error('RSK public nodes dont support getLogs. need to set RSK_ARCHIVAL_RPC');
113
- runners = hostString.split(',').map(host => ({ url: host }));
114
- }
109
+ // if (this.chainName === 'rsk' && method === 'getLogs') {
110
+ // const hostString = getEnvValue('RSK_ARCHIVAL_RPC')
111
+ // if (!hostString)
112
+ // throw new Error('RSK public nodes dont support getLogs. need to set RSK_ARCHIVAL_RPC');
113
+ // (runners as any) = hostString.split(',').map(host => ({ url: host }))
114
+ // }
115
115
  for (const runner of runners) {
116
116
  try {
117
117
  const result = await httpRPC[method](runner.url, params);
@@ -48,7 +48,7 @@ export type IndexerGetTokenTransfersOptions = {
48
48
  offset?: number;
49
49
  debugMode?: boolean;
50
50
  fromAddressFilter?: string | string[];
51
- transferType?: 'in' | 'out';
51
+ transferType?: 'in' | 'out' | 'all';
52
52
  tokens?: string | string[];
53
53
  token?: string;
54
54
  };
@@ -313,11 +313,23 @@ async function getTokenTransfers({ chain = 'ethereum', fromAddressFilter, fromBl
313
313
  limit,
314
314
  offset,
315
315
  tokens,
316
+ from_address: false,
317
+ to_address: false,
316
318
  };
317
- if (transferType === 'in')
318
- params.to_address = true;
319
- else
320
- params.from_address = true;
319
+ switch (transferType) {
320
+ case 'in':
321
+ params.to_address = true;
322
+ break;
323
+ case 'out':
324
+ params.from_address = true;
325
+ break;
326
+ case 'all':
327
+ params.from_address = true;
328
+ params.to_address = true;
329
+ break;
330
+ default:
331
+ throw new Error('Invalid transferType');
332
+ }
321
333
  const { data: { transfers: _logs, totalCount } } = await axiosIndexer(`/token-transfers`, { params, });
322
334
  logs.push(..._logs);
323
335
  offset += limit;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const providers_json_1 = __importDefault(require("../providers.json"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const providerList = providers_json_1.default;
10
+ async function getChainData() {
11
+ try {
12
+ const { data: chainData } = await (0, axios_1.default)('https://chainlist.org/rpcs.json');
13
+ return chainData;
14
+ }
15
+ catch (e) {
16
+ console.log('Failed to fetch chainlist.org, falling back to local copy');
17
+ // https://unpkg.com/@defillama/sdk@latest/build/providers.json
18
+ return require(__dirname + '/chainlistOrgCache.json');
19
+ }
20
+ }
21
+ async function main() {
22
+ let chainData = await getChainData();
23
+ const providerIDMap = {};
24
+ Object.values(chainData).forEach((i) => providerIDMap[i.chainId] = {
25
+ ...i,
26
+ rpc: new Set(i.rpc.map((j) => j.url))
27
+ });
28
+ Object.entries(providerList).forEach(([key, data]) => {
29
+ const chainListdata = providerIDMap[data.chainId];
30
+ if (!chainListdata)
31
+ return;
32
+ data.rpc = data.rpc.filter((i) => {
33
+ if (i.endsWith('/'))
34
+ i = i.slice(0, -1);
35
+ if (chainListdata.rpc.has(i)) {
36
+ console.log(`Removing rpc ${i} from ${key} as it is already in chainlist`);
37
+ return false;
38
+ }
39
+ return true;
40
+ });
41
+ if (!data.rpc.length && chainListdata.shortName === key) {
42
+ delete providerList[key];
43
+ console.log(`Removing ${key} as it has no rpcs left`);
44
+ return;
45
+ }
46
+ });
47
+ fs_1.default.writeFileSync(__dirname + '/../providers.json', JSON.stringify(providers_json_1.default, null, 2));
48
+ }
49
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.130",
3
+ "version": "5.0.133",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@
9
9
  "watch": "tsc --watch",
10
10
  "test": "LLAMA_DEBUG_MODE='' SDK_DEBUG='' jest",
11
11
  "update-providers": "ts-node src/util/updateProviderList.ts",
12
+ "remove-rpcs": "ts-node src/util/removeRedundantRPCs.ts",
12
13
  "format": "prettier --write \"src/**/*.ts\"",
13
14
  "prepublishOnly": "npm run build"
14
15
  },