@streamflow/common 6.1.1 → 6.2.0

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.
@@ -26,4 +26,5 @@ export interface ConfirmationParams {
26
26
  commitment?: Commitment;
27
27
  }
28
28
  export declare class TransactionFailedError extends Error {
29
+ constructor(m: string);
29
30
  }
@@ -18,8 +18,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.TransactionFailedError = void 0;
19
19
  var TransactionFailedError = /** @class */ (function (_super) {
20
20
  __extends(TransactionFailedError, _super);
21
- function TransactionFailedError() {
22
- return _super !== null && _super.apply(this, arguments) || this;
21
+ function TransactionFailedError(m) {
22
+ var _this = _super.call(this, m) || this;
23
+ Object.setPrototypeOf(_this, TransactionFailedError.prototype);
24
+ _this.name = "TransactionFailedError";
25
+ return _this;
23
26
  }
24
27
  return TransactionFailedError;
25
28
  }(Error));
@@ -152,5 +152,5 @@ export declare function prepareBaseInstructions(connection: Connection, { comput
152
152
  */
153
153
  export declare function getMintAndProgram(connection: Connection, address: PublicKey, commitment?: Commitment): Promise<{
154
154
  mint: Mint;
155
- programId: PublicKey;
155
+ tokenProgramId: PublicKey;
156
156
  }>;
@@ -464,7 +464,7 @@ function enrichAtaParams(connection, paramsBatch) {
464
464
  return __generator(this, function (_a) {
465
465
  programIdByMint = {};
466
466
  return [2 /*return*/, Promise.all(paramsBatch.map(function (params) { return __awaiter(_this, void 0, void 0, function () {
467
- var mintStr, programId;
467
+ var mintStr, tokenProgramId;
468
468
  return __generator(this, function (_a) {
469
469
  switch (_a.label) {
470
470
  case 0:
@@ -475,8 +475,8 @@ function enrichAtaParams(connection, paramsBatch) {
475
475
  if (!!(mintStr in programIdByMint)) return [3 /*break*/, 2];
476
476
  return [4 /*yield*/, getMintAndProgram(connection, params.mint)];
477
477
  case 1:
478
- programId = (_a.sent()).programId;
479
- programIdByMint[mintStr] = programId;
478
+ tokenProgramId = (_a.sent()).tokenProgramId;
479
+ programIdByMint[mintStr] = tokenProgramId;
480
480
  _a.label = 2;
481
481
  case 2:
482
482
  params.programId = programIdByMint[mintStr];
@@ -581,36 +581,42 @@ function checkOrCreateAtaBatch(connection, owners, mint, invoker, programId) {
581
581
  switch (_d.label) {
582
582
  case 0:
583
583
  ixs = [];
584
- atas = [];
585
- _d.label = 1;
584
+ if (!!programId) return [3 /*break*/, 2];
585
+ return [4 /*yield*/, getMintAndProgram(connection, mint)];
586
586
  case 1:
587
- _d.trys.push([1, 6, 7, 8]);
588
- owners_1 = __values(owners), owners_1_1 = owners_1.next();
587
+ programId = (_d.sent()).tokenProgramId;
589
588
  _d.label = 2;
590
589
  case 2:
591
- if (!!owners_1_1.done) return [3 /*break*/, 5];
590
+ atas = [];
591
+ _d.label = 3;
592
+ case 3:
593
+ _d.trys.push([3, 8, 9, 10]);
594
+ owners_1 = __values(owners), owners_1_1 = owners_1.next();
595
+ _d.label = 4;
596
+ case 4:
597
+ if (!!owners_1_1.done) return [3 /*break*/, 7];
592
598
  owner = owners_1_1.value;
593
599
  _b = (_a = atas).push;
594
600
  return [4 /*yield*/, ata(mint, owner, programId)];
595
- case 3:
601
+ case 5:
596
602
  _b.apply(_a, [_d.sent()]);
597
- _d.label = 4;
598
- case 4:
599
- owners_1_1 = owners_1.next();
600
- return [3 /*break*/, 2];
601
- case 5: return [3 /*break*/, 8];
603
+ _d.label = 6;
602
604
  case 6:
605
+ owners_1_1 = owners_1.next();
606
+ return [3 /*break*/, 4];
607
+ case 7: return [3 /*break*/, 10];
608
+ case 8:
603
609
  e_3_1 = _d.sent();
604
610
  e_3 = { error: e_3_1 };
605
- return [3 /*break*/, 8];
606
- case 7:
611
+ return [3 /*break*/, 10];
612
+ case 9:
607
613
  try {
608
614
  if (owners_1_1 && !owners_1_1.done && (_c = owners_1.return)) _c.call(owners_1);
609
615
  }
610
616
  finally { if (e_3) throw e_3.error; }
611
617
  return [7 /*endfinally*/];
612
- case 8: return [4 /*yield*/, connection.getMultipleAccountsInfo(atas)];
613
- case 9:
618
+ case 10: return [4 /*yield*/, connection.getMultipleAccountsInfo(atas)];
619
+ case 11:
614
620
  response = _d.sent();
615
621
  for (i = 0; i < response.length; i++) {
616
622
  if (!response[i]) {
@@ -663,7 +669,7 @@ function getMintAndProgram(connection, address, commitment) {
663
669
  }
664
670
  return [2 /*return*/, {
665
671
  mint: (0, spl_token_1.unpackMint)(address, accountInfo, programId),
666
- programId: programId,
672
+ tokenProgramId: programId,
667
673
  }];
668
674
  }
669
675
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/common",
3
- "version": "6.1.1",
3
+ "version": "6.2.0",
4
4
  "description": "Common utilities and types used by streamflow packages.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "lint-config": "eslint --print-config",
24
24
  "prepublishOnly": "npm run lint && npm run build"
25
25
  },
26
- "gitHead": "a05d8010b3000b00038ca16a4d5b915436319bdc",
26
+ "gitHead": "06f6635b47854013b63db62e9da401b4f004bfdc",
27
27
  "devDependencies": {
28
28
  "@streamflow/eslint-config": "6.0.0",
29
29
  "@types/bn.js": "5.1.1",