@cryptorubic/web3 1.5.1-alpha.tron.5 → 1.5.1-alpha.tron.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptorubic/web3",
3
- "version": "1.5.1-alpha.tron.5",
3
+ "version": "1.5.1-alpha.tron.6",
4
4
  "dependencies": {
5
5
  "@ethersproject/bignumber": "^5.8.0",
6
6
  "@mysten/sui": "^1.24.0",
@@ -75,10 +75,10 @@ class TronAdapter extends abstract_adapter_1.AbstractAdapter {
75
75
  return tokensBalances;
76
76
  }
77
77
  async batchMulticallTokenBalance(userAddress, tokensAddresses, batchSize) {
78
- const multicalls = [];
78
+ const balances = [];
79
79
  for (let i = 0; i < tokensAddresses.length; i += batchSize) {
80
80
  const batchRequest = tokensAddresses.slice(i, i + batchSize);
81
- const multicallPromise = this.multicallContractsMethods(trc_20_contract_abi_1.TRC20_CONTRACT_ABI, batchRequest.map((tokenAddress) => ({
81
+ const batchResult = await this.multicallContractsMethods(trc_20_contract_abi_1.TRC20_CONTRACT_ABI, batchRequest.map((tokenAddress) => ({
82
82
  contractAddress: tokenAddress,
83
83
  methodsData: [
84
84
  {
@@ -87,10 +87,8 @@ class TronAdapter extends abstract_adapter_1.AbstractAdapter {
87
87
  }
88
88
  ]
89
89
  })));
90
- multicalls.push(multicallPromise);
90
+ balances.push(...batchResult);
91
91
  }
92
- const res = await Promise.all(multicalls);
93
- const balances = res.map((batchResult) => batchResult.flat());
94
92
  return balances;
95
93
  }
96
94
  // public async multicallContractsMethods<Output extends TronWeb3PrimitiveType>(
@@ -147,6 +145,10 @@ class TronAdapter extends abstract_adapter_1.AbstractAdapter {
147
145
  let outputIndex = 0;
148
146
  return contractsData.map((contractData) => contractData.methodsData.map((methodData) => {
149
147
  const output = outputs[outputIndex];
148
+ if (!output) {
149
+ console.log('[multicallContractsMethods] Error index:', { outputIndex, outputs });
150
+ return { output: null, success: false };
151
+ }
150
152
  const methodOutputAbi = contractAbi.find((funcSignature) => funcSignature.name === methodData.methodName).outputs;
151
153
  outputIndex++;
152
154
  return {
@@ -156,11 +158,10 @@ class TronAdapter extends abstract_adapter_1.AbstractAdapter {
156
158
  }));
157
159
  }
158
160
  catch (err) {
159
- console.log('[multicallContractsMethods] err ==>', err);
160
161
  this.logger
161
162
  ? this.logger.customError('[TronAdapter_multicallContractsMethods] Error: ', err)
162
163
  : console.debug('[TronAdapter_multicallContractsMethods] Error:', err);
163
- return this.multicallContractsMethodsByOne(contractAbi, contractsData);
164
+ return contractsData.map((contractData) => contractData.methodsData.map(() => ({ output: null, success: false })));
164
165
  }
165
166
  }
166
167
  async getBlockNumber() {