@haven-fi/solauto-sdk 1.0.256 → 1.0.258
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.
|
@@ -41,6 +41,7 @@ export declare class TransactionsManager {
|
|
|
41
41
|
private retries;
|
|
42
42
|
private retryDelay;
|
|
43
43
|
private statuses;
|
|
44
|
+
private statusesStartIdx;
|
|
44
45
|
private lookupTables;
|
|
45
46
|
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, priorityFeeSetting?: PriorityFeeSetting, errorsToThrow?: ErrorsToThrow | undefined, retries?: number, retryDelay?: number);
|
|
46
47
|
private assembleTransactionSets;
|
|
@@ -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;
|
|
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,CA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Aa,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;IA+DzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAgCxB,qBAAqB;YAiDrB,cAAc;YAkCd,eAAe;CAkD9B"}
|
|
@@ -12,6 +12,7 @@ const transactionUtils_1 = require("./transactionUtils");
|
|
|
12
12
|
const types_1 = require("../types");
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
|
15
|
+
const CHORES_TX_NAME = "account chores";
|
|
15
16
|
class TransactionTooLargeError extends Error {
|
|
16
17
|
constructor(message) {
|
|
17
18
|
super(message);
|
|
@@ -111,9 +112,12 @@ class TransactionSet {
|
|
|
111
112
|
return Array.from(new Set(this.items.map((x) => x.lookupTableAddresses).flat()));
|
|
112
113
|
}
|
|
113
114
|
name() {
|
|
114
|
-
|
|
115
|
+
let names = this.items
|
|
115
116
|
.filter((x) => x.tx && x.name !== undefined)
|
|
116
117
|
.map((x) => x.name.toLowerCase());
|
|
118
|
+
if (names.length > 1) {
|
|
119
|
+
names = names.filter((x) => x !== CHORES_TX_NAME);
|
|
120
|
+
}
|
|
117
121
|
if (names.length >= 3) {
|
|
118
122
|
return [names.slice(0, -1).join(", "), names[names.length - 1]].join(", and ");
|
|
119
123
|
}
|
|
@@ -140,6 +144,7 @@ class TransactionsManager {
|
|
|
140
144
|
this.retries = retries;
|
|
141
145
|
this.retryDelay = retryDelay;
|
|
142
146
|
this.statuses = [];
|
|
147
|
+
this.statusesStartIdx = 0;
|
|
143
148
|
this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
|
|
144
149
|
}
|
|
145
150
|
async assembleTransactionSets(items) {
|
|
@@ -260,13 +265,13 @@ class TransactionsManager {
|
|
|
260
265
|
choresBefore.prepend(updateLookupTable.tx);
|
|
261
266
|
}
|
|
262
267
|
if (choresBefore.getInstructions().length > 0) {
|
|
263
|
-
const chore = new TransactionItem(async () => ({ tx: choresBefore }),
|
|
268
|
+
const chore = new TransactionItem(async () => ({ tx: choresBefore }), CHORES_TX_NAME);
|
|
264
269
|
await chore.initialize();
|
|
265
270
|
items.unshift(chore);
|
|
266
271
|
this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
|
|
267
272
|
}
|
|
268
273
|
if (choresAfter.getInstructions().length > 0) {
|
|
269
|
-
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
|
274
|
+
const chore = new TransactionItem(async () => ({ tx: choresAfter }), CHORES_TX_NAME);
|
|
270
275
|
await chore.initialize();
|
|
271
276
|
items.push(chore);
|
|
272
277
|
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
|
@@ -290,6 +295,7 @@ class TransactionsManager {
|
|
|
290
295
|
}
|
|
291
296
|
this.txHandler.log("Transaction items:", items.length);
|
|
292
297
|
const itemSets = await this.assembleTransactionSets(items);
|
|
298
|
+
this.statusesStartIdx = this.statuses.length;
|
|
293
299
|
this.updateStatusForSets(itemSets);
|
|
294
300
|
this.txHandler.log("Initial item sets:", itemSets.length);
|
|
295
301
|
if (this.txType === "only-simulate" && itemSets.length > 1) {
|
|
@@ -334,6 +340,11 @@ class TransactionsManager {
|
|
|
334
340
|
...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
|
|
335
341
|
]);
|
|
336
342
|
if (newItemSets.length > 1) {
|
|
343
|
+
this.statuses.splice(this.statusesStartIdx + 1, itemSets.length - 1, ...newItemSets.map((x, i) => ({
|
|
344
|
+
name: x.name(),
|
|
345
|
+
status: TransactionStatus.Queued,
|
|
346
|
+
attemptNum: i === 0 ? attemptNum : 0,
|
|
347
|
+
})));
|
|
337
348
|
itemSets.splice(currentIndex + 1, itemSets.length - currentIndex - 1, ...newItemSets.slice(1));
|
|
338
349
|
this.updateStatusForSets(newItemSets.slice(1));
|
|
339
350
|
}
|
package/package.json
CHANGED
|
@@ -26,6 +26,8 @@ import { TransactionExpiredBlockheightExceededError } from "@solana/web3.js";
|
|
|
26
26
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
|
27
27
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
|
28
28
|
|
|
29
|
+
const CHORES_TX_NAME = "account chores";
|
|
30
|
+
|
|
29
31
|
export class TransactionTooLargeError extends Error {
|
|
30
32
|
constructor(message: string) {
|
|
31
33
|
super(message);
|
|
@@ -171,9 +173,12 @@ class TransactionSet {
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
name(): string {
|
|
174
|
-
|
|
176
|
+
let names = this.items
|
|
175
177
|
.filter((x) => x.tx && x.name !== undefined)
|
|
176
178
|
.map((x) => x.name!.toLowerCase());
|
|
179
|
+
if (names.length > 1) {
|
|
180
|
+
names = names.filter((x) => x !== CHORES_TX_NAME);
|
|
181
|
+
}
|
|
177
182
|
if (names.length >= 3) {
|
|
178
183
|
return [names.slice(0, -1).join(", "), names[names.length - 1]].join(
|
|
179
184
|
", and "
|
|
@@ -203,6 +208,7 @@ export type TransactionManagerStatuses = {
|
|
|
203
208
|
|
|
204
209
|
export class TransactionsManager {
|
|
205
210
|
private statuses: TransactionManagerStatuses = [];
|
|
211
|
+
private statusesStartIdx: number = 0;
|
|
206
212
|
private lookupTables: LookupTables;
|
|
207
213
|
|
|
208
214
|
constructor(
|
|
@@ -387,7 +393,10 @@ export class TransactionsManager {
|
|
|
387
393
|
choresBefore.prepend(updateLookupTable.tx);
|
|
388
394
|
}
|
|
389
395
|
if (choresBefore.getInstructions().length > 0) {
|
|
390
|
-
const chore = new TransactionItem(
|
|
396
|
+
const chore = new TransactionItem(
|
|
397
|
+
async () => ({ tx: choresBefore }),
|
|
398
|
+
CHORES_TX_NAME
|
|
399
|
+
);
|
|
391
400
|
await chore.initialize();
|
|
392
401
|
items.unshift(chore);
|
|
393
402
|
this.txHandler.log(
|
|
@@ -396,7 +405,10 @@ export class TransactionsManager {
|
|
|
396
405
|
);
|
|
397
406
|
}
|
|
398
407
|
if (choresAfter.getInstructions().length > 0) {
|
|
399
|
-
const chore = new TransactionItem(
|
|
408
|
+
const chore = new TransactionItem(
|
|
409
|
+
async () => ({ tx: choresAfter }),
|
|
410
|
+
CHORES_TX_NAME
|
|
411
|
+
);
|
|
400
412
|
await chore.initialize();
|
|
401
413
|
items.push(chore);
|
|
402
414
|
this.txHandler.log(
|
|
@@ -431,6 +443,7 @@ export class TransactionsManager {
|
|
|
431
443
|
|
|
432
444
|
this.txHandler.log("Transaction items:", items.length);
|
|
433
445
|
const itemSets = await this.assembleTransactionSets(items);
|
|
446
|
+
this.statusesStartIdx = this.statuses.length;
|
|
434
447
|
this.updateStatusForSets(itemSets);
|
|
435
448
|
this.txHandler.log("Initial item sets:", itemSets.length);
|
|
436
449
|
|
|
@@ -513,6 +526,15 @@ export class TransactionsManager {
|
|
|
513
526
|
]);
|
|
514
527
|
|
|
515
528
|
if (newItemSets.length > 1) {
|
|
529
|
+
this.statuses.splice(
|
|
530
|
+
this.statusesStartIdx + 1,
|
|
531
|
+
itemSets.length - 1,
|
|
532
|
+
...newItemSets.map((x, i) => ({
|
|
533
|
+
name: x.name(),
|
|
534
|
+
status: TransactionStatus.Queued,
|
|
535
|
+
attemptNum: i === 0 ? attemptNum : 0,
|
|
536
|
+
}))
|
|
537
|
+
);
|
|
516
538
|
itemSets.splice(
|
|
517
539
|
currentIndex + 1,
|
|
518
540
|
itemSets.length - currentIndex - 1,
|