@defillama/sdk 5.0.185 → 5.0.188
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 +1 -0
- package/build/Balances.js +2 -1
- package/build/ChainApi.d.ts +1 -0
- package/build/ChainApi.js +19 -5
- package/build/abi/multicall3.js +1 -0
- package/build/generalUtil.d.ts +1 -0
- package/build/generalUtil.js +5 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/providers.json +1 -1
- package/build/util/LlamaProvider.d.ts +10 -0
- package/build/util/LlamaProvider.js +23 -1
- package/build/util/coins.d.ts +1 -0
- package/build/util/common.js +2 -2
- package/build/util/env.js +2 -1
- package/build/util/indexer.d.ts +16 -0
- package/build/util/indexer.js +323 -78
- package/build/util/logs.decode.shared.d.ts +8 -0
- package/build/util/logs.decode.shared.js +288 -0
- package/build/util/logs.js +31 -19
- package/build/util/updateProviderList.js +61 -16
- package/package.json +5 -2
|
@@ -4,6 +4,13 @@ type ProviderWithURL = {
|
|
|
4
4
|
url: string;
|
|
5
5
|
provider: AbstractProvider;
|
|
6
6
|
};
|
|
7
|
+
type ProviderConfigMap = {
|
|
8
|
+
[chain: string]: {
|
|
9
|
+
rpc?: string[];
|
|
10
|
+
chainId?: number;
|
|
11
|
+
explorer?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
7
14
|
export declare class LlamaProvider extends FallbackProvider {
|
|
8
15
|
isCustomLlamaProvider: boolean;
|
|
9
16
|
rpcs: ProviderWithURL[];
|
|
@@ -28,6 +35,9 @@ export declare class LlamaProvider extends FallbackProvider {
|
|
|
28
35
|
getTransactionReceipt(_hash: string): Promise<any>;
|
|
29
36
|
_performAction(method: string, params: any, attempts?: number): Promise<any>;
|
|
30
37
|
}
|
|
38
|
+
export declare function getEVMProvidersConfigMap(): ProviderConfigMap;
|
|
39
|
+
export declare function getEVMChainSet(): Set<string>;
|
|
40
|
+
export declare function isEvmChain(chain: string): boolean;
|
|
31
41
|
export declare const providers: {
|
|
32
42
|
[chain: string]: AbstractProvider;
|
|
33
43
|
};
|
|
@@ -4,6 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.providers = exports.LlamaProvider = void 0;
|
|
7
|
+
exports.getEVMProvidersConfigMap = getEVMProvidersConfigMap;
|
|
8
|
+
exports.getEVMChainSet = getEVMChainSet;
|
|
9
|
+
exports.isEvmChain = isEvmChain;
|
|
7
10
|
exports.setProvider = setProvider;
|
|
8
11
|
exports.getProvider = getProvider;
|
|
9
12
|
const ethers_1 = require("ethers");
|
|
@@ -146,6 +149,25 @@ class LlamaProvider extends ethers_1.FallbackProvider {
|
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
151
|
exports.LlamaProvider = LlamaProvider;
|
|
152
|
+
function getEVMProvidersConfigMap() {
|
|
153
|
+
return buildProviders !== null && buildProviders !== void 0 ? buildProviders : providers_json_1.default;
|
|
154
|
+
}
|
|
155
|
+
let evmChainSet = null;
|
|
156
|
+
function getEVMChainSet() {
|
|
157
|
+
if (!evmChainSet) {
|
|
158
|
+
const pList = getEVMProvidersConfigMap();
|
|
159
|
+
evmChainSet = new Set(Object.keys(pList));
|
|
160
|
+
}
|
|
161
|
+
return evmChainSet;
|
|
162
|
+
}
|
|
163
|
+
function isEvmChain(chain) {
|
|
164
|
+
const pList = getEVMProvidersConfigMap();
|
|
165
|
+
if (pList[chain])
|
|
166
|
+
return true;
|
|
167
|
+
// check if we have RPC config for this chain via env variable
|
|
168
|
+
// let rpcList: (string | undefined) = getChainRPCs(chain, undefined) // skip this check as it can be true for non-evm chains like solana as well
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
149
171
|
function createProvider(name, rpcString, chainId = 400069, archivalRPCList = []) {
|
|
150
172
|
chainId = (0, env_1.getChainId)(name, chainId);
|
|
151
173
|
const networkish = { name, chainId };
|
|
@@ -193,7 +215,7 @@ function getProvider(chain = "ethereum", _getArchivalNode = false) {
|
|
|
193
215
|
chainKey = chain + '_historical';
|
|
194
216
|
if (exports.providers[chainKey])
|
|
195
217
|
return exports.providers[chainKey];
|
|
196
|
-
const pList =
|
|
218
|
+
const pList = getEVMProvidersConfigMap();
|
|
197
219
|
// use RPC from env variable if set else use RPC from providers.json
|
|
198
220
|
let rpcList = (0, env_1.getChainRPCs)(rpcKey, (_a = pList[chain]) === null || _a === void 0 ? void 0 : _a.rpc);
|
|
199
221
|
let archivalRPCList = (0, env_1.getArchivalRPCs)(rpcKey);
|
package/build/util/coins.d.ts
CHANGED
package/build/util/common.js
CHANGED
|
@@ -120,7 +120,7 @@ function sumSingleBalance(balances, token, balance, chain) {
|
|
|
120
120
|
if (typeof balance.toString === 'function')
|
|
121
121
|
balance = balance.toString();
|
|
122
122
|
else
|
|
123
|
-
throw new Error('Invalid balance value:' + balance);
|
|
123
|
+
throw new Error('Invalid balance value:' + balance + ' ' + token);
|
|
124
124
|
}
|
|
125
125
|
if (typeof balance === 'number' || (balances[token] && typeof balances[token] === 'number')) {
|
|
126
126
|
const prevBalance = +(balances.hasOwnProperty(token) ? balances[token] : 0);
|
|
@@ -140,7 +140,7 @@ function sumSingleBalance(balances, token, balance, chain) {
|
|
|
140
140
|
if (typeof value === 'bigint')
|
|
141
141
|
return;
|
|
142
142
|
if ([null, undefined].includes(value) || isNaN(+value))
|
|
143
|
-
throw new Error(`Invalid balance: ${balance}`);
|
|
143
|
+
throw new Error(`Invalid balance: ${balance} - ${token}`);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
function mergeBalances(balances, balancesToMerge) {
|
package/build/util/env.js
CHANGED
|
@@ -19,13 +19,14 @@ exports.shouldSkipBlockValidation = shouldSkipBlockValidation;
|
|
|
19
19
|
exports.getBoolEnvValue = getBoolEnvValue;
|
|
20
20
|
const whitelistedEnvConstants = [
|
|
21
21
|
'R2_ENDPOINT', 'R2_ACCESS_KEY_ID', 'R2_SECRET_ACCESS_KEY', 'TRON_PRO_API_KEY', 'COINS_API_KEY',
|
|
22
|
-
'ELASTICSEARCH_CONFIG', 'GRAPH_API_KEY', 'LLAMA_INDEXER_ENDPOINT', 'LLAMA_INDEXER_API_KEY', 'LLAMA_INDEXER_V2_ENDPOINT', 'LLAMA_INDEXER_V2_API_KEY',
|
|
22
|
+
'ELASTICSEARCH_CONFIG', 'GRAPH_API_KEY', 'LLAMA_INDEXER_ENDPOINT', 'LLAMA_INDEXER_API_KEY', 'LLAMA_INDEXER_V2_ENDPOINT', 'LLAMA_INDEXER_V2_API_KEY', 'LLAMA_INDEXER_TIMEOUT_MS'
|
|
23
23
|
];
|
|
24
24
|
const isDebugLevel3 = process.env.LLAMA_SDK_DEBUG_LEVEL_3 === 'true';
|
|
25
25
|
const defaultEnvValues = {
|
|
26
26
|
INTERNAL_SDK_CACHE_FILE: './cache.json',
|
|
27
27
|
TRON_RPC_CONCURRENCY_LIMIT: '5',
|
|
28
28
|
LLAMA_INDEXER_ADDRESS_CHUNK_SIZE: '20',
|
|
29
|
+
LLAMA_INDEXER_TIMEOUT_MS: '300000',
|
|
29
30
|
TRON_WALLET_RPC: 'https://api.trongrid.io',
|
|
30
31
|
// TRON_EVM_RPC: 'https://rpc.ankr.com/tron_jsonrpc', // no longer used
|
|
31
32
|
NAKA_RPC: 'https://node.nakachain.xyz',
|
package/build/util/indexer.d.ts
CHANGED
|
@@ -27,10 +27,26 @@ export type IndexerGetLogsOptions = {
|
|
|
27
27
|
offset?: number;
|
|
28
28
|
debugMode?: boolean;
|
|
29
29
|
noTarget?: boolean;
|
|
30
|
+
collect?: boolean;
|
|
30
31
|
parseLog?: boolean;
|
|
31
32
|
processor?: (logs: any[]) => Promise<void> | void;
|
|
32
33
|
maxBlockRange?: number;
|
|
33
34
|
allowParseFailure?: boolean;
|
|
35
|
+
/** Feature flag: enable client-side streaming of /logs v2 */
|
|
36
|
+
clientStreaming?: boolean;
|
|
37
|
+
/** Decoder type: 'viem' (faster) or 'ethers' (fallback) */
|
|
38
|
+
decoderType?: "viem" | "ethers";
|
|
39
|
+
/** Metrics hooks (optional) */
|
|
40
|
+
onWireStats?: (s: {
|
|
41
|
+
chunkSize: number;
|
|
42
|
+
bytesReceived: number;
|
|
43
|
+
itemsProcessed: number;
|
|
44
|
+
}) => void;
|
|
45
|
+
onDecodeStats?: (s: {
|
|
46
|
+
batchSize: number;
|
|
47
|
+
decodeTime: number;
|
|
48
|
+
itemsDecoded: number;
|
|
49
|
+
}) => void;
|
|
34
50
|
};
|
|
35
51
|
export type IndexerGetTokenTransfersOptions = {
|
|
36
52
|
target?: Address;
|