@haven-fi/solauto-sdk 1.0.333 → 1.0.335

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.
@@ -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,IAAI,MAAM,EAAE;CAY3B;AAyFD,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;I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AAC,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;YA+E7B,qBAAqB;YAuDrB,cAAc;YAqCd,eAAe;CAmD9B"}
@@ -86,13 +86,13 @@ class TransactionSet {
86
86
  return false;
87
87
  }
88
88
  const singleTx = await this.getSingleTransaction();
89
- return (0, solanaUtils_1.addTxOptimizations)(this.txHandler.umi.identity, singleTx, 1, 1)
89
+ const tx = (0, solanaUtils_1.addTxOptimizations)(this.txHandler.umi.identity, singleTx, 1, 1)
90
90
  .add(item.tx)
91
91
  .setAddressLookupTables(await this.lookupTables.getLutInputs([
92
92
  ...this.lutAddresses(),
93
93
  ...item.lookupTableAddresses,
94
- ]))
95
- .fitsInOneTransaction(this.txHandler.umi);
94
+ ]));
95
+ return tx.fitsInOneTransaction(this.txHandler.umi);
96
96
  }
97
97
  add(...items) {
98
98
  this.items.push(...items.filter((x) => x.tx && x.tx.getInstructions().length > 0));
@@ -349,14 +349,21 @@ class TransactionsManager {
349
349
  transactions.push(await set.getSingleTransaction());
350
350
  }
351
351
  this.updateStatusForSets(itemSets, TransactionStatus.Processing, attemptNum);
352
- const txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.signer, transactions, false, this.priorityFeeSetting);
353
- if (Boolean(txSigs) && txSigs.length > 0) {
354
- this.updateStatusForSets(itemSets, TransactionStatus.Successful, attemptNum, txSigs);
352
+ let txSigs;
353
+ let error;
354
+ try {
355
+ txSigs = await (0, jitoUtils_1.sendJitoBundledTransactions)(this.txHandler.umi, this.txHandler.connection, this.txHandler.signer, transactions, this.txType, this.priorityFeeSetting);
355
356
  }
356
- else {
357
- this.updateStatusForSets(itemSets, TransactionStatus.Failed, attemptNum, txSigs, true);
358
- throw new Error("Unknown error");
357
+ catch (e) {
358
+ error = e.message;
359
+ }
360
+ if (error || !Boolean(txSigs) || txSigs?.length === 0) {
361
+ this.updateStatusForSets(itemSets, TransactionStatus.Failed, attemptNum, txSigs, true, error);
362
+ if (error) {
363
+ throw new Error(error ? error : "Unknown error");
364
+ }
359
365
  }
366
+ this.updateStatusForSets(itemSets, TransactionStatus.Successful, attemptNum, txSigs);
360
367
  }, this.retries, this.retryDelay, this.errorsToThrow).catch((e) => {
361
368
  this.updateStatusForSets(itemSets, TransactionStatus.Failed, num, undefined, true, e.message);
362
369
  throw e;
@@ -1,6 +1,6 @@
1
- import { PublicKey } from "@solana/web3.js";
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
2
  import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
3
- import { PriorityFeeSetting } from "../types";
3
+ import { PriorityFeeSetting, TransactionRunType } from "../types";
4
4
  export declare function getRandomTipAccount(): Promise<PublicKey>;
5
- export declare function sendJitoBundledTransactions(umi: Umi, signer: Signer, txs: TransactionBuilder[], simulateOnly?: boolean, priorityFeeSetting?: PriorityFeeSetting): Promise<string[] | undefined>;
5
+ export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting): 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,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9C,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AAsHD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,YAAY,CAAC,EAAE,OAAO,EACtB,kBAAkB,GAAE,kBAA2C,GAC9D,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAkD/B"}
1
+ {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAG9E,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;AAwHD,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,GAC9D,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAyD/B"}
@@ -13,6 +13,7 @@ const generalUtils_1 = require("./generalUtils");
13
13
  const types_1 = require("../types");
14
14
  const axios_1 = __importDefault(require("axios"));
15
15
  const bs58_1 = __importDefault(require("bs58"));
16
+ const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
16
17
  async function getRandomTipAccount() {
17
18
  const tipAccounts = [
18
19
  "96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5",
@@ -95,8 +96,11 @@ async function sendJitoBundle(transactions) {
95
96
  });
96
97
  }
97
98
  catch (e) {
98
- if (e.response) {
99
+ if (e.response.data.error) {
99
100
  console.error("Jito send bundle error:", e.response.data.error);
101
+ throw new Error(e.response.data.error.message);
102
+ }
103
+ else {
100
104
  throw e;
101
105
  }
102
106
  }
@@ -104,7 +108,11 @@ async function sendJitoBundle(transactions) {
104
108
  (0, generalUtils_1.consoleLog)("Bundle ID:", bundleId);
105
109
  return bundleId ? await pollBundleStatus(bundleId) : [];
106
110
  }
107
- async function sendJitoBundledTransactions(umi, signer, txs, simulateOnly, priorityFeeSetting = types_1.PriorityFeeSetting.Min) {
111
+ async function sendJitoBundledTransactions(umi, connection, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min) {
112
+ if (txs.length === 1) {
113
+ const res = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(umi, connection, txs[0], txType, priorityFeeSetting);
114
+ return res ? [bytes_1.bs58.encode(res)] : undefined;
115
+ }
108
116
  (0, generalUtils_1.consoleLog)("Sending Jito bundle...");
109
117
  (0, generalUtils_1.consoleLog)("Transactions: ", txs.length);
110
118
  (0, generalUtils_1.consoleLog)("Transaction sizes: ", txs.map((x) => x.getTransactionSize(umi)));
@@ -115,11 +123,8 @@ async function sendJitoBundledTransactions(umi, signer, txs, simulateOnly, prior
115
123
  : undefined;
116
124
  let builtTxs = await umiToVersionedTransactions(umi, signer, txs, true, // false if simulating first and rebuilding later
117
125
  feeEstimates);
118
- for (let i = 0; i < txs.length; i++) {
119
- (0, generalUtils_1.consoleLog)("Transaction", i, txs[i].getInstructions());
120
- }
121
126
  // const simulationResults = await simulateJitoBundle(umi, builtTxs);
122
- if (!simulateOnly) {
127
+ if (txType !== "only-simulate") {
123
128
  // let builtTxs = await umiToVersionedTransactions(
124
129
  // client.signer,
125
130
  // txs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.333",
3
+ "version": "1.0.335",
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",
@@ -136,15 +136,16 @@ class TransactionSet {
136
136
  }
137
137
 
138
138
  const singleTx = await this.getSingleTransaction();
139
- return addTxOptimizations(this.txHandler.umi.identity, singleTx, 1, 1)
139
+ const tx = addTxOptimizations(this.txHandler.umi.identity, singleTx, 1, 1)
140
140
  .add(item.tx)
141
141
  .setAddressLookupTables(
142
142
  await this.lookupTables.getLutInputs([
143
143
  ...this.lutAddresses(),
144
144
  ...item.lookupTableAddresses,
145
145
  ])
146
- )
147
- .fitsInOneTransaction(this.txHandler.umi);
146
+ );
147
+
148
+ return tx.fitsInOneTransaction(this.txHandler.umi);
148
149
  }
149
150
 
150
151
  add(...items: TransactionItem[]) {
@@ -551,30 +552,42 @@ export class TransactionsManager {
551
552
  TransactionStatus.Processing,
552
553
  attemptNum
553
554
  );
554
- const txSigs = await sendJitoBundledTransactions(
555
- this.txHandler.umi,
556
- this.txHandler.signer,
557
- transactions,
558
- false,
559
- this.priorityFeeSetting
560
- );
561
- if (Boolean(txSigs) && txSigs!.length > 0) {
562
- this.updateStatusForSets(
563
- itemSets,
564
- TransactionStatus.Successful,
565
- attemptNum,
566
- txSigs
555
+
556
+ let txSigs: string[] | undefined;
557
+ let error: string | undefined;
558
+ try {
559
+ txSigs = await sendJitoBundledTransactions(
560
+ this.txHandler.umi,
561
+ this.txHandler.connection,
562
+ this.txHandler.signer,
563
+ transactions,
564
+ this.txType,
565
+ this.priorityFeeSetting
567
566
  );
568
- } else {
567
+ } catch (e: any) {
568
+ error = e.message;
569
+ }
570
+
571
+ if (error || !Boolean(txSigs) || txSigs?.length === 0) {
569
572
  this.updateStatusForSets(
570
573
  itemSets,
571
574
  TransactionStatus.Failed,
572
575
  attemptNum,
573
576
  txSigs,
574
- true
577
+ true,
578
+ error
575
579
  );
576
- throw new Error("Unknown error");
580
+ if (error) {
581
+ throw new Error(error ? error : "Unknown error");
582
+ }
577
583
  }
584
+
585
+ this.updateStatusForSets(
586
+ itemSets,
587
+ TransactionStatus.Successful,
588
+ attemptNum,
589
+ txSigs
590
+ );
578
591
  },
579
592
  this.retries,
580
593
  this.retryDelay,
@@ -1,4 +1,4 @@
1
- import { PublicKey, VersionedTransaction } from "@solana/web3.js";
1
+ import { Connection, PublicKey, 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 {
@@ -11,10 +11,11 @@ import {
11
11
  assembleFinalTransaction,
12
12
  buildIronforgeApiUrl,
13
13
  getComputeUnitPriceEstimate,
14
+ sendSingleOptimizedTransaction,
14
15
  systemTransferUmiIx,
15
16
  } from "./solanaUtils";
16
17
  import { consoleLog } from "./generalUtils";
17
- import { PriorityFeeSetting } from "../types";
18
+ import { PriorityFeeSetting, TransactionRunType } from "../types";
18
19
  import axios from "axios";
19
20
  import base58 from "bs58";
20
21
  import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
@@ -139,8 +140,10 @@ async function sendJitoBundle(transactions: string[]): Promise<string[]> {
139
140
  }
140
141
  );
141
142
  } catch (e: any) {
142
- if (e.response) {
143
+ if (e.response.data.error) {
143
144
  console.error("Jito send bundle error:", e.response.data.error);
145
+ throw new Error(e.response.data.error.message);
146
+ } else {
144
147
  throw e;
145
148
  }
146
149
  }
@@ -152,11 +155,23 @@ async function sendJitoBundle(transactions: string[]): Promise<string[]> {
152
155
 
153
156
  export async function sendJitoBundledTransactions(
154
157
  umi: Umi,
158
+ connection: Connection,
155
159
  signer: Signer,
156
160
  txs: TransactionBuilder[],
157
- simulateOnly?: boolean,
161
+ txType?: TransactionRunType,
158
162
  priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min
159
163
  ): Promise<string[] | undefined> {
164
+ if (txs.length === 1) {
165
+ const res = await sendSingleOptimizedTransaction(
166
+ umi,
167
+ connection,
168
+ txs[0],
169
+ txType,
170
+ priorityFeeSetting
171
+ );
172
+ return res ? [bs58.encode(res)] : undefined;
173
+ }
174
+
160
175
  consoleLog("Sending Jito bundle...");
161
176
  consoleLog("Transactions: ", txs.length);
162
177
  consoleLog(
@@ -184,13 +199,9 @@ export async function sendJitoBundledTransactions(
184
199
  feeEstimates
185
200
  );
186
201
 
187
- for (let i = 0; i < txs.length; i++) {
188
- consoleLog("Transaction", i, txs[i].getInstructions());
189
- }
190
-
191
202
  // const simulationResults = await simulateJitoBundle(umi, builtTxs);
192
203
 
193
- if (!simulateOnly) {
204
+ if (txType !== "only-simulate") {
194
205
  // let builtTxs = await umiToVersionedTransactions(
195
206
  // client.signer,
196
207
  // txs,