@atomiqlabs/chain-evm 1.0.0-dev.47 → 1.0.0-dev.48

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.
@@ -4,6 +4,7 @@ exports.EVMTransactions = void 0;
4
4
  const EVMModule_1 = require("../EVMModule");
5
5
  const ethers_1 = require("ethers");
6
6
  const Utils_1 = require("../../../utils/Utils");
7
+ const MAX_UNCONFIRMED_TXNS = 10;
7
8
  class EVMTransactions extends EVMModule_1.EVMModule {
8
9
  constructor() {
9
10
  super(...arguments);
@@ -116,7 +117,7 @@ class EVMTransactions extends EVMModule_1.EVMModule {
116
117
  " waitForConfirmation: " + waitForConfirmation + " parallel: " + parallel);
117
118
  const txIds = [];
118
119
  if (parallel) {
119
- const promises = [];
120
+ let promises = [];
120
121
  for (let i = 0; i < txs.length; i++) {
121
122
  let tx;
122
123
  if (signer.isBrowserWallet) {
@@ -131,6 +132,10 @@ class EVMTransactions extends EVMModule_1.EVMModule {
131
132
  promises.push(this.confirmTransaction(tx, abortSignal));
132
133
  txIds.push(tx.hash);
133
134
  this.logger.debug("sendAndConfirm(): transaction sent (" + (i + 1) + "/" + signedTxs.length + "): " + tx.hash);
135
+ if (promises.length >= MAX_UNCONFIRMED_TXNS) {
136
+ await Promise.all(promises);
137
+ promises = [];
138
+ }
134
139
  }
135
140
  if (promises.length > 0)
136
141
  await Promise.all(promises);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-evm",
3
- "version": "1.0.0-dev.47",
3
+ "version": "1.0.0-dev.48",
4
4
  "description": "EVM specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -18,6 +18,8 @@ export type EVMTxTrace = {
18
18
  type: "CREATE" | "CALL" | "STATICCALL"
19
19
  };
20
20
 
21
+ const MAX_UNCONFIRMED_TXNS = 10;
22
+
21
23
  export class EVMTransactions extends EVMModule<any> {
22
24
 
23
25
  private readonly latestConfirmedNonces: {[address: string]: number} = {};
@@ -140,7 +142,7 @@ export class EVMTransactions extends EVMModule<any> {
140
142
 
141
143
  const txIds: string[] = [];
142
144
  if(parallel) {
143
- const promises: Promise<void>[] = [];
145
+ let promises: Promise<void>[] = [];
144
146
  for(let i=0;i<txs.length;i++) {
145
147
  let tx: {nonce: number, from: string, hash: string};
146
148
  if(signer.isBrowserWallet) {
@@ -153,6 +155,10 @@ export class EVMTransactions extends EVMModule<any> {
153
155
  if(waitForConfirmation) promises.push(this.confirmTransaction(tx, abortSignal));
154
156
  txIds.push(tx.hash);
155
157
  this.logger.debug("sendAndConfirm(): transaction sent ("+(i+1)+"/"+signedTxs.length+"): "+tx.hash);
158
+ if(promises.length >= MAX_UNCONFIRMED_TXNS) {
159
+ await Promise.all(promises);
160
+ promises = [];
161
+ }
156
162
  }
157
163
  if(promises.length>0) await Promise.all(promises);
158
164
  } else {