@defillama/sdk 5.0.78 → 5.0.81

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.
@@ -168,11 +168,12 @@ function setProvider(chain, provider) {
168
168
  exports.setProvider = setProvider;
169
169
  function getProvider(chain = "ethereum", _getArchivalNode = false) {
170
170
  var _a, _b;
171
+ const rpcKey = chain === 'tron' ? 'tron_evm' : chain;
171
172
  if (exports.providers[chain])
172
173
  return exports.providers[chain];
173
174
  // use RPC from env variable if set else use RPC from providers.json
174
- let rpcList = (0, env_1.getChainRPCs)(chain, (_a = providers_json_1.default[chain]) === null || _a === void 0 ? void 0 : _a.rpc);
175
- let archivalRPCList = (0, env_1.getArchivalRPCs)(chain);
175
+ let rpcList = (0, env_1.getChainRPCs)(rpcKey, (_a = providers_json_1.default[chain]) === null || _a === void 0 ? void 0 : _a.rpc);
176
+ let archivalRPCList = (0, env_1.getArchivalRPCs)(rpcKey);
176
177
  if (!rpcList) {
177
178
  // @ts-ignore (throwing error here would alter function behavior and have side effects)
178
179
  return null;
package/build/util/env.js CHANGED
@@ -12,6 +12,7 @@ const defaultEnvValues = {
12
12
  INTERNAL_SDK_CACHE_FILE: './cache.json',
13
13
  TRON_RPC_CONCURRENCY_LIMIT: '5',
14
14
  TRON_RPC: 'https://api.trongrid.io',
15
+ TRON_EVM_RPC: 'https://rpc.ankr.com/tron_jsonrpc',
15
16
  NAKA_RPC: 'https://node.nakachain.xyz',
16
17
  ETHF_RPC: 'https://rpc.dischain.xyz/',
17
18
  CORE_RPC: "https://rpc.coredao.org,https://rpc.ankr.com/core,https://1rpc.io/core,https://rpc-core.icecreamswap.com",
@@ -101,8 +102,7 @@ function getArchivalRPCs(chain) {
101
102
  }
102
103
  exports.getArchivalRPCs = getArchivalRPCs;
103
104
  function getChainRPCs(chain, defaultList = []) {
104
- const key = chain + '_RPC';
105
- const envValue = getEnvValue(key);
105
+ const envValue = getEnvRPC(chain);
106
106
  if (defaultList.length) {
107
107
  const listString = defaultList.join(',');
108
108
  if (envValue)
@@ -6,6 +6,7 @@ const ethers_1 = require("ethers");
6
6
  const blocks_1 = require("./blocks");
7
7
  const cache_1 = require("./cache");
8
8
  const debugLog_1 = require("./debugLog");
9
+ const tron_1 = require("../abi/tron");
9
10
  const currentVersion = 'v3';
10
11
  async function getLogs(options) {
11
12
  let { target, chain = 'ethereum', fromBlock, toBlock, fromTimestamp, toTimestamp, eventAbi, topic, topics, extraTopics, // can be passed as input as extra filter arguments
@@ -30,6 +31,8 @@ async function getLogs(options) {
30
31
  return res.flat();
31
32
  return res;
32
33
  }
34
+ if (chain === 'tron')
35
+ target = (0, tron_1.hexifyTarget)(target);
33
36
  let iface;
34
37
  if (eventAbi)
35
38
  iface = new ethers_1.Interface([eventAbi]);
@@ -50,6 +50,11 @@ async function main() {
50
50
  return;
51
51
  }
52
52
  i.rpc = Array.from(new Set(filterRPCs(i.rpc)));
53
+ if (key.endsWith('-mainnet')) {
54
+ const shortName = key.slice(0, -8);
55
+ if (!providerList[shortName])
56
+ providerList[shortName] = i;
57
+ }
53
58
  });
54
59
  Object.keys(providerList).forEach((i) => {
55
60
  if (!providerList[i].rpc.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defillama/sdk",
3
- "version": "5.0.78",
3
+ "version": "5.0.81",
4
4
  "description": "SDK for calculating TVL",
5
5
  "main": "build/index.js",
6
6
  "scripts": {