@streamflow/stream 7.2.0 → 7.2.1

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.
@@ -59,18 +59,25 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
59
59
  this.commitment = commitment;
60
60
  this.connection = new web3_js_1.Connection(optionsOrClusterUrl, this.commitment);
61
61
  this.programId = programId !== "" ? new web3_js_1.PublicKey(programId) : new web3_js_1.PublicKey(constants_js_1.PROGRAM_ID[cluster]);
62
- this.sendThrottler = sendThrottler ?? (0, solana_1.buildSendThrottler)(sendRate);
62
+ this.schedulingParams = {
63
+ sendThrottler: sendThrottler ?? (0, solana_1.buildSendThrottler)(sendRate),
64
+ };
63
65
  }
64
66
  else {
65
67
  const { clusterUrl, cluster = types_js_2.ICluster.Mainnet, commitment = "confirmed", programId = "", sendScheduler, } = optionsOrClusterUrl;
66
68
  this.commitment = commitment;
67
69
  this.connection = new web3_js_1.Connection(clusterUrl, this.commitment);
68
70
  this.programId = programId !== "" ? new web3_js_1.PublicKey(programId) : new web3_js_1.PublicKey(constants_js_1.PROGRAM_ID[cluster]);
69
- this.sendThrottler = !sendScheduler
71
+ const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : undefined;
72
+ const sendThrottler = !sendScheduler
70
73
  ? (0, solana_1.buildSendThrottler)(1)
71
74
  : "sendRate" in sendScheduler
72
75
  ? (0, solana_1.buildSendThrottler)(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval)
73
76
  : sendScheduler;
77
+ this.schedulingParams = {
78
+ ...schedulingOptions,
79
+ sendThrottler,
80
+ };
74
81
  }
75
82
  const alignedUnlocksProgram = {
76
83
  ...streamflow_aligned_unlocks_json_1.default,
@@ -114,7 +121,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
114
121
  hash,
115
122
  context,
116
123
  commitment: this.getCommitment(),
117
- }, { sendThrottler: this.sendThrottler });
124
+ }, this.schedulingParams);
118
125
  return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
119
126
  }
120
127
  async prepareCreateInstructions(streamParams, extParams) {
@@ -271,7 +278,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
271
278
  hash,
272
279
  context,
273
280
  commitment: this.getCommitment(),
274
- }, { sendThrottler: this.sendThrottler });
281
+ }, this.schedulingParams);
275
282
  return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
276
283
  }
277
284
  /**
@@ -414,7 +421,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
414
421
  const signedBatch = await (0, utils_js_1.signAllTransactionWithRecipients)(sender, batch);
415
422
  if (prepareInstructions.length > 0) {
416
423
  const prepareTx = signedBatch.pop();
417
- await (0, utils_js_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx, { hash, context }, { sendThrottler: this.sendThrottler });
424
+ await (0, utils_js_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx, { hash, context }, this.schedulingParams);
418
425
  }
419
426
  const responses = [];
420
427
  if (metadataPubKeys.length > 0) {
@@ -422,7 +429,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
422
429
  //ephemeral signer need to be used first before proceeding with the next
423
430
  for (const batchTx of signedBatch) {
424
431
  responses.push(...(await Promise.allSettled([
425
- (0, solana_1.executeTransaction)(this.connection, batchTx.tx, { hash, context }, { sendThrottler: this.sendThrottler }),
432
+ (0, solana_1.executeTransaction)(this.connection, batchTx.tx, { hash, context }, this.schedulingParams),
426
433
  ])));
427
434
  }
428
435
  }
@@ -430,7 +437,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
430
437
  //send all transactions in parallel and wait for them to settle.
431
438
  //it allows to speed up the process of sending transactions
432
439
  //we then filter all promise responses and handle failed transactions
433
- responses.push(...(await (0, solana_1.executeMultipleTransactions)(this.connection, signedBatch.map((item) => item.tx), { hash, context }, { sendThrottler: this.sendThrottler })));
440
+ responses.push(...(await (0, solana_1.executeMultipleTransactions)(this.connection, signedBatch.map((item) => item.tx), { hash, context }, this.schedulingParams)));
434
441
  }
435
442
  responses.forEach((item, index) => {
436
443
  if (item.status === "fulfilled") {
@@ -521,12 +528,12 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
521
528
  const signedBatch = await (0, utils_js_1.signAllTransactionWithRecipients)(sender, batch);
522
529
  if (prepareInstructions.length > 0) {
523
530
  const prepareTx = signedBatch.shift();
524
- await (0, utils_js_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx, { hash, context }, { sendThrottler: this.sendThrottler });
531
+ await (0, utils_js_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx, { hash, context }, this.schedulingParams);
525
532
  }
526
533
  const responses = [];
527
534
  for (const batchTx of signedBatch) {
528
535
  responses.push(...(await Promise.allSettled([
529
- (0, solana_1.executeTransaction)(this.connection, batchTx.tx, { hash, context }, { sendThrottler: this.sendThrottler }),
536
+ (0, solana_1.executeTransaction)(this.connection, batchTx.tx, { hash, context }, this.schedulingParams),
530
537
  ])));
531
538
  }
532
539
  responses.forEach((item, index) => {
@@ -553,7 +560,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
553
560
  hash,
554
561
  context,
555
562
  commitment: this.getCommitment(),
556
- }, { sendThrottler: this.sendThrottler });
563
+ }, this.schedulingParams);
557
564
  return { ixs, txId: signature };
558
565
  }
559
566
  /**
@@ -603,7 +610,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
603
610
  hash,
604
611
  context,
605
612
  commitment: this.getCommitment(),
606
- }, { sendThrottler: this.sendThrottler });
613
+ }, this.schedulingParams);
607
614
  return { ixs, txId: signature };
608
615
  }
609
616
  async prepareCancelInstructions(cancelData, extParams) {
@@ -703,7 +710,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
703
710
  hash,
704
711
  context,
705
712
  commitment: this.getCommitment(),
706
- }, { sendThrottler: this.sendThrottler });
713
+ }, this.schedulingParams);
707
714
  return { ixs, txId: signature };
708
715
  }
709
716
  /**
@@ -750,7 +757,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
750
757
  hash,
751
758
  context,
752
759
  commitment: this.getCommitment(),
753
- }, { sendThrottler: this.sendThrottler });
760
+ }, this.schedulingParams);
754
761
  return { ixs, txId: signature };
755
762
  }
756
763
  /**
@@ -918,7 +925,7 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
918
925
  hash,
919
926
  context,
920
927
  commitment: this.getCommitment(),
921
- }, { sendThrottler: this.sendThrottler });
928
+ }, this.schedulingParams);
922
929
  return {
923
930
  ixs,
924
931
  txId: signature,
@@ -287,6 +287,23 @@ export declare enum SolanaAlignedProxyErrorCode {
287
287
  /** All funds are already unlocked */
288
288
  AllFundsUnlocked = "AllFundsUnlocked"
289
289
  }
290
+ /**
291
+ * @interface
292
+ */
293
+ export interface SolanaTransactionSchedulingOptions {
294
+ /**
295
+ * concurrency rate for scheduling
296
+ */
297
+ sendRate: number;
298
+ /**
299
+ * time interval between consecutive sends
300
+ */
301
+ sendInterval?: number;
302
+ /**
303
+ * time interval before confirming the transaction
304
+ */
305
+ waitBeforeConfirming?: number;
306
+ }
290
307
  /**
291
308
  * @interface
292
309
  */
@@ -298,16 +315,7 @@ export interface SolanaStreamClientOptions {
298
315
  commitment?: Commitment | ConnectionConfig;
299
316
  sendRate?: number;
300
317
  sendThrottler?: PQueue;
301
- sendScheduler?: PQueue | {
302
- /**
303
- * concurrency rate for scheduling
304
- */
305
- sendRate: number;
306
- /**
307
- * time interval between consecutive sends
308
- */
309
- sendInterval?: number;
310
- };
318
+ sendScheduler?: PQueue | SolanaTransactionSchedulingOptions;
311
319
  }
312
320
  /**
313
321
  * @interface
@@ -15,8 +15,8 @@ export declare class SolanaStreamClient extends BaseStreamClient {
15
15
  private connection;
16
16
  private programId;
17
17
  private commitment;
18
- private sendThrottler;
19
18
  private alignedProxyProgram;
19
+ private schedulingParams;
20
20
  /**
21
21
  * Create Stream instance with flat arguments
22
22
  */
@@ -24,8 +24,8 @@ export class SolanaStreamClient extends BaseStreamClient {
24
24
  connection;
25
25
  programId;
26
26
  commitment;
27
- sendThrottler;
28
27
  alignedProxyProgram;
28
+ schedulingParams;
29
29
  /**
30
30
  * Create Stream instance
31
31
  */
@@ -35,18 +35,25 @@ export class SolanaStreamClient extends BaseStreamClient {
35
35
  this.commitment = commitment;
36
36
  this.connection = new Connection(optionsOrClusterUrl, this.commitment);
37
37
  this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(PROGRAM_ID[cluster]);
38
- this.sendThrottler = sendThrottler ?? buildSendThrottler(sendRate);
38
+ this.schedulingParams = {
39
+ sendThrottler: sendThrottler ?? buildSendThrottler(sendRate),
40
+ };
39
41
  }
40
42
  else {
41
43
  const { clusterUrl, cluster = ICluster.Mainnet, commitment = "confirmed", programId = "", sendScheduler, } = optionsOrClusterUrl;
42
44
  this.commitment = commitment;
43
45
  this.connection = new Connection(clusterUrl, this.commitment);
44
46
  this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(PROGRAM_ID[cluster]);
45
- this.sendThrottler = !sendScheduler
47
+ const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : undefined;
48
+ const sendThrottler = !sendScheduler
46
49
  ? buildSendThrottler(1)
47
50
  : "sendRate" in sendScheduler
48
51
  ? buildSendThrottler(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval)
49
52
  : sendScheduler;
53
+ this.schedulingParams = {
54
+ ...schedulingOptions,
55
+ sendThrottler,
56
+ };
50
57
  }
51
58
  const alignedUnlocksProgram = {
52
59
  ...StreamflowAlignedUnlocksIDL,
@@ -90,7 +97,7 @@ export class SolanaStreamClient extends BaseStreamClient {
90
97
  hash,
91
98
  context,
92
99
  commitment: this.getCommitment(),
93
- }, { sendThrottler: this.sendThrottler });
100
+ }, this.schedulingParams);
94
101
  return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
95
102
  }
96
103
  async prepareCreateInstructions(streamParams, extParams) {
@@ -247,7 +254,7 @@ export class SolanaStreamClient extends BaseStreamClient {
247
254
  hash,
248
255
  context,
249
256
  commitment: this.getCommitment(),
250
- }, { sendThrottler: this.sendThrottler });
257
+ }, this.schedulingParams);
251
258
  return { ixs, txId: signature, metadataId: metadataPubKey.toBase58() };
252
259
  }
253
260
  /**
@@ -390,7 +397,7 @@ export class SolanaStreamClient extends BaseStreamClient {
390
397
  const signedBatch = await signAllTransactionWithRecipients(sender, batch);
391
398
  if (prepareInstructions.length > 0) {
392
399
  const prepareTx = signedBatch.pop();
393
- await sendAndConfirmStreamRawTransaction(this.connection, prepareTx, { hash, context }, { sendThrottler: this.sendThrottler });
400
+ await sendAndConfirmStreamRawTransaction(this.connection, prepareTx, { hash, context }, this.schedulingParams);
394
401
  }
395
402
  const responses = [];
396
403
  if (metadataPubKeys.length > 0) {
@@ -398,7 +405,7 @@ export class SolanaStreamClient extends BaseStreamClient {
398
405
  //ephemeral signer need to be used first before proceeding with the next
399
406
  for (const batchTx of signedBatch) {
400
407
  responses.push(...(await Promise.allSettled([
401
- executeTransaction(this.connection, batchTx.tx, { hash, context }, { sendThrottler: this.sendThrottler }),
408
+ executeTransaction(this.connection, batchTx.tx, { hash, context }, this.schedulingParams),
402
409
  ])));
403
410
  }
404
411
  }
@@ -406,7 +413,7 @@ export class SolanaStreamClient extends BaseStreamClient {
406
413
  //send all transactions in parallel and wait for them to settle.
407
414
  //it allows to speed up the process of sending transactions
408
415
  //we then filter all promise responses and handle failed transactions
409
- responses.push(...(await executeMultipleTransactions(this.connection, signedBatch.map((item) => item.tx), { hash, context }, { sendThrottler: this.sendThrottler })));
416
+ responses.push(...(await executeMultipleTransactions(this.connection, signedBatch.map((item) => item.tx), { hash, context }, this.schedulingParams)));
410
417
  }
411
418
  responses.forEach((item, index) => {
412
419
  if (item.status === "fulfilled") {
@@ -497,12 +504,12 @@ export class SolanaStreamClient extends BaseStreamClient {
497
504
  const signedBatch = await signAllTransactionWithRecipients(sender, batch);
498
505
  if (prepareInstructions.length > 0) {
499
506
  const prepareTx = signedBatch.shift();
500
- await sendAndConfirmStreamRawTransaction(this.connection, prepareTx, { hash, context }, { sendThrottler: this.sendThrottler });
507
+ await sendAndConfirmStreamRawTransaction(this.connection, prepareTx, { hash, context }, this.schedulingParams);
501
508
  }
502
509
  const responses = [];
503
510
  for (const batchTx of signedBatch) {
504
511
  responses.push(...(await Promise.allSettled([
505
- executeTransaction(this.connection, batchTx.tx, { hash, context }, { sendThrottler: this.sendThrottler }),
512
+ executeTransaction(this.connection, batchTx.tx, { hash, context }, this.schedulingParams),
506
513
  ])));
507
514
  }
508
515
  responses.forEach((item, index) => {
@@ -529,7 +536,7 @@ export class SolanaStreamClient extends BaseStreamClient {
529
536
  hash,
530
537
  context,
531
538
  commitment: this.getCommitment(),
532
- }, { sendThrottler: this.sendThrottler });
539
+ }, this.schedulingParams);
533
540
  return { ixs, txId: signature };
534
541
  }
535
542
  /**
@@ -579,7 +586,7 @@ export class SolanaStreamClient extends BaseStreamClient {
579
586
  hash,
580
587
  context,
581
588
  commitment: this.getCommitment(),
582
- }, { sendThrottler: this.sendThrottler });
589
+ }, this.schedulingParams);
583
590
  return { ixs, txId: signature };
584
591
  }
585
592
  async prepareCancelInstructions(cancelData, extParams) {
@@ -679,7 +686,7 @@ export class SolanaStreamClient extends BaseStreamClient {
679
686
  hash,
680
687
  context,
681
688
  commitment: this.getCommitment(),
682
- }, { sendThrottler: this.sendThrottler });
689
+ }, this.schedulingParams);
683
690
  return { ixs, txId: signature };
684
691
  }
685
692
  /**
@@ -726,7 +733,7 @@ export class SolanaStreamClient extends BaseStreamClient {
726
733
  hash,
727
734
  context,
728
735
  commitment: this.getCommitment(),
729
- }, { sendThrottler: this.sendThrottler });
736
+ }, this.schedulingParams);
730
737
  return { ixs, txId: signature };
731
738
  }
732
739
  /**
@@ -894,7 +901,7 @@ export class SolanaStreamClient extends BaseStreamClient {
894
901
  hash,
895
902
  context,
896
903
  commitment: this.getCommitment(),
897
- }, { sendThrottler: this.sendThrottler });
904
+ }, this.schedulingParams);
898
905
  return {
899
906
  ixs,
900
907
  txId: signature,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "7.2.0",
3
+ "version": "7.2.1",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "main": "./dist/esm/index.js",
@@ -42,9 +42,9 @@
42
42
  "lint": "eslint --fix .",
43
43
  "prepublishOnly": "pnpm run lint && pnpm run test run && pnpm run build"
44
44
  },
45
- "gitHead": "e56411e57d702a9f74d9611317fffa7e0a827c8c",
45
+ "gitHead": "56f65828955f62400c0b2eebaeb53c7f123dca60",
46
46
  "devDependencies": {
47
- "@streamflow/eslint-config": "7.2.0",
47
+ "@streamflow/eslint-config": "7.2.1",
48
48
  "@types/bn.js": "5.1.1",
49
49
  "@types/ethereum-checksum-address": "^0.0.0",
50
50
  "date-fns": "2.28.0",
@@ -59,7 +59,7 @@
59
59
  "@solana/spl-token": "0.4.9",
60
60
  "@solana/wallet-adapter-base": "0.9.19",
61
61
  "@solana/web3.js": "1.95.4",
62
- "@streamflow/common": "7.2.0",
62
+ "@streamflow/common": "7.2.1",
63
63
  "@suiet/wallet-kit": "0.2.22",
64
64
  "aptos": "1.21.0",
65
65
  "bn.js": "5.2.1",