@haven-fi/solauto-sdk 1.0.243 → 1.0.245

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.
@@ -42,8 +42,9 @@ export declare abstract class SolautoClient extends ReferralStateManager {
42
42
  lutAccountsToAdd(): PublicKey[];
43
43
  fetchExistingAuthorityLutAccounts(): Promise<PublicKey[]>;
44
44
  updateLookupTable(): Promise<{
45
- updateLutTx: TransactionBuilder;
46
- needsToBeIsolated: boolean;
45
+ tx: TransactionBuilder;
46
+ new: boolean;
47
+ accountsToAdd: PublicKey[];
47
48
  } | undefined>;
48
49
  solautoPositionSettings(): SolautoSettingsParameters | undefined;
49
50
  solautoPositionActiveDca(): DCASettings | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,gBAAgB,EAChB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAA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Ae,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
@@ -145,18 +145,21 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
145
145
  const accountsToAdd = this.lutAccountsToAdd().filter((x) => !existingLutAccounts
146
146
  .map((x) => x.toString().toLowerCase())
147
147
  .includes(x.toString().toLowerCase()));
148
- if (accountsToAdd.length > 0) {
149
- tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
150
- payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
151
- authority: this.authority,
152
- lookupTable: this.authorityLutAddress,
153
- addresses: accountsToAdd,
154
- })));
155
- }
156
- if (tx.getInstructions().length > 0) {
157
- this.log("Updating authority lookup table...");
148
+ if (accountsToAdd.length === 0) {
149
+ return undefined;
158
150
  }
159
- return { updateLutTx: tx, needsToBeIsolated: true };
151
+ tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
152
+ payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
153
+ authority: this.authority,
154
+ lookupTable: this.authorityLutAddress,
155
+ addresses: accountsToAdd,
156
+ })));
157
+ this.log("Requires authority LUT update...");
158
+ return {
159
+ tx,
160
+ new: existingLutAccounts.length === 0,
161
+ accountsToAdd,
162
+ };
160
163
  }
161
164
  solautoPositionSettings() {
162
165
  return (this.livePositionUpdates.settings ??
@@ -11,6 +11,7 @@ export declare class TransactionItem {
11
11
  name?: string | undefined;
12
12
  lookupTableAddresses: string[];
13
13
  tx?: TransactionBuilder;
14
+ initialized: boolean;
14
15
  constructor(fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>, name?: string | undefined);
15
16
  initialize(): Promise<void>;
16
17
  refetch(attemptNum: number): Promise<void>;
@@ -47,8 +48,9 @@ export declare class TransactionsManager {
47
48
  private debugAccounts;
48
49
  private getUpdatedPriorityFeeSetting;
49
50
  private updateStatusForSets;
51
+ private updateLut;
50
52
  clientSend(transactions: TransactionItem[]): Promise<TransactionManagerStatuses>;
51
- send(items: TransactionItem[], initialized?: boolean): Promise<TransactionManagerStatuses>;
53
+ send(items: TransactionItem[]): Promise<TransactionManagerStatuses>;
52
54
  private processTransactionSet;
53
55
  private refreshItemSet;
54
56
  private sendTransaction;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAI7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IAPtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,oBAAY,iBAAiB;IAC3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kD9B"}
1
+ {"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAK7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAVpB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA8CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAUpC,OAAO,CAAC,mBAAmB;YAMb,SAAS;IAgBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA4EzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA6BxB,qBAAqB;YAiDrB,cAAc;YAyBd,eAAe;CAkD9B"}
@@ -11,6 +11,7 @@ const generalUtils_1 = require("../utils/generalUtils");
11
11
  const transactionUtils_1 = require("./transactionUtils");
12
12
  const types_1 = require("../types");
13
13
  const web3_js_1 = require("@solana/web3.js");
14
+ const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
14
15
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
15
16
  class TransactionTooLargeError extends Error {
16
17
  constructor(message) {
@@ -44,9 +45,11 @@ class TransactionItem {
44
45
  constructor(fetchTx, name) {
45
46
  this.fetchTx = fetchTx;
46
47
  this.name = name;
48
+ this.initialized = false;
47
49
  }
48
50
  async initialize() {
49
51
  await this.refetch(0);
52
+ this.initialized = true;
50
53
  }
51
54
  async refetch(attemptNum) {
52
55
  const resp = await this.fetchTx(attemptNum);
@@ -236,30 +239,44 @@ class TransactionsManager {
236
239
  this.updateStatus(itemSet.name(), TransactionStatus.Queued, 0);
237
240
  });
238
241
  }
242
+ async updateLut(tx) {
243
+ const updateLutTxName = "create lookup table";
244
+ await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(tx, updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError)), 3, 150, this.errorsToThrow);
245
+ }
239
246
  async clientSend(transactions) {
240
247
  const items = [...transactions];
241
248
  const client = this.txHandler;
242
249
  const updateLookupTable = await client.updateLookupTable();
243
- const updateLutTxName = "create lookup table";
244
- if (updateLookupTable &&
245
- updateLookupTable.updateLutTx.getInstructions().length > 0 &&
246
- updateLookupTable?.needsToBeIsolated) {
247
- await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => await this.sendTransaction(updateLookupTable.updateLutTx, updateLutTxName, attemptNum, this.getUpdatedPriorityFeeSetting(prevError)), 3, 150, this.errorsToThrow);
250
+ let isolatedLutTx = updateLookupTable?.new;
251
+ if (updateLookupTable && !isolatedLutTx) {
252
+ for (const item of items) {
253
+ await item.initialize();
254
+ }
255
+ const txAccounts = items.flatMap((x) => x.tx.getInstructions().flatMap((x) => x.keys.flatMap((x) => x.pubkey)));
256
+ const newAccountsUsage = txAccounts.reduce((count, item) => {
257
+ return updateLookupTable.accountsToAdd.find((x) => x.equals((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(item)))
258
+ ? count + 1
259
+ : count;
260
+ }, 0);
261
+ isolatedLutTx = newAccountsUsage > 1;
262
+ }
263
+ if (updateLookupTable && isolatedLutTx) {
264
+ await this.updateLut(updateLookupTable.tx);
248
265
  }
249
266
  this.lookupTables.defaultLuts = client.defaultLookupTables();
250
- for (const item of items) {
251
- await item.initialize();
267
+ if (!items[0].initialized || (updateLookupTable && isolatedLutTx)) {
268
+ for (const item of items) {
269
+ await item.initialize();
270
+ }
252
271
  }
253
- let choresBeforeName;
254
272
  const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(client, (0, umi_1.transactionBuilder)().add(items
255
273
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
256
274
  .map((x) => x.tx)));
257
- if (updateLookupTable && !updateLookupTable.needsToBeIsolated) {
258
- choresBefore.prepend(updateLookupTable.updateLutTx);
259
- choresBeforeName = "update lookup table";
275
+ if (updateLookupTable && !isolatedLutTx) {
276
+ choresBefore.prepend(updateLookupTable.tx);
260
277
  }
261
278
  if (choresBefore.getInstructions().length > 0) {
262
- const chore = new TransactionItem(async () => ({ tx: choresBefore, }), choresBeforeName);
279
+ const chore = new TransactionItem(async () => ({ tx: choresBefore }));
263
280
  await chore.initialize();
264
281
  items.unshift(chore);
265
282
  this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
@@ -270,7 +287,7 @@ class TransactionsManager {
270
287
  items.push(chore);
271
288
  this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
272
289
  }
273
- const result = await this.send(items, true).catch((e) => {
290
+ const result = await this.send(items).catch((e) => {
274
291
  client.resetLiveTxUpdates(false);
275
292
  throw e;
276
293
  });
@@ -279,10 +296,10 @@ class TransactionsManager {
279
296
  }
280
297
  return result;
281
298
  }
282
- async send(items, initialized) {
299
+ async send(items) {
283
300
  this.statuses = [];
284
301
  this.lookupTables.reset();
285
- if (!initialized) {
302
+ if (!items[0].initialized) {
286
303
  for (const item of items) {
287
304
  await item.initialize();
288
305
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.243",
3
+ "version": "1.0.245",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -247,7 +247,12 @@ export abstract class SolautoClient extends ReferralStateManager {
247
247
  }
248
248
 
249
249
  async updateLookupTable(): Promise<
250
- { updateLutTx: TransactionBuilder; needsToBeIsolated: boolean } | undefined
250
+ | {
251
+ tx: TransactionBuilder;
252
+ new: boolean;
253
+ accountsToAdd: PublicKey[];
254
+ }
255
+ | undefined
251
256
  > {
252
257
  const existingLutAccounts = await this.fetchExistingAuthorityLutAccounts();
253
258
  if (
@@ -279,25 +284,28 @@ export abstract class SolautoClient extends ReferralStateManager {
279
284
  .map((x) => x.toString().toLowerCase())
280
285
  .includes(x.toString().toLowerCase())
281
286
  );
282
- if (accountsToAdd.length > 0) {
283
- tx = tx.add(
284
- getWrappedInstruction(
285
- this.signer,
286
- AddressLookupTableProgram.extendLookupTable({
287
- payer: toWeb3JsPublicKey(this.signer.publicKey),
288
- authority: this.authority,
289
- lookupTable: this.authorityLutAddress,
290
- addresses: accountsToAdd,
291
- })
292
- )
293
- );
287
+ if (accountsToAdd.length === 0) {
288
+ return undefined;
294
289
  }
295
290
 
296
- if (tx.getInstructions().length > 0) {
297
- this.log("Updating authority lookup table...");
298
- }
291
+ tx = tx.add(
292
+ getWrappedInstruction(
293
+ this.signer,
294
+ AddressLookupTableProgram.extendLookupTable({
295
+ payer: toWeb3JsPublicKey(this.signer.publicKey),
296
+ authority: this.authority,
297
+ lookupTable: this.authorityLutAddress,
298
+ addresses: accountsToAdd,
299
+ })
300
+ )
301
+ );
299
302
 
300
- return { updateLutTx: tx, needsToBeIsolated: true };
303
+ this.log("Requires authority LUT update...");
304
+ return {
305
+ tx,
306
+ new: existingLutAccounts.length === 0,
307
+ accountsToAdd,
308
+ };
301
309
  }
302
310
 
303
311
  solautoPositionSettings(): SolautoSettingsParameters | undefined {
@@ -23,6 +23,7 @@ import {
23
23
  } from "../types";
24
24
  import { ReferralStateManager, TxHandler } from "../clients";
25
25
  import { TransactionExpiredBlockheightExceededError } from "@solana/web3.js";
26
+ import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
26
27
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
27
28
 
28
29
  export class TransactionTooLargeError extends Error {
@@ -71,6 +72,7 @@ class LookupTables {
71
72
  export class TransactionItem {
72
73
  lookupTableAddresses!: string[];
73
74
  tx?: TransactionBuilder;
75
+ public initialized: boolean = false;
74
76
 
75
77
  constructor(
76
78
  public fetchTx: (
@@ -81,6 +83,7 @@ export class TransactionItem {
81
83
 
82
84
  async initialize() {
83
85
  await this.refetch(0);
86
+ this.initialized = true;
84
87
  }
85
88
 
86
89
  async refetch(attemptNum: number) {
@@ -339,6 +342,22 @@ export class TransactionsManager {
339
342
  });
340
343
  }
341
344
 
345
+ private async updateLut(tx: TransactionBuilder) {
346
+ const updateLutTxName = "create lookup table";
347
+ await retryWithExponentialBackoff(
348
+ async (attemptNum, prevError) =>
349
+ await this.sendTransaction(
350
+ tx,
351
+ updateLutTxName,
352
+ attemptNum,
353
+ this.getUpdatedPriorityFeeSetting(prevError)
354
+ ),
355
+ 3,
356
+ 150,
357
+ this.errorsToThrow
358
+ );
359
+ }
360
+
342
361
  public async clientSend(
343
362
  transactions: TransactionItem[]
344
363
  ): Promise<TransactionManagerStatuses> {
@@ -346,33 +365,35 @@ export class TransactionsManager {
346
365
  const client = this.txHandler as SolautoClient;
347
366
 
348
367
  const updateLookupTable = await client.updateLookupTable();
349
- const updateLutTxName = "create lookup table";
350
- if (
351
- updateLookupTable &&
352
- updateLookupTable.updateLutTx.getInstructions().length > 0 &&
353
- updateLookupTable?.needsToBeIsolated
354
- ) {
355
- await retryWithExponentialBackoff(
356
- async (attemptNum, prevError) =>
357
- await this.sendTransaction(
358
- updateLookupTable.updateLutTx,
359
- updateLutTxName,
360
- attemptNum,
361
- this.getUpdatedPriorityFeeSetting(prevError)
362
- ),
363
- 3,
364
- 150,
365
- this.errorsToThrow
368
+
369
+ let isolatedLutTx = updateLookupTable?.new;
370
+ if (updateLookupTable && !isolatedLutTx) {
371
+ for (const item of items) {
372
+ await item.initialize();
373
+ }
374
+ const txAccounts = items.flatMap((x) =>
375
+ x.tx!.getInstructions().flatMap((x) => x.keys.flatMap((x) => x.pubkey))
366
376
  );
377
+ const newAccountsUsage = txAccounts.reduce((count, item) => {
378
+ return updateLookupTable.accountsToAdd.find((x) =>
379
+ x.equals(toWeb3JsPublicKey(item))
380
+ )
381
+ ? count + 1
382
+ : count;
383
+ }, 0);
384
+ isolatedLutTx = newAccountsUsage > 1;
385
+ }
386
+ if (updateLookupTable && isolatedLutTx) {
387
+ await this.updateLut(updateLookupTable.tx);
367
388
  }
368
-
369
389
  this.lookupTables.defaultLuts = client.defaultLookupTables();
370
390
 
371
- for (const item of items) {
372
- await item.initialize();
391
+ if (!items[0].initialized || (updateLookupTable && isolatedLutTx)) {
392
+ for (const item of items) {
393
+ await item.initialize();
394
+ }
373
395
  }
374
396
 
375
- let choresBeforeName: string | undefined;
376
397
  const [choresBefore, choresAfter] = await getTransactionChores(
377
398
  client,
378
399
  transactionBuilder().add(
@@ -381,12 +402,11 @@ export class TransactionsManager {
381
402
  .map((x) => x.tx!)
382
403
  )
383
404
  );
384
- if (updateLookupTable && !updateLookupTable.needsToBeIsolated) {
385
- choresBefore.prepend(updateLookupTable.updateLutTx);
386
- choresBeforeName = "update lookup table";
405
+ if (updateLookupTable && !isolatedLutTx) {
406
+ choresBefore.prepend(updateLookupTable.tx);
387
407
  }
388
408
  if (choresBefore.getInstructions().length > 0) {
389
- const chore = new TransactionItem(async () => ({ tx: choresBefore, }), choresBeforeName);
409
+ const chore = new TransactionItem(async () => ({ tx: choresBefore }));
390
410
  await chore.initialize();
391
411
  items.unshift(chore);
392
412
  this.txHandler.log(
@@ -404,7 +424,7 @@ export class TransactionsManager {
404
424
  );
405
425
  }
406
426
 
407
- const result = await this.send(items, true).catch((e) => {
427
+ const result = await this.send(items).catch((e) => {
408
428
  client.resetLiveTxUpdates(false);
409
429
  throw e;
410
430
  });
@@ -417,13 +437,12 @@ export class TransactionsManager {
417
437
  }
418
438
 
419
439
  public async send(
420
- items: TransactionItem[],
421
- initialized?: boolean
440
+ items: TransactionItem[]
422
441
  ): Promise<TransactionManagerStatuses> {
423
442
  this.statuses = [];
424
443
  this.lookupTables.reset();
425
444
 
426
- if (!initialized) {
445
+ if (!items[0].initialized) {
427
446
  for (const item of items) {
428
447
  await item.initialize();
429
448
  }
@@ -490,7 +509,7 @@ export class TransactionsManager {
490
509
  this.updateStatus(
491
510
  itemSet.name(),
492
511
  TransactionStatus.Failed,
493
- this.retries,
512
+ this.retries
494
513
  );
495
514
  }
496
515
  throw e;
@@ -504,17 +523,21 @@ export class TransactionsManager {
504
523
  ): Promise<TransactionSet | undefined> {
505
524
  const itemSet = itemSets[currentIndex];
506
525
  await itemSet.refetchAll(attemptNum);
507
-
526
+
508
527
  const newItemSets = await this.assembleTransactionSets([
509
528
  ...itemSet.items,
510
529
  ...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
511
530
  ]);
512
-
531
+
513
532
  if (newItemSets.length > 1) {
514
- itemSets.splice(currentIndex + 1, itemSets.length - currentIndex - 1, ...newItemSets.slice(1));
533
+ itemSets.splice(
534
+ currentIndex + 1,
535
+ itemSets.length - currentIndex - 1,
536
+ ...newItemSets.slice(1)
537
+ );
515
538
  this.updateStatusForSets(newItemSets.slice(1));
516
539
  }
517
-
540
+
518
541
  return newItemSets[0];
519
542
  }
520
543