@haven-fi/solauto-sdk 1.0.255 → 1.0.257

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;AAK7D,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;AAgFD,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,EAA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pB,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,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;IA4DzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA+BxB,qBAAqB;YAiDrB,cAAc;YAyBd,eAAe;CAkD9B"}
@@ -11,8 +11,8 @@ const generalUtils_1 = require("../utils/generalUtils");
11
11
  const transactionUtils_1 = require("./transactionUtils");
12
12
  const types_1 = require("../types");
13
13
  const web3_js_1 = require("@solana/web3.js");
14
- const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
15
14
  // import { sendJitoBundledTransactions } from "../utils/jitoUtils";
15
+ const CHORES_TX_NAME = "account chores";
16
16
  class TransactionTooLargeError extends Error {
17
17
  constructor(message) {
18
18
  super(message);
@@ -112,9 +112,12 @@ class TransactionSet {
112
112
  return Array.from(new Set(this.items.map((x) => x.lookupTableAddresses).flat()));
113
113
  }
114
114
  name() {
115
- const names = this.items
115
+ let names = this.items
116
116
  .filter((x) => x.tx && x.name !== undefined)
117
117
  .map((x) => x.name.toLowerCase());
118
+ if (names.length > 1) {
119
+ names = names.filter(x => x !== CHORES_TX_NAME);
120
+ }
118
121
  if (names.length >= 3) {
119
122
  return [names.slice(0, -1).join(", "), names[names.length - 1]].join(", and ");
120
123
  }
@@ -247,43 +250,27 @@ class TransactionsManager {
247
250
  const items = [...transactions];
248
251
  const client = this.txHandler;
249
252
  const updateLookupTable = await client.updateLookupTable();
250
- let isolatedLutTx = updateLookupTable?.new;
251
- if (updateLookupTable && !isolatedLutTx) {
252
- for (const item of items) {
253
- await item.initialize();
254
- }
255
- const txAccounts = items.flatMap((x) => x.tx.getInstructions().flatMap((x) => x.keys.map((x) => x.pubkey)));
256
- const newAccountsUsage = txAccounts.reduce((count, pk) => {
257
- return updateLookupTable.accountsToAdd.find((x) => x.equals((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(pk)))
258
- ? count + 1
259
- : count;
260
- }, 0);
261
- isolatedLutTx = Boolean(newAccountsUsage);
262
- }
263
- this.txHandler.log(updateLookupTable?.accountsToAdd.map(x => x.toString()));
264
- if (updateLookupTable && isolatedLutTx) {
253
+ if (updateLookupTable && updateLookupTable?.new) {
265
254
  await this.updateLut(updateLookupTable.tx, updateLookupTable.new);
266
255
  }
267
256
  this.lookupTables.defaultLuts = client.defaultLookupTables();
268
- if (!items[0].initialized || (updateLookupTable && isolatedLutTx)) {
269
- for (const item of items) {
270
- await item.initialize();
271
- }
257
+ for (const item of items) {
258
+ await item.initialize();
272
259
  }
273
260
  const [choresBefore, choresAfter] = await (0, transactionUtils_1.getTransactionChores)(client, (0, umi_1.transactionBuilder)().add(items
274
261
  .filter((x) => x.tx && x.tx.getInstructions().length > 0)
275
262
  .map((x) => x.tx)));
276
- if (updateLookupTable && !isolatedLutTx) {
263
+ if (updateLookupTable && !updateLookupTable?.new) {
277
264
  choresBefore.prepend(updateLookupTable.tx);
278
265
  }
279
266
  if (choresBefore.getInstructions().length > 0) {
280
- const chore = new TransactionItem(async () => ({ tx: choresBefore }), "account chores");
267
+ const chore = new TransactionItem(async () => ({ tx: choresBefore }), CHORES_TX_NAME);
281
268
  await chore.initialize();
282
269
  items.unshift(chore);
283
270
  this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
284
271
  }
285
272
  if (choresAfter.getInstructions().length > 0) {
286
- const chore = new TransactionItem(async () => ({ tx: choresAfter }));
273
+ const chore = new TransactionItem(async () => ({ tx: choresAfter }), CHORES_TX_NAME);
287
274
  await chore.initialize();
288
275
  items.push(chore);
289
276
  this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.255",
3
+ "version": "1.0.257",
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",
@@ -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
- const names = this.items
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 "
@@ -366,33 +371,13 @@ export class TransactionsManager {
366
371
 
367
372
  const updateLookupTable = await client.updateLookupTable();
368
373
 
369
- let isolatedLutTx = updateLookupTable?.new;
370
- if (updateLookupTable && !isolatedLutTx) {
371
- for (const item of items) {
372
- await item.initialize();
373
- }
374
- const txAccounts = items.flatMap((x) =>
375
- x.tx!.getInstructions().flatMap((x) => x.keys.map((x) => x.pubkey))
376
- );
377
- const newAccountsUsage = txAccounts.reduce((count, pk) => {
378
- return updateLookupTable.accountsToAdd.find((x) =>
379
- x.equals(toWeb3JsPublicKey(pk))
380
- )
381
- ? count + 1
382
- : count;
383
- }, 0);
384
- isolatedLutTx = Boolean(newAccountsUsage);
385
- }
386
- this.txHandler.log(updateLookupTable?.accountsToAdd.map(x => x.toString()));
387
- if (updateLookupTable && isolatedLutTx) {
374
+ if (updateLookupTable && updateLookupTable?.new) {
388
375
  await this.updateLut(updateLookupTable.tx, updateLookupTable.new);
389
376
  }
390
377
  this.lookupTables.defaultLuts = client.defaultLookupTables();
391
378
 
392
- if (!items[0].initialized || (updateLookupTable && isolatedLutTx)) {
393
- for (const item of items) {
394
- await item.initialize();
395
- }
379
+ for (const item of items) {
380
+ await item.initialize();
396
381
  }
397
382
 
398
383
  const [choresBefore, choresAfter] = await getTransactionChores(
@@ -403,11 +388,14 @@ export class TransactionsManager {
403
388
  .map((x) => x.tx!)
404
389
  )
405
390
  );
406
- if (updateLookupTable && !isolatedLutTx) {
391
+ if (updateLookupTable && !updateLookupTable?.new) {
407
392
  choresBefore.prepend(updateLookupTable.tx);
408
393
  }
409
394
  if (choresBefore.getInstructions().length > 0) {
410
- const chore = new TransactionItem(async () => ({ tx: choresBefore }), "account chores");
395
+ const chore = new TransactionItem(
396
+ async () => ({ tx: choresBefore }),
397
+ CHORES_TX_NAME
398
+ );
411
399
  await chore.initialize();
412
400
  items.unshift(chore);
413
401
  this.txHandler.log(
@@ -416,7 +404,7 @@ export class TransactionsManager {
416
404
  );
417
405
  }
418
406
  if (choresAfter.getInstructions().length > 0) {
419
- const chore = new TransactionItem(async () => ({ tx: choresAfter }));
407
+ const chore = new TransactionItem(async () => ({ tx: choresAfter }), CHORES_TX_NAME);
420
408
  await chore.initialize();
421
409
  items.push(chore);
422
410
  this.txHandler.log(