@haven-fi/solauto-sdk 1.0.339 → 1.0.341
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/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +9 -4
- package/dist/utils/jitoUtils.d.ts +1 -1
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +8 -3
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +23 -4
- package/src/utils/jitoUtils.ts +11 -4
@@ -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,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;AAW7D,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,I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,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAmCxB,6BAA6B;
|
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,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;AAW7D,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;AA0FD,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,UAAU;IAClB,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAXpB,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,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAgBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA4FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YAmCxB,6BAA6B;YAgG7B,qBAAqB;YAuDrB,cAAc;YAqCd,eAAe;CAmD9B"}
|
@@ -336,7 +336,7 @@ class TransactionsManager {
|
|
336
336
|
}
|
337
337
|
async processTransactionsAtomically(itemSets) {
|
338
338
|
let num = 0;
|
339
|
-
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => {
|
339
|
+
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => {
|
340
340
|
num = attemptNum;
|
341
341
|
if (attemptNum > 0) {
|
342
342
|
for (let i = 0; i < itemSets.length; i++) {
|
@@ -348,22 +348,27 @@ class TransactionsManager {
|
|
348
348
|
for (const set of itemSets) {
|
349
349
|
transactions.push(await set.getSingleTransaction());
|
350
350
|
}
|
351
|
+
transactions = transactions.filter((x) => x.getInstructions().length > 0);
|
352
|
+
if (transactions.length === 0) {
|
353
|
+
this.updateStatusForSets(itemSets, TransactionStatus.Skipped, attemptNum);
|
354
|
+
return;
|
355
|
+
}
|
351
356
|
this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum);
|
352
357
|
let txSigs;
|
353
358
|
let error;
|
354
359
|
try {
|
355
|
-
txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, transactions, this.txType, this.
|
360
|
+
txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, transactions, this.txType, this.getUpdatedPriorityFeeSetting(prevError, attemptNum), () => this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum, undefined, true));
|
356
361
|
}
|
357
362
|
catch (e) {
|
358
363
|
error = e;
|
359
364
|
}
|
360
365
|
if (error || !Boolean(txSigs) || txSigs?.length === 0) {
|
361
|
-
this.updateStatusForSets(itemSets, TransactionStatus.Failed, attemptNum, txSigs,
|
366
|
+
this.updateStatusForSets(itemSets, TransactionStatus.Failed, attemptNum, txSigs, undefined, error?.message);
|
362
367
|
throw error ? error : new Error("Unknown error");
|
363
368
|
}
|
364
369
|
this.updateStatusForSets(itemSets, TransactionStatus.Successful, attemptNum, txSigs);
|
365
370
|
}, this.retries, this.retryDelay, this.errorsToThrow).catch((e) => {
|
366
|
-
this.updateStatusForSets(itemSets, TransactionStatus.Failed, num, undefined,
|
371
|
+
this.updateStatusForSets(itemSets, TransactionStatus.Failed, num, undefined, undefined, e.message);
|
367
372
|
throw e;
|
368
373
|
});
|
369
374
|
}
|
@@ -2,5 +2,5 @@ import { Connection, PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
3
3
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
4
|
export declare function getRandomTipAccount(): Promise<PublicKey>;
|
5
|
-
export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting): Promise<string[] | undefined>;
|
5
|
+
export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<string[] | undefined>;
|
6
6
|
//# sourceMappingURL=jitoUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAoE,MAAM,iBAAiB,CAAC;AAG1H,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AAyHD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA+D/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -84,7 +84,7 @@ async function pollBundleStatus(bundleId, interval = 1000, timeout = 40000) {
|
|
84
84
|
}
|
85
85
|
}
|
86
86
|
}
|
87
|
-
|
87
|
+
throw new web3_js_1.TransactionExpiredBlockheightExceededError("Unable to confirm transaction. Try a higher priority fee.");
|
88
88
|
}
|
89
89
|
async function sendJitoBundle(transactions) {
|
90
90
|
let resp;
|
@@ -109,7 +109,7 @@ async function sendJitoBundle(transactions) {
|
|
109
109
|
(0, generalUtils_1.consoleLog)("Bundle ID:", bundleId);
|
110
110
|
return bundleId ? await pollBundleStatus(bundleId) : [];
|
111
111
|
}
|
112
|
-
async function sendJitoBundledTransactions(umi, connection, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min) {
|
112
|
+
async function sendJitoBundledTransactions(umi, connection, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
|
113
113
|
if (txs.length === 1) {
|
114
114
|
const res = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(umi, connection, txs[0], txType, priorityFeeSetting);
|
115
115
|
return res ? [bytes_1.bs58.encode(res)] : undefined;
|
@@ -133,7 +133,12 @@ async function sendJitoBundledTransactions(umi, connection, signer, txs, txType,
|
|
133
133
|
// feeEstimates,
|
134
134
|
// simulationResults.map((x) => x.unitsConsumed! * 1.15)
|
135
135
|
// );
|
136
|
-
const
|
136
|
+
const serializedTxs = builtTxs.map((x) => x.serialize());
|
137
|
+
if (serializedTxs.find(x => x.length > 1232)) {
|
138
|
+
throw new Error("A transaction too large");
|
139
|
+
}
|
140
|
+
onAwaitingSign?.();
|
141
|
+
const txSigs = await sendJitoBundle(serializedTxs.map((x) => bs58_1.default.encode(x)));
|
137
142
|
return txSigs.length > 0 ? txSigs : undefined;
|
138
143
|
}
|
139
144
|
return undefined;
|
package/package.json
CHANGED
@@ -530,7 +530,7 @@ export class TransactionsManager {
|
|
530
530
|
let num = 0;
|
531
531
|
|
532
532
|
await retryWithExponentialBackoff(
|
533
|
-
async (attemptNum) => {
|
533
|
+
async (attemptNum, prevError) => {
|
534
534
|
num = attemptNum;
|
535
535
|
|
536
536
|
if (attemptNum > 0) {
|
@@ -546,6 +546,17 @@ export class TransactionsManager {
|
|
546
546
|
for (const set of itemSets) {
|
547
547
|
transactions.push(await set.getSingleTransaction());
|
548
548
|
}
|
549
|
+
transactions = transactions.filter(
|
550
|
+
(x) => x.getInstructions().length > 0
|
551
|
+
);
|
552
|
+
if (transactions.length === 0) {
|
553
|
+
this.updateStatusForSets(
|
554
|
+
itemSets,
|
555
|
+
TransactionStatus.Skipped,
|
556
|
+
attemptNum
|
557
|
+
);
|
558
|
+
return;
|
559
|
+
}
|
549
560
|
|
550
561
|
this.updateStatusForSets(
|
551
562
|
itemSets,
|
@@ -562,7 +573,15 @@ export class TransactionsManager {
|
|
562
573
|
this.txHandler.signer,
|
563
574
|
transactions,
|
564
575
|
this.txType,
|
565
|
-
this.
|
576
|
+
this.getUpdatedPriorityFeeSetting(prevError, attemptNum),
|
577
|
+
() =>
|
578
|
+
this.updateStatusForSets(
|
579
|
+
itemSets,
|
580
|
+
TransactionStatus.Processing,
|
581
|
+
attemptNum,
|
582
|
+
undefined,
|
583
|
+
true
|
584
|
+
)
|
566
585
|
);
|
567
586
|
} catch (e: any) {
|
568
587
|
error = e as Error;
|
@@ -574,7 +593,7 @@ export class TransactionsManager {
|
|
574
593
|
TransactionStatus.Failed,
|
575
594
|
attemptNum,
|
576
595
|
txSigs,
|
577
|
-
|
596
|
+
undefined,
|
578
597
|
error?.message
|
579
598
|
);
|
580
599
|
throw error ? error : new Error("Unknown error");
|
@@ -596,7 +615,7 @@ export class TransactionsManager {
|
|
596
615
|
TransactionStatus.Failed,
|
597
616
|
num,
|
598
617
|
undefined,
|
599
|
-
|
618
|
+
undefined,
|
600
619
|
e.message
|
601
620
|
);
|
602
621
|
throw e;
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Connection, PublicKey, VersionedTransaction } from "@solana/web3.js";
|
1
|
+
import { Connection, PublicKey, TransactionExpiredBlockheightExceededError, VersionedTransaction } from "@solana/web3.js";
|
2
2
|
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
3
3
|
import { JITO_BLOCK_ENGINE } from "../constants/solautoConstants";
|
4
4
|
import {
|
@@ -125,7 +125,7 @@ async function pollBundleStatus(
|
|
125
125
|
}
|
126
126
|
}
|
127
127
|
}
|
128
|
-
|
128
|
+
throw new TransactionExpiredBlockheightExceededError("Unable to confirm transaction. Try a higher priority fee.");
|
129
129
|
}
|
130
130
|
|
131
131
|
async function sendJitoBundle(transactions: string[]): Promise<string[]> {
|
@@ -160,7 +160,8 @@ export async function sendJitoBundledTransactions(
|
|
160
160
|
signer: Signer,
|
161
161
|
txs: TransactionBuilder[],
|
162
162
|
txType?: TransactionRunType,
|
163
|
-
priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min
|
163
|
+
priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min,
|
164
|
+
onAwaitingSign?: () => void
|
164
165
|
): Promise<string[] | undefined> {
|
165
166
|
if (txs.length === 1) {
|
166
167
|
const res = await sendSingleOptimizedTransaction(
|
@@ -211,8 +212,14 @@ export async function sendJitoBundledTransactions(
|
|
211
212
|
// simulationResults.map((x) => x.unitsConsumed! * 1.15)
|
212
213
|
// );
|
213
214
|
|
215
|
+
const serializedTxs = builtTxs.map((x) => x.serialize());
|
216
|
+
if (serializedTxs.find(x => x.length > 1232)) {
|
217
|
+
throw new Error("A transaction too large");
|
218
|
+
}
|
219
|
+
|
220
|
+
onAwaitingSign?.();
|
214
221
|
const txSigs = await sendJitoBundle(
|
215
|
-
|
222
|
+
serializedTxs.map((x) => base58.encode(x))
|
216
223
|
);
|
217
224
|
return txSigs.length > 0 ? txSigs : undefined;
|
218
225
|
}
|