@defillama/sdk 5.0.238 → 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.
- package/package.json +1 -1
- package/build/Balances.d.ts +0 -139
- package/build/Balances.js +0 -363
- package/build/ChainApi.d.ts +0 -142
- package/build/ChainApi.js +0 -310
- package/build/abi/abi2.d.ts +0 -5
- package/build/abi/abi2.js +0 -215
- package/build/abi/cachedABIs.d.ts +0 -4
- package/build/abi/cachedABIs.js +0 -8
- package/build/abi/convertResults.d.ts +0 -5
- package/build/abi/convertResults.js +0 -60
- package/build/abi/index.d.ts +0 -31
- package/build/abi/index.js +0 -327
- package/build/abi/multicall.d.ts +0 -23
- package/build/abi/multicall.js +0 -382
- package/build/abi/multicall3.d.ts +0 -7
- package/build/abi/multicall3.js +0 -397
- package/build/abi/rpcCall.d.ts +0 -4
- package/build/abi/rpcCall.js +0 -62
- package/build/abi/tron.d.ts +0 -33
- package/build/abi/tron.js +0 -116
- package/build/api.d.ts +0 -10
- package/build/api.js +0 -45
- package/build/api2.d.ts +0 -5
- package/build/api2.js +0 -41
- package/build/chains/algorand.d.ts +0 -277
- package/build/chains/algorand.js +0 -618
- package/build/chains/aptos.d.ts +0 -230
- package/build/chains/aptos.js +0 -612
- package/build/chains/cardano.d.ts +0 -242
- package/build/chains/cardano.js +0 -407
- package/build/chains/cosmos.d.ts +0 -252
- package/build/chains/cosmos.js +0 -618
- package/build/chains/icp.d.ts +0 -235
- package/build/chains/icp.js +0 -1040
- package/build/chains/index.d.ts +0 -23
- package/build/chains/index.js +0 -59
- package/build/chains/near.d.ts +0 -192
- package/build/chains/near.js +0 -446
- package/build/chains/rpc.d.ts +0 -125
- package/build/chains/rpc.js +0 -326
- package/build/chains/starknet.d.ts +0 -205
- package/build/chains/starknet.js +0 -884
- package/build/chains/stellar.d.ts +0 -410
- package/build/chains/stellar.js +0 -1082
- package/build/chains/substrate.d.ts +0 -333
- package/build/chains/substrate.js +0 -1042
- package/build/chains/sui.d.ts +0 -365
- package/build/chains/sui.js +0 -1135
- package/build/chains/svm.d.ts +0 -340
- package/build/chains/svm.js +0 -760
- package/build/chains/tezos.d.ts +0 -225
- package/build/chains/tezos.js +0 -412
- package/build/chains/ton.d.ts +0 -353
- package/build/chains/ton.js +0 -788
- package/build/chains/tron.d.ts +0 -45
- package/build/chains/tron.js +0 -110
- package/build/chains/utxo.d.ts +0 -202
- package/build/chains/utxo.js +0 -592
- package/build/chains/xrpl.d.ts +0 -179
- package/build/chains/xrpl.js +0 -467
- package/build/computeTVL/blocks.d.ts +0 -1
- package/build/computeTVL/blocks.js +0 -12
- package/build/computeTVL/humanizeNumber.d.ts +0 -1
- package/build/computeTVL/humanizeNumber.js +0 -19
- package/build/erc20/index.d.ts +0 -31
- package/build/erc20/index.js +0 -56
- package/build/eth/index.d.ts +0 -22
- package/build/eth/index.js +0 -118
- package/build/general.d.ts +0 -5
- package/build/general.js +0 -20
- package/build/generalUtil.d.ts +0 -8
- package/build/generalUtil.js +0 -73
- package/build/index.d.ts +0 -32
- package/build/index.js +0 -74
- package/build/providers.json +0 -1
- package/build/types.d.ts +0 -76
- package/build/types.js +0 -2
- package/build/util/LlamaProvider.d.ts +0 -46
- package/build/util/LlamaProvider.js +0 -367
- package/build/util/blocks.d.ts +0 -36
- package/build/util/blocks.js +0 -500
- package/build/util/cache.d.ts +0 -45
- package/build/util/cache.js +0 -309
- package/build/util/chainUtils/data.json +0 -1425
- package/build/util/chainUtils/index.d.ts +0 -11
- package/build/util/chainUtils/index.js +0 -136
- package/build/util/coins.d.ts +0 -19
- package/build/util/coins.js +0 -124
- package/build/util/common.d.ts +0 -34
- package/build/util/common.js +0 -376
- package/build/util/computeTVL.d.ts +0 -19
- package/build/util/computeTVL.js +0 -102
- package/build/util/cosmos.d.ts +0 -1
- package/build/util/cosmos.js +0 -8
- package/build/util/debugLog.d.ts +0 -4
- package/build/util/debugLog.js +0 -18
- package/build/util/discord.d.ts +0 -1
- package/build/util/discord.js +0 -33
- package/build/util/elastic.d.ts +0 -43
- package/build/util/elastic.js +0 -113
- package/build/util/env.d.ts +0 -20
- package/build/util/env.js +0 -175
- package/build/util/graph.d.ts +0 -8
- package/build/util/graph.js +0 -50
- package/build/util/index.d.ts +0 -32
- package/build/util/index.js +0 -227
- package/build/util/indexer.compatibility.d.ts +0 -6
- package/build/util/indexer.compatibility.js +0 -64
- package/build/util/indexer.d.ts +0 -92
- package/build/util/indexer.js +0 -850
- package/build/util/indexerSql.d.ts +0 -9
- package/build/util/indexerSql.js +0 -102
- package/build/util/internal-cache.d.ts +0 -11
- package/build/util/internal-cache.js +0 -77
- package/build/util/logs.d.ts +0 -58
- package/build/util/logs.decode.shared.d.ts +0 -8
- package/build/util/logs.decode.shared.js +0 -289
- package/build/util/logs.js +0 -432
- package/build/util/promisePool.d.ts +0 -8
- package/build/util/promisePool.js +0 -31
- package/build/util/r2.d.ts +0 -4
- package/build/util/r2.js +0 -52
- package/build/util/removeRedundantRPCs.d.ts +0 -1
- package/build/util/removeRedundantRPCs.js +0 -49
- package/build/util/transactions.d.ts +0 -35
- package/build/util/transactions.js +0 -22
- package/build/util/updateChainLabels.d.ts +0 -1
- package/build/util/updateChainLabels.js +0 -5
- package/build/util/updateProviderList.d.ts +0 -1
- package/build/util/updateProviderList.js +0 -275
package/build/abi/multicall3.js
DELETED
|
@@ -1,397 +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.default = makeMultiCall;
|
|
7
|
-
exports.isMulticallV3Supported = isMulticallV3Supported;
|
|
8
|
-
exports.getMulticallAddress = getMulticallAddress;
|
|
9
|
-
const ethers_1 = require("ethers");
|
|
10
|
-
const convertResults_1 = __importDefault(require("./convertResults"));
|
|
11
|
-
const multicall_1 = __importDefault(require("./multicall"));
|
|
12
|
-
const index_1 = require("./index");
|
|
13
|
-
const env_1 = require("../util/env");
|
|
14
|
-
// https://github.com/mds1/multicall
|
|
15
|
-
// https://www.multicall3.com/deployments
|
|
16
|
-
const MULTICALL_V3_ADDRESS = '0xca11bde05977b3631167028862be2a173976ca11';
|
|
17
|
-
const DEPLOYMENT_BLOCK = {
|
|
18
|
-
ethereum: 14353601,
|
|
19
|
-
ethf: 14353601,
|
|
20
|
-
arbitrum: 7654707,
|
|
21
|
-
arbitrum_nova: 1746963,
|
|
22
|
-
optimism: 4286263,
|
|
23
|
-
polygon: 25770160,
|
|
24
|
-
polygon_zkevm: 57746,
|
|
25
|
-
fantom: 33001987,
|
|
26
|
-
bsc: 15921452,
|
|
27
|
-
moonriver: 609002,
|
|
28
|
-
moonbeam: 609002,
|
|
29
|
-
avax: 11907934,
|
|
30
|
-
harmony: 24185753,
|
|
31
|
-
cronos: 1963112,
|
|
32
|
-
klaytn: 96002415,
|
|
33
|
-
godwoken_v1: 15034,
|
|
34
|
-
celo: 13112599,
|
|
35
|
-
oasis: 1481392,
|
|
36
|
-
rsk: 4249540,
|
|
37
|
-
metis: 2338552,
|
|
38
|
-
heco: 14413501,
|
|
39
|
-
okexchain: 10364792,
|
|
40
|
-
astar: 761794,
|
|
41
|
-
aurora: 62907816,
|
|
42
|
-
boba: 446859,
|
|
43
|
-
songbird: 13382504,
|
|
44
|
-
fuse: 16146628,
|
|
45
|
-
flare: 3002461,
|
|
46
|
-
milkomeda: 4377424,
|
|
47
|
-
velas: 55883577,
|
|
48
|
-
// telos: 246530709,
|
|
49
|
-
step: 5734583,
|
|
50
|
-
canto: 2905789,
|
|
51
|
-
iotex: 22163670,
|
|
52
|
-
bitgert: 2118034,
|
|
53
|
-
kava: 3661165,
|
|
54
|
-
dfk: 14790551,
|
|
55
|
-
pulse: 14353601,
|
|
56
|
-
onus: 805931,
|
|
57
|
-
rollux: 119222,
|
|
58
|
-
xdai: 21022491,
|
|
59
|
-
evmos: 188483,
|
|
60
|
-
thundercore: 100671921,
|
|
61
|
-
kcc: 11760430,
|
|
62
|
-
linea: 42,
|
|
63
|
-
zora: 5882,
|
|
64
|
-
eos_evm: 7943933,
|
|
65
|
-
// dogechain: 14151696, // for some reason this is not working
|
|
66
|
-
tron: 51067989,
|
|
67
|
-
era: 3908235,
|
|
68
|
-
mantle: 304717,
|
|
69
|
-
base: 5022,
|
|
70
|
-
darwinia: 251739,
|
|
71
|
-
op_bnb: 412254,
|
|
72
|
-
shimmer_evm: 1290,
|
|
73
|
-
manta: 332890,
|
|
74
|
-
neon_evm: 206545524,
|
|
75
|
-
beam: 3,
|
|
76
|
-
pgn: 3380209,
|
|
77
|
-
meter: 41238476,
|
|
78
|
-
meer: 744781,
|
|
79
|
-
lukso: 468183,
|
|
80
|
-
nos: 1578065,
|
|
81
|
-
scroll: 14,
|
|
82
|
-
q: 8357148,
|
|
83
|
-
edg: 18117872,
|
|
84
|
-
chz: 8007643,
|
|
85
|
-
azktn: 31317,
|
|
86
|
-
lightlink_phoenix: 51289975,
|
|
87
|
-
eon: 646592,
|
|
88
|
-
jfin: 13857465,
|
|
89
|
-
ethereumclassic: 18288646,
|
|
90
|
-
core: 6988931,
|
|
91
|
-
callisto: 13811517,
|
|
92
|
-
bittorrent: 31078552,
|
|
93
|
-
zeta: 1632781,
|
|
94
|
-
area: 353286,
|
|
95
|
-
zkfair: 6090959,
|
|
96
|
-
mode: 2465882,
|
|
97
|
-
xai: 222549,
|
|
98
|
-
dos: 161908,
|
|
99
|
-
// xdc: 71542788, // not working for some reason
|
|
100
|
-
fraxtal: 100,
|
|
101
|
-
lyra: 1935198,
|
|
102
|
-
blast: 88189,
|
|
103
|
-
omax: 4750251,
|
|
104
|
-
astrzk: 183817,
|
|
105
|
-
shibarium: 3485946,
|
|
106
|
-
imx: 3680945,
|
|
107
|
-
sapphire: 734531,
|
|
108
|
-
jbc: 2919675,
|
|
109
|
-
rss3_vsl: 14193,
|
|
110
|
-
islm: 10515193,
|
|
111
|
-
're-al': 695,
|
|
112
|
-
real: 695,
|
|
113
|
-
svm: 400460,
|
|
114
|
-
degen: 414273,
|
|
115
|
-
karak: 4475345,
|
|
116
|
-
iotaevm: 25022,
|
|
117
|
-
planq: 8470015,
|
|
118
|
-
bob: 946071,
|
|
119
|
-
bitr: 1045566,
|
|
120
|
-
btr: 3225645,
|
|
121
|
-
dreyerx: 163720,
|
|
122
|
-
cyeth: 1,
|
|
123
|
-
taiko: 11269,
|
|
124
|
-
sei: 79351444,
|
|
125
|
-
aura: 6731307,
|
|
126
|
-
conflux: 97705330,
|
|
127
|
-
etlk: 1,
|
|
128
|
-
alg: 2344547,
|
|
129
|
-
lisk: 4664276,
|
|
130
|
-
gravity: 52682,
|
|
131
|
-
flow: 968659,
|
|
132
|
-
rupx: 35231,
|
|
133
|
-
fluence: 207583,
|
|
134
|
-
ontology: 17984796,
|
|
135
|
-
wc: 4353799,
|
|
136
|
-
unit0: 9727,
|
|
137
|
-
spn: 39,
|
|
138
|
-
starchain: 23898035,
|
|
139
|
-
apechain: 20889,
|
|
140
|
-
zircuit: 5815253,
|
|
141
|
-
qom: 10050,
|
|
142
|
-
matchain: 2598669,
|
|
143
|
-
shape: 3443414,
|
|
144
|
-
morph: 169985,
|
|
145
|
-
sonic: 1,
|
|
146
|
-
ace: 1,
|
|
147
|
-
ink: 1,
|
|
148
|
-
sophon: 1,
|
|
149
|
-
sty: 1,
|
|
150
|
-
vana: 818176,
|
|
151
|
-
swellchain: 878173,
|
|
152
|
-
odyssey: 1,
|
|
153
|
-
aleph_zero: 4603377,
|
|
154
|
-
wemix: 66084281,
|
|
155
|
-
soneium: 1,
|
|
156
|
-
ronin: 1,
|
|
157
|
-
peaq: 1,
|
|
158
|
-
berachain: 1,
|
|
159
|
-
plume: 1,
|
|
160
|
-
plume_mainnet: 39679,
|
|
161
|
-
abstract: 5288,
|
|
162
|
-
zero_network: 11517,
|
|
163
|
-
unichain: 1,
|
|
164
|
-
sanko: 1,
|
|
165
|
-
formnetwork: 1,
|
|
166
|
-
hemi: 1,
|
|
167
|
-
hedera: 1,
|
|
168
|
-
hyperliquid: 13051,
|
|
169
|
-
saga: 467530,
|
|
170
|
-
goat: 1,
|
|
171
|
-
corn: 1,
|
|
172
|
-
hoe: 2589,
|
|
173
|
-
power: 46125,
|
|
174
|
-
bittensor_evm: 5098260,
|
|
175
|
-
wbt: 1,
|
|
176
|
-
tangle: 1,
|
|
177
|
-
nero: 1,
|
|
178
|
-
flame: 1,
|
|
179
|
-
sseed: 1,
|
|
180
|
-
lens: 1,
|
|
181
|
-
basecamp: 1,
|
|
182
|
-
platon: 1,
|
|
183
|
-
xrplevm: 1,
|
|
184
|
-
katana: 1,
|
|
185
|
-
mint: 1,
|
|
186
|
-
btnx: 516999,
|
|
187
|
-
vechain: 22103870,
|
|
188
|
-
tac: 1,
|
|
189
|
-
eventum: 1,
|
|
190
|
-
somnia: 1,
|
|
191
|
-
camp: 1,
|
|
192
|
-
bitci: 1,
|
|
193
|
-
plasma: 1,
|
|
194
|
-
eteria: 918,
|
|
195
|
-
gatelayer: 1,
|
|
196
|
-
xone: 3752043,
|
|
197
|
-
mezo: 351760,
|
|
198
|
-
edu_chain: 16410660,
|
|
199
|
-
stratis: 1420372,
|
|
200
|
-
'0g': 6546802,
|
|
201
|
-
besc: 1,
|
|
202
|
-
monad: 9248132,
|
|
203
|
-
incentiv: 1036482,
|
|
204
|
-
bsquared: 1,
|
|
205
|
-
mantra: 1,
|
|
206
|
-
cross: 1,
|
|
207
|
-
doma: 1,
|
|
208
|
-
capx: 30800,
|
|
209
|
-
stable: 2423647,
|
|
210
|
-
megaeth: 1858081,
|
|
211
|
-
injective: 1,
|
|
212
|
-
occ: 1,
|
|
213
|
-
pepu: 1,
|
|
214
|
-
ebc: 1,
|
|
215
|
-
citrea: 1,
|
|
216
|
-
tempo: 1,
|
|
217
|
-
edegex: 1,
|
|
218
|
-
wchain: 2207643,
|
|
219
|
-
fluent: 754598,
|
|
220
|
-
pharos: 1,
|
|
221
|
-
anubi: 1,
|
|
222
|
-
robinhood: 1,
|
|
223
|
-
srx: 1,
|
|
224
|
-
xo: 1,
|
|
225
|
-
rls: 1,
|
|
226
|
-
quai: 1,
|
|
227
|
-
adi: 1,
|
|
228
|
-
eden: 1,
|
|
229
|
-
intuition: 288,
|
|
230
|
-
mrt: 1,
|
|
231
|
-
ap3x: 1871253,
|
|
232
|
-
bot: 17537440,
|
|
233
|
-
codex: 1,
|
|
234
|
-
gensyn: 1,
|
|
235
|
-
krown: 6666,
|
|
236
|
-
kiteai: 29260,
|
|
237
|
-
eni: 1,
|
|
238
|
-
bitkub: 1,
|
|
239
|
-
shido: 1,
|
|
240
|
-
prom: 1238475,
|
|
241
|
-
nibiru: 19587573,
|
|
242
|
-
arc: 1,
|
|
243
|
-
};
|
|
244
|
-
async function makeMultiCall(functionABI, calls, chain, block) {
|
|
245
|
-
if (!functionABI)
|
|
246
|
-
throw new Error('Missing ABI parameter');
|
|
247
|
-
if (calls.some(i => !i.contract))
|
|
248
|
-
throw new Error('Missing target, abi:' + functionABI);
|
|
249
|
-
if (!isMulticallV3Supported(chain, block))
|
|
250
|
-
return (0, multicall_1.default)(functionABI, calls, chain, block);
|
|
251
|
-
const contractInterface = new ethers_1.ethers.Interface([functionABI]);
|
|
252
|
-
let fd = contractInterface.fragments[0];
|
|
253
|
-
const failedEncodingIndexes = [];
|
|
254
|
-
const goodEncodingIndexes = [];
|
|
255
|
-
const goodCalls = [];
|
|
256
|
-
const contractCalls = calls.map((call, idx) => {
|
|
257
|
-
try {
|
|
258
|
-
const data = contractInterface.encodeFunctionData(fd, call.params);
|
|
259
|
-
let contract = call.contract;
|
|
260
|
-
if (contract === null || contract === void 0 ? void 0 : contract.startsWith('0x')) {
|
|
261
|
-
contract = contract.toLowerCase(); // lowercase so a bad EIP-55 checksum does not reject the call - single `call` passes the target as-is to eth_call, so multiCall should accept the same input
|
|
262
|
-
const _isValidAddress = ethers_1.ethers.getAddress(contract); // Validates the address
|
|
263
|
-
}
|
|
264
|
-
goodCalls.push(call);
|
|
265
|
-
goodEncodingIndexes.push(idx);
|
|
266
|
-
return {
|
|
267
|
-
to: contract,
|
|
268
|
-
data,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
catch (e) {
|
|
272
|
-
failedEncodingIndexes.push(idx);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
// if some calls failed to encode, we fetch the good ones and fill the rest with null
|
|
276
|
-
if (failedEncodingIndexes.length) {
|
|
277
|
-
const goodCallResponses = await makeMultiCall(functionABI, goodCalls, chain, block);
|
|
278
|
-
const responses = [];
|
|
279
|
-
failedEncodingIndexes.forEach(idx => {
|
|
280
|
-
responses[idx] = { input: { params: calls[idx].params, target: calls[idx].contract }, success: false, output: null, error: new Error('Bad encoding') };
|
|
281
|
-
});
|
|
282
|
-
goodEncodingIndexes.forEach((goodIdx, i) => {
|
|
283
|
-
responses[goodIdx] = goodCallResponses[i];
|
|
284
|
-
});
|
|
285
|
-
return responses;
|
|
286
|
-
}
|
|
287
|
-
let returnValues;
|
|
288
|
-
try {
|
|
289
|
-
await _call();
|
|
290
|
-
}
|
|
291
|
-
catch (e) {
|
|
292
|
-
// debugLog(chain, 'Multicall failed, retrying call...')
|
|
293
|
-
await _call();
|
|
294
|
-
}
|
|
295
|
-
return returnValues.map(([success, values], index) => {
|
|
296
|
-
let output = null;
|
|
297
|
-
let error = null;
|
|
298
|
-
try {
|
|
299
|
-
output = (0, convertResults_1.default)(contractInterface.decodeFunctionResult(fd, values), { functionABI: fd, chain });
|
|
300
|
-
}
|
|
301
|
-
catch (e) {
|
|
302
|
-
error = e;
|
|
303
|
-
success = false;
|
|
304
|
-
}
|
|
305
|
-
const res = {
|
|
306
|
-
input: {
|
|
307
|
-
params: calls[index].params,
|
|
308
|
-
target: calls[index].contract,
|
|
309
|
-
},
|
|
310
|
-
success, output,
|
|
311
|
-
};
|
|
312
|
-
if (error)
|
|
313
|
-
res.error = error;
|
|
314
|
-
return res;
|
|
315
|
-
});
|
|
316
|
-
async function _call() {
|
|
317
|
-
const multicallAddress = getMulticallAddress(chain, block);
|
|
318
|
-
const { output: returnData } = await (0, index_1.call)({ chain, block, target: multicallAddress, abi: 'function tryAggregate(bool requireSuccess, tuple(address target, bytes callData)[] calls) payable returns (tuple(bool success, bytes returnData)[] returnData)', params: [false, contractCalls.map((call) => [call.to, call.data])] });
|
|
319
|
-
returnValues = returnData;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
const envMulticallCache = {};
|
|
323
|
-
function getMulticallV3ContractFromEnv(chain) {
|
|
324
|
-
var _a;
|
|
325
|
-
if (!envMulticallCache.hasOwnProperty(chain)) {
|
|
326
|
-
envMulticallCache[chain] = (_a = (0, env_1.getEnvValue)(`${chain}_RPC_MULTICALL_V3`)) !== null && _a !== void 0 ? _a : null;
|
|
327
|
-
}
|
|
328
|
-
return envMulticallCache[chain];
|
|
329
|
-
}
|
|
330
|
-
function isMulticallV3Supported(chain, block) {
|
|
331
|
-
const contractFromEnv = getMulticallV3ContractFromEnv(chain);
|
|
332
|
-
if (contractFromEnv)
|
|
333
|
-
return true;
|
|
334
|
-
const startBlock = DEPLOYMENT_BLOCK[chain];
|
|
335
|
-
if (!startBlock)
|
|
336
|
-
return false;
|
|
337
|
-
if (!block)
|
|
338
|
-
return true;
|
|
339
|
-
if (typeof block === 'string')
|
|
340
|
-
return block === 'latest';
|
|
341
|
-
return block > startBlock;
|
|
342
|
-
}
|
|
343
|
-
function getMulticallAddress(chain, block) {
|
|
344
|
-
var _a;
|
|
345
|
-
const contractFromEnv = getMulticallV3ContractFromEnv(chain);
|
|
346
|
-
if (contractFromEnv)
|
|
347
|
-
return contractFromEnv;
|
|
348
|
-
if (!isMulticallV3Supported(chain, block))
|
|
349
|
-
return null;
|
|
350
|
-
return (_a = CUSTOM_MULTICALL_ADDRESSES[chain]) !== null && _a !== void 0 ? _a : MULTICALL_V3_ADDRESS;
|
|
351
|
-
}
|
|
352
|
-
const CUSTOM_MULTICALL_ADDRESSES = {
|
|
353
|
-
'onus': '0x748c384f759cc596f0d9fa96dcabe8a11e443b30',
|
|
354
|
-
'era': '0xF9cda624FBC7e059355ce98a31693d299FACd963',
|
|
355
|
-
'tron': 'TEazPvZwDjDtFeJupyo7QunvnrnUjPH8ED',
|
|
356
|
-
'op_bnb': '0x5eF9501fE659b97C45f3A7efD298c14405b454D1',
|
|
357
|
-
'beam': '0x4956f15efdc3dc16645e90cc356eafa65ffc65ec',
|
|
358
|
-
'nos': '0x337F5fBB75007e59cC4A6132017Bd96748b09F7F',
|
|
359
|
-
'chz': '0x0E6a1Df694c4be9BFFC4D76f2B936bB1A1df7fAC',
|
|
360
|
-
'lightlink_phoenix': '0xb9a543d7B7dF05C8845AeA6627dE4a6622Ac863C',
|
|
361
|
-
'eon': '0x4ea6779581bDAcd376724A52070bE89FfB74eC39',
|
|
362
|
-
'svm': '0x40a3a97ac5d9acadF9F96cB8283a912dDFd05dc8',
|
|
363
|
-
'degen': '0xFBF562a98aB8584178efDcFd09755FF9A1e7E3a2',
|
|
364
|
-
'karak': '0x73331e33f1552E706D56aa453ce19BCE314B4F59',
|
|
365
|
-
'taiko': '0xcb2436774C3e191c85056d248EF4260ce5f27A9D',
|
|
366
|
-
'qom': '0x7A52370716ea730585884F5BDB0f6E60C39b8C64',
|
|
367
|
-
'matchain': '0xDa91510Bd8c50bfa54FC2BE2dD6dAbE03eA8496c',
|
|
368
|
-
'ace': '0x025A2B4fCE1E0bD736D5cebe6C8a52229795376B',
|
|
369
|
-
'sophon': '0x5f4867441d2416cA88B1b3fd38f21811680CD2C8',
|
|
370
|
-
'vana': '0xFe92b91F3326e58557478c28EeAe1936E0c7148a',
|
|
371
|
-
'odyssey': '0xD5F04861e1249F488ef8898607cF7ad0F334d823',
|
|
372
|
-
'zero_network': '0x0307F341a18f1FC1f63a7Ceeac970245A08C5a80',
|
|
373
|
-
'saga': '0x864DDc9B50B9A0dF676d826c9B9EDe9F8913a160',
|
|
374
|
-
'hedera': '0x18fa376d92511dd04090566ab6144847c03557d8',
|
|
375
|
-
'xrplevm': '0xaB3a12b26e72F4D6D9B579aCb5027a0918eF1114',
|
|
376
|
-
'vechain': '0x8B2fF167683c5e1DFD6717d934B560F20cf9F2a3',
|
|
377
|
-
'eventum': '0xc7dEfc896E1Dd9D98AEa402d928C78c0FD1dc36C',
|
|
378
|
-
'somnia': '0x5e44F178E8cF9B2F5409B6f18ce936aB817C5a11',
|
|
379
|
-
'bitci': '0x777238B119cD07e6849b0817f284532DC0F9F8D9',
|
|
380
|
-
'eteria': '0x8cC688B1F99b651ee00bB0Cb0aae61F416F8384b',
|
|
381
|
-
'xone': '0xe39d7BCDdaBBD0526D143185Fb7b459099Fd40c9',
|
|
382
|
-
'besc': '0xBcdb671cBC7711fE533E8B46E52EbC1470145F67',
|
|
383
|
-
'capx': '0x8E1cd29c79dD1Dd4966Cd6A05EeC7d25B5f47f2b',
|
|
384
|
-
'pepu': '0xBB6bf9447031408804af92aE6fBeDc002Dcb20aB',
|
|
385
|
-
'ebc': '0x965b692662d431cc4714f4E6d1191b0B18733243',
|
|
386
|
-
'citrea': '0xA738e84fdE890Bc60b99AF7ccE43990E534304de',
|
|
387
|
-
'anubi': '0x2BaB36196519Ce9Cc31Bc4899FCBB8124A413b02',
|
|
388
|
-
'srx': '0xFd4b34b5763f54a580a0d9f7997A2A993ef9ceE9',
|
|
389
|
-
'xo': '0x7c6d6eAafF566E3B8a6D072ca1825E8F18141fDb',
|
|
390
|
-
'quai': '0x00567637197E6554e2CF47a3988Cb7B819f4E92C',
|
|
391
|
-
'adi': '0xcC5fae7aF4A6684d05D92Db59279B70e827F31BE',
|
|
392
|
-
'krown': '0xBa9E76d893f88B42d90b954921118C269D203a2C',
|
|
393
|
-
'kiteai': '0xE3104A157cc4C0d3c7C3a8c655092668D068c149',
|
|
394
|
-
'eni': '0xbf9d276932DF9c0AA1644b2569482f7a754433be',
|
|
395
|
-
'shido': '0xe3da1EC9e9BfEa1fE8C5905133c36A86351e4561',
|
|
396
|
-
'prom': '0xfF785aF3De8C2cb5727A8665984E741c16679131',
|
|
397
|
-
};
|
package/build/abi/rpcCall.d.ts
DELETED
package/build/abi/rpcCall.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.call = call;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const debugLog_1 = require("../util/debugLog");
|
|
6
|
-
const env_1 = require("../util/env");
|
|
7
|
-
const COUNTERS = {};
|
|
8
|
-
const emitter = new events_1.EventEmitter();
|
|
9
|
-
emitter.setMaxListeners(500000);
|
|
10
|
-
async function call(provider, data, block, chain, options = { retry: true }) {
|
|
11
|
-
var _a;
|
|
12
|
-
const retry = (_a = options.retry) !== null && _a !== void 0 ? _a : true;
|
|
13
|
-
data.blockTag = block;
|
|
14
|
-
if (!chain)
|
|
15
|
-
chain = 'noChain';
|
|
16
|
-
const counter = getChainCounter(chain);
|
|
17
|
-
const currentId = counter.requestCount++;
|
|
18
|
-
const eventId = `${chain}-${currentId}`;
|
|
19
|
-
let chainMaxParallelCalls = (0, env_1.getMaxParallelRequests)(chain);
|
|
20
|
-
if (!provider)
|
|
21
|
-
throw new Error('Provider not found for chain: ' + chain);
|
|
22
|
-
if (counter.activeWorkers > chainMaxParallelCalls) {
|
|
23
|
-
counter.queue.push(eventId);
|
|
24
|
-
await (0, events_1.once)(emitter, eventId);
|
|
25
|
-
}
|
|
26
|
-
counter.activeWorkers++;
|
|
27
|
-
if (debugLog_1.DEBUG_ENABLED) {
|
|
28
|
-
const showEveryX = counter.queue.length > 100 ? 50 : 10; // show log fewer times if lot more are queued up
|
|
29
|
-
if (currentId % showEveryX === 0)
|
|
30
|
-
(0, debugLog_1.debugLog)(`chain: ${chain} request #: ${currentId} queue: ${counter.queue.length} active requests: ${counter.activeWorkers}`);
|
|
31
|
-
}
|
|
32
|
-
let response;
|
|
33
|
-
try {
|
|
34
|
-
response = await provider.call(data);
|
|
35
|
-
onComplete();
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
onComplete();
|
|
39
|
-
if (retry)
|
|
40
|
-
return call(provider, data, block, chain, { ...options, retry: false });
|
|
41
|
-
throw e;
|
|
42
|
-
}
|
|
43
|
-
return response;
|
|
44
|
-
function onComplete() {
|
|
45
|
-
counter.activeWorkers--;
|
|
46
|
-
if (counter.queue.length) {
|
|
47
|
-
const nextRequestId = counter.pickFromTop ? counter.queue.shift() : counter.queue.pop();
|
|
48
|
-
counter.pickFromTop = !counter.pickFromTop;
|
|
49
|
-
emitter.emit(nextRequestId);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function getChainCounter(chain) {
|
|
54
|
-
if (!COUNTERS[chain])
|
|
55
|
-
COUNTERS[chain] = {
|
|
56
|
-
activeWorkers: 0,
|
|
57
|
-
queue: [],
|
|
58
|
-
requestCount: 0,
|
|
59
|
-
pickFromTop: true,
|
|
60
|
-
};
|
|
61
|
-
return COUNTERS[chain];
|
|
62
|
-
}
|
package/build/abi/tron.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Address } from "../types";
|
|
2
|
-
import { evmToTronAddress, tronToEvmAddress } from "../util/common";
|
|
3
|
-
type CallParams = any;
|
|
4
|
-
type CallOptions = {
|
|
5
|
-
target: Address;
|
|
6
|
-
abi: string | any;
|
|
7
|
-
params?: CallParams;
|
|
8
|
-
isMulticall?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare function call(options: CallOptions): Promise<any>;
|
|
11
|
-
export declare function multiCall(_functionABI: any, _calls: {
|
|
12
|
-
contract: string;
|
|
13
|
-
params: any[];
|
|
14
|
-
}[]): Promise<any>;
|
|
15
|
-
export declare function getBalance(params: {
|
|
16
|
-
target: Address;
|
|
17
|
-
decimals?: number;
|
|
18
|
-
}): Promise<{
|
|
19
|
-
output: string;
|
|
20
|
-
}>;
|
|
21
|
-
export declare function getBalances(params: {
|
|
22
|
-
targets: Address[];
|
|
23
|
-
block?: number;
|
|
24
|
-
decimals?: number;
|
|
25
|
-
}): Promise<{
|
|
26
|
-
output: {
|
|
27
|
-
target: string;
|
|
28
|
-
balance: any;
|
|
29
|
-
}[];
|
|
30
|
-
}>;
|
|
31
|
-
export declare const unhexifyTarget: typeof evmToTronAddress;
|
|
32
|
-
export declare const hexifyTarget: typeof tronToEvmAddress;
|
|
33
|
-
export {};
|
package/build/abi/tron.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.hexifyTarget = exports.unhexifyTarget = void 0;
|
|
40
|
-
exports.call = call;
|
|
41
|
-
exports.multiCall = multiCall;
|
|
42
|
-
exports.getBalance = getBalance;
|
|
43
|
-
exports.getBalances = getBalances;
|
|
44
|
-
const general_1 = require("../general");
|
|
45
|
-
const p_limit_1 = __importDefault(require("p-limit"));
|
|
46
|
-
const env_1 = require("../util/env");
|
|
47
|
-
const common_1 = require("../util/common");
|
|
48
|
-
const evmAbi = __importStar(require("./index"));
|
|
49
|
-
const limitRPCCalls = (0, p_limit_1.default)(+(0, env_1.getEnvValue)('TRON_RPC_CONCURRENCY_LIMIT', '5'));
|
|
50
|
-
const getEndpoint = () => (0, env_1.getEnvValue)('TRON_WALLET_RPC');
|
|
51
|
-
const balanceCache = {};
|
|
52
|
-
async function call(options) {
|
|
53
|
-
return evmAbi.call({ ...options, chain: 'tron', });
|
|
54
|
-
}
|
|
55
|
-
async function multiCall(_functionABI, _calls) {
|
|
56
|
-
return evmAbi.multiCall({
|
|
57
|
-
abi: _functionABI,
|
|
58
|
-
calls: _calls.map(c => ({ target: c.contract, params: c.params })),
|
|
59
|
-
chain: 'tron',
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async function getBalance(params) {
|
|
63
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64
|
-
if (!params.target)
|
|
65
|
-
throw new Error('getBalance: target is required');
|
|
66
|
-
const data = await limitRPCCalls(() => {
|
|
67
|
-
if (!balanceCache[params.target])
|
|
68
|
-
// drop the entry if the request fails, otherwise the rejected promise is served to every
|
|
69
|
-
// later call for this address and the process never retries it
|
|
70
|
-
balanceCache[params.target] = post({ address: params.target, visible: true, }, '/wallet/getaccount')
|
|
71
|
-
.catch((e) => {
|
|
72
|
-
delete balanceCache[params.target];
|
|
73
|
-
throw e;
|
|
74
|
-
});
|
|
75
|
-
return balanceCache[params.target];
|
|
76
|
-
});
|
|
77
|
-
const frozenBalance = (_b = (_a = data.frozen) === null || _a === void 0 ? void 0 : _a.reduce((t, { frozen_balance }) => t + frozen_balance, 0)) !== null && _b !== void 0 ? _b : 0;
|
|
78
|
-
const frozenBalanceV2 = (_d = (_c = data.frozenV2) === null || _c === void 0 ? void 0 : _c.reduce((t, { amount = 0 }) => t + amount, 0)) !== null && _d !== void 0 ? _d : 0;
|
|
79
|
-
const freeBalance = (_e = data.balance) !== null && _e !== void 0 ? _e : 0;
|
|
80
|
-
const delegatedBandwidthBalance = (_f = data.delegated_frozenV2_balance_for_bandwidth) !== null && _f !== void 0 ? _f : 0;
|
|
81
|
-
const delegatedEnergyBalance = (_h = (_g = data.account_resource) === null || _g === void 0 ? void 0 : _g.delegated_frozenV2_balance_for_energy) !== null && _h !== void 0 ? _h : 0;
|
|
82
|
-
let balance = (freeBalance + frozenBalance + frozenBalanceV2 + delegatedBandwidthBalance + delegatedEnergyBalance).toString();
|
|
83
|
-
return {
|
|
84
|
-
output: (0, general_1.handleDecimals)(balance, params.decimals),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
async function getBalances(params) {
|
|
88
|
-
const { targets, decimals } = params;
|
|
89
|
-
const res = await Promise.all(targets.map(i => getBalance({ target: i, decimals })));
|
|
90
|
-
return {
|
|
91
|
-
output: res.map((v, i) => ({ target: targets[i], balance: v.output })),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
exports.unhexifyTarget = common_1.evmToTronAddress;
|
|
95
|
-
exports.hexifyTarget = common_1.tronToEvmAddress;
|
|
96
|
-
async function post(body = {}, endpoint = '/wallet/triggerconstantcontract') {
|
|
97
|
-
await (0, common_1.sleepRandom)(3000); // sleep random time to avoid rate limit
|
|
98
|
-
const hosts = (getEndpoint()).split(',');
|
|
99
|
-
hosts.sort(() => Math.random() - 0.5); // shuffle hosts
|
|
100
|
-
const errors = [];
|
|
101
|
-
for (const host of hosts) {
|
|
102
|
-
try {
|
|
103
|
-
const headers = { 'Content-Type': 'application/json' };
|
|
104
|
-
const apiKey = (0, env_1.getEnvValue)('TRON_PRO_API_KEY');
|
|
105
|
-
if (apiKey)
|
|
106
|
-
headers['TRON-PRO-API-KEY'] = apiKey;
|
|
107
|
-
const res = await (0, common_1.postJson)(host + endpoint, body, { headers, });
|
|
108
|
-
return res;
|
|
109
|
-
}
|
|
110
|
-
catch (e) {
|
|
111
|
-
// debugLog('Tron RPC error', e.message)
|
|
112
|
-
errors.push(e);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
throw new Error((0, common_1.shortenString)(`All TRON RPCs are not working. Errors: ${errors.map((i) => i.message).join('; ')}`, 1500));
|
|
116
|
-
}
|
package/build/api.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * as util from "./util";
|
|
2
|
-
export * as eth from "./eth";
|
|
3
|
-
export * as erc20 from "./erc20";
|
|
4
|
-
export * as abi from "./abi";
|
|
5
|
-
import { setProvider, getProvider } from "./general";
|
|
6
|
-
declare const config: {
|
|
7
|
-
setProvider: typeof setProvider;
|
|
8
|
-
getProvider: typeof getProvider;
|
|
9
|
-
};
|
|
10
|
-
export { config };
|
package/build/api.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.config = exports.abi = exports.erc20 = exports.eth = exports.util = void 0;
|
|
37
|
-
exports.util = __importStar(require("./util"));
|
|
38
|
-
exports.eth = __importStar(require("./eth"));
|
|
39
|
-
exports.erc20 = __importStar(require("./erc20"));
|
|
40
|
-
exports.abi = __importStar(require("./abi"));
|
|
41
|
-
const general_1 = require("./general");
|
|
42
|
-
const config = {
|
|
43
|
-
setProvider: general_1.setProvider, getProvider: general_1.getProvider,
|
|
44
|
-
};
|
|
45
|
-
exports.config = config;
|