@defillama/sdk 5.0.126 → 5.0.130
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.
package/build/util/blocks.js
CHANGED
|
@@ -10,7 +10,6 @@ const generalUtil_1 = require("../generalUtil");
|
|
|
10
10
|
const debugLog_1 = require("./debugLog");
|
|
11
11
|
const cosmos_1 = require("./cosmos");
|
|
12
12
|
const cache_1 = require("./cache");
|
|
13
|
-
const blockscout_1 = require("./blockscout");
|
|
14
13
|
const p_limit_1 = __importDefault(require("p-limit"));
|
|
15
14
|
const env_1 = require("./env");
|
|
16
15
|
const defaultChains = ["avax", "bsc", "polygon", "arbitrum"];
|
|
@@ -159,16 +158,6 @@ async function _lookupBlock(timestamp, extraParams) {
|
|
|
159
158
|
var _a, _b;
|
|
160
159
|
const { allowedTimeRange = 5 * 60, acceptableBlockImprecision = 10 } = extraParams !== null && extraParams !== void 0 ? extraParams : {};
|
|
161
160
|
const chain = (_a = extraParams === null || extraParams === void 0 ? void 0 : extraParams.chain) !== null && _a !== void 0 ? _a : "ethereum";
|
|
162
|
-
if (blockscout_1.blockscoutEndpoints[chain]) {
|
|
163
|
-
try {
|
|
164
|
-
const block = await (0, blockscout_1.getBlockscoutBlock)(timestamp, chain);
|
|
165
|
-
addBlockToCache(block);
|
|
166
|
-
return block;
|
|
167
|
-
}
|
|
168
|
-
catch (e) { // fallback to usual way of fetching logs
|
|
169
|
-
(0, debugLog_1.debugLog)('error fetching block from blockscout', e, chain);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
161
|
if (chain === 'waves') {
|
|
173
162
|
const api = `https://nodes.wavesnodes.com/blocks/heightByTimestamp/${timestamp}`;
|
|
174
163
|
const { data } = await (0, axios_1.default)(api);
|
|
@@ -40,7 +40,9 @@ async function main() {
|
|
|
40
40
|
if (!i.rpc.length)
|
|
41
41
|
return;
|
|
42
42
|
if (providerIDMap[i.chainId]) {
|
|
43
|
-
|
|
43
|
+
const isBEVM = i.chainId + '' === '11501'; // bevm chain id clashes with
|
|
44
|
+
if (!isBEVM)
|
|
45
|
+
providerIDMap[i.chainId].push(...i.rpc);
|
|
44
46
|
}
|
|
45
47
|
else if (providerList[i.shortName.toLowerCase()]) {
|
|
46
48
|
(0, debugLog_1.debugLog)(`Duplicate short name ${i.chainId} for ${i.shortName}, doing nothing`);
|
|
@@ -98,7 +100,7 @@ function filterRPCs(rpc) {
|
|
|
98
100
|
if (i.includes('$'))
|
|
99
101
|
return false; // remove anything where api key is injected
|
|
100
102
|
// reject websocket, http, testnet, devnet, and anything with '='
|
|
101
|
-
if (/(wss\:|ws\:|http\:|test|devnet|terminet\.io|huobichain\.com|getblock\.io|bitstack\.com|nodereal.io\/v1|pokt\.network|\=)/.test(i))
|
|
103
|
+
if (/(wss\:|ws\:|http\:|test|devnet|terminet\.io|huobichain\.com|getblock\.io|bitstack\.com|nodereal.io\/v1|pokt\.network|ankr\.com|\=)/.test(i))
|
|
102
104
|
return false; // remove anything with blacklisted words
|
|
103
105
|
return true;
|
|
104
106
|
}).map((i) => {
|
package/package.json
CHANGED
package/build/util/blockscout.js
DELETED
|
@@ -1,26 +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
|
-
exports.getBlockscoutBlock = exports.blockscoutEndpoints = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
exports.blockscoutEndpoints = {
|
|
9
|
-
celo: 'https://explorer.celo.org',
|
|
10
|
-
onus: 'https://explorer.onuschain.io',
|
|
11
|
-
base: 'https://base.blockscout.com',
|
|
12
|
-
// scroll: 'https://blockscout.scroll.io',
|
|
13
|
-
canto: 'https://explorer.plexnode.wtf',
|
|
14
|
-
};
|
|
15
|
-
async function getBlockscoutBlock(timestamp, chain) {
|
|
16
|
-
const api = `${exports.blockscoutEndpoints[chain]}/api?module=block&action=getblocknobytime×tamp=${timestamp}&closest=before`;
|
|
17
|
-
const { data } = await (0, axios_1.default)(api);
|
|
18
|
-
if (data.status !== '1')
|
|
19
|
-
throw new Error('Issue fetching block from blockscout: ' + api);
|
|
20
|
-
return {
|
|
21
|
-
timestamp,
|
|
22
|
-
block: +data.result.blockNumber,
|
|
23
|
-
number: +data.result.blockNumber,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.getBlockscoutBlock = getBlockscoutBlock;
|