@streamflow/stream 3.0.7 → 3.0.10

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.
@@ -36,6 +36,37 @@ export default class StreamClient {
36
36
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
37
37
  */
38
38
  create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateParams): Promise<CreateResponse>;
39
+ /**
40
+ * Creates a new stream/vesting contract using unchecked instruction.
41
+ *
42
+ * Unchecked instruction differes from the regular in:
43
+ * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
44
+ * as sender/recipient/partner or there are risks of funds being locked in the contract)
45
+ * - initialized contract PDA off chain
46
+ *
47
+ * If you are not sure if you should use create or create_unchecked, go for create to be safer.
48
+ *
49
+ * @param {CreateParams} data
50
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
51
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
52
+ * @param {string} data.mint - SPL Token mint.
53
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
54
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
55
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
56
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
57
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
58
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
59
+ * @param {string} data.name - Stream name/subject.
60
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
61
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
62
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
63
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
64
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
65
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
66
+ * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
67
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
68
+ */
69
+ createUnchecked({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateParams): Promise<CreateResponse>;
39
70
  /**
40
71
  * Creates a new stream/vesting contract.
41
72
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -98,6 +98,7 @@ var constants_1 = require("./constants");
98
98
  var instructions_1 = require("./instructions");
99
99
  var common_1 = require("@project-serum/common");
100
100
  var bs58_1 = require("@project-serum/anchor/dist/cjs/utils/bytes/bs58");
101
+ var METADATA_ACC_SIZE = 1104;
101
102
  var StreamClient = /** @class */ (function () {
102
103
  /**
103
104
  * Create Stream instance
@@ -211,15 +212,16 @@ var StreamClient = /** @class */ (function () {
211
212
  commitment = typeof this.commitment == "string"
212
213
  ? this.commitment
213
214
  : this.commitment.commitment;
214
- return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
215
+ return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
215
216
  case 6:
216
217
  hash = _g.sent();
217
218
  tx = (_f = new web3_js_1.Transaction({
218
219
  feePayer: sender.publicKey,
219
- recentBlockhash: hash.blockhash,
220
+ blockhash: hash.blockhash,
221
+ lastValidBlockHeight: hash.lastValidBlockHeight,
220
222
  })).add.apply(_f, __spreadArray([], __read(ixs), false));
221
223
  tx.partialSign(metadata);
222
- return [4 /*yield*/, this.sign(sender, tx)];
224
+ return [4 /*yield*/, this.sign(sender, tx, hash)];
223
225
  case 7:
224
226
  signature = _g.sent();
225
227
  return [2 /*return*/, { ixs: ixs, tx: signature, metadata: metadata }];
@@ -227,6 +229,120 @@ var StreamClient = /** @class */ (function () {
227
229
  });
228
230
  });
229
231
  };
232
+ /**
233
+ * Creates a new stream/vesting contract using unchecked instruction.
234
+ *
235
+ * Unchecked instruction differes from the regular in:
236
+ * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
237
+ * as sender/recipient/partner or there are risks of funds being locked in the contract)
238
+ * - initialized contract PDA off chain
239
+ *
240
+ * If you are not sure if you should use create or create_unchecked, go for create to be safer.
241
+ *
242
+ * @param {CreateParams} data
243
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
244
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
245
+ * @param {string} data.mint - SPL Token mint.
246
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
247
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
248
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
249
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
250
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
251
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
252
+ * @param {string} data.name - Stream name/subject.
253
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
254
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
255
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
256
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
257
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
258
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
259
+ * @param {number} [data.withdrawalFrequency = 0] - Relevant when automatic withdrawal is enabled. If greater than 0 our withdrawor will take care of withdrawals. If equal to 0 our withdrawor will skip, but everyone else can initiate withdrawals.
260
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
261
+ */
262
+ StreamClient.prototype.createUnchecked = function (_a) {
263
+ var sender = _a.sender, recipient = _a.recipient, mint = _a.mint, start = _a.start, depositedAmount = _a.depositedAmount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _b = _a.automaticWithdrawal, automaticWithdrawal = _b === void 0 ? false : _b, _c = _a.withdrawalFrequency, withdrawalFrequency = _c === void 0 ? 0 : _c, _d = _a.partner, partner = _d === void 0 ? null : _d;
264
+ return __awaiter(this, void 0, void 0, function () {
265
+ var mintPublicKey, recipientPublicKey, metadata, rentToExempt, createMetadataInstruction, _e, escrowTokens, senderTokens, partnerPublicKey, createInstruction, commitment, ixs, hash, tx, signature;
266
+ var _f;
267
+ return __generator(this, function (_g) {
268
+ switch (_g.label) {
269
+ case 0:
270
+ mintPublicKey = new web3_js_1.PublicKey(mint);
271
+ recipientPublicKey = new web3_js_1.PublicKey(recipient);
272
+ metadata = web3_js_1.Keypair.generate();
273
+ return [4 /*yield*/, this.connection.getMinimumBalanceForRentExemption(METADATA_ACC_SIZE)];
274
+ case 1:
275
+ rentToExempt = _g.sent();
276
+ createMetadataInstruction = web3_js_1.SystemProgram.createAccount({
277
+ programId: this.programId,
278
+ space: METADATA_ACC_SIZE,
279
+ lamports: rentToExempt,
280
+ fromPubkey: sender === null || sender === void 0 ? void 0 : sender.publicKey,
281
+ newAccountPubkey: metadata.publicKey,
282
+ });
283
+ return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
284
+ case 2:
285
+ _e = __read.apply(void 0, [_g.sent(), 1]), escrowTokens = _e[0];
286
+ return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
287
+ case 3:
288
+ senderTokens = _g.sent();
289
+ partnerPublicKey = partner
290
+ ? new web3_js_1.PublicKey(partner)
291
+ : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
292
+ createInstruction = (0, instructions_1.createUncheckedStreamInstruction)({
293
+ start: new bn_js_1.default(start),
294
+ depositedAmount: depositedAmount,
295
+ period: new bn_js_1.default(period),
296
+ amountPerPeriod: amountPerPeriod,
297
+ cliff: new bn_js_1.default(cliff),
298
+ cliffAmount: cliffAmount,
299
+ cancelableBySender: cancelableBySender,
300
+ cancelableByRecipient: cancelableByRecipient,
301
+ automaticWithdrawal: automaticWithdrawal,
302
+ transferableBySender: transferableBySender,
303
+ transferableByRecipient: transferableByRecipient,
304
+ canTopup: canTopup,
305
+ name: name,
306
+ withdrawFrequency: new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period),
307
+ recipient: recipientPublicKey,
308
+ partner: partnerPublicKey,
309
+ }, this.programId, {
310
+ sender: sender.publicKey,
311
+ senderTokens: senderTokens,
312
+ metadata: metadata.publicKey,
313
+ escrowTokens: escrowTokens,
314
+ mint: new web3_js_1.PublicKey(mint),
315
+ feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
316
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
317
+ timelockProgram: this.programId,
318
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
319
+ withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
320
+ systemProgram: web3_js_1.SystemProgram.programId,
321
+ });
322
+ commitment = typeof this.commitment == "string"
323
+ ? this.commitment
324
+ : this.commitment.commitment;
325
+ ixs = [
326
+ createMetadataInstruction,
327
+ createInstruction,
328
+ ];
329
+ return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
330
+ case 4:
331
+ hash = _g.sent();
332
+ tx = (_f = new web3_js_1.Transaction({
333
+ feePayer: sender.publicKey,
334
+ blockhash: hash.blockhash,
335
+ lastValidBlockHeight: hash.lastValidBlockHeight,
336
+ })).add.apply(_f, __spreadArray([], __read(ixs), false));
337
+ tx.partialSign(metadata);
338
+ return [4 /*yield*/, this.sign(sender, tx, hash)];
339
+ case 5:
340
+ signature = _g.sent();
341
+ return [2 /*return*/, { ixs: ixs, tx: signature, metadata: metadata }];
342
+ }
343
+ });
344
+ });
345
+ };
230
346
  /**
231
347
  * Creates a new stream/vesting contract.
232
348
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -393,14 +509,15 @@ var StreamClient = /** @class */ (function () {
393
509
  commitment = typeof this.commitment == "string"
394
510
  ? this.commitment
395
511
  : this.commitment.commitment;
396
- return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
512
+ return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
397
513
  case 4:
398
514
  hash = _c.sent();
399
515
  tx = (_b = new web3_js_1.Transaction({
400
516
  feePayer: invoker.publicKey,
401
- recentBlockhash: hash.blockhash,
517
+ blockhash: hash.blockhash,
518
+ lastValidBlockHeight: hash.lastValidBlockHeight,
402
519
  })).add.apply(_b, __spreadArray([], __read(ixs), false));
403
- return [4 /*yield*/, this.sign(invoker, tx)];
520
+ return [4 /*yield*/, this.sign(invoker, tx, hash)];
404
521
  case 5:
405
522
  signature = _c.sent();
406
523
  return [2 /*return*/, { ixs: ixs, tx: signature }];
@@ -455,14 +572,15 @@ var StreamClient = /** @class */ (function () {
455
572
  commitment = typeof this.commitment == "string"
456
573
  ? this.commitment
457
574
  : this.commitment.commitment;
458
- return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
575
+ return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
459
576
  case 4:
460
577
  hash = _c.sent();
461
578
  tx = (_b = new web3_js_1.Transaction({
462
579
  feePayer: invoker.publicKey,
463
- recentBlockhash: hash.blockhash,
580
+ blockhash: hash.blockhash,
581
+ lastValidBlockHeight: hash.lastValidBlockHeight,
464
582
  })).add.apply(_b, __spreadArray([], __read(ixs), false));
465
- return [4 /*yield*/, this.sign(invoker, tx)];
583
+ return [4 /*yield*/, this.sign(invoker, tx, hash)];
466
584
  case 5:
467
585
  signature = _c.sent();
468
586
  return [2 /*return*/, { ixs: ixs, tx: signature }];
@@ -513,14 +631,15 @@ var StreamClient = /** @class */ (function () {
513
631
  commitment = typeof this.commitment == "string"
514
632
  ? this.commitment
515
633
  : this.commitment.commitment;
516
- return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
634
+ return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
517
635
  case 3:
518
636
  hash = _c.sent();
519
637
  tx = (_b = new web3_js_1.Transaction({
520
638
  feePayer: invoker.publicKey,
521
- recentBlockhash: hash.blockhash,
639
+ blockhash: hash.blockhash,
640
+ lastValidBlockHeight: hash.lastValidBlockHeight,
522
641
  })).add.apply(_b, __spreadArray([], __read(ixs), false));
523
- return [4 /*yield*/, this.sign(invoker, tx)];
642
+ return [4 /*yield*/, this.sign(invoker, tx, hash)];
524
643
  case 4:
525
644
  signature = _c.sent();
526
645
  return [2 /*return*/, { ixs: ixs, tx: signature }];
@@ -575,14 +694,15 @@ var StreamClient = /** @class */ (function () {
575
694
  commitment = typeof this.commitment == "string"
576
695
  ? this.commitment
577
696
  : this.commitment.commitment;
578
- return [4 /*yield*/, this.connection.getRecentBlockhash(commitment)];
697
+ return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
579
698
  case 4:
580
699
  hash = _d.sent();
581
700
  tx = (_c = new web3_js_1.Transaction({
582
701
  feePayer: invoker.publicKey,
583
- recentBlockhash: hash.blockhash,
702
+ blockhash: hash.blockhash,
703
+ lastValidBlockHeight: hash.lastValidBlockHeight,
584
704
  })).add.apply(_c, __spreadArray([], __read(ixs), false));
585
- return [4 /*yield*/, this.sign(invoker, tx)];
705
+ return [4 /*yield*/, this.sign(invoker, tx, hash)];
586
706
  case 5:
587
707
  signature = _d.sent();
588
708
  return [2 /*return*/, { ixs: ixs, tx: signature }];
@@ -664,24 +784,30 @@ var StreamClient = /** @class */ (function () {
664
784
  });
665
785
  });
666
786
  };
667
- StreamClient.prototype.sign = function (invoker, tx) {
787
+ StreamClient.prototype.sign = function (invoker, tx, hash) {
668
788
  return __awaiter(this, void 0, void 0, function () {
669
- var rawTx, signature;
789
+ var rawTx, confirmationStrategy, signature;
670
790
  return __generator(this, function (_a) {
671
791
  switch (_a.label) {
672
792
  case 0:
673
- if (!(invoker instanceof web3_js_1.Keypair)) return [3 /*break*/, 1];
674
- tx.partialSign(invoker);
675
- return [3 /*break*/, 3];
676
- case 1:
677
- if (!(invoker === null || invoker === void 0 ? void 0 : invoker.signTransaction)) return [3 /*break*/, 3];
793
+ if (!isAnchorWallet(invoker)) return [3 /*break*/, 2];
678
794
  return [4 /*yield*/, invoker.signTransaction(tx)];
679
- case 2:
795
+ case 1:
680
796
  _a.sent();
797
+ return [3 /*break*/, 3];
798
+ case 2:
799
+ tx.partialSign(invoker);
681
800
  _a.label = 3;
682
801
  case 3:
683
802
  rawTx = tx.serialize();
684
- return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx)];
803
+ if (!hash.lastValidBlockHeight || !tx.signature || !hash.blockhash)
804
+ throw Error("Error with transaction parameters.");
805
+ confirmationStrategy = {
806
+ lastValidBlockHeight: hash.lastValidBlockHeight,
807
+ signature: (0, bs58_1.encode)(tx.signature),
808
+ blockhash: hash.blockhash,
809
+ };
810
+ return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx, confirmationStrategy)];
685
811
  case 4:
686
812
  signature = _a.sent();
687
813
  return [2 /*return*/, signature];
@@ -37,6 +37,38 @@ interface CreateStreamAccounts {
37
37
  systemProgram: PublicKey;
38
38
  }
39
39
  export declare const createStreamInstruction: (data: CreateStreamData, programId: PublicKey, accounts: CreateStreamAccounts) => TransactionInstruction;
40
+ interface CreateUncheckedStreamData {
41
+ start: BN;
42
+ depositedAmount: BN;
43
+ period: BN;
44
+ amountPerPeriod: BN;
45
+ cliff: BN;
46
+ cliffAmount: BN;
47
+ cancelableBySender: boolean;
48
+ cancelableByRecipient: boolean;
49
+ automaticWithdrawal: boolean;
50
+ transferableBySender: boolean;
51
+ transferableByRecipient: boolean;
52
+ canTopup: boolean;
53
+ name: string;
54
+ withdrawFrequency: BN;
55
+ recipient: PublicKey;
56
+ partner: PublicKey;
57
+ }
58
+ interface CreateUncheckedStreamAccounts {
59
+ sender: PublicKey;
60
+ senderTokens: PublicKey;
61
+ metadata: PublicKey;
62
+ escrowTokens: PublicKey;
63
+ mint: PublicKey;
64
+ feeOracle: PublicKey;
65
+ rent: PublicKey;
66
+ timelockProgram: PublicKey;
67
+ tokenProgram: PublicKey;
68
+ withdrawor: PublicKey;
69
+ systemProgram: PublicKey;
70
+ }
71
+ export declare const createUncheckedStreamInstruction: (data: CreateUncheckedStreamData, programId: PublicKey, accounts: CreateUncheckedStreamAccounts) => TransactionInstruction;
40
72
  interface WithdrawAccounts {
41
73
  authority: PublicKey;
42
74
  recipient: PublicKey;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.withdrawStreamInstruction = exports.createStreamInstruction = void 0;
26
+ exports.topupStreamInstruction = exports.transferStreamInstruction = exports.cancelStreamInstruction = exports.withdrawStreamInstruction = exports.createUncheckedStreamInstruction = exports.createStreamInstruction = void 0;
27
27
  var buffer_1 = require("buffer");
28
28
  var web3_js_1 = require("@solana/web3.js");
29
29
  var js_sha256_1 = require("js-sha256");
@@ -85,6 +85,7 @@ var createStreamInstruction = function (data, programId, accounts) {
85
85
  bufferData = buffer_1.Buffer.concat([
86
86
  buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:create")).slice(0, 8),
87
87
  bufferData,
88
+ buffer_1.Buffer.alloc(10)
88
89
  ]);
89
90
  return new web3_js_1.TransactionInstruction({
90
91
  keys: keys,
@@ -93,6 +94,57 @@ var createStreamInstruction = function (data, programId, accounts) {
93
94
  });
94
95
  };
95
96
  exports.createStreamInstruction = createStreamInstruction;
97
+ var createUncheckedStreamInstruction = function (data, programId, accounts) {
98
+ var keys = [
99
+ { pubkey: accounts.sender, isSigner: true, isWritable: true },
100
+ { pubkey: accounts.senderTokens, isSigner: false, isWritable: true },
101
+ { pubkey: accounts.metadata, isSigner: false, isWritable: true },
102
+ { pubkey: accounts.escrowTokens, isSigner: false, isWritable: true },
103
+ { pubkey: accounts.withdrawor, isSigner: false, isWritable: true },
104
+ { pubkey: accounts.mint, isSigner: false, isWritable: false },
105
+ { pubkey: accounts.feeOracle, isSigner: false, isWritable: false },
106
+ { pubkey: accounts.rent, isSigner: false, isWritable: false },
107
+ { pubkey: accounts.timelockProgram, isSigner: false, isWritable: false },
108
+ { pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
109
+ { pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
110
+ ];
111
+ var bufferData = buffer_1.Buffer.alloc(Layout.createUncheckedStreamLayout.span);
112
+ var encodedUIntArray = new TextEncoder().encode(data.name);
113
+ var streamNameBuffer = buffer_1.Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
114
+ var decodedData = {
115
+ start_time: data.start.toArrayLike(buffer_1.Buffer, "le", 8),
116
+ net_amount_deposited: data.depositedAmount.toArrayLike(buffer_1.Buffer, "le", 8),
117
+ period: data.period.toArrayLike(buffer_1.Buffer, "le", 8),
118
+ amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
119
+ cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
120
+ cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
121
+ cancelable_by_sender: data.cancelableBySender,
122
+ cancelable_by_recipient: data.cancelableByRecipient,
123
+ automatic_withdrawal: data.automaticWithdrawal,
124
+ transferable_by_sender: data.transferableBySender,
125
+ transferable_by_recipient: data.transferableByRecipient,
126
+ can_topup: data.canTopup,
127
+ stream_name: streamNameBuffer,
128
+ withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
129
+ recipient: data.recipient.toBuffer(),
130
+ partner: data.partner.toBuffer(),
131
+ pausable: buffer_1.Buffer.alloc(1),
132
+ can_update_rate: buffer_1.Buffer.alloc(1),
133
+ };
134
+ var encodeLength = Layout.createUncheckedStreamLayout.encode(decodedData, bufferData);
135
+ bufferData = bufferData.slice(0, encodeLength);
136
+ bufferData = buffer_1.Buffer.concat([
137
+ buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:create_unchecked")).slice(0, 8),
138
+ bufferData,
139
+ buffer_1.Buffer.alloc(10),
140
+ ]);
141
+ return new web3_js_1.TransactionInstruction({
142
+ keys: keys,
143
+ programId: programId,
144
+ data: bufferData,
145
+ });
146
+ };
147
+ exports.createUncheckedStreamInstruction = createUncheckedStreamInstruction;
96
148
  var withdrawStreamInstruction = function (amount, programId, _a) {
97
149
  var authority = _a.authority, recipient = _a.recipient, recipientTokens = _a.recipientTokens, metadata = _a.metadata, escrowTokens = _a.escrowTokens, streamflowTreasury = _a.streamflowTreasury, streamflowTreasuryTokens = _a.streamflowTreasuryTokens, partner = _a.partner, partnerTokens = _a.partnerTokens, mint = _a.mint, tokenProgram = _a.tokenProgram;
98
150
  var keys = [
@@ -119,6 +171,7 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
119
171
  data = buffer_1.Buffer.concat([
120
172
  buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:withdraw")).slice(0, 8),
121
173
  data,
174
+ buffer_1.Buffer.alloc(10)
122
175
  ]);
123
176
  return new web3_js_1.TransactionInstruction({
124
177
  keys: keys,
@@ -148,7 +201,10 @@ var cancelStreamInstruction = function (programId, _a) {
148
201
  { pubkey: mint, isSigner: false, isWritable: false },
149
202
  { pubkey: tokenProgram, isSigner: false, isWritable: false },
150
203
  ];
151
- var data = buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:cancel")).slice(0, 8);
204
+ var data = buffer_1.Buffer.concat([
205
+ buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:cancel")).slice(0, 8),
206
+ buffer_1.Buffer.alloc(10),
207
+ ]);
152
208
  return new web3_js_1.TransactionInstruction({
153
209
  keys: keys,
154
210
  programId: programId,
@@ -169,7 +225,10 @@ var transferStreamInstruction = function (programId, _a) {
169
225
  { pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
170
226
  { pubkey: systemProgram, isSigner: false, isWritable: false },
171
227
  ];
172
- var data = buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:transfer_recipient")).slice(0, 8);
228
+ var data = buffer_1.Buffer.concat([
229
+ buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:transfer_recipient")).slice(0, 8),
230
+ buffer_1.Buffer.alloc(10),
231
+ ]);
173
232
  return new web3_js_1.TransactionInstruction({
174
233
  keys: keys,
175
234
  programId: programId,
@@ -204,6 +263,7 @@ var topupStreamInstruction = function (amount, programId, _a) {
204
263
  data = buffer_1.Buffer.concat([
205
264
  buffer_1.Buffer.from(js_sha256_1.sha256.digest("global:topup")).slice(0, 8),
206
265
  data,
266
+ buffer_1.Buffer.alloc(10)
207
267
  ]);
208
268
  return new web3_js_1.TransactionInstruction({
209
269
  keys: keys,
package/dist/layout.d.ts CHANGED
@@ -7,6 +7,10 @@ export declare const streamLayout: typeof BufferLayout.Structure;
7
7
  * Create stream instruction layout
8
8
  */
9
9
  export declare const createStreamLayout: typeof BufferLayout.Structure;
10
+ /**
11
+ * Create unchecked stream instruction layout
12
+ */
13
+ export declare const createUncheckedStreamLayout: typeof BufferLayout.Structure;
10
14
  /**
11
15
  * Withdraw stream instruction layout
12
16
  */
package/dist/layout.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
3
+ exports.topupStreamLayout = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
4
4
  var BufferLayout = require("buffer-layout");
5
5
  /**
6
6
  * Stream layout
@@ -63,6 +63,29 @@ exports.createStreamLayout = BufferLayout.struct([
63
63
  BufferLayout.blob(64, "stream_name"),
64
64
  BufferLayout.blob(8, "withdraw_frequency"),
65
65
  ]);
66
+ /**
67
+ * Create unchecked stream instruction layout
68
+ */
69
+ exports.createUncheckedStreamLayout = BufferLayout.struct([
70
+ BufferLayout.blob(8, "start_time"),
71
+ BufferLayout.blob(8, "net_amount_deposited"),
72
+ BufferLayout.blob(8, "period"),
73
+ BufferLayout.blob(8, "amount_per_period"),
74
+ BufferLayout.blob(8, "cliff"),
75
+ BufferLayout.blob(8, "cliff_amount"),
76
+ BufferLayout.u8("cancelable_by_sender"),
77
+ BufferLayout.u8("cancelable_by_recipient"),
78
+ BufferLayout.u8("automatic_withdrawal"),
79
+ BufferLayout.u8("transferable_by_sender"),
80
+ BufferLayout.u8("transferable_by_recipient"),
81
+ BufferLayout.u8("can_topup"),
82
+ BufferLayout.blob(64, "stream_name"),
83
+ BufferLayout.blob(8, "withdraw_frequency"),
84
+ BufferLayout.blob(32, "recipient"),
85
+ BufferLayout.blob(32, "partner"),
86
+ BufferLayout.u8("pausable"),
87
+ BufferLayout.u8("can_update_rate"),
88
+ ]);
66
89
  /**
67
90
  * Withdraw stream instruction layout
68
91
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "3.0.7",
3
+ "version": "3.0.10",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",