@streamflow/stream 3.0.8 → 3.0.11

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];
@@ -799,7 +925,7 @@ function ata(mint, account) {
799
925
  return __awaiter(this, void 0, void 0, function () {
800
926
  return __generator(this, function (_a) {
801
927
  switch (_a.label) {
802
- case 0: return [4 /*yield*/, spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, mint, account)];
928
+ case 0: return [4 /*yield*/, spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, mint, account, true)];
803
929
  case 1: return [2 /*return*/, _a.sent()];
804
930
  }
805
931
  });
@@ -1,15 +0,0 @@
1
- export declare const DATE_FORMAT = "yyyy-MM-dd";
2
- export declare const TIME_FORMAT = "HH:mm";
3
- export declare const PERIOD: {
4
- SECOND: number;
5
- MINUTE: number;
6
- HOUR: number;
7
- DAY: number;
8
- WEEK: number;
9
- MONTH: number;
10
- YEAR: number;
11
- };
12
- export declare const timePeriodOptions: {
13
- value: number;
14
- label: string;
15
- }[];
@@ -1,250 +1,166 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (_) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
- var __read = (this && this.__read) || function (o, n) {
62
- var m = typeof Symbol === "function" && o[Symbol.iterator];
63
- if (!m) return o;
64
- var i = m.call(o), r, ar = [], e;
65
- try {
66
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
67
- }
68
- catch (error) { e = { error: error }; }
69
- finally {
70
- try {
71
- if (r && !r.done && (m = i["return"])) m.call(i);
72
- }
73
- finally { if (e) throw e.error; }
74
- }
75
- return ar;
76
- };
77
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
78
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
79
- if (ar || !(i in from)) {
80
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
81
- ar[i] = from[i];
82
- }
83
- }
84
- return to.concat(ar || Array.prototype.slice.call(from));
85
- };
86
- var __importDefault = (this && this.__importDefault) || function (mod) {
87
- return (mod && mod.__esModule) ? mod : { "default": mod };
88
- };
89
- var _a;
90
- Object.defineProperty(exports, "__esModule", { value: true });
91
- exports.timePeriodOptions = exports.PERIOD = exports.TIME_FORMAT = exports.DATE_FORMAT = void 0;
92
- var StreamClient_1 = __importDefault(require("../StreamClient"));
93
- var types_1 = require("../types");
94
- var web3 = __importStar(require("@solana/web3.js"));
95
- var utils_1 = require("../utils");
96
- var airdrop_request_1 = require("./test_dependencies/airdrop/airdrop-request");
97
- var anchor_1 = require("@project-serum/anchor");
98
- var constants_1 = require("../constants");
99
- var bn_js_1 = require("bn.js");
100
- var streamInstance = null;
101
- var sender;
102
- var recipient;
103
- var recipients = [];
104
- var connection = null;
105
- var date_fns_1 = require("date-fns");
106
- var CLUSTER_LOCAL = "local";
107
- var clusterUrls = (_a = {},
108
- _a[CLUSTER_LOCAL] = function () { return "http://localhost:8899"; },
109
- _a[types_1.Cluster.Devnet] = function () { return "https://api.devnet.solana.com"; },
110
- _a[types_1.Cluster.Mainnet] = function () { return "https://api.mainnet-beta.solana.com"; },
111
- _a);
112
- beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
113
- return __generator(this, function (_a) {
114
- switch (_a.label) {
115
- case 0:
116
- streamInstance = new StreamClient_1.default(clusterUrls[types_1.Cluster.Devnet](), types_1.Cluster.Devnet, {
117
- commitment: "confirmed",
118
- disableRetryOnRateLimit: true,
119
- });
120
- connection = new web3.Connection(web3.clusterApiUrl(), "confirmed");
121
- sender = new anchor_1.Wallet(web3.Keypair.generate());
122
- recipient = new anchor_1.Wallet(web3.Keypair.generate());
123
- recipients = __spreadArray([], __read(new Array(10)), false).map(function () { return new anchor_1.Wallet(web3.Keypair.generate()); });
124
- return [4 /*yield*/, (0, airdrop_request_1.requestAirdrop)(sender, connection)];
125
- case 1:
126
- _a.sent();
127
- return [2 /*return*/];
128
- }
129
- });
130
- }); }, 100000);
131
- test("Sender wallet airdropped funds", function () { return __awaiter(void 0, void 0, void 0, function () {
132
- var _a;
133
- return __generator(this, function (_b) {
134
- switch (_b.label) {
135
- case 0:
136
- _a = expect;
137
- return [4 /*yield*/, (connection === null || connection === void 0 ? void 0 : connection.getBalance(sender.publicKey))];
138
- case 1:
139
- _a.apply(void 0, [_b.sent()]).toBeGreaterThan(0);
140
- return [2 /*return*/];
141
- }
142
- });
143
- }); }, 100000);
144
- test("Stream client connects to cluster", function () { return __awaiter(void 0, void 0, void 0, function () {
145
- var streamInstanceConnection;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0:
149
- expect(streamInstance).toBeTruthy();
150
- return [4 /*yield*/, (streamInstance === null || streamInstance === void 0 ? void 0 : streamInstance.getConnection())];
151
- case 1:
152
- streamInstanceConnection = _a.sent();
153
- expect(streamInstanceConnection).toBeTruthy();
154
- return [2 /*return*/];
155
- }
156
- });
157
- }); });
158
- var newCreateMultipleStreamsPayload = function (values, sender) {
159
- var recipients = values.recipients, releaseAmount = values.releaseAmount, startDate = values.startDate, startTime = values.startTime, releaseFrequencyCounter = values.releaseFrequencyCounter, releaseFrequencyPeriod = values.releaseFrequencyPeriod, whoCanTransfer = values.whoCanTransfer, whoCanCancel = values.whoCanCancel, referral = values.referral;
160
- var start = (0, date_fns_1.getUnixTime)(new Date(startDate + "T" + startTime));
161
- var recipientsFormatted = recipients.map(function (_a) {
162
- var depositedAmount = _a.depositedAmount, recipient = _a.recipient, name = _a.name;
163
- return ({
164
- recipient: recipient,
165
- name: name,
166
- depositedAmount: (0, utils_1.getBN)(depositedAmount, 9),
167
- amountPerPeriod: (0, utils_1.getBN)(releaseAmount, 9),
168
- cliffAmount: new bn_js_1.BN(0),
169
- });
170
- });
171
- var data = {
172
- sender: sender,
173
- recipientsData: recipientsFormatted,
174
- mint: constants_1.AIRDROP_TEST_TOKEN,
175
- start: start,
176
- period: releaseFrequencyCounter * releaseFrequencyPeriod,
177
- cliff: start,
178
- cancelableBySender: whoCanCancel === types_1.TransferCancelOptions.Sender ||
179
- whoCanCancel === types_1.TransferCancelOptions.Both,
180
- cancelableByRecipient: whoCanCancel === types_1.TransferCancelOptions.Recipient ||
181
- whoCanCancel === types_1.TransferCancelOptions.Both,
182
- transferableBySender: whoCanTransfer === types_1.TransferCancelOptions.Sender ||
183
- whoCanTransfer === types_1.TransferCancelOptions.Both,
184
- transferableByRecipient: whoCanTransfer === types_1.TransferCancelOptions.Recipient ||
185
- whoCanTransfer === types_1.TransferCancelOptions.Both,
186
- automaticWithdrawal: false,
187
- withdrawalFrequency: 0,
188
- canTopup: true,
189
- partner: referral,
190
- };
191
- return data;
192
- };
193
- exports.DATE_FORMAT = "yyyy-MM-dd";
194
- exports.TIME_FORMAT = "HH:mm";
195
- exports.PERIOD = {
196
- SECOND: 1,
197
- MINUTE: 60,
198
- HOUR: 3600,
199
- DAY: 24 * 3600,
200
- WEEK: 7 * 24 * 3600,
201
- MONTH: Math.floor(30.4167 * 24 * 3600),
202
- YEAR: 365 * 24 * 3600, // 365 days
203
- };
204
- exports.timePeriodOptions = [
205
- { value: exports.PERIOD.SECOND, label: "second" },
206
- { value: exports.PERIOD.MINUTE, label: "minute" },
207
- { value: exports.PERIOD.HOUR, label: "hour" },
208
- { value: exports.PERIOD.DAY, label: "day" },
209
- { value: exports.PERIOD.WEEK, label: "week" },
210
- { value: exports.PERIOD.MONTH, label: "month" },
211
- { value: exports.PERIOD.YEAR, label: "year" },
212
- ];
213
- test("Can create multiple stremas", function () { return __awaiter(void 0, void 0, void 0, function () {
214
- var now, recipientsPayload, values, data, response, errors;
215
- return __generator(this, function (_a) {
216
- switch (_a.label) {
217
- case 0:
218
- now = new Date();
219
- recipientsPayload = recipients.map(function (recipient, i) { return ({
220
- recipient: recipient.publicKey.toBase58(),
221
- recipientEmail: "",
222
- name: "Recipient " + i,
223
- depositedAmount: 0.0001,
224
- }); });
225
- values = {
226
- releaseAmount: 0.00001,
227
- tokenSymbol: "",
228
- startDate: (0, date_fns_1.format)(now, exports.DATE_FORMAT),
229
- startTime: (0, date_fns_1.format)((0, date_fns_1.add)(now, { minutes: 5 }), exports.TIME_FORMAT),
230
- releaseFrequencyCounter: 1,
231
- releaseFrequencyPeriod: exports.timePeriodOptions[0].value,
232
- whoCanTransfer: types_1.TransferCancelOptions.Recipient,
233
- whoCanCancel: types_1.TransferCancelOptions.Sender,
234
- automaticWithdrawal: false,
235
- withdrawalFrequencyCounter: 1,
236
- withdrawalFrequencyPeriod: exports.timePeriodOptions[1].value,
237
- referral: "",
238
- email: "",
239
- recipients: recipientsPayload,
240
- };
241
- data = newCreateMultipleStreamsPayload(values, sender);
242
- return [4 /*yield*/, (streamInstance === null || streamInstance === void 0 ? void 0 : streamInstance.createMultiple(data))];
243
- case 1:
244
- response = _a.sent();
245
- errors = response === null || response === void 0 ? void 0 : response.errors;
246
- console.log(errors);
247
- return [2 /*return*/, response];
248
- }
249
- });
250
- }); }, 600000);
2
+ // import StreamClient from "../StreamClient";
3
+ // import {
4
+ // Cluster,
5
+ // CreateMultiParams,
6
+ // CreateMultipleStreamsValues,
7
+ // LocalCluster,
8
+ // TransferCancelOptions,
9
+ // } from "../types";
10
+ // import * as web3 from "@solana/web3.js";
11
+ // import { getBN } from "../utils";
12
+ // import { requestAirdrop } from "./test_dependencies/airdrop/airdrop-request";
13
+ // import { Wallet } from "@project-serum/anchor";
14
+ // import { AIRDROP_TEST_TOKEN } from "../constants";
15
+ // import { BN } from "bn.js";
16
+ // let streamInstance: StreamClient | null = null;
17
+ // let sender: Wallet;
18
+ // let recipient: Wallet;
19
+ // let recipients: Wallet[] = [];
20
+ // let connection: web3.Connection | null = null;
21
+ // import { add, addMinutes, format, getUnixTime } from "date-fns";
22
+ // const CLUSTER_LOCAL = "local";
23
+ //
24
+ // const clusterUrls: { [s: string]: () => string } = {
25
+ // [CLUSTER_LOCAL]: () => "http://localhost:8899", // http://127.0.0.1:8899",
26
+ // [Cluster.Devnet]: () => "https://api.devnet.solana.com",
27
+ // [Cluster.Mainnet]: () => "https://api.mainnet-beta.solana.com",
28
+ // };
29
+ // beforeAll(async () => {
30
+ // streamInstance = new StreamClient(
31
+ // clusterUrls[Cluster.Devnet](),
32
+ // Cluster.Devnet,
33
+ // {
34
+ // commitment: "confirmed",
35
+ // disableRetryOnRateLimit: true,
36
+ // }
37
+ // );
38
+ // connection = new web3.Connection(web3.clusterApiUrl(), "confirmed");
39
+ //
40
+ // sender = new Wallet(web3.Keypair.generate());
41
+ // recipient = new Wallet(web3.Keypair.generate());
42
+ // recipients = [...new Array(10)].map(
43
+ // () => new Wallet(web3.Keypair.generate())
44
+ // );
45
+ // await requestAirdrop(sender, connection);
46
+ // }, 100000);
47
+ //
48
+ // test("Sender wallet airdropped funds", async () => {
49
+ // expect(await connection?.getBalance(sender.publicKey)).toBeGreaterThan(0);
50
+ // }, 100000);
51
+ //
52
+ // test("Stream client connects to cluster", async () => {
53
+ // expect(streamInstance).toBeTruthy();
54
+ // const streamInstanceConnection = await streamInstance?.getConnection();
55
+ // expect(streamInstanceConnection).toBeTruthy();
56
+ // });
57
+ //
58
+ // const newCreateMultipleStreamsPayload = (
59
+ // values: CreateMultipleStreamsValues,
60
+ // sender: Wallet
61
+ // ) => {
62
+ // const {
63
+ // recipients,
64
+ // releaseAmount,
65
+ // startDate,
66
+ // startTime,
67
+ // releaseFrequencyCounter,
68
+ // releaseFrequencyPeriod,
69
+ // whoCanTransfer,
70
+ // whoCanCancel,
71
+ // referral,
72
+ // } = values;
73
+ //
74
+ // const start = getUnixTime(new Date(startDate + "T" + startTime));
75
+ //
76
+ // const recipientsFormatted = recipients.map(
77
+ // ({ depositedAmount, recipient, name }) => ({
78
+ // recipient,
79
+ // name,
80
+ // depositedAmount: getBN(depositedAmount, 9),
81
+ // amountPerPeriod: getBN(releaseAmount, 9),
82
+ // cliffAmount: new BN(0),
83
+ // })
84
+ // );
85
+ // const data: CreateMultiParams = {
86
+ // sender,
87
+ // recipientsData: recipientsFormatted,
88
+ // mint: AIRDROP_TEST_TOKEN,
89
+ // start,
90
+ // period: releaseFrequencyCounter * releaseFrequencyPeriod,
91
+ // cliff: start,
92
+ // cancelableBySender:
93
+ // whoCanCancel === TransferCancelOptions.Sender ||
94
+ // whoCanCancel === TransferCancelOptions.Both,
95
+ // cancelableByRecipient:
96
+ // whoCanCancel === TransferCancelOptions.Recipient ||
97
+ // whoCanCancel === TransferCancelOptions.Both,
98
+ // transferableBySender:
99
+ // whoCanTransfer === TransferCancelOptions.Sender ||
100
+ // whoCanTransfer === TransferCancelOptions.Both,
101
+ // transferableByRecipient:
102
+ // whoCanTransfer === TransferCancelOptions.Recipient ||
103
+ // whoCanTransfer === TransferCancelOptions.Both,
104
+ // automaticWithdrawal: false,
105
+ // withdrawalFrequency: 0,
106
+ // canTopup: true,
107
+ // partner: referral,
108
+ // };
109
+ //
110
+ // return data;
111
+ // };
112
+ //
113
+ // export const DATE_FORMAT = "yyyy-MM-dd";
114
+ // export const TIME_FORMAT = "HH:mm";
115
+ //
116
+ // export const PERIOD = {
117
+ // SECOND: 1,
118
+ // MINUTE: 60,
119
+ // HOUR: 3600,
120
+ // DAY: 24 * 3600,
121
+ // WEEK: 7 * 24 * 3600,
122
+ // MONTH: Math.floor(30.4167 * 24 * 3600), //30.4167 days
123
+ // YEAR: 365 * 24 * 3600, // 365 days
124
+ // };
125
+ //
126
+ // export const timePeriodOptions = [
127
+ // { value: PERIOD.SECOND, label: "second" },
128
+ // { value: PERIOD.MINUTE, label: "minute" },
129
+ // { value: PERIOD.HOUR, label: "hour" },
130
+ // { value: PERIOD.DAY, label: "day" },
131
+ // { value: PERIOD.WEEK, label: "week" },
132
+ // { value: PERIOD.MONTH, label: "month" },
133
+ // { value: PERIOD.YEAR, label: "year" },
134
+ // ];
135
+ //
136
+ // test("Can create multiple stremas", async () => {
137
+ // const now = new Date();
138
+ // const recipientsPayload = recipients.map((recipient, i) => ({
139
+ // recipient: recipient.publicKey.toBase58(),
140
+ // recipientEmail: "",
141
+ // name: "Recipient " + i,
142
+ // depositedAmount: 0.0001,
143
+ // }));
144
+ //
145
+ // const values: CreateMultipleStreamsValues = {
146
+ // releaseAmount: 0.00001,
147
+ // tokenSymbol: "",
148
+ // startDate: format(now, DATE_FORMAT),
149
+ // startTime: format(add(now, { minutes: 5 }), TIME_FORMAT),
150
+ // releaseFrequencyCounter: 1,
151
+ // releaseFrequencyPeriod: timePeriodOptions[0].value,
152
+ // whoCanTransfer: TransferCancelOptions.Recipient,
153
+ // whoCanCancel: TransferCancelOptions.Sender,
154
+ // automaticWithdrawal: false,
155
+ // withdrawalFrequencyCounter: 1,
156
+ // withdrawalFrequencyPeriod: timePeriodOptions[1].value,
157
+ // referral: "",
158
+ // email: "",
159
+ // recipients: recipientsPayload,
160
+ // };
161
+ // const data = newCreateMultipleStreamsPayload(values, sender);
162
+ // const response = await streamInstance?.createMultiple(data);
163
+ // const errors = response?.errors;
164
+ // console.log(errors);
165
+ // return response;
166
+ // }, 600000);
@@ -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");
@@ -94,6 +94,57 @@ var createStreamInstruction = function (data, programId, accounts) {
94
94
  });
95
95
  };
96
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;
97
148
  var withdrawStreamInstruction = function (amount, programId, _a) {
98
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;
99
150
  var 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.8",
3
+ "version": "3.0.11",
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/",
@@ -12,7 +12,11 @@
12
12
  "gitHead": "a37306eba0e762af096db642fa22f07194014cfd",
13
13
  "devDependencies": {
14
14
  "@types/bn.js": "^5.1.0",
15
+ "@types/jest": "^28.1.4",
16
+ "@types/mocha": "^9.1.1",
15
17
  "date-fns": "^2.28.0",
18
+ "jest": "^28.1.2",
19
+ "mocha": "^10.0.0",
16
20
  "typescript": "^4.6.4"
17
21
  },
18
22
  "dependencies": {