@haven-fi/solauto-sdk 1.0.236 → 1.0.238
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionsManager.d.ts +3 -0
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +10 -2
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +5 -3
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +10 -2
- package/src/utils/solanaUtils.ts +7 -4
@@ -3,6 +3,9 @@ import { SolautoClient } from "../clients/solautoClient";
|
|
3
3
|
import { ErrorsToThrow } from "../utils/generalUtils";
|
4
4
|
import { PriorityFeeSetting, TransactionItemInputs, TransactionRunType } from "../types";
|
5
5
|
import { ReferralStateManager } from "../clients";
|
6
|
+
export declare class TransactionTooLargeError extends Error {
|
7
|
+
constructor(message: string);
|
8
|
+
}
|
6
9
|
export declare class TransactionItem {
|
7
10
|
fetchTx: (attemptNum: number) => Promise<TransactionItemInputs | undefined>;
|
8
11
|
name?: string | undefined;
|
@@ -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,EAClB,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,a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AAC,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,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,aAAa,CAAC,EAAE,aAAa,YAAA,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA8CN,aAAa;IAoBd,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,EAC/B,eAAe,CAAC,EAAE,kBAAkB,GACnC,OAAO,CAAC,0BAA0B,CAAC;IAyEzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;YAwGxB,eAAe;CAkD9B"}
|
@@ -3,13 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.TransactionsManager = exports.TransactionStatus = exports.TransactionItem = void 0;
|
6
|
+
exports.TransactionsManager = exports.TransactionStatus = exports.TransactionItem = exports.TransactionTooLargeError = void 0;
|
7
7
|
const bs58_1 = __importDefault(require("bs58"));
|
8
8
|
const umi_1 = require("@metaplex-foundation/umi");
|
9
9
|
const solanaUtils_1 = require("../utils/solanaUtils");
|
10
10
|
const generalUtils_1 = require("../utils/generalUtils");
|
11
11
|
const transactionUtils_1 = require("./transactionUtils");
|
12
12
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
13
|
+
class TransactionTooLargeError extends Error {
|
14
|
+
constructor(message) {
|
15
|
+
super(message);
|
16
|
+
this.name = 'TransactionTooLargeError';
|
17
|
+
Object.setPrototypeOf(this, TransactionTooLargeError.prototype);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
exports.TransactionTooLargeError = TransactionTooLargeError;
|
13
21
|
class LookupTables {
|
14
22
|
constructor(defaultLuts, umi) {
|
15
23
|
this.defaultLuts = defaultLuts;
|
@@ -141,7 +149,7 @@ class TransactionsManager {
|
|
141
149
|
}
|
142
150
|
const transaction = item.tx.setAddressLookupTables(await this.lookupTables.getLutInputs(item.lookupTableAddresses));
|
143
151
|
if (!transaction.fitsInOneTransaction(this.txHandler.umi)) {
|
144
|
-
throw new
|
152
|
+
throw new TransactionTooLargeError(`Exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`);
|
145
153
|
}
|
146
154
|
else {
|
147
155
|
let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAKL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAgC,GAC1C,CAAC,UAAU,EAAE,GAAG,CAAC,CAQnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wB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,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,CAAC,EAAE,MAAM,EACzB,gBAAgB,CAAC,EAAE,MAAM,sBAgE1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAiDD,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,eAAe,GAAE,kBAA2C,EAC5D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA6EjC"}
|
@@ -167,7 +167,6 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
|
|
167
167
|
return feeEstimate;
|
168
168
|
}
|
169
169
|
async function spamSendTransactionUntilConfirmed(connection, transaction, blockhash, spamInterval = 1000) {
|
170
|
-
let confirmed = false;
|
171
170
|
let transactionSignature = null;
|
172
171
|
const sendTx = async () => {
|
173
172
|
try {
|
@@ -186,7 +185,7 @@ async function spamSendTransactionUntilConfirmed(connection, transaction, blockh
|
|
186
185
|
if (!transactionSignature) {
|
187
186
|
throw new Error("Failed to send");
|
188
187
|
}
|
189
|
-
await connection
|
188
|
+
const resp = await connection
|
190
189
|
.confirmTransaction({
|
191
190
|
...blockhash,
|
192
191
|
signature: transactionSignature,
|
@@ -194,9 +193,12 @@ async function spamSendTransactionUntilConfirmed(connection, transaction, blockh
|
|
194
193
|
.finally(() => {
|
195
194
|
clearInterval(sendIntervalId);
|
196
195
|
});
|
196
|
+
if (resp.value.err) {
|
197
|
+
throw resp.value.err;
|
198
|
+
}
|
197
199
|
return transactionSignature;
|
198
200
|
}
|
199
|
-
async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prioritySetting = types_1.PriorityFeeSetting.
|
201
|
+
async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prioritySetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
|
200
202
|
(0, generalUtils_1.consoleLog)("Sending single optimized transaction...");
|
201
203
|
(0, generalUtils_1.consoleLog)("Instructions: ", tx.getInstructions().length);
|
202
204
|
(0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
|
package/package.json
CHANGED
@@ -23,6 +23,14 @@ import {
|
|
23
23
|
import { ReferralStateManager, TxHandler } from "../clients";
|
24
24
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
25
25
|
|
26
|
+
export class TransactionTooLargeError extends Error {
|
27
|
+
constructor(message: string) {
|
28
|
+
super(message);
|
29
|
+
this.name = 'TransactionTooLargeError';
|
30
|
+
Object.setPrototypeOf(this, TransactionTooLargeError.prototype);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
26
34
|
class LookupTables {
|
27
35
|
cache: AddressLookupTableInput[] = [];
|
28
36
|
|
@@ -225,8 +233,8 @@ export class TransactionsManager {
|
|
225
233
|
await this.lookupTables.getLutInputs(item.lookupTableAddresses)
|
226
234
|
);
|
227
235
|
if (!transaction.fitsInOneTransaction(this.txHandler.umi)) {
|
228
|
-
throw new
|
229
|
-
`
|
236
|
+
throw new TransactionTooLargeError(
|
237
|
+
`Exceeds max transaction size (${transaction.getTransactionSize(this.txHandler.umi)})`
|
230
238
|
);
|
231
239
|
} else {
|
232
240
|
let newSet = new TransactionSet(this.txHandler, this.lookupTables, [
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -302,7 +302,6 @@ async function spamSendTransactionUntilConfirmed(
|
|
302
302
|
blockhash: BlockhashWithExpiryBlockHeight,
|
303
303
|
spamInterval: number = 1000
|
304
304
|
): Promise<string> {
|
305
|
-
let confirmed = false;
|
306
305
|
let transactionSignature: string | null = null;
|
307
306
|
|
308
307
|
const sendTx = async () => {
|
@@ -328,7 +327,7 @@ async function spamSendTransactionUntilConfirmed(
|
|
328
327
|
throw new Error("Failed to send");
|
329
328
|
}
|
330
329
|
|
331
|
-
await connection
|
330
|
+
const resp = await connection
|
332
331
|
.confirmTransaction({
|
333
332
|
...blockhash,
|
334
333
|
signature: transactionSignature,
|
@@ -337,6 +336,10 @@ async function spamSendTransactionUntilConfirmed(
|
|
337
336
|
clearInterval(sendIntervalId);
|
338
337
|
});
|
339
338
|
|
339
|
+
if (resp.value.err) {
|
340
|
+
throw resp.value.err;
|
341
|
+
}
|
342
|
+
|
340
343
|
return transactionSignature;
|
341
344
|
}
|
342
345
|
|
@@ -345,7 +348,7 @@ export async function sendSingleOptimizedTransaction(
|
|
345
348
|
connection: Connection,
|
346
349
|
tx: TransactionBuilder,
|
347
350
|
txType?: TransactionRunType,
|
348
|
-
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.
|
351
|
+
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Min,
|
349
352
|
onAwaitingSign?: () => void
|
350
353
|
): Promise<Uint8Array | undefined> {
|
351
354
|
consoleLog("Sending single optimized transaction...");
|
@@ -415,7 +418,7 @@ export async function sendSingleOptimizedTransaction(
|
|
415
418
|
const txSig = await spamSendTransactionUntilConfirmed(
|
416
419
|
connection,
|
417
420
|
toWeb3JsTransaction(signedTx),
|
418
|
-
blockhash
|
421
|
+
blockhash
|
419
422
|
);
|
420
423
|
|
421
424
|
consoleLog(`Transaction signature: ${txSig}`);
|