@defillama/sdk 2.3.54 → 2.3.55
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/general.js +2 -1
- package/build/util/index.js +16 -12
- package/package.json +1 -1
package/build/general.js
CHANGED
|
@@ -44,7 +44,7 @@ exports.providers = {
|
|
|
44
44
|
celo: createProvider("celo", "https://forno.celo.org", 42220),
|
|
45
45
|
iotex: createProvider("iotex", "https://babel-api.mainnet.iotex.io", 4689),
|
|
46
46
|
moonriver: createProvider("moonriver", "https://rpc.api.moonriver.moonbeam.network/,https://moonriver.api.onfinality.io/public", 1285),
|
|
47
|
-
shiden: createProvider("shiden", "https://rpc.
|
|
47
|
+
shiden: createProvider("shiden", "https://rpc.astar.network:8545,https://astar.api.onfinality.io/public", 336),
|
|
48
48
|
palm: createProvider("palm", "https://palm-mainnet.infura.io/v3/3a961d6501e54add9a41aa53f15de99b", 11297108109),
|
|
49
49
|
energyweb: createProvider("energyweb", "https://rpc.energyweb.org", 246),
|
|
50
50
|
songbird: createProvider("songbird", "https://songbird.towolabs.com/rpc", 19),
|
|
@@ -85,6 +85,7 @@ exports.providers = {
|
|
|
85
85
|
conflux: createProvider("conflux", "https://evm.confluxrpc.com", 1030),
|
|
86
86
|
milkomeda: createProvider("milkomeda", "https://rpc-mainnet-cardano-evm.c1.milkomeda.com", 2001),
|
|
87
87
|
dfk: createProvider("dfk", "https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc", 53935),
|
|
88
|
+
crab: createProvider("crab", "https://crab-rpc.darwinia.network", 44),
|
|
88
89
|
};
|
|
89
90
|
function getProvider(chain) {
|
|
90
91
|
if (chain === void 0) { chain = "ethereum"; }
|
package/build/util/index.js
CHANGED
|
@@ -115,19 +115,23 @@ function getLatestBlock(chain) {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
exports.getLatestBlock = getLatestBlock;
|
|
118
|
+
var intialBlocks = {
|
|
119
|
+
terra: 4724001,
|
|
120
|
+
crab: 4969901
|
|
121
|
+
};
|
|
118
122
|
function lookupBlock(timestamp, extraParams) {
|
|
119
|
-
var _a, _b, _c;
|
|
123
|
+
var _a, _b, _c, _d, _e;
|
|
120
124
|
if (extraParams === void 0) { extraParams = {}; }
|
|
121
125
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
126
|
var provider, lastBlock, high, low, block, mid, e_1;
|
|
123
|
-
return __generator(this, function (
|
|
124
|
-
switch (
|
|
127
|
+
return __generator(this, function (_f) {
|
|
128
|
+
switch (_f.label) {
|
|
125
129
|
case 0:
|
|
126
|
-
|
|
130
|
+
_f.trys.push([0, 6, , 7]);
|
|
127
131
|
provider = getExtraProvider(extraParams.chain);
|
|
128
132
|
return [4 /*yield*/, getBlock(provider, "latest", extraParams.chain)];
|
|
129
133
|
case 1:
|
|
130
|
-
lastBlock =
|
|
134
|
+
lastBlock = _f.sent();
|
|
131
135
|
if ((lastBlock.timestamp - timestamp) < -30 * 60) {
|
|
132
136
|
throw new Error("Last block of chain \"" + extraParams.chain + "\" is further than 30 minutes into the past. Provider is \"" + ((_b = (_a = provider) === null || _a === void 0 ? void 0 : _a.connection) === null || _b === void 0 ? void 0 : _b.url) + "\"");
|
|
133
137
|
}
|
|
@@ -139,24 +143,24 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
139
143
|
}];
|
|
140
144
|
}
|
|
141
145
|
high = lastBlock.number;
|
|
142
|
-
low = (extraParams === null || extraParams === void 0 ? void 0 : extraParams.chain)
|
|
146
|
+
low = (_d = intialBlocks[(_c = extraParams === null || extraParams === void 0 ? void 0 : extraParams.chain) !== null && _c !== void 0 ? _c : "ethereum"]) !== null && _d !== void 0 ? _d : 0;
|
|
143
147
|
block = void 0;
|
|
144
|
-
|
|
148
|
+
_f.label = 2;
|
|
145
149
|
case 2:
|
|
146
150
|
mid = Math.floor((high + low) / 2);
|
|
147
151
|
return [4 /*yield*/, getBlock(provider, mid, extraParams.chain)];
|
|
148
152
|
case 3:
|
|
149
|
-
block =
|
|
153
|
+
block = _f.sent();
|
|
150
154
|
if (block.timestamp < timestamp) {
|
|
151
155
|
low = mid + 1;
|
|
152
156
|
}
|
|
153
157
|
else {
|
|
154
158
|
high = mid - 1;
|
|
155
159
|
}
|
|
156
|
-
|
|
160
|
+
_f.label = 4;
|
|
157
161
|
case 4:
|
|
158
162
|
if (high - low > 4) return [3 /*break*/, 2];
|
|
159
|
-
|
|
163
|
+
_f.label = 5;
|
|
160
164
|
case 5:
|
|
161
165
|
if (Math.abs(block.timestamp - timestamp) > 3600) {
|
|
162
166
|
throw new Error("Block selected is more than 1 hour away from the requested timestamp");
|
|
@@ -166,9 +170,9 @@ function lookupBlock(timestamp, extraParams) {
|
|
|
166
170
|
timestamp: block.timestamp,
|
|
167
171
|
}];
|
|
168
172
|
case 6:
|
|
169
|
-
e_1 =
|
|
173
|
+
e_1 = _f.sent();
|
|
170
174
|
console.log(e_1);
|
|
171
|
-
throw new Error("Couldn't find block height for chain " + ((
|
|
175
|
+
throw new Error("Couldn't find block height for chain " + ((_e = extraParams.chain) !== null && _e !== void 0 ? _e : 'ethereum') + ", RPC node rugged");
|
|
172
176
|
case 7: return [2 /*return*/];
|
|
173
177
|
}
|
|
174
178
|
});
|