@defillama/sdk 5.0.10 → 5.0.12

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 (40) hide show
  1. package/build/Balances.d.ts +10 -0
  2. package/build/Balances.js +51 -107
  3. package/build/ChainApi.d.ts +1 -0
  4. package/build/ChainApi.js +152 -253
  5. package/build/abi/abi2.js +47 -144
  6. package/build/abi/convertResults.js +9 -29
  7. package/build/abi/index.js +220 -326
  8. package/build/abi/multicall.js +115 -217
  9. package/build/abi/multicall3.js +59 -123
  10. package/build/abi/rpcCall.js +43 -106
  11. package/build/abi/tron.js +153 -283
  12. package/build/api.js +3 -4
  13. package/build/computeTVL/blocks.d.ts +1 -1
  14. package/build/computeTVL/blocks.js +2 -1
  15. package/build/computeTVL/humanizeNumber.js +6 -7
  16. package/build/computeTVL/prices.js +55 -145
  17. package/build/erc20/index.js +34 -122
  18. package/build/eth/index.js +37 -107
  19. package/build/general.js +22 -23
  20. package/build/generalUtil.js +68 -127
  21. package/build/index.js +2 -2
  22. package/build/providers.json +1 -1
  23. package/build/util/blocks.d.ts +5 -2
  24. package/build/util/blocks.js +234 -373
  25. package/build/util/blockscout.js +13 -58
  26. package/build/util/cache.js +112 -274
  27. package/build/util/computeTVL.js +72 -150
  28. package/build/util/cosmos.js +21 -75
  29. package/build/util/debugLog.js +5 -13
  30. package/build/util/env.d.ts +3 -2
  31. package/build/util/env.js +30 -35
  32. package/build/util/index.d.ts +5 -3
  33. package/build/util/index.js +105 -134
  34. package/build/util/internal-cache.js +7 -8
  35. package/build/util/logs.d.ts +1 -2
  36. package/build/util/logs.js +148 -236
  37. package/build/util/promisePool.js +11 -62
  38. package/build/util/r2.js +36 -95
  39. package/build/util/updateProviderList.js +23 -83
  40. package/package.json +2 -3
@@ -1,91 +1,31 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
4
  };
52
5
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var providers_json_1 = __importDefault(require("../providers.json"));
54
- var fs_1 = __importDefault(require("fs"));
55
- var node_fetch_1 = __importDefault(require("node-fetch"));
56
- function fetchJson(url) {
57
- return (0, node_fetch_1.default)(url).then(function (res) { return res.json(); });
58
- }
59
- function main() {
60
- return __awaiter(this, void 0, void 0, function () {
61
- var chainData, existingChainIds, existingChainNames, newList;
62
- return __generator(this, function (_a) {
63
- switch (_a.label) {
64
- case 0: return [4 /*yield*/, fetchJson('https://chainid.network/chains.json')];
65
- case 1:
66
- chainData = _a.sent();
67
- existingChainIds = new Set(Object.values(providers_json_1.default).map(function (i) { return i.chainId; }));
68
- existingChainNames = new Set(Object.keys(providers_json_1.default).map(function (i) { return i.toLowerCase(); }));
69
- chainData = chainData
70
- .filter(function (i) { return i.rpc.length; })
71
- .filter(function (i) { return !i.status || i.status === 'active'; })
72
- .filter(function (i) { return i.shortName; })
73
- .filter(function (i) { return !existingChainIds.has(i.chainId); })
74
- .filter(function (i) { return !existingChainNames.has(i.shortName.toLowerCase()); });
75
- chainData.forEach(function (i) {
76
- i.rpc = i.rpc.filter(function (j) { return !/wss:/.test(j); });
77
- });
78
- newList = __assign({}, providers_json_1.default);
79
- chainData.forEach(function (i) {
80
- newList[i.shortName.toLowerCase()] = {
81
- rpc: i.rpc,
82
- chainId: i.chainId
83
- };
84
- });
85
- fs_1.default.writeFileSync(__dirname + '/../providers.json', JSON.stringify(newList));
86
- return [2 /*return*/];
87
- }
88
- });
6
+ const providers_json_1 = __importDefault(require("../providers.json"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const axios_1 = __importDefault(require("axios"));
9
+ async function main() {
10
+ let { data: chainData } = await (0, axios_1.default)('https://chainid.network/chains.json');
11
+ const existingChainIds = new Set(Object.values(providers_json_1.default).map(i => i.chainId));
12
+ const existingChainNames = new Set(Object.keys(providers_json_1.default).map(i => i.toLowerCase()));
13
+ chainData = chainData
14
+ .filter((i) => i.rpc.length)
15
+ .filter((i) => !i.status || i.status === 'active')
16
+ .filter((i) => i.shortName)
17
+ .filter((i) => !existingChainIds.has(i.chainId))
18
+ .filter((i) => !existingChainNames.has(i.shortName.toLowerCase()));
19
+ chainData.forEach((i) => {
20
+ i.rpc = i.rpc.filter((j) => !/wss:/.test(j));
21
+ });
22
+ const newList = { ...providers_json_1.default };
23
+ chainData.forEach((i) => {
24
+ newList[i.shortName.toLowerCase()] = {
25
+ rpc: i.rpc,
26
+ chainId: i.chainId
27
+ };
89
28
  });
29
+ fs_1.default.writeFileSync(__dirname + '/../providers.json', JSON.stringify(newList));
90
30
  }
91
31
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.10",
3
+ "version": "5.0.12",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -25,14 +25,13 @@
25
25
  "dependencies": {
26
26
  "@aws-sdk/client-s3": "^3.400.0",
27
27
  "@supercharge/promise-pool": "^2.1.0",
28
+ "axios": "^1.6.5",
28
29
  "ethers": "^6.0.0",
29
- "node-fetch": "^2.6.7",
30
30
  "p-limit": "^3.0.0",
31
31
  "tron-format-address": "^0.1.11"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^29.2.3",
35
- "@types/node-fetch": "^2.5.8",
36
35
  "jest": "^29.3.1",
37
36
  "ts-jest": "^29.1.1",
38
37
  "ts-node": "^10.9.1",