@defillama/sdk 5.0.236 → 5.0.240

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.
Files changed (131) hide show
  1. package/package.json +3 -3
  2. package/build/Balances.d.ts +0 -139
  3. package/build/Balances.js +0 -363
  4. package/build/ChainApi.d.ts +0 -142
  5. package/build/ChainApi.js +0 -297
  6. package/build/abi/abi2.d.ts +0 -5
  7. package/build/abi/abi2.js +0 -215
  8. package/build/abi/cachedABIs.d.ts +0 -4
  9. package/build/abi/cachedABIs.js +0 -8
  10. package/build/abi/convertResults.d.ts +0 -5
  11. package/build/abi/convertResults.js +0 -60
  12. package/build/abi/index.d.ts +0 -31
  13. package/build/abi/index.js +0 -327
  14. package/build/abi/multicall.d.ts +0 -23
  15. package/build/abi/multicall.js +0 -382
  16. package/build/abi/multicall3.d.ts +0 -7
  17. package/build/abi/multicall3.js +0 -397
  18. package/build/abi/rpcCall.d.ts +0 -4
  19. package/build/abi/rpcCall.js +0 -62
  20. package/build/abi/tron.d.ts +0 -33
  21. package/build/abi/tron.js +0 -110
  22. package/build/api.d.ts +0 -10
  23. package/build/api.js +0 -45
  24. package/build/api2.d.ts +0 -5
  25. package/build/api2.js +0 -41
  26. package/build/chains/algorand.d.ts +0 -277
  27. package/build/chains/algorand.js +0 -618
  28. package/build/chains/aptos.d.ts +0 -230
  29. package/build/chains/aptos.js +0 -612
  30. package/build/chains/cardano.d.ts +0 -242
  31. package/build/chains/cardano.js +0 -407
  32. package/build/chains/cosmos.d.ts +0 -252
  33. package/build/chains/cosmos.js +0 -618
  34. package/build/chains/icp.d.ts +0 -235
  35. package/build/chains/icp.js +0 -1040
  36. package/build/chains/index.d.ts +0 -23
  37. package/build/chains/index.js +0 -59
  38. package/build/chains/near.d.ts +0 -192
  39. package/build/chains/near.js +0 -446
  40. package/build/chains/rpc.d.ts +0 -125
  41. package/build/chains/rpc.js +0 -326
  42. package/build/chains/starknet.d.ts +0 -205
  43. package/build/chains/starknet.js +0 -884
  44. package/build/chains/stellar.d.ts +0 -410
  45. package/build/chains/stellar.js +0 -1082
  46. package/build/chains/substrate.d.ts +0 -333
  47. package/build/chains/substrate.js +0 -1042
  48. package/build/chains/sui.d.ts +0 -365
  49. package/build/chains/sui.js +0 -1135
  50. package/build/chains/svm.d.ts +0 -340
  51. package/build/chains/svm.js +0 -760
  52. package/build/chains/tezos.d.ts +0 -225
  53. package/build/chains/tezos.js +0 -412
  54. package/build/chains/ton.d.ts +0 -353
  55. package/build/chains/ton.js +0 -788
  56. package/build/chains/tron.d.ts +0 -45
  57. package/build/chains/tron.js +0 -110
  58. package/build/chains/utxo.d.ts +0 -202
  59. package/build/chains/utxo.js +0 -592
  60. package/build/chains/xrpl.d.ts +0 -179
  61. package/build/chains/xrpl.js +0 -467
  62. package/build/computeTVL/blocks.d.ts +0 -1
  63. package/build/computeTVL/blocks.js +0 -12
  64. package/build/computeTVL/humanizeNumber.d.ts +0 -1
  65. package/build/computeTVL/humanizeNumber.js +0 -19
  66. package/build/erc20/index.d.ts +0 -31
  67. package/build/erc20/index.js +0 -56
  68. package/build/eth/index.d.ts +0 -22
  69. package/build/eth/index.js +0 -118
  70. package/build/general.d.ts +0 -5
  71. package/build/general.js +0 -20
  72. package/build/generalUtil.d.ts +0 -8
  73. package/build/generalUtil.js +0 -73
  74. package/build/index.d.ts +0 -32
  75. package/build/index.js +0 -74
  76. package/build/providers.json +0 -1
  77. package/build/types.d.ts +0 -76
  78. package/build/types.js +0 -2
  79. package/build/util/LlamaProvider.d.ts +0 -46
  80. package/build/util/LlamaProvider.js +0 -365
  81. package/build/util/blocks.d.ts +0 -36
  82. package/build/util/blocks.js +0 -292
  83. package/build/util/cache.d.ts +0 -45
  84. package/build/util/cache.js +0 -309
  85. package/build/util/chainUtils/data.json +0 -1356
  86. package/build/util/chainUtils/index.d.ts +0 -11
  87. package/build/util/chainUtils/index.js +0 -136
  88. package/build/util/coins.d.ts +0 -19
  89. package/build/util/coins.js +0 -113
  90. package/build/util/common.d.ts +0 -34
  91. package/build/util/common.js +0 -373
  92. package/build/util/computeTVL.d.ts +0 -19
  93. package/build/util/computeTVL.js +0 -102
  94. package/build/util/cosmos.d.ts +0 -1
  95. package/build/util/cosmos.js +0 -8
  96. package/build/util/debugLog.d.ts +0 -4
  97. package/build/util/debugLog.js +0 -18
  98. package/build/util/discord.d.ts +0 -1
  99. package/build/util/discord.js +0 -33
  100. package/build/util/elastic.d.ts +0 -43
  101. package/build/util/elastic.js +0 -113
  102. package/build/util/env.d.ts +0 -19
  103. package/build/util/env.js +0 -158
  104. package/build/util/graph.d.ts +0 -8
  105. package/build/util/graph.js +0 -50
  106. package/build/util/index.d.ts +0 -32
  107. package/build/util/index.js +0 -227
  108. package/build/util/indexer.compatibility.d.ts +0 -6
  109. package/build/util/indexer.compatibility.js +0 -64
  110. package/build/util/indexer.d.ts +0 -92
  111. package/build/util/indexer.js +0 -744
  112. package/build/util/indexerSql.d.ts +0 -9
  113. package/build/util/indexerSql.js +0 -102
  114. package/build/util/internal-cache.d.ts +0 -11
  115. package/build/util/internal-cache.js +0 -77
  116. package/build/util/logs.d.ts +0 -55
  117. package/build/util/logs.decode.shared.d.ts +0 -8
  118. package/build/util/logs.decode.shared.js +0 -289
  119. package/build/util/logs.js +0 -401
  120. package/build/util/promisePool.d.ts +0 -8
  121. package/build/util/promisePool.js +0 -31
  122. package/build/util/r2.d.ts +0 -4
  123. package/build/util/r2.js +0 -52
  124. package/build/util/removeRedundantRPCs.d.ts +0 -1
  125. package/build/util/removeRedundantRPCs.js +0 -49
  126. package/build/util/transactions.d.ts +0 -35
  127. package/build/util/transactions.js +0 -22
  128. package/build/util/updateChainLabels.d.ts +0 -1
  129. package/build/util/updateChainLabels.js +0 -5
  130. package/build/util/updateProviderList.d.ts +0 -1
  131. package/build/util/updateProviderList.js +0 -274
@@ -1,274 +0,0 @@
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 debugLog_1 = require("./debugLog");
9
- const promise_pool_1 = __importDefault(require("@supercharge/promise-pool"));
10
- const generalUtil_1 = require("../generalUtil");
11
- const chainUtils_1 = require("../util/chainUtils");
12
- const concurrentCheckChains = +(process.env.SDK_BUILD_CONCURRENT_CHAINS || 7);
13
- const chainRemovalThreshold = +(process.env.SDK_BUILD_CHAIN_REMOVAL_THRESHOLD || 20);
14
- const droppedTestnetChainsSet = new Set([]);
15
- const providerList = providers_json_1.default;
16
- async function getChainData() {
17
- try {
18
- const chainData = await (0, generalUtil_1.fetchJson)('https://chainlist.org/rpcs.json');
19
- // fix for zksync era name clash
20
- const eteriaListing = chainData.find((i) => i.chainId === 140);
21
- if (eteriaListing)
22
- eteriaListing.shortName = 'eteria';
23
- return chainData;
24
- }
25
- catch (e) {
26
- console.log('Failed to fetch chainlist.org, falling back to local copy');
27
- // https://unpkg.com/@defillama/sdk@latest/build/providers.json
28
- return require(__dirname + '/chainlistOrgCache.json');
29
- }
30
- }
31
- async function main() {
32
- await (0, chainUtils_1.updateChainLabels)();
33
- const oldProviders = await (0, generalUtil_1.fetchJson)(`https://unpkg.com/@defillama/sdk@latest/build/providers.json`);
34
- const currentChains = await (0, generalUtil_1.fetchJson)(`https://raw.githubusercontent.com/DefiLlama/DefiLlama-Adapters/refs/heads/main/projects/helper/chains.json`);
35
- const currentChainsSet = new Set(currentChains);
36
- let chainData = await getChainData();
37
- const providerIDMap = {};
38
- const chainIdToKeyMap = {};
39
- Object.entries(providerList).forEach(([key, i]) => {
40
- providerIDMap[i.chainId] = i.rpc;
41
- chainIdToKeyMap[i.chainId] = key;
42
- });
43
- const shortNameToKeyMap = {};
44
- Object.entries(chainShortNameMapping).forEach(([key, shortName]) => shortNameToKeyMap[shortName] = key);
45
- chainData = chainData
46
- .filter((i) => i.rpc.length)
47
- // .filter((i: any) => !i.status || (i.status === 'active' || i.status === 'incubating'))
48
- .filter((i) => i.shortName)
49
- .filter((i) => {
50
- var _a, _b;
51
- if (currentChainsSet.has(i.shortName))
52
- return true;
53
- const bannedKeys = ['sepolia', 'test', 'goerli', 'devnet', 'holesky',];
54
- const bannedRPCKeys = ['sepolia', 'goerli', 'devnet', 'holesky'];
55
- const isTestnetKey = bannedKeys.some((j) => i.shortName.includes(j));
56
- const hasTestnetRPC = i.rpc.some((rpc) => bannedRPCKeys.some((k) => rpc === null || rpc === void 0 ? void 0 : rpc.url.includes(k)));
57
- const hasTestnetName = ((_a = i.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('testnet')) || ((_b = i.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('devnet'));
58
- if (isTestnetKey || hasTestnetRPC || hasTestnetName) {
59
- droppedTestnetChainsSet.add(i.shortName);
60
- // console.log(`Excluding testnet chain ${i.name} (${i.shortName})`)
61
- }
62
- return !isTestnetKey && !hasTestnetRPC && !hasTestnetName;
63
- });
64
- // trim/remove mainnet|-mainnet|_mainnet from short names, preliminary rpc filtering
65
- const rpcFilterRegex = /(wss\:|ws\:|terminet\.io|huobichain\.com|getblock\.io|bitstack\.com|nodereal.io\/v1|pokt\.network|histori\.xyz|chainstacklabs\.com|owlracle\.info|blastapi\.io)/;
66
- chainData.forEach((i) => {
67
- if (currentChainsSet.has(i.shortName)) {
68
- // keep the short name as is
69
- }
70
- if (i.shortName.endsWith('-mainnet'))
71
- i.shortName = i.shortName.slice(0, -8);
72
- else if (i.shortName.endsWith('_mainnet'))
73
- i.shortName = i.shortName.slice(0, -8);
74
- else if (i.shortName.endsWith('mainnet'))
75
- i.shortName = i.shortName.slice(0, -7);
76
- i.rpc = i.rpc.filter((j) => {
77
- if (!j.url)
78
- return false;
79
- if (rpcFilterRegex.test(j.url)) {
80
- // console.log(`Removing blacklisted rpc ${j.url} from ${i.name}`)
81
- return false; // remove anything with blacklisted words
82
- }
83
- return true;
84
- });
85
- });
86
- // shuffle the array
87
- chainData.sort(() => Math.random() - 0.5);
88
- // chain keys this chain could end up under in providers.json
89
- const getCandidateKeys = (i) => {
90
- const keys = [i.shortName.toLowerCase().replace(/-/g, '_')];
91
- if (chainIdToKeyMap[i.chainId])
92
- keys.push(chainIdToKeyMap[i.chainId]);
93
- if (shortNameToKeyMap[i.shortName])
94
- keys.push(shortNameToKeyMap[i.shortName]);
95
- return keys;
96
- };
97
- // only check rpc health for chains we track and that are not dead, the rest are only filtered statically
98
- const shouldCheckRPCs = (i) => {
99
- const keys = getCandidateKeys(i);
100
- const isTracked = keys.some((k) => currentChainsSet.has(k));
101
- const isDead = keys.some((k) => (0, chainUtils_1.isDeadChain)(k));
102
- return isTracked && !isDead;
103
- };
104
- const skippedRPCChecks = { dead: 0, untracked: 0 };
105
- await promise_pool_1.default
106
- .withConcurrency(concurrentCheckChains)
107
- .for(chainData)
108
- .process(async (i) => {
109
- var _a, _b;
110
- const rpcs = i.rpc.map((j) => j.url);
111
- if (shouldCheckRPCs(i)) {
112
- i.rpc = await filterForWorkingRPCs(rpcs, i.name, i.chainId);
113
- }
114
- else {
115
- if (getCandidateKeys(i).some((k) => (0, chainUtils_1.isDeadChain)(k)))
116
- skippedRPCChecks.dead++;
117
- else
118
- skippedRPCChecks.untracked++;
119
- i.rpc = rpcs.length < 4 ? rpcs : filterRPCs(rpcs);
120
- }
121
- if (!i.rpc.length)
122
- return;
123
- if (providerIDMap[i.chainId]) {
124
- const isBEVM = i.chainId + '' === '11501'; // bevm chain id clashes with
125
- if (!isBEVM)
126
- providerIDMap[i.chainId].push(...i.rpc);
127
- }
128
- else if (providerList[i.shortName.toLowerCase()]) {
129
- (0, debugLog_1.debugLog)(`Duplicate short name ${i.chainId} for ${i.shortName}, doing nothing`);
130
- }
131
- else {
132
- const label = i.shortName.toLowerCase().replace(/-/g, '_');
133
- providerList[label] = {
134
- rpc: i.rpc,
135
- chainId: i.chainId
136
- };
137
- let explorer = (_b = (_a = i.explorers) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.url;
138
- if (explorer)
139
- providerList[label].explorer = explorer;
140
- }
141
- });
142
- Object.entries(providerList).forEach(([key, i]) => {
143
- i.rpc.forEach((j) => {
144
- if (filterRPCs([j]).length === 0) {
145
- (0, debugLog_1.debugLog)(`Removing rpc ${j} from ${key}`);
146
- }
147
- });
148
- i.rpc = Array.from(new Set(filterRPCs(i.rpc)));
149
- });
150
- Object.keys(providerList).forEach((i) => {
151
- if (!providerList[i].rpc.length)
152
- delete providerList[i];
153
- });
154
- for (const [key, shorName] of Object.entries(chainShortNameMapping)) {
155
- if (providerList[key])
156
- continue;
157
- providerList[key] = providerList[shorName];
158
- }
159
- // add from the old providers any missing rpcs that is in the tvl chain list
160
- Object.entries(oldProviders).forEach(([key, i]) => {
161
- if (!currentChainsSet.has(key))
162
- return;
163
- if (providerList[key])
164
- return;
165
- console.log(`Adding missing chain ${key} from old providers`);
166
- providerList[key] = i;
167
- });
168
- const droppedChains = Object.keys(oldProviders).filter(oldChain => providerList[oldChain] === undefined);
169
- const filteredDroppedChains = droppedChains.filter(i => !droppedTestnetChainsSet.has(i) && !i.includes('test'));
170
- console.log('Dropped chains before testnet filtering:', droppedChains.length);
171
- console.log('Dropped chains after testnet filtering:', filteredDroppedChains.length);
172
- if (filteredDroppedChains.length > chainRemovalThreshold) {
173
- throw new Error(`Following chains used to be included but is not anymore, can the devs fix please?\n${filteredDroppedChains.join(', ')}`);
174
- }
175
- delete providerList.bitcoin; // what were they smoking?
176
- const rpcCount = Object.values(providerList).reduce((acc, i) => { var _a; return acc + ((_a = i === null || i === void 0 ? void 0 : i.rpc.length) !== null && _a !== void 0 ? _a : 0); }, 0);
177
- const rpcCountOld = Object.values(oldProviders).reduce((acc, i) => { var _a; return acc + ((_a = i === null || i === void 0 ? void 0 : i.rpc.length) !== null && _a !== void 0 ? _a : 0); }, 0);
178
- const newlyAddedChains = Object.keys(providerList).filter(chain => oldProviders[chain] === undefined);
179
- console.log('Final provider list:');
180
- console.log('Skipped rpc checks (dead chains):', skippedRPCChecks.dead);
181
- console.log('Skipped rpc checks (untracked chains):', skippedRPCChecks.untracked);
182
- console.log('Chain count:', Object.keys(providerList).length);
183
- console.log('Newly added chains count:', newlyAddedChains.length);
184
- console.log('Dropped chain count:', filteredDroppedChains.length);
185
- console.log('RPC count:', rpcCount);
186
- console.log('RPC count current:', rpcCountOld);
187
- console.log('Dropped chains:', filteredDroppedChains.join(', '));
188
- console.log('Newly added chains:', newlyAddedChains.join(', '));
189
- fs_1.default.writeFileSync(__dirname + '/../providers.json', JSON.stringify(providerList));
190
- }
191
- const blacklist = [
192
- 'https://eth.api.onfinality.io/public'
193
- ];
194
- // this is stricter filtering used only when chain has more than 10 rpcs
195
- function filterRPCs(rpc) {
196
- return rpc.filter((i) => {
197
- if (blacklist.includes(i))
198
- return false; // remove rpcs returning bad block heights etc
199
- if (i.endsWith('/demo'))
200
- return false; // remove demo rpc
201
- if (!i.startsWith('http'))
202
- return false; // remove demo rpc
203
- if (i.includes('$'))
204
- return false; // remove anything where api key is injected
205
- // reject websocket, http, testnet, devnet, and anything with '='
206
- if (/(wss\:|ws\:|http\:|test|devnet|terminet|huobichain|getblock|bitstack|nodereal.io\/v1|pokt\.network|ankr\.com|histori\.xyz|chainstacklabs|owlracle|blastapi|routeme|\=)/.test(i))
207
- return false; // remove anything with blacklisted words
208
- return true;
209
- }).map((i) => {
210
- if (i.endsWith('/'))
211
- return i.slice(0, -1);
212
- return i;
213
- });
214
- }
215
- const chainShortNameMapping = {
216
- real: 're-al',
217
- karura: 'karura_evm',
218
- taiko: 'tko-mainnet',
219
- bsquared: 'b2-mainnet',
220
- ox_chain: 'ox-chain',
221
- ailayer: 'ailayer-mainnet',
222
- ontology: 'OntologyMainnet',
223
- occ: 'edu_chain',
224
- hyperliquid: 'hyper_evm',
225
- hydradx: 'hdx',
226
- nibiru: 'cataclysm_1',
227
- fraxtal: 'frax',
228
- elsm: 'ely',
229
- tac: 'tacchain',
230
- xone: 'xoc',
231
- wchain: 'wcn',
232
- hydragon: 'hydra',
233
- camp: 'campmainnet',
234
- mantra: 'mantrachain',
235
- saga: 'sagaevm',
236
- robinhood: 'robinhoodchain',
237
- bcypher: 'bchyper',
238
- area: 'areum',
239
- };
240
- async function filterForWorkingRPCs(rpc, chain, chainId) {
241
- if (rpc.length < 4)
242
- return rpc;
243
- rpc = filterRPCs(rpc);
244
- const filteredRPCs = [];
245
- await (0, generalUtil_1.runInPromisePool)({
246
- items: rpc,
247
- concurrency: concurrentCheckChains,
248
- permitFailure: true,
249
- processor: async (i) => {
250
- try {
251
- const data = await (0, generalUtil_1.postJson)(i, {
252
- jsonrpc: '2.0',
253
- method: 'eth_chainId',
254
- params: [],
255
- id: 1
256
- }, {
257
- timeout: 60000
258
- });
259
- if (data.result) {
260
- const returnedChainId = parseInt(data.result, 16);
261
- if (returnedChainId !== chainId) {
262
- console.log(`RPC ${i} for ${chain} returned invalid chainId ${returnedChainId}, expected ${chainId}`);
263
- }
264
- filteredRPCs.push(i);
265
- }
266
- }
267
- catch (e) {
268
- console.log('ignoring bad rpc', chain, e === null || e === void 0 ? void 0 : e.message);
269
- }
270
- }
271
- });
272
- return filteredRPCs;
273
- }
274
- main();