@streamflow/stream 6.0.3 → 6.1.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.
- package/dist/solana/StreamClient.js +102 -70
- package/dist/solana/types.d.ts +2 -2
- package/dist/solana/utils.d.ts +4 -2
- package/dist/solana/utils.js +42 -21
- package/package.json +3 -3
|
@@ -170,7 +170,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
170
170
|
*/
|
|
171
171
|
SolanaStreamClient.prototype.create = function (data, extParams) {
|
|
172
172
|
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var _a, ixs, metadata, metadataPubKey, _b, tx, hash, signature;
|
|
173
|
+
var _a, ixs, metadata, metadataPubKey, _b, tx, hash, context, signature;
|
|
174
174
|
return __generator(this, function (_c) {
|
|
175
175
|
switch (_c.label) {
|
|
176
176
|
case 0: return [4 /*yield*/, this.prepareCreateInstructions(data, extParams)];
|
|
@@ -178,8 +178,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
178
178
|
_a = _c.sent(), ixs = _a.ixs, metadata = _a.metadata, metadataPubKey = _a.metadataPubKey;
|
|
179
179
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.sender.publicKey, undefined, metadata)];
|
|
180
180
|
case 2:
|
|
181
|
-
_b = _c.sent(), tx = _b.tx, hash = _b.hash;
|
|
182
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.sender, tx,
|
|
181
|
+
_b = _c.sent(), tx = _b.tx, hash = _b.hash, context = _b.context;
|
|
182
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.sender, tx, {
|
|
183
|
+
hash: hash,
|
|
184
|
+
context: context,
|
|
185
|
+
commitment: this.getCommitment(),
|
|
186
|
+
})];
|
|
183
187
|
case 3:
|
|
184
188
|
signature = _c.sent();
|
|
185
189
|
return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
|
|
@@ -290,7 +294,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
290
294
|
*/
|
|
291
295
|
SolanaStreamClient.prototype.createUnchecked = function (data, extParams) {
|
|
292
296
|
return __awaiter(this, void 0, void 0, function () {
|
|
293
|
-
var _a, ixs, metadata, metadataPubKey, _b, tx, hash, signature;
|
|
297
|
+
var _a, ixs, metadata, metadataPubKey, _b, tx, hash, context, signature;
|
|
294
298
|
return __generator(this, function (_c) {
|
|
295
299
|
switch (_c.label) {
|
|
296
300
|
case 0: return [4 /*yield*/, this.prepareCreateUncheckedInstructions(data, extParams)];
|
|
@@ -298,8 +302,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
298
302
|
_a = _c.sent(), ixs = _a.ixs, metadata = _a.metadata, metadataPubKey = _a.metadataPubKey;
|
|
299
303
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.sender.publicKey, undefined, metadata)];
|
|
300
304
|
case 2:
|
|
301
|
-
_b = _c.sent(), tx = _b.tx, hash = _b.hash;
|
|
302
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.sender, tx,
|
|
305
|
+
_b = _c.sent(), tx = _b.tx, hash = _b.hash, context = _b.context;
|
|
306
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.sender, tx, {
|
|
307
|
+
hash: hash,
|
|
308
|
+
context: context,
|
|
309
|
+
commitment: this.getCommitment(),
|
|
310
|
+
})];
|
|
303
311
|
case 3:
|
|
304
312
|
signature = _c.sent();
|
|
305
313
|
return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
|
|
@@ -399,11 +407,11 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
399
407
|
SolanaStreamClient.prototype.createMultiple = function (data, _a) {
|
|
400
408
|
var sender = _a.sender, metadataPubKeys = _a.metadataPubKeys, _b = _a.isNative, isNative = _b === void 0 ? false : _b, computePrice = _a.computePrice, computeLimit = _a.computeLimit;
|
|
401
409
|
return __awaiter(this, void 0, void 0, function () {
|
|
402
|
-
var recipients, metadatas, metadataToRecipient, errors, signatures, batch, instructionsBatch, i, recipientData, _c, ixs, metadata, metadataPubKey, hash, instructionsBatch_1, instructionsBatch_1_1,
|
|
403
|
-
var e_2,
|
|
410
|
+
var recipients, metadatas, metadataToRecipient, errors, signatures, batch, instructionsBatch, i, recipientData, _c, ixs, metadata, metadataPubKey, _d, hash, context, instructionsBatch_1, instructionsBatch_1_1, _e, ixs, metadata, recipient, messageV0, tx, totalDepositedAmount, nativeInstructions, messageV0, tx, signedBatch, prepareTx, responses, signedBatch_1, signedBatch_1_1, batchTx, _f, _g, _h, _j, e_1_1, batchTransactionsCalls, _k, _l, _m, _o, successes, failures;
|
|
411
|
+
var e_2, _p, e_1, _q;
|
|
404
412
|
var _this = this;
|
|
405
|
-
return __generator(this, function (
|
|
406
|
-
switch (
|
|
413
|
+
return __generator(this, function (_r) {
|
|
414
|
+
switch (_r.label) {
|
|
407
415
|
case 0:
|
|
408
416
|
recipients = data.recipients;
|
|
409
417
|
if (!sender.publicKey) {
|
|
@@ -417,7 +425,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
417
425
|
instructionsBatch = [];
|
|
418
426
|
metadataPubKeys = metadataPubKeys || [];
|
|
419
427
|
i = 0;
|
|
420
|
-
|
|
428
|
+
_r.label = 1;
|
|
421
429
|
case 1:
|
|
422
430
|
if (!(i < recipients.length)) return [3 /*break*/, 4];
|
|
423
431
|
recipientData = recipients[i];
|
|
@@ -428,7 +436,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
428
436
|
computeLimit: computeLimit,
|
|
429
437
|
})];
|
|
430
438
|
case 2:
|
|
431
|
-
_c =
|
|
439
|
+
_c = _r.sent(), ixs = _c.ixs, metadata = _c.metadata, metadataPubKey = _c.metadataPubKey;
|
|
432
440
|
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
433
441
|
metadatas.push(metadataPubKey.toBase58());
|
|
434
442
|
instructionsBatch.push({
|
|
@@ -436,23 +444,24 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
436
444
|
metadata: metadata,
|
|
437
445
|
recipient: recipientData.recipient,
|
|
438
446
|
});
|
|
439
|
-
|
|
447
|
+
_r.label = 3;
|
|
440
448
|
case 3:
|
|
441
449
|
i++;
|
|
442
450
|
return [3 /*break*/, 1];
|
|
443
|
-
case 4: return [4 /*yield*/, this.connection.
|
|
451
|
+
case 4: return [4 /*yield*/, this.connection.getLatestBlockhashAndContext()];
|
|
444
452
|
case 5:
|
|
445
|
-
|
|
453
|
+
_d = _r.sent(), hash = _d.value, context = _d.context;
|
|
446
454
|
try {
|
|
447
455
|
for (instructionsBatch_1 = __values(instructionsBatch), instructionsBatch_1_1 = instructionsBatch_1.next(); !instructionsBatch_1_1.done; instructionsBatch_1_1 = instructionsBatch_1.next()) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
})
|
|
456
|
+
_e = instructionsBatch_1_1.value, ixs = _e.ixs, metadata = _e.metadata, recipient = _e.recipient;
|
|
457
|
+
messageV0 = new web3_js_1.TransactionMessage({
|
|
458
|
+
payerKey: sender.publicKey,
|
|
459
|
+
recentBlockhash: hash.blockhash,
|
|
460
|
+
instructions: ixs,
|
|
461
|
+
}).compileToV0Message();
|
|
462
|
+
tx = new web3_js_1.VersionedTransaction(messageV0);
|
|
454
463
|
if (metadata) {
|
|
455
|
-
tx.
|
|
464
|
+
tx.sign([metadata]);
|
|
456
465
|
}
|
|
457
466
|
batch.push({ tx: tx, recipient: recipient });
|
|
458
467
|
}
|
|
@@ -460,7 +469,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
460
469
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
461
470
|
finally {
|
|
462
471
|
try {
|
|
463
|
-
if (instructionsBatch_1_1 && !instructionsBatch_1_1.done && (
|
|
472
|
+
if (instructionsBatch_1_1 && !instructionsBatch_1_1.done && (_p = instructionsBatch_1.return)) _p.call(instructionsBatch_1);
|
|
464
473
|
}
|
|
465
474
|
finally { if (e_2) throw e_2.error; }
|
|
466
475
|
}
|
|
@@ -468,71 +477,73 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
468
477
|
totalDepositedAmount = recipients.reduce(function (acc, recipient) { return recipient.amount.add(acc); }, new bn_js_1.default(0));
|
|
469
478
|
return [4 /*yield*/, (0, solana_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalDepositedAmount)];
|
|
470
479
|
case 6:
|
|
471
|
-
nativeInstructions =
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
})
|
|
480
|
+
nativeInstructions = _r.sent();
|
|
481
|
+
messageV0 = new web3_js_1.TransactionMessage({
|
|
482
|
+
payerKey: sender.publicKey,
|
|
483
|
+
recentBlockhash: hash.blockhash,
|
|
484
|
+
instructions: nativeInstructions,
|
|
485
|
+
}).compileToV0Message();
|
|
486
|
+
tx = new web3_js_1.VersionedTransaction(messageV0);
|
|
477
487
|
batch.push({
|
|
478
488
|
tx: tx,
|
|
479
489
|
recipient: sender.publicKey.toBase58(),
|
|
480
490
|
});
|
|
481
|
-
|
|
491
|
+
_r.label = 7;
|
|
482
492
|
case 7: return [4 /*yield*/, (0, utils_1.signAllTransactionWithRecipients)(sender, batch)];
|
|
483
493
|
case 8:
|
|
484
|
-
signedBatch =
|
|
485
|
-
signedBatch.forEach(function (item, index) {
|
|
486
|
-
item.tx.lastValidBlockHeight = batch[index].tx.lastValidBlockHeight;
|
|
487
|
-
});
|
|
494
|
+
signedBatch = _r.sent();
|
|
488
495
|
if (!isNative) return [3 /*break*/, 10];
|
|
489
496
|
prepareTx = signedBatch.pop();
|
|
490
|
-
return [4 /*yield*/, (0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx)];
|
|
497
|
+
return [4 /*yield*/, (0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx, { hash: hash, context: context })];
|
|
491
498
|
case 9:
|
|
492
|
-
|
|
493
|
-
|
|
499
|
+
_r.sent();
|
|
500
|
+
_r.label = 10;
|
|
494
501
|
case 10:
|
|
495
502
|
responses = [];
|
|
496
503
|
if (!(metadataPubKeys.length > 0)) return [3 /*break*/, 19];
|
|
497
|
-
|
|
504
|
+
_r.label = 11;
|
|
498
505
|
case 11:
|
|
499
|
-
|
|
506
|
+
_r.trys.push([11, 16, 17, 18]);
|
|
500
507
|
signedBatch_1 = __values(signedBatch), signedBatch_1_1 = signedBatch_1.next();
|
|
501
|
-
|
|
508
|
+
_r.label = 12;
|
|
502
509
|
case 12:
|
|
503
510
|
if (!!signedBatch_1_1.done) return [3 /*break*/, 15];
|
|
504
511
|
batchTx = signedBatch_1_1.value;
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
return [4 /*yield*/, Promise.allSettled([
|
|
512
|
+
_g = (_f = responses.push).apply;
|
|
513
|
+
_h = [responses];
|
|
514
|
+
_j = [[]];
|
|
515
|
+
return [4 /*yield*/, Promise.allSettled([
|
|
516
|
+
(0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, batchTx, { hash: hash, context: context }),
|
|
517
|
+
])];
|
|
509
518
|
case 13:
|
|
510
|
-
|
|
511
|
-
|
|
519
|
+
_g.apply(_f, _h.concat([__spreadArray.apply(void 0, _j.concat([__read.apply(void 0, [(_r.sent())]), false]))]));
|
|
520
|
+
_r.label = 14;
|
|
512
521
|
case 14:
|
|
513
522
|
signedBatch_1_1 = signedBatch_1.next();
|
|
514
523
|
return [3 /*break*/, 12];
|
|
515
524
|
case 15: return [3 /*break*/, 18];
|
|
516
525
|
case 16:
|
|
517
|
-
e_1_1 =
|
|
526
|
+
e_1_1 = _r.sent();
|
|
518
527
|
e_1 = { error: e_1_1 };
|
|
519
528
|
return [3 /*break*/, 18];
|
|
520
529
|
case 17:
|
|
521
530
|
try {
|
|
522
|
-
if (signedBatch_1_1 && !signedBatch_1_1.done && (
|
|
531
|
+
if (signedBatch_1_1 && !signedBatch_1_1.done && (_q = signedBatch_1.return)) _q.call(signedBatch_1);
|
|
523
532
|
}
|
|
524
533
|
finally { if (e_1) throw e_1.error; }
|
|
525
534
|
return [7 /*endfinally*/];
|
|
526
535
|
case 18: return [3 /*break*/, 21];
|
|
527
536
|
case 19:
|
|
528
|
-
batchTransactionsCalls = signedBatch.map(function (el) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
537
|
+
batchTransactionsCalls = signedBatch.map(function (el) {
|
|
538
|
+
return (0, utils_1.sendAndConfirmStreamRawTransaction)(_this.connection, el, { hash: hash, context: context });
|
|
539
|
+
});
|
|
540
|
+
_l = (_k = responses.push).apply;
|
|
541
|
+
_m = [responses];
|
|
542
|
+
_o = [[]];
|
|
532
543
|
return [4 /*yield*/, Promise.allSettled(batchTransactionsCalls)];
|
|
533
544
|
case 20:
|
|
534
|
-
|
|
535
|
-
|
|
545
|
+
_l.apply(_k, _m.concat([__spreadArray.apply(void 0, _o.concat([__read.apply(void 0, [(_r.sent())]), false]))]));
|
|
546
|
+
_r.label = 21;
|
|
536
547
|
case 21:
|
|
537
548
|
successes = responses
|
|
538
549
|
.filter(function (el) { return el.status === "fulfilled"; })
|
|
@@ -553,7 +564,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
553
564
|
SolanaStreamClient.prototype.withdraw = function (_a, extParams) {
|
|
554
565
|
var id = _a.id, _b = _a.amount, amount = _b === void 0 ? constants_2.WITHDRAW_AVAILABLE_AMOUNT : _b;
|
|
555
566
|
return __awaiter(this, void 0, void 0, function () {
|
|
556
|
-
var ixs, _c, tx, hash, signature;
|
|
567
|
+
var ixs, _c, tx, hash, context, signature;
|
|
557
568
|
return __generator(this, function (_d) {
|
|
558
569
|
switch (_d.label) {
|
|
559
570
|
case 0: return [4 /*yield*/, this.prepareWithdrawInstructions({ id: id, amount: amount }, extParams)];
|
|
@@ -561,8 +572,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
561
572
|
ixs = _d.sent();
|
|
562
573
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey)];
|
|
563
574
|
case 2:
|
|
564
|
-
_c = _d.sent(), tx = _c.tx, hash = _c.hash;
|
|
565
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx,
|
|
575
|
+
_c = _d.sent(), tx = _c.tx, hash = _c.hash, context = _c.context;
|
|
576
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
|
|
577
|
+
hash: hash,
|
|
578
|
+
context: context,
|
|
579
|
+
commitment: this.getCommitment(),
|
|
580
|
+
})];
|
|
566
581
|
case 3:
|
|
567
582
|
signature = _d.sent();
|
|
568
583
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -629,7 +644,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
629
644
|
SolanaStreamClient.prototype.cancel = function (_a, extParams) {
|
|
630
645
|
var id = _a.id;
|
|
631
646
|
return __awaiter(this, void 0, void 0, function () {
|
|
632
|
-
var ixs, _b, tx, hash, signature;
|
|
647
|
+
var ixs, _b, tx, hash, context, signature;
|
|
633
648
|
return __generator(this, function (_c) {
|
|
634
649
|
switch (_c.label) {
|
|
635
650
|
case 0: return [4 /*yield*/, this.prepareCancelInstructions({ id: id }, extParams)];
|
|
@@ -637,8 +652,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
637
652
|
ixs = _c.sent();
|
|
638
653
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey)];
|
|
639
654
|
case 2:
|
|
640
|
-
_b = _c.sent(), tx = _b.tx, hash = _b.hash;
|
|
641
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx,
|
|
655
|
+
_b = _c.sent(), tx = _b.tx, hash = _b.hash, context = _b.context;
|
|
656
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
|
|
657
|
+
hash: hash,
|
|
658
|
+
context: context,
|
|
659
|
+
commitment: this.getCommitment(),
|
|
660
|
+
})];
|
|
642
661
|
case 3:
|
|
643
662
|
signature = _c.sent();
|
|
644
663
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -708,7 +727,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
708
727
|
SolanaStreamClient.prototype.transfer = function (_a, extParams) {
|
|
709
728
|
var id = _a.id, newRecipient = _a.newRecipient;
|
|
710
729
|
return __awaiter(this, void 0, void 0, function () {
|
|
711
|
-
var ixs, _b, tx, hash, signature;
|
|
730
|
+
var ixs, _b, tx, hash, context, signature;
|
|
712
731
|
return __generator(this, function (_c) {
|
|
713
732
|
switch (_c.label) {
|
|
714
733
|
case 0: return [4 /*yield*/, this.prepareTransferInstructions({ id: id, newRecipient: newRecipient }, extParams)];
|
|
@@ -716,8 +735,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
716
735
|
ixs = _c.sent();
|
|
717
736
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey)];
|
|
718
737
|
case 2:
|
|
719
|
-
_b = _c.sent(), tx = _b.tx, hash = _b.hash;
|
|
720
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx,
|
|
738
|
+
_b = _c.sent(), tx = _b.tx, hash = _b.hash, context = _b.context;
|
|
739
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
|
|
740
|
+
hash: hash,
|
|
741
|
+
context: context,
|
|
742
|
+
commitment: this.getCommitment(),
|
|
743
|
+
})];
|
|
721
744
|
case 3:
|
|
722
745
|
signature = _c.sent();
|
|
723
746
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -778,7 +801,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
778
801
|
SolanaStreamClient.prototype.topup = function (_a, extParams) {
|
|
779
802
|
var id = _a.id, amount = _a.amount;
|
|
780
803
|
return __awaiter(this, void 0, void 0, function () {
|
|
781
|
-
var ixs, _b, tx, hash, signature;
|
|
804
|
+
var ixs, _b, tx, hash, context, signature;
|
|
782
805
|
return __generator(this, function (_c) {
|
|
783
806
|
switch (_c.label) {
|
|
784
807
|
case 0: return [4 /*yield*/, this.prepareTopupInstructions({ id: id, amount: amount }, extParams)];
|
|
@@ -786,8 +809,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
786
809
|
ixs = _c.sent();
|
|
787
810
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey)];
|
|
788
811
|
case 2:
|
|
789
|
-
_b = _c.sent(), tx = _b.tx, hash = _b.hash;
|
|
790
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx,
|
|
812
|
+
_b = _c.sent(), tx = _b.tx, hash = _b.hash, context = _b.context;
|
|
813
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
|
|
814
|
+
hash: hash,
|
|
815
|
+
context: context,
|
|
816
|
+
commitment: this.getCommitment(),
|
|
817
|
+
})];
|
|
791
818
|
case 3:
|
|
792
819
|
signature = _c.sent();
|
|
793
820
|
return [2 /*return*/, { ixs: ixs, txId: signature }];
|
|
@@ -927,7 +954,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
927
954
|
*/
|
|
928
955
|
SolanaStreamClient.prototype.update = function (data, extParams) {
|
|
929
956
|
return __awaiter(this, void 0, void 0, function () {
|
|
930
|
-
var ixs, _a, tx, hash, signature;
|
|
957
|
+
var ixs, _a, tx, hash, context, signature;
|
|
931
958
|
return __generator(this, function (_b) {
|
|
932
959
|
switch (_b.label) {
|
|
933
960
|
case 0: return [4 /*yield*/, this.prepareUpdateInstructions(data, extParams)];
|
|
@@ -935,8 +962,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
935
962
|
ixs = _b.sent();
|
|
936
963
|
return [4 /*yield*/, (0, solana_1.prepareTransaction)(this.connection, ixs, extParams.invoker.publicKey)];
|
|
937
964
|
case 2:
|
|
938
|
-
_a = _b.sent(), tx = _a.tx, hash = _a.hash;
|
|
939
|
-
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx,
|
|
965
|
+
_a = _b.sent(), tx = _a.tx, hash = _a.hash, context = _a.context;
|
|
966
|
+
return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, extParams.invoker, tx, {
|
|
967
|
+
hash: hash,
|
|
968
|
+
context: context,
|
|
969
|
+
commitment: this.getCommitment(),
|
|
970
|
+
})];
|
|
940
971
|
case 3:
|
|
941
972
|
signature = _b.sent();
|
|
942
973
|
return [2 /*return*/, {
|
|
@@ -1018,7 +1049,8 @@ var SolanaStreamClient = /** @class */ (function (_super) {
|
|
|
1018
1049
|
};
|
|
1019
1050
|
SolanaStreamClient.prototype.extractErrorCode = function (err) {
|
|
1020
1051
|
var _a;
|
|
1021
|
-
|
|
1052
|
+
var logs = "logs" in err && Array.isArray(err.logs) ? err.logs : undefined;
|
|
1053
|
+
return (0, utils_1.extractSolanaErrorCode)((_a = err.toString()) !== null && _a !== void 0 ? _a : "Unknown error!", logs);
|
|
1022
1054
|
};
|
|
1023
1055
|
/**
|
|
1024
1056
|
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
2
|
-
import { AccountInfo, PublicKey, Keypair,
|
|
2
|
+
import { AccountInfo, PublicKey, Keypair, VersionedTransaction } from "@solana/web3.js";
|
|
3
3
|
import { ITransactionSolanaExt } from "@streamflow/common/solana";
|
|
4
4
|
import BN from "bn.js";
|
|
5
5
|
import { IRecipient, Stream, StreamType } from "../common/types";
|
|
@@ -120,7 +120,7 @@ export interface MetadataRecipientHashMap {
|
|
|
120
120
|
}
|
|
121
121
|
export interface BatchItem {
|
|
122
122
|
recipient: string;
|
|
123
|
-
tx:
|
|
123
|
+
tx: VersionedTransaction;
|
|
124
124
|
}
|
|
125
125
|
export interface BatchItemSuccess extends BatchItem {
|
|
126
126
|
signature: string;
|
package/dist/solana/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
2
2
|
import { Connection, Keypair } from "@solana/web3.js";
|
|
3
|
+
import { ConfirmationParams } from "@streamflow/common/solana";
|
|
3
4
|
import { DecodedStream, BatchItem, BatchItemResult } from "./types";
|
|
4
5
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
5
6
|
/**
|
|
@@ -13,7 +14,8 @@ export declare function signAllTransactionWithRecipients(sender: Keypair | Signe
|
|
|
13
14
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
14
15
|
* @param {Connection} connection - Solana web3 connection object.
|
|
15
16
|
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
17
|
+
* @param {ConfirmationParams} confirmationParams - Confirmation Params that will be used for execution
|
|
16
18
|
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
17
19
|
*/
|
|
18
|
-
export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem): Promise<BatchItemResult>;
|
|
19
|
-
export declare function extractSolanaErrorCode(errorText: string): string | null;
|
|
20
|
+
export declare function sendAndConfirmStreamRawTransaction(connection: Connection, batchItem: BatchItem, confirmationParams: ConfirmationParams): Promise<BatchItemResult>;
|
|
21
|
+
export declare function extractSolanaErrorCode(errorText: string, logs?: string[]): string | null;
|
package/dist/solana/utils.js
CHANGED
|
@@ -46,6 +46,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __values = (this && this.__values) || function(o) {
|
|
50
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
51
|
+
if (m) return m.call(o);
|
|
52
|
+
if (o && typeof o.length === "number") return {
|
|
53
|
+
next: function () {
|
|
54
|
+
if (o && i >= o.length) o = void 0;
|
|
55
|
+
return { value: o && o[i++], done: !o };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
|
+
};
|
|
49
60
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
61
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
62
|
};
|
|
@@ -54,7 +65,6 @@ exports.extractSolanaErrorCode = exports.sendAndConfirmStreamRawTransaction = ex
|
|
|
54
65
|
var web3_js_1 = require("@solana/web3.js");
|
|
55
66
|
var solana_1 = require("@streamflow/common/solana");
|
|
56
67
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
57
|
-
var bs58_1 = __importDefault(require("bs58"));
|
|
58
68
|
var layout_1 = require("./layout");
|
|
59
69
|
var constants_1 = require("./constants");
|
|
60
70
|
var decoder = new TextDecoder("utf-8");
|
|
@@ -123,7 +133,7 @@ function signAllTransactionWithRecipients(sender, items) {
|
|
|
123
133
|
isWallet = (0, solana_1.isSignerWallet)(sender);
|
|
124
134
|
if (!isKeypair) return [3 /*break*/, 1];
|
|
125
135
|
return [2 /*return*/, items.map(function (t) {
|
|
126
|
-
t.tx.
|
|
136
|
+
t.tx.sign([sender]);
|
|
127
137
|
return { tx: t.tx, recipient: t.recipient };
|
|
128
138
|
})];
|
|
129
139
|
case 1:
|
|
@@ -144,33 +154,25 @@ exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
|
|
|
144
154
|
* Sign passed BatchItems with wallet request or KeyPair
|
|
145
155
|
* @param {Connection} connection - Solana web3 connection object.
|
|
146
156
|
* @param {BatchItem} batchItem - Signed transaction ready to be send.
|
|
157
|
+
* @param {ConfirmationParams} confirmationParams - Confirmation Params that will be used for execution
|
|
147
158
|
* @return {Promise<BatchItemResult>} - Returns settled transaction item
|
|
148
159
|
*/
|
|
149
|
-
function sendAndConfirmStreamRawTransaction(connection, batchItem) {
|
|
150
|
-
var _a, _b;
|
|
160
|
+
function sendAndConfirmStreamRawTransaction(connection, batchItem, confirmationParams) {
|
|
151
161
|
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var
|
|
153
|
-
return __generator(this, function (
|
|
154
|
-
switch (
|
|
162
|
+
var completedTxSignature, error_1;
|
|
163
|
+
return __generator(this, function (_a) {
|
|
164
|
+
switch (_a.label) {
|
|
155
165
|
case 0:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (!lastValidBlockHeight || !signature || !recentBlockhash)
|
|
159
|
-
throw { recipient: batchItem.recipient, error: "no recent blockhash" };
|
|
160
|
-
confirmationStrategy = {
|
|
161
|
-
lastValidBlockHeight: lastValidBlockHeight,
|
|
162
|
-
signature: bs58_1.default.encode(signature),
|
|
163
|
-
blockhash: recentBlockhash,
|
|
164
|
-
};
|
|
165
|
-
return [4 /*yield*/, (0, solana_1.executeTransaction)(connection, batchItem.tx, confirmationStrategy)];
|
|
166
|
+
_a.trys.push([0, 2, , 3]);
|
|
167
|
+
return [4 /*yield*/, (0, solana_1.executeTransaction)(connection, batchItem.tx, confirmationParams)];
|
|
166
168
|
case 1:
|
|
167
|
-
completedTxSignature =
|
|
169
|
+
completedTxSignature = _a.sent();
|
|
168
170
|
return [2 /*return*/, __assign(__assign({}, batchItem), { signature: completedTxSignature })];
|
|
169
171
|
case 2:
|
|
170
|
-
error_1 =
|
|
172
|
+
error_1 = _a.sent();
|
|
171
173
|
throw {
|
|
172
174
|
recipient: batchItem.recipient,
|
|
173
|
-
error:
|
|
175
|
+
error: error_1,
|
|
174
176
|
};
|
|
175
177
|
case 3: return [2 /*return*/];
|
|
176
178
|
}
|
|
@@ -178,8 +180,27 @@ function sendAndConfirmStreamRawTransaction(connection, batchItem) {
|
|
|
178
180
|
});
|
|
179
181
|
}
|
|
180
182
|
exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
|
|
181
|
-
function extractSolanaErrorCode(errorText) {
|
|
183
|
+
function extractSolanaErrorCode(errorText, logs) {
|
|
184
|
+
var e_1, _a;
|
|
182
185
|
var match = constants_1.SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
186
|
+
if (!match && logs) {
|
|
187
|
+
try {
|
|
188
|
+
for (var logs_1 = __values(logs), logs_1_1 = logs_1.next(); !logs_1_1.done; logs_1_1 = logs_1.next()) {
|
|
189
|
+
var logLine = logs_1_1.value;
|
|
190
|
+
match = constants_1.SOLANA_ERROR_MATCH_REGEX.exec(logLine);
|
|
191
|
+
if (match !== null) {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
197
|
+
finally {
|
|
198
|
+
try {
|
|
199
|
+
if (logs_1_1 && !logs_1_1.done && (_a = logs_1.return)) _a.call(logs_1);
|
|
200
|
+
}
|
|
201
|
+
finally { if (e_1) throw e_1.error; }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
183
204
|
if (!match) {
|
|
184
205
|
return null;
|
|
185
206
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"lint": "eslint --fix .",
|
|
36
36
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "170947ffbd1de885ac95c4b809b0e889d938eaaf",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@streamflow/eslint-config": "6.0.0",
|
|
41
41
|
"@types/bn.js": "5.1.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@solana/spl-token": "0.3.6",
|
|
55
55
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
56
56
|
"@solana/web3.js": "1.70.1",
|
|
57
|
-
"@streamflow/common": "6.0
|
|
57
|
+
"@streamflow/common": "6.1.0",
|
|
58
58
|
"@suiet/wallet-kit": "0.2.22",
|
|
59
59
|
"aptos": "1.4.0",
|
|
60
60
|
"bn.js": "5.2.1",
|