@defillama/sdk 5.0.175 → 5.0.177
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/Balances.d.ts +2 -2
- package/build/ChainApi.d.ts +26 -14
- package/build/ChainApi.js +58 -28
- package/build/abi/abi2.js +23 -15
- package/build/abi/cachedABIs.d.ts +1 -1
- package/build/abi/convertResults.d.ts +4 -1
- package/build/abi/convertResults.js +20 -15
- package/build/abi/index.js +16 -39
- package/build/abi/multicall.js +6 -31
- package/build/abi/multicall3.js +36 -37
- package/build/abi/rpcCall.js +1 -2
- package/build/abi/tron.d.ts +5 -6
- package/build/abi/tron.js +79 -198
- package/build/api.js +17 -7
- package/build/api2.js +17 -7
- package/build/computeTVL/humanizeNumber.js +1 -2
- package/build/erc20/index.js +5 -6
- package/build/eth/index.d.ts +1 -0
- package/build/eth/index.js +39 -16
- package/build/general.js +2 -2
- package/build/generalUtil.d.ts +2 -24
- package/build/generalUtil.js +39 -246
- package/build/index.js +17 -7
- package/build/providers.json +1 -1
- package/build/util/LlamaProvider.js +8 -3
- package/build/util/blocks.js +17 -20
- package/build/util/cache.d.ts +11 -2
- package/build/util/cache.js +53 -9
- package/build/util/common.d.ts +33 -0
- package/build/util/common.js +352 -0
- package/build/util/computeTVL.js +6 -11
- package/build/util/cosmos.js +6 -9
- package/build/util/debugLog.js +3 -3
- package/build/util/elastic.d.ts +19 -0
- package/build/util/elastic.js +54 -6
- package/build/util/env.d.ts +7 -1
- package/build/util/env.js +28 -15
- package/build/util/graph.js +4 -8
- package/build/util/index.d.ts +1 -1
- package/build/util/index.js +17 -15
- package/build/util/indexer.js +21 -19
- package/build/util/internal-cache.js +22 -13
- package/build/util/logs.js +7 -7
- package/build/util/promisePool.d.ts +4 -1
- package/build/util/promisePool.js +22 -7
- package/build/util/r2.d.ts +0 -1
- package/build/util/r2.js +4 -9
- package/build/util/removeRedundantRPCs.js +2 -2
- package/build/util/transactions.js +1 -2
- package/build/util/updateProviderList.js +6 -6
- package/package.json +2 -2
- package/build/computeTVL/prices.d.ts +0 -9
- package/build/computeTVL/prices.js +0 -73
package/build/Balances.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare class Balances {
|
|
|
65
65
|
rawTokenBalances: BalancesV1;
|
|
66
66
|
labelBreakdown?: {
|
|
67
67
|
[key: string]: number;
|
|
68
|
-
}
|
|
68
|
+
};
|
|
69
69
|
debugData?: {
|
|
70
70
|
tokenData: {
|
|
71
71
|
balance: string | number;
|
|
@@ -76,7 +76,7 @@ export declare class Balances {
|
|
|
76
76
|
token: string;
|
|
77
77
|
symbol: string;
|
|
78
78
|
}[];
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
}>;
|
|
81
81
|
resizeBy(ratio: number): this;
|
|
82
82
|
static getUSDValue(balances: BalancesV1, timestamp?: number): Promise<number>;
|
package/build/ChainApi.d.ts
CHANGED
|
@@ -12,6 +12,23 @@ type Erc4626SumOptions = {
|
|
|
12
12
|
permitFailure?: boolean;
|
|
13
13
|
isOG4626?: boolean;
|
|
14
14
|
};
|
|
15
|
+
type GetTokenBalancesOptions = {
|
|
16
|
+
token?: string;
|
|
17
|
+
tokens?: string[];
|
|
18
|
+
owner?: string;
|
|
19
|
+
owners?: string[];
|
|
20
|
+
tokensAndOwners?: [string, string][];
|
|
21
|
+
tokensAndOwners2?: [string[], string[]];
|
|
22
|
+
ownerTokens?: [string[], string][];
|
|
23
|
+
blacklistedTokens?: string[];
|
|
24
|
+
blacklistedOwners?: string[];
|
|
25
|
+
skipDuplicates?: boolean;
|
|
26
|
+
permitFailure?: boolean;
|
|
27
|
+
withTokenData?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type SumTokensOptions = GetTokenBalancesOptions & {
|
|
30
|
+
balancesV2Options?: BalancesV2Options;
|
|
31
|
+
};
|
|
15
32
|
type DebugStats = {
|
|
16
33
|
total: number;
|
|
17
34
|
[key: string]: any;
|
|
@@ -61,18 +78,13 @@ export declare class ChainApi {
|
|
|
61
78
|
deleteTokens(tokens: string[]): void;
|
|
62
79
|
erc4626Sum2(options: Erc4626SumOptions): Promise<BalancesV1>;
|
|
63
80
|
erc4626Sum({ calls, tokenAbi, balanceAbi, balanceCalls, permitFailure, isOG4626 }: Erc4626SumOptions): Promise<BalancesV1>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
ownerTokens?: any[];
|
|
72
|
-
blacklistedTokens?: string[];
|
|
73
|
-
blacklistedOwners?: string[];
|
|
74
|
-
balancesV2Options?: BalancesV2Options;
|
|
75
|
-
}): Promise<BalancesV1>;
|
|
81
|
+
getTokenBalances({ token, tokens, owners, owner, tokensAndOwners, tokensAndOwners2, blacklistedTokens, blacklistedOwners, ownerTokens, skipDuplicates, permitFailure, withTokenData, }: GetTokenBalancesOptions): Promise<string[] | [token: string, balance: string][]>;
|
|
82
|
+
sumTokens({ balancesV2Options, ...tokenBalanceOptions }: SumTokensOptions): Promise<BalancesV1>;
|
|
83
|
+
getERC20TokenBalances(options: GetTokenBalancesOptions): Promise<string[] | [token: string, balance: string][]>;
|
|
84
|
+
getGasTokenBalance(owner: string, options?: GetTokenBalancesOptions): Promise<string | [token: string, balance: string]>;
|
|
85
|
+
getGasTokenBalances(options: GetTokenBalancesOptions): Promise<string[] | [token: string, balance: string][]>;
|
|
86
|
+
getEthBalance(owner: string, options?: GetTokenBalancesOptions): Promise<string | [token: string, balance: string]>;
|
|
87
|
+
getEthBalances(options: GetTokenBalancesOptions): Promise<string[] | [token: string, balance: string][]>;
|
|
76
88
|
getUSDValue(): Promise<number>;
|
|
77
89
|
getUSDString(): Promise<string>;
|
|
78
90
|
getUSDJSONs(): Promise<{
|
|
@@ -81,7 +93,7 @@ export declare class ChainApi {
|
|
|
81
93
|
rawTokenBalances: BalancesV1;
|
|
82
94
|
labelBreakdown?: {
|
|
83
95
|
[key: string]: number;
|
|
84
|
-
}
|
|
96
|
+
};
|
|
85
97
|
debugData?: {
|
|
86
98
|
tokenData: {
|
|
87
99
|
balance: string | number;
|
|
@@ -92,7 +104,7 @@ export declare class ChainApi {
|
|
|
92
104
|
token: string;
|
|
93
105
|
symbol: string;
|
|
94
106
|
}[];
|
|
95
|
-
}
|
|
107
|
+
};
|
|
96
108
|
}>;
|
|
97
109
|
getLogs(params: GetLogsOptions): Promise<any[] | import("ethers").EventLog[] | import("ethers").EventLog[][]>;
|
|
98
110
|
getBalancesV2(): Balances;
|
package/build/ChainApi.js
CHANGED
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ChainApi = void 0;
|
|
7
|
+
exports.getDebugStats = getDebugStats;
|
|
7
8
|
const abi2_1 = require("./abi/abi2");
|
|
8
9
|
const Balances_1 = __importDefault(require("./Balances"));
|
|
9
10
|
const blocks_1 = require("./computeTVL/blocks");
|
|
10
11
|
const general_1 = require("./general");
|
|
11
12
|
const providers_json_1 = __importDefault(require("./providers.json"));
|
|
12
|
-
const multicall3_1 = require("./abi/multicall3");
|
|
13
13
|
const eth_1 = require("./eth");
|
|
14
|
-
const
|
|
14
|
+
const common_1 = require("./util/common");
|
|
15
15
|
const debugLog_1 = require("./util/debugLog");
|
|
16
16
|
const logs_1 = __importDefault(require("./util/logs"));
|
|
17
17
|
const transactions_1 = require("./util/transactions");
|
|
@@ -164,7 +164,7 @@ class ChainApi {
|
|
|
164
164
|
});
|
|
165
165
|
return this.getBalances();
|
|
166
166
|
}
|
|
167
|
-
async
|
|
167
|
+
async getTokenBalances({ token, tokens = [], owners = [], owner, tokensAndOwners = [], tokensAndOwners2 = [], blacklistedTokens = [], blacklistedOwners = [], ownerTokens = [], skipDuplicates = false, permitFailure = false, withTokenData = false, }) {
|
|
168
168
|
if (tokensAndOwners2.length)
|
|
169
169
|
tokensAndOwners.push(...tokensAndOwners2[0].map((i, j) => [i, tokensAndOwners2[1][j]]));
|
|
170
170
|
if (token)
|
|
@@ -176,36 +176,67 @@ class ChainApi {
|
|
|
176
176
|
}
|
|
177
177
|
for (const [tokens, owner] of ownerTokens)
|
|
178
178
|
tokens.forEach((i) => tokensAndOwners.push([i, owner]));
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
if (skipDuplicates)
|
|
180
|
+
tokensAndOwners = getUniqueTokensAndOwners(tokensAndOwners, this.chain);
|
|
181
|
+
blacklistedOwners = (0, common_1.getUniqueAddresses)(blacklistedOwners);
|
|
182
|
+
blacklistedTokens = (0, common_1.getUniqueAddresses)(blacklistedTokens);
|
|
182
183
|
tokensAndOwners = tokensAndOwners.filter(i => !blacklistedTokens.includes(i[0]) && !blacklistedOwners.includes(i[1]));
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
const tokenBalances = [];
|
|
185
|
+
const erc20TokensResponseIndex = [];
|
|
186
|
+
const ethBalanceResponseIndex = [];
|
|
187
|
+
const erc20TokensAndOwners = [];
|
|
188
|
+
const ethBalOwners = [];
|
|
189
|
+
tokensAndOwners.forEach((i, j) => {
|
|
190
|
+
if (i[0] !== nullAddress) {
|
|
191
|
+
erc20TokensAndOwners.push(i);
|
|
192
|
+
erc20TokensResponseIndex.push(j);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
ethBalOwners.push(i[1]);
|
|
196
|
+
ethBalanceResponseIndex.push(j);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
this.addStat('sumTokens', erc20TokensAndOwners.length + ethBalOwners.length, true);
|
|
186
200
|
const bals = await this.multiCall({
|
|
187
|
-
calls:
|
|
201
|
+
calls: erc20TokensAndOwners.map(([token, owner]) => ({ target: token, params: [owner] })),
|
|
188
202
|
abi: 'erc20:balanceOf',
|
|
203
|
+
permitFailure,
|
|
204
|
+
});
|
|
205
|
+
bals.forEach((i, j) => {
|
|
206
|
+
if (!i)
|
|
207
|
+
i = '0';
|
|
208
|
+
const token = erc20TokensAndOwners[j][0];
|
|
209
|
+
const responseIndex = erc20TokensResponseIndex[j];
|
|
210
|
+
tokenBalances[responseIndex] = [token, i];
|
|
189
211
|
});
|
|
190
|
-
this.addTokens(tokensAndOwners.map(i => i[0]), bals, balancesV2Options);
|
|
191
212
|
if (ethBalOwners.length) {
|
|
192
|
-
let ethBals =
|
|
193
|
-
|
|
194
|
-
if (multicallAddress) {
|
|
195
|
-
ethBals = await this.multiCall({
|
|
196
|
-
calls: ethBalOwners,
|
|
197
|
-
target: multicallAddress,
|
|
198
|
-
abi: 'function getEthBalance(address) view returns (uint256)',
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
const res = await (0, eth_1.getBalances)({ chain: this.chain, targets: ethBalOwners, block: this.block });
|
|
203
|
-
ethBals = res.output.map((i) => i.balance);
|
|
204
|
-
}
|
|
205
|
-
ethBals.map(i => this.addToken(nullAddress, i, balancesV2Options));
|
|
213
|
+
let ethBals = (await (0, eth_1.getBalances)({ chain: this.chain, targets: ethBalOwners, block: this.block, permitFailure })).output.map((i) => i.balance);
|
|
214
|
+
ethBals.map((i, idx) => tokenBalances[ethBalanceResponseIndex[idx]] = [nullAddress, i]);
|
|
206
215
|
}
|
|
216
|
+
if (!withTokenData)
|
|
217
|
+
return tokenBalances.map(i => i[1]);
|
|
218
|
+
return tokenBalances;
|
|
219
|
+
}
|
|
220
|
+
async sumTokens({ balancesV2Options = {}, ...tokenBalanceOptions }) {
|
|
221
|
+
const tokenBalances = await this.getTokenBalances({ ...tokenBalanceOptions, skipDuplicates: true, withTokenData: true });
|
|
222
|
+
tokenBalances.forEach(([token, balance]) => this.addToken(token, balance, balancesV2Options));
|
|
207
223
|
return this.getBalances();
|
|
208
224
|
}
|
|
225
|
+
async getERC20TokenBalances(options) {
|
|
226
|
+
return this.getTokenBalances(options);
|
|
227
|
+
}
|
|
228
|
+
async getGasTokenBalance(owner, options) {
|
|
229
|
+
return (await this.getGasTokenBalances({ ...options, owner, }))[0];
|
|
230
|
+
}
|
|
231
|
+
async getGasTokenBalances(options) {
|
|
232
|
+
return this.getTokenBalances({ ...options, token: nullAddress });
|
|
233
|
+
}
|
|
234
|
+
async getEthBalance(owner, options) {
|
|
235
|
+
return this.getGasTokenBalance(owner, options !== null && options !== void 0 ? options : {});
|
|
236
|
+
}
|
|
237
|
+
async getEthBalances(options) {
|
|
238
|
+
return this.getGasTokenBalances(options);
|
|
239
|
+
}
|
|
209
240
|
async getUSDValue() {
|
|
210
241
|
return this._balances.getUSDValue();
|
|
211
242
|
}
|
|
@@ -239,10 +270,9 @@ function getUniqueTokensAndOwners(toa, chain) {
|
|
|
239
270
|
if (!toa.length)
|
|
240
271
|
return [];
|
|
241
272
|
const mergedToa = toa.map(i => i.join('~'));
|
|
242
|
-
const uniqueMerged = (0,
|
|
273
|
+
const uniqueMerged = (0, common_1.getUniqueAddresses)(mergedToa, chain);
|
|
243
274
|
return uniqueMerged.map(i => i.split('~'));
|
|
244
275
|
}
|
|
245
276
|
function getDebugStats() {
|
|
246
277
|
return callStatsByProject;
|
|
247
278
|
}
|
|
248
|
-
exports.getDebugStats = getDebugStats;
|
package/build/abi/abi2.js
CHANGED
|
@@ -15,17 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
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
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.call = call;
|
|
37
|
+
exports.multiCall = multiCall;
|
|
38
|
+
exports.fetchList = fetchList;
|
|
39
|
+
exports.bytecodeCall = bytecodeCall;
|
|
27
40
|
const abi1 = __importStar(require("./index"));
|
|
28
|
-
const debugLog_1 = require("../util/debugLog");
|
|
29
41
|
async function call(params) {
|
|
30
42
|
try {
|
|
31
43
|
const response = await abi1.call(params);
|
|
@@ -43,7 +55,6 @@ async function call(params) {
|
|
|
43
55
|
return null;
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
|
-
exports.call = call;
|
|
47
58
|
async function multiCall(params) {
|
|
48
59
|
if (params.excludeFailed)
|
|
49
60
|
params.permitFailure = true;
|
|
@@ -66,7 +77,6 @@ async function multiCall(params) {
|
|
|
66
77
|
return output;
|
|
67
78
|
return output.map((i) => i.output);
|
|
68
79
|
}
|
|
69
|
-
exports.multiCall = multiCall;
|
|
70
80
|
async function fetchList(params) {
|
|
71
81
|
// itemAbi2 is used when we need to make a second call to get the final result
|
|
72
82
|
let { startFrom = 0, lengthAbi, itemAbi, withMetadata, startFromOne = false, itemCount, target, targets, calls: _targets, chain, block, permitFailure, groupedByInput, excludeFailed, itemAbi2, field, field2, } = params;
|
|
@@ -93,7 +103,7 @@ async function fetchList(params) {
|
|
|
93
103
|
itemLength = itemCount;
|
|
94
104
|
else
|
|
95
105
|
itemLength = await call({ chain, block, target, abi: lengthAbi, });
|
|
96
|
-
|
|
106
|
+
// debugLog('length: ', itemLength)
|
|
97
107
|
if (startFromOne) {
|
|
98
108
|
itemLength++;
|
|
99
109
|
if (startFrom === 0)
|
|
@@ -110,7 +120,7 @@ async function fetchList(params) {
|
|
|
110
120
|
itemLengths = targets.map(() => itemCount);
|
|
111
121
|
else
|
|
112
122
|
itemLengths = await multiCall({ chain, block, calls: targets, abi: lengthAbi, });
|
|
113
|
-
|
|
123
|
+
// debugLog('itemLengths: ', itemLengths)
|
|
114
124
|
let groupedByRes = itemLengths.map(() => []);
|
|
115
125
|
const indexToTargetMapping = {};
|
|
116
126
|
let k = 0;
|
|
@@ -146,11 +156,9 @@ async function fetchList(params) {
|
|
|
146
156
|
res2.forEach((i, idx) => groupedByRes[indexToTargetMapping[idx]].push(i));
|
|
147
157
|
return groupedByRes;
|
|
148
158
|
}
|
|
149
|
-
exports.fetchList = fetchList;
|
|
150
159
|
async function bytecodeCall(params) {
|
|
151
160
|
const response = await abi1.bytecodeCall(params);
|
|
152
161
|
if (params.withMetadata)
|
|
153
162
|
return response;
|
|
154
163
|
return response.output;
|
|
155
164
|
}
|
|
156
|
-
exports.bytecodeCall = bytecodeCall;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
export default function (results: ethers.Result, functionABI?:
|
|
2
|
+
export default function (results: ethers.Result, { functionABI, chain }?: {
|
|
3
|
+
functionABI?: ethers.FunctionFragment;
|
|
4
|
+
chain?: string;
|
|
5
|
+
}): any;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const common_1 = require("../util/common");
|
|
3
5
|
function isNumberOrBigNumber(value) {
|
|
4
6
|
return typeof value === 'bigint' || typeof value === "number";
|
|
5
7
|
}
|
|
@@ -17,7 +19,7 @@ function stringifyBigNumbers(result) {
|
|
|
17
19
|
});
|
|
18
20
|
return final;
|
|
19
21
|
}
|
|
20
|
-
function default_1(results, functionABI) {
|
|
22
|
+
function default_1(results, { functionABI, chain } = {}) {
|
|
21
23
|
let response;
|
|
22
24
|
if (typeof results === "string" || typeof results === "boolean")
|
|
23
25
|
return results;
|
|
@@ -25,11 +27,9 @@ function default_1(results, functionABI) {
|
|
|
25
27
|
return results.toString();
|
|
26
28
|
response = stringifyBigNumbers(results);
|
|
27
29
|
if (functionABI && functionABI.outputs) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (name)
|
|
32
|
-
response[name] = response[i];
|
|
30
|
+
functionABI.outputs.map((componentDefinition, i) => {
|
|
31
|
+
setComponentDetails(response[i], componentDefinition, chain);
|
|
32
|
+
setNameAndTranformAddress({ response, componentDefinition, chain, index: i });
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
if (response instanceof Array)
|
|
@@ -37,19 +37,24 @@ function default_1(results, functionABI) {
|
|
|
37
37
|
return response[0];
|
|
38
38
|
return response;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
function setComponentDetails(component, componentDefinition) {
|
|
40
|
+
function setComponentDetails(component, componentDefinition, chain) {
|
|
42
41
|
if (componentDefinition.type === "tuple[]")
|
|
43
|
-
return component.map(setDetails);
|
|
42
|
+
return component.map((item) => setDetails(item, chain));
|
|
44
43
|
if (componentDefinition.type === "tuple")
|
|
45
|
-
return setDetails(component);
|
|
46
|
-
function setDetails(value) {
|
|
44
|
+
return setDetails(component, chain);
|
|
45
|
+
function setDetails(value, chain) {
|
|
47
46
|
const definitions = componentDefinition.components || componentDefinition.arrayChildren.components;
|
|
48
47
|
definitions.map((def, i) => {
|
|
49
|
-
setComponentDetails(value[i], def);
|
|
50
|
-
|
|
51
|
-
if (name)
|
|
52
|
-
value[name] = value[i];
|
|
48
|
+
setComponentDetails(value[i], def, chain);
|
|
49
|
+
setNameAndTranformAddress({ response: value, componentDefinition: def, chain, index: i });
|
|
53
50
|
});
|
|
54
51
|
}
|
|
55
52
|
}
|
|
53
|
+
function setNameAndTranformAddress({ response, componentDefinition, chain, index }) {
|
|
54
|
+
if (chain === 'tron' && componentDefinition.type === 'address') {
|
|
55
|
+
response[index] = (0, common_1.evmToTronAddress)(response[index]);
|
|
56
|
+
}
|
|
57
|
+
if (componentDefinition === null || componentDefinition === void 0 ? void 0 : componentDefinition.name)
|
|
58
|
+
response[componentDefinition.name] = response[index];
|
|
59
|
+
return response;
|
|
60
|
+
}
|
package/build/abi/index.js
CHANGED
|
@@ -1,32 +1,11 @@
|
|
|
1
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
6
|
+
exports.call = call;
|
|
7
|
+
exports.bytecodeCall = bytecodeCall;
|
|
8
|
+
exports.multiCall = multiCall;
|
|
30
9
|
const cachedABIs_1 = __importDefault(require("./cachedABIs"));
|
|
31
10
|
const ethers_1 = require("ethers");
|
|
32
11
|
const general_1 = require("../general");
|
|
@@ -35,8 +14,7 @@ const convertResults_1 = __importDefault(require("./convertResults"));
|
|
|
35
14
|
const debugLog_1 = require("../util/debugLog");
|
|
36
15
|
const internal_cache_1 = require("../util/internal-cache");
|
|
37
16
|
const util_1 = require("../util");
|
|
38
|
-
const
|
|
39
|
-
const generalUtil_1 = require("../generalUtil");
|
|
17
|
+
const common_1 = require("../util/common");
|
|
40
18
|
const env_1 = require("../util/env");
|
|
41
19
|
const nullAddress = '0x0000000000000000000000000000000000000000';
|
|
42
20
|
// https://docs.soliditylang.org/en/latest/abi-spec.html
|
|
@@ -102,12 +80,12 @@ function fixBlockTag(params) {
|
|
|
102
80
|
function isValidTarget(target, chain) {
|
|
103
81
|
if (typeof target !== 'string')
|
|
104
82
|
return false;
|
|
105
|
-
if (chain === 'tron')
|
|
106
|
-
return true;
|
|
107
83
|
return target.startsWith('0x') && target !== nullAddress;
|
|
108
84
|
}
|
|
109
85
|
async function call(params) {
|
|
110
86
|
var _a;
|
|
87
|
+
if (params.chain === 'tron')
|
|
88
|
+
(0, common_1.fixTronCallParams)(params);
|
|
111
89
|
if (!isValidTarget(params.target, params.chain))
|
|
112
90
|
throw new Error('Invalid target: ' + params.target);
|
|
113
91
|
fixBlockTag(params);
|
|
@@ -120,8 +98,7 @@ async function call(params) {
|
|
|
120
98
|
return cachedCall(params);
|
|
121
99
|
const abi = resolveABI(params.abi);
|
|
122
100
|
const callParams = normalizeParams(params.params);
|
|
123
|
-
if (chain === 'tron')
|
|
124
|
-
return Tron.call({ ...params, abi, params: callParams });
|
|
101
|
+
// if (chain === 'tron') return Tron.call({ ...params, abi, params: callParams })
|
|
125
102
|
const contractInterface = new ethers_1.ethers.Interface([abi]);
|
|
126
103
|
const functionABI = ethers_1.ethers.FunctionFragment.from(abi);
|
|
127
104
|
const callData = contractInterface.encodeFunctionData(functionABI, callParams);
|
|
@@ -134,7 +111,7 @@ async function call(params) {
|
|
|
134
111
|
});
|
|
135
112
|
errorParams.result = result;
|
|
136
113
|
const decodedResult = contractInterface.decodeFunctionResult(abi, result);
|
|
137
|
-
const output = (0, convertResults_1.default)(decodedResult, functionABI);
|
|
114
|
+
const output = (0, convertResults_1.default)(decodedResult, { functionABI, chain });
|
|
138
115
|
if (params.logArray && abi.name == 'balanceOf' && abi.outputs[0].type == 'uint256')
|
|
139
116
|
params.logArray.push({
|
|
140
117
|
chain,
|
|
@@ -148,10 +125,9 @@ async function call(params) {
|
|
|
148
125
|
}
|
|
149
126
|
catch (e) {
|
|
150
127
|
errorParams.isCallError = true;
|
|
151
|
-
throw (0,
|
|
128
|
+
throw (0, common_1.formError)(e, errorParams);
|
|
152
129
|
}
|
|
153
130
|
}
|
|
154
|
-
exports.call = call;
|
|
155
131
|
async function bytecodeCall(params) {
|
|
156
132
|
fixBlockTag(params);
|
|
157
133
|
const { block, bytecode, inputTypes, inputs, outputTypes, chain } = params;
|
|
@@ -164,13 +140,14 @@ async function bytecodeCall(params) {
|
|
|
164
140
|
const result = await (0, general_1.getProvider)(chain).call({ data: callData, blockTag: block });
|
|
165
141
|
const decodedResult = ethers_1.ethers.AbiCoder.defaultAbiCoder().decode(outputTypes, result);
|
|
166
142
|
return {
|
|
167
|
-
output: (0, convertResults_1.default)(decodedResult),
|
|
143
|
+
output: (0, convertResults_1.default)(decodedResult, { chain }),
|
|
168
144
|
};
|
|
169
145
|
}
|
|
170
|
-
exports.bytecodeCall = bytecodeCall;
|
|
171
146
|
async function multiCall(params) {
|
|
172
147
|
var _a;
|
|
173
148
|
fixBlockTag(params);
|
|
149
|
+
if (params.chain === 'tron')
|
|
150
|
+
(0, common_1.fixTronCallParams)(params);
|
|
174
151
|
if (cachedABIs_1.default[params.abi])
|
|
175
152
|
params.abi = cachedABIs_1.default[params.abi];
|
|
176
153
|
const chain = (_a = params.chain) !== null && _a !== void 0 ? _a : 'ethereum';
|
|
@@ -195,7 +172,7 @@ async function multiCall(params) {
|
|
|
195
172
|
return !isValidTarget(i.target, params.chain);
|
|
196
173
|
return true;
|
|
197
174
|
})) {
|
|
198
|
-
|
|
175
|
+
// debugLog('Multicall is missing target', JSON.stringify(params, null, 2))
|
|
199
176
|
throw new Error('Multicall is missing a target');
|
|
200
177
|
}
|
|
201
178
|
}
|
|
@@ -217,7 +194,8 @@ async function multiCall(params) {
|
|
|
217
194
|
const results = await (0, util_1.runInPromisePool)({
|
|
218
195
|
items: (0, util_1.sliceIntoChunks)(contractCalls, chunkSize),
|
|
219
196
|
concurrency: 10,
|
|
220
|
-
processor: (calls) => (0, multicall3_1.default)(abi, calls, chain, params.block)
|
|
197
|
+
processor: (calls) => (0, multicall3_1.default)(abi, calls, chain, params.block),
|
|
198
|
+
permitFailure: params.permitFailure,
|
|
221
199
|
});
|
|
222
200
|
const flatResults = [].concat.apply([], results);
|
|
223
201
|
const failedQueries = flatResults.filter(r => !r.success);
|
|
@@ -226,7 +204,7 @@ async function multiCall(params) {
|
|
|
226
204
|
if (!params.permitFailure) {
|
|
227
205
|
params.failedQueries = failedQueries;
|
|
228
206
|
params.isMultiCallError = true;
|
|
229
|
-
throw (0,
|
|
207
|
+
throw (0, common_1.formError)(null, params);
|
|
230
208
|
}
|
|
231
209
|
}
|
|
232
210
|
if (params.logArray && abi.name == 'balanceOf' && abi.outputs[0].type == 'uint256')
|
|
@@ -240,7 +218,6 @@ async function multiCall(params) {
|
|
|
240
218
|
output: flatResults, // flatten array
|
|
241
219
|
};
|
|
242
220
|
}
|
|
243
|
-
exports.multiCall = multiCall;
|
|
244
221
|
async function cachedCall(params) {
|
|
245
222
|
params.skipCache = true;
|
|
246
223
|
if (!isCachableAbi(params.abi))
|
package/build/abi/multicall.js
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
6
|
+
exports.AGGREGATE_SELECTOR = exports.MULTICALL_ADDRESS_OPTIMISM = exports.MULTICALL_ADDRESS_AURORA = exports.MULTICALL_ADDRESS_MOONRIVER = exports.MULTICALL_ADDRESS_AVAX = exports.MULTICALL_ADDRESS_ARBITRUM = exports.MULTICALL_ADDRESS_HARMONY = exports.MULTICALL_ADDRESS_HECO = exports.MULTICALL_ADDRESS_XDAI = exports.MULTICALL_ADDRESS_FANTOM = exports.MULTICALL_ADDRESS_BSC = exports.MULTICALL_ADDRESS_POLYGON = exports.MULTICALL_ADDRESS_GOERLI = exports.MULTICALL_ADDRESS_RINKEBY = exports.MULTICALL_ADDRESS_KOVAN = exports.MULTICALL_ADDRESS_MAINNET = void 0;
|
|
7
|
+
exports.default = makeMultiCall;
|
|
8
|
+
exports.multicallAddressOrThrow = multicallAddressOrThrow;
|
|
9
|
+
exports.networkSupportsMulticall = networkSupportsMulticall;
|
|
30
10
|
const ethers_1 = require("ethers");
|
|
31
11
|
const general_1 = require("../general");
|
|
32
12
|
const convertResults_1 = __importDefault(require("./convertResults"));
|
|
33
13
|
const rpcCall_1 = require("./rpcCall");
|
|
34
14
|
const debugLog_1 = require("../util/debugLog");
|
|
35
15
|
const util_1 = require("../util");
|
|
36
|
-
const Tron = __importStar(require("./tron"));
|
|
37
16
|
const env_1 = require("../util/env");
|
|
38
17
|
exports.MULTICALL_ADDRESS_MAINNET = "0xeefba1e63905ef1d7acba5a8513c70307c1ce441";
|
|
39
18
|
exports.MULTICALL_ADDRESS_KOVAN = "0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a";
|
|
@@ -52,8 +31,6 @@ exports.MULTICALL_ADDRESS_AURORA = "0xe0e3887b158F7F9c80c835a61ED809389BC08d1b";
|
|
|
52
31
|
exports.MULTICALL_ADDRESS_OPTIMISM = "0xD0E99f15B24F265074747B2A1444eB02b9E30422";
|
|
53
32
|
exports.AGGREGATE_SELECTOR = "0x252dba42";
|
|
54
33
|
async function makeMultiCall(functionABI, calls, chain, block) {
|
|
55
|
-
if (chain === 'tron')
|
|
56
|
-
return Tron.multiCall(functionABI, calls);
|
|
57
34
|
const contractInterface = new ethers_1.ethers.Interface([functionABI]);
|
|
58
35
|
let fd = contractInterface.fragments[0];
|
|
59
36
|
const contractCalls = calls.map((call) => {
|
|
@@ -68,7 +45,7 @@ async function makeMultiCall(functionABI, calls, chain, block) {
|
|
|
68
45
|
let output;
|
|
69
46
|
let error = undefined;
|
|
70
47
|
try {
|
|
71
|
-
output = (0, convertResults_1.default)(contractInterface.decodeFunctionResult(fd, values), fd);
|
|
48
|
+
output = (0, convertResults_1.default)(contractInterface.decodeFunctionResult(fd, values), { functionABI: fd, chain });
|
|
72
49
|
}
|
|
73
50
|
catch (e) {
|
|
74
51
|
output = null;
|
|
@@ -87,7 +64,6 @@ async function makeMultiCall(functionABI, calls, chain, block) {
|
|
|
87
64
|
return res;
|
|
88
65
|
});
|
|
89
66
|
}
|
|
90
|
-
exports.default = makeMultiCall;
|
|
91
67
|
async function executeCalls(contractCalls, chain, block) {
|
|
92
68
|
if (await networkSupportsMulticall(chain)) {
|
|
93
69
|
try {
|
|
@@ -154,7 +130,6 @@ async function multicallAddressOrThrow(chain) {
|
|
|
154
130
|
}
|
|
155
131
|
return address;
|
|
156
132
|
}
|
|
157
|
-
exports.multicallAddressOrThrow = multicallAddressOrThrow;
|
|
158
133
|
const networkMulticallCache = {};
|
|
159
134
|
async function networkSupportsMulticall(chain) {
|
|
160
135
|
var _a;
|
|
@@ -168,7 +143,6 @@ async function networkSupportsMulticall(chain) {
|
|
|
168
143
|
}
|
|
169
144
|
return networkMulticallCache[chain];
|
|
170
145
|
}
|
|
171
|
-
exports.networkSupportsMulticall = networkSupportsMulticall;
|
|
172
146
|
function multicallAddress(chainId) {
|
|
173
147
|
if (typeof chainId === "bigint")
|
|
174
148
|
chainId = Number(chainId);
|
|
@@ -394,6 +368,7 @@ function multicallAddress(chainId) {
|
|
|
394
368
|
return '0x63cee78B11774535132fd773C5dDe3c4b41CD07f';
|
|
395
369
|
case 11820: return '0x6d761c3fe633c67b1d3a55678b04eb4ad11c4642'; // artela
|
|
396
370
|
case 2355: return '0x566da61a4D0841a67bA8F2c7e5975885fa0Af4DA'; // silicon_zk
|
|
371
|
+
case 728126428: return 'TEazPvZwDjDtFeJupyo7QunvnrnUjPH8ED'; // silicon_zk
|
|
397
372
|
default:
|
|
398
373
|
return null;
|
|
399
374
|
}
|