@haven-fi/solauto-sdk 1.0.471 → 1.0.473
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/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +3 -1
- package/dist/transactions/transactionsManager.d.ts +1 -1
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +31 -16
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +4 -1
- package/src/transactions/transactionsManager.ts +42 -23
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAoBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,OAAO,EAIL,eAAe,EAChB,MAAM,iCAAiC,CAAC;AA0BzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA6LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAoH7B;AA2LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,oBAqDlG;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,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M,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAqI5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO;;;;EAoG/B"}
|
@@ -517,9 +517,11 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
517
517
|
catch (e) {
|
518
518
|
(0, generalUtils_1.consoleLog)(e);
|
519
519
|
}
|
520
|
-
|
520
|
+
const errData = {
|
521
521
|
errorName: errorName,
|
522
522
|
errorInfo: errorInfo,
|
523
523
|
canBeIgnored,
|
524
524
|
};
|
525
|
+
(0, generalUtils_1.consoleLog)(errData);
|
526
|
+
return errData;
|
525
527
|
}
|
@@ -61,7 +61,7 @@ export declare class TransactionsManager {
|
|
61
61
|
send(items: TransactionItem[]): Promise<TransactionManagerStatuses>;
|
62
62
|
private processTransactionsAtomically;
|
63
63
|
private processTransactionSet;
|
64
|
-
private
|
64
|
+
private refreshItemSets;
|
65
65
|
private sendTransaction;
|
66
66
|
}
|
67
67
|
export {};
|
@@ -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;AAMzD,OAAO,
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,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AM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,mBAAmB;IAU5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa,CAAC;IAdxB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;IAE3B,kBAAkB,SAAmB;gBAG3B,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,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EACrC,WAAW,CAAC,EAAE,WAAW;YAab,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA+FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA4BxB,6BAA6B;YAsI7B,qBAAqB;YAoDrB,eAAe;YAwDf,eAAe;CA4D9B"}
|
@@ -150,7 +150,7 @@ class TransactionsManager {
|
|
150
150
|
this.atomically = atomically;
|
151
151
|
this.errorsToThrow = errorsToThrow;
|
152
152
|
this.statuses = [];
|
153
|
-
this.updateOracleTxName = "
|
153
|
+
this.updateOracleTxName = "update oracle";
|
154
154
|
this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
|
155
155
|
this.signableRetries =
|
156
156
|
retryConfig?.signableRetries ?? retryConfig?.totalRetries ?? 3;
|
@@ -346,10 +346,13 @@ class TransactionsManager {
|
|
346
346
|
}
|
347
347
|
num = attemptNum;
|
348
348
|
if (attemptNum > 0) {
|
349
|
-
|
350
|
-
|
349
|
+
const refreshedSets = await this.refreshItemSets(itemSets, attemptNum);
|
350
|
+
if (!refreshedSets || !refreshedSets.length) {
|
351
|
+
return;
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
itemSets = refreshedSets;
|
351
355
|
}
|
352
|
-
itemSets = await this.assembleTransactionSets(itemSets.flatMap((x) => x.items));
|
353
356
|
}
|
354
357
|
transactions = [];
|
355
358
|
for (const set of itemSets) {
|
@@ -402,7 +405,8 @@ class TransactionsManager {
|
|
402
405
|
}
|
403
406
|
num = attemptNum;
|
404
407
|
if (currentIndex > 0 || attemptNum > 0) {
|
405
|
-
|
408
|
+
const refreshedSets = await this.refreshItemSets(itemSets, attemptNum, currentIndex);
|
409
|
+
itemSet = refreshedSets ? refreshedSets[0] : undefined;
|
406
410
|
}
|
407
411
|
if (!itemSet)
|
408
412
|
return;
|
@@ -416,18 +420,29 @@ class TransactionsManager {
|
|
416
420
|
}
|
417
421
|
}, this.totalRetries, this.retryDelay, this.errorsToThrow);
|
418
422
|
}
|
419
|
-
async
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
423
|
+
async refreshItemSets(itemSets, attemptNum, currentIndex) {
|
424
|
+
if (currentIndex !== undefined) {
|
425
|
+
const itemSet = itemSets[currentIndex];
|
426
|
+
await itemSet.refetchAll(attemptNum);
|
427
|
+
}
|
428
|
+
else {
|
429
|
+
for (const itemSet of itemSets) {
|
430
|
+
await itemSet.refetchAll(attemptNum);
|
431
|
+
}
|
432
|
+
}
|
433
|
+
const newItemSets = await this.assembleTransactionSets(currentIndex !== undefined
|
434
|
+
? [
|
435
|
+
...itemSets[currentIndex].items,
|
436
|
+
...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
|
437
|
+
]
|
438
|
+
: itemSets.flatMap((set) => set.items));
|
439
|
+
const newItemSetNames = newItemSets.map((x) => x.name());
|
440
|
+
if (newItemSetNames.length === 1 &&
|
441
|
+
newItemSetNames[0] === this.updateOracleTxName) {
|
442
|
+
(0, generalUtils_1.consoleLog)("Skipping unnecessary oracle update");
|
428
443
|
return undefined;
|
429
444
|
}
|
430
|
-
if (newItemSets.length > 1) {
|
445
|
+
if (currentIndex !== undefined && newItemSets.length > 1) {
|
431
446
|
itemSets.splice(currentIndex, itemSets.length - currentIndex, ...newItemSets);
|
432
447
|
const startOfQueuedStatuses = this.statuses.findIndex((x) => x.status === TransactionStatus.Queued);
|
433
448
|
this.statuses.splice(startOfQueuedStatuses, this.statuses.length - startOfQueuedStatuses, ...newItemSets.map((x, i) => ({
|
@@ -436,7 +451,7 @@ class TransactionsManager {
|
|
436
451
|
status: i === 0 ? TransactionStatus.Processing : TransactionStatus.Queued,
|
437
452
|
})));
|
438
453
|
}
|
439
|
-
return newItemSets
|
454
|
+
return newItemSets;
|
440
455
|
}
|
441
456
|
async sendTransaction(tx, txName, attemptNum, priorityFeeSetting, txType) {
|
442
457
|
this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
|
package/package.json
CHANGED
@@ -12,6 +12,7 @@ import {
|
|
12
12
|
sendSingleOptimizedTransaction,
|
13
13
|
} from "../utils/solanaUtils";
|
14
14
|
import {
|
15
|
+
consoleLog,
|
15
16
|
ErrorsToThrow,
|
16
17
|
retryWithExponentialBackoff,
|
17
18
|
} from "../utils/generalUtils";
|
@@ -231,7 +232,7 @@ export class TransactionsManager {
|
|
231
232
|
private totalRetries: number;
|
232
233
|
private retryDelay: number;
|
233
234
|
|
234
|
-
updateOracleTxName = "
|
235
|
+
updateOracleTxName = "update oracle";
|
235
236
|
|
236
237
|
constructor(
|
237
238
|
private txHandler: SolautoClient | ReferralStateManager,
|
@@ -555,12 +556,15 @@ export class TransactionsManager {
|
|
555
556
|
num = attemptNum;
|
556
557
|
|
557
558
|
if (attemptNum > 0) {
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
itemSets = await this.assembleTransactionSets(
|
562
|
-
itemSets.flatMap((x) => x.items)
|
559
|
+
const refreshedSets = await this.refreshItemSets(
|
560
|
+
itemSets,
|
561
|
+
attemptNum
|
563
562
|
);
|
563
|
+
if (!refreshedSets || !refreshedSets.length) {
|
564
|
+
return;
|
565
|
+
} else {
|
566
|
+
itemSets = refreshedSets;
|
567
|
+
}
|
564
568
|
}
|
565
569
|
|
566
570
|
transactions = [];
|
@@ -689,11 +693,12 @@ export class TransactionsManager {
|
|
689
693
|
num = attemptNum;
|
690
694
|
|
691
695
|
if (currentIndex > 0 || attemptNum > 0) {
|
692
|
-
|
696
|
+
const refreshedSets = await this.refreshItemSets(
|
693
697
|
itemSets,
|
694
|
-
|
695
|
-
|
698
|
+
attemptNum,
|
699
|
+
currentIndex
|
696
700
|
);
|
701
|
+
itemSet = refreshedSets ? refreshedSets[0] : undefined;
|
697
702
|
}
|
698
703
|
if (!itemSet) return;
|
699
704
|
|
@@ -720,25 +725,39 @@ export class TransactionsManager {
|
|
720
725
|
);
|
721
726
|
}
|
722
727
|
|
723
|
-
private async
|
728
|
+
private async refreshItemSets(
|
724
729
|
itemSets: TransactionSet[],
|
725
|
-
|
726
|
-
|
727
|
-
): Promise<TransactionSet | undefined> {
|
728
|
-
|
729
|
-
|
730
|
+
attemptNum: number,
|
731
|
+
currentIndex?: number
|
732
|
+
): Promise<TransactionSet[] | undefined> {
|
733
|
+
if (currentIndex !== undefined) {
|
734
|
+
const itemSet = itemSets[currentIndex];
|
735
|
+
await itemSet.refetchAll(attemptNum);
|
736
|
+
} else {
|
737
|
+
for (const itemSet of itemSets) {
|
738
|
+
await itemSet.refetchAll(attemptNum);
|
739
|
+
}
|
740
|
+
}
|
730
741
|
|
731
|
-
const newItemSets = await this.assembleTransactionSets(
|
732
|
-
|
733
|
-
|
734
|
-
|
742
|
+
const newItemSets = await this.assembleTransactionSets(
|
743
|
+
currentIndex !== undefined
|
744
|
+
? [
|
745
|
+
...itemSets[currentIndex].items,
|
746
|
+
...itemSets.slice(currentIndex + 1).flatMap((set) => set.items),
|
747
|
+
]
|
748
|
+
: itemSets.flatMap((set) => set.items)
|
749
|
+
);
|
735
750
|
|
736
|
-
const newItemSetNames = newItemSets.map(x => x.name());
|
737
|
-
if (
|
751
|
+
const newItemSetNames = newItemSets.map((x) => x.name());
|
752
|
+
if (
|
753
|
+
newItemSetNames.length === 1 &&
|
754
|
+
newItemSetNames[0] === this.updateOracleTxName
|
755
|
+
) {
|
756
|
+
consoleLog("Skipping unnecessary oracle update");
|
738
757
|
return undefined;
|
739
758
|
}
|
740
759
|
|
741
|
-
if (newItemSets.length > 1) {
|
760
|
+
if (currentIndex !== undefined && newItemSets.length > 1) {
|
742
761
|
itemSets.splice(
|
743
762
|
currentIndex,
|
744
763
|
itemSets.length - currentIndex,
|
@@ -759,7 +778,7 @@ export class TransactionsManager {
|
|
759
778
|
);
|
760
779
|
}
|
761
780
|
|
762
|
-
return newItemSets
|
781
|
+
return newItemSets;
|
763
782
|
}
|
764
783
|
|
765
784
|
private async sendTransaction(
|