@streamflow/stream 3.0.18 → 3.0.19

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.
Files changed (52) hide show
  1. package/dist/Stream.d.ts +87 -0
  2. package/dist/Stream.js +503 -0
  3. package/dist/StreamClient.d.ts +146 -0
  4. package/dist/{solana/StreamClient.js → StreamClient.js} +397 -301
  5. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.d.ts +3 -0
  6. package/dist/__tests__/test_dependencies/airdrop/airdrop-request.js +67 -0
  7. package/dist/__tests__/test_dependencies/airdrop/airdrop.d.ts +6 -0
  8. package/dist/__tests__/test_dependencies/airdrop/airdrop.js +215 -0
  9. package/dist/__tests__/test_dependencies/constants/index.d.ts +122 -0
  10. package/dist/__tests__/test_dependencies/constants/index.js +158 -0
  11. package/dist/__tests__/test_dependencies/idl/airdrop.d.ts +27 -0
  12. package/dist/__tests__/test_dependencies/idl/airdrop.js +171 -0
  13. package/dist/{solana/constants.d.ts → constants.d.ts} +1 -1
  14. package/dist/{solana/constants.js → constants.js} +5 -5
  15. package/dist/{solana/timelockIDL.d.ts → idl/timelock.d.ts} +0 -0
  16. package/dist/{solana/timelockIDL.js → idl/timelock.js} +0 -0
  17. package/dist/index.d.ts +6 -5
  18. package/dist/index.js +10 -19
  19. package/dist/{solana/instructions.d.ts → instructions.d.ts} +2 -8
  20. package/dist/{solana/instructions.js → instructions.js} +38 -55
  21. package/dist/layout.d.ts +22 -0
  22. package/dist/{solana/layout.js → layout.js} +3 -65
  23. package/dist/{solana/types.d.ts → types.d.ts} +34 -37
  24. package/dist/{solana/types.js → types.js} +20 -3
  25. package/dist/{common/utils.d.ts → utils.d.ts} +4 -0
  26. package/dist/utils.js +126 -0
  27. package/package.json +1 -1
  28. package/dist/__tests__/aptos/streamClient.spec.d.ts +0 -1
  29. package/dist/__tests__/aptos/streamClient.spec.js +0 -160
  30. package/dist/aptos/StreamClient.d.ts +0 -49
  31. package/dist/aptos/StreamClient.js +0 -362
  32. package/dist/aptos/constants.d.ts +0 -2
  33. package/dist/aptos/constants.js +0 -12
  34. package/dist/aptos/index.d.ts +0 -2
  35. package/dist/aptos/index.js +0 -24
  36. package/dist/aptos/types.d.ts +0 -145
  37. package/dist/aptos/types.js +0 -65
  38. package/dist/common/BaseStreamClient.d.ts +0 -11
  39. package/dist/common/BaseStreamClient.js +0 -9
  40. package/dist/common/GenericStreamClient.d.ts +0 -60
  41. package/dist/common/GenericStreamClient.js +0 -137
  42. package/dist/common/types.d.ts +0 -71
  43. package/dist/common/types.js +0 -28
  44. package/dist/common/utils.js +0 -31
  45. package/dist/solana/StreamClient.d.ts +0 -71
  46. package/dist/solana/index.d.ts +0 -7
  47. package/dist/solana/index.js +0 -43
  48. package/dist/solana/instructionTypes.d.ts +0 -86
  49. package/dist/solana/instructionTypes.js +0 -2
  50. package/dist/solana/layout.d.ts +0 -27
  51. package/dist/solana/utils.d.ts +0 -42
  52. package/dist/solana/utils.js +0 -271
@@ -1,20 +1,5 @@
1
1
  "use strict";
2
2
  // Latest version of the SDK that does not use Anchor. It supports raw instructions.
3
- var __extends = (this && this.__extends) || (function () {
4
- var extendStatics = function (d, b) {
5
- extendStatics = Object.setPrototypeOf ||
6
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
- return extendStatics(d, b);
9
- };
10
- return function (d, b) {
11
- if (typeof b !== "function" && b !== null)
12
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13
- extendStatics(d, b);
14
- function __() { this.constructor = d; }
15
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
- };
17
- })();
18
3
  var __assign = (this && this.__assign) || function () {
19
4
  __assign = Object.assign || function(t) {
20
5
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -104,84 +89,101 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
104
89
  Object.defineProperty(exports, "__esModule", { value: true });
105
90
  var bn_js_1 = __importDefault(require("bn.js"));
106
91
  var buffer_1 = require("buffer");
107
- var bs58_1 = __importDefault(require("bs58"));
92
+ var anchor_1 = require("@project-serum/anchor");
108
93
  var spl_token_1 = require("@solana/spl-token");
109
94
  var web3_js_1 = require("@solana/web3.js");
110
95
  var types_1 = require("./types");
111
96
  var utils_1 = require("./utils");
112
97
  var constants_1 = require("./constants");
113
98
  var instructions_1 = require("./instructions");
114
- var types_2 = require("../common/types");
115
- var BaseStreamClient_1 = require("../common/BaseStreamClient");
99
+ var bs58_1 = require("@project-serum/anchor/dist/cjs/utils/bytes/bs58");
116
100
  var METADATA_ACC_SIZE = 1104;
117
- var SolanaStreamClient = /** @class */ (function (_super) {
118
- __extends(SolanaStreamClient, _super);
101
+ var StreamClient = /** @class */ (function () {
119
102
  /**
120
103
  * Create Stream instance
121
104
  */
122
- function SolanaStreamClient(clusterUrl, cluster, commitment, programId) {
123
- if (cluster === void 0) { cluster = types_2.ICluster.Mainnet; }
105
+ function StreamClient(clusterUrl, cluster, commitment, programId) {
106
+ if (cluster === void 0) { cluster = types_1.Cluster.Mainnet; }
124
107
  if (commitment === void 0) { commitment = "confirmed"; }
125
108
  if (programId === void 0) { programId = ""; }
126
- var _this = _super.call(this) || this;
127
- _this.commitment = commitment;
128
- _this.connection = new web3_js_1.Connection(clusterUrl, _this.commitment);
129
- _this.programId =
130
- programId !== "" ? new web3_js_1.PublicKey(programId) : new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]);
131
- return _this;
109
+ this.commitment = commitment;
110
+ this.cluster = cluster;
111
+ this.connection = new web3_js_1.Connection(clusterUrl, this.commitment);
112
+ this.programId = new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]);
113
+ if (programId != "") {
114
+ this.programId = new web3_js_1.PublicKey(programId);
115
+ }
132
116
  }
133
- SolanaStreamClient.prototype.getConnection = function () {
117
+ StreamClient.prototype.getConnection = function () {
134
118
  return this.connection;
135
119
  };
136
- SolanaStreamClient.prototype.getProgramId = function () {
120
+ StreamClient.prototype.getProgramId = function () {
137
121
  return this.programId.toBase58();
138
122
  };
139
123
  /**
140
124
  * Creates a new stream/vesting contract.
141
125
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
126
+ * @param {CreateParams} data
127
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
128
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
129
+ * @param {string} data.mint - SPL Token mint.
130
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
131
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
132
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
133
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
134
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
135
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
136
+ * @param {string} data.name - Stream name/subject.
137
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
138
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
139
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
140
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
141
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
142
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
143
+ * @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.
144
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
145
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
142
146
  */
143
- SolanaStreamClient.prototype.create = function (_a, _b) {
144
- var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, 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, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d;
145
- var sender = _b.sender, _e = _b.partner, partner = _e === void 0 ? null : _e, _f = _b.isNative, isNative = _f === void 0 ? false : _f;
147
+ StreamClient.prototype.create = function (_a) {
148
+ 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, _e = _a.isNative, isNative = _e === void 0 ? false : _e;
146
149
  return __awaiter(this, void 0, void 0, function () {
147
- var ixs, mintPublicKey, recipientPublicKey, metadata, _g, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, nativeInstructions, _h, commitment, hash, tx, signature;
148
- var _j;
149
- return __generator(this, function (_k) {
150
- switch (_k.label) {
150
+ var ixs, mintPublicKey, recipientPublicKey, metadata, _f, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, nativeInstructions, _g, commitment, hash, tx, signature;
151
+ var _h;
152
+ return __generator(this, function (_j) {
153
+ switch (_j.label) {
151
154
  case 0:
152
- if (!sender.publicKey) {
153
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
154
- }
155
155
  ixs = [];
156
156
  mintPublicKey = isNative ? spl_token_1.NATIVE_MINT : new web3_js_1.PublicKey(mint);
157
157
  recipientPublicKey = new web3_js_1.PublicKey(recipient);
158
158
  metadata = web3_js_1.Keypair.generate();
159
159
  return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
160
160
  case 1:
161
- _g = __read.apply(void 0, [_k.sent(), 1]), escrowTokens = _g[0];
162
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
161
+ _f = __read.apply(void 0, [_j.sent(), 1]), escrowTokens = _f[0];
162
+ return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
163
163
  case 2:
164
- senderTokens = _k.sent();
165
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, recipientPublicKey)];
164
+ senderTokens = _j.sent();
165
+ return [4 /*yield*/, ata(mintPublicKey, recipientPublicKey)];
166
166
  case 3:
167
- recipientTokens = _k.sent();
168
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
167
+ recipientTokens = _j.sent();
168
+ return [4 /*yield*/, ata(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
169
169
  case 4:
170
- streamflowTreasuryTokens = _k.sent();
171
- partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
172
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, partnerPublicKey)];
170
+ streamflowTreasuryTokens = _j.sent();
171
+ partnerPublicKey = partner
172
+ ? new web3_js_1.PublicKey(partner)
173
+ : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
174
+ return [4 /*yield*/, ata(mintPublicKey, partnerPublicKey)];
173
175
  case 5:
174
- partnerTokens = _k.sent();
176
+ partnerTokens = _j.sent();
175
177
  if (!isNative) return [3 /*break*/, 7];
176
178
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, depositedAmount)];
177
179
  case 6:
178
- _h = _k.sent();
180
+ _g = _j.sent();
179
181
  return [3 /*break*/, 8];
180
182
  case 7:
181
- _h = [];
182
- _k.label = 8;
183
+ _g = [];
184
+ _j.label = 8;
183
185
  case 8:
184
- nativeInstructions = _h;
186
+ nativeInstructions = _g;
185
187
  ixs.push((0, instructions_1.createStreamInstruction)({
186
188
  start: new bn_js_1.default(start),
187
189
  depositedAmount: depositedAmount,
@@ -217,19 +219,21 @@ var SolanaStreamClient = /** @class */ (function (_super) {
217
219
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
218
220
  systemProgram: web3_js_1.SystemProgram.programId,
219
221
  }));
220
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
222
+ commitment = typeof this.commitment == "string"
223
+ ? this.commitment
224
+ : this.commitment.commitment;
221
225
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
222
226
  case 9:
223
- hash = _k.sent();
224
- tx = (_j = new web3_js_1.Transaction({
227
+ hash = _j.sent();
228
+ tx = (_h = new web3_js_1.Transaction({
225
229
  feePayer: sender.publicKey,
226
230
  blockhash: hash.blockhash,
227
231
  lastValidBlockHeight: hash.lastValidBlockHeight,
228
- })).add.apply(_j, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
232
+ })).add.apply(_h, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
229
233
  tx.partialSign(metadata);
230
234
  return [4 /*yield*/, this.sign(sender, tx, hash)];
231
235
  case 10:
232
- signature = _k.sent();
236
+ signature = _j.sent();
233
237
  return [2 /*return*/, { ixs: ixs, tx: signature, metadata: metadata }];
234
238
  }
235
239
  });
@@ -244,25 +248,42 @@ var SolanaStreamClient = /** @class */ (function (_super) {
244
248
  * - initialized contract PDA off chain
245
249
  *
246
250
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
251
+ *
252
+ * @param {CreateParams} data
253
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
254
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
255
+ * @param {string} data.mint - SPL Token mint.
256
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
257
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
258
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
259
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
260
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
261
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
262
+ * @param {string} data.name - Stream name/subject.
263
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
264
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
265
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
266
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
267
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
268
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
269
+ * @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.
270
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
271
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
247
272
  */
248
- SolanaStreamClient.prototype.createUnchecked = function (_a, _b) {
249
- var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, 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, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d;
250
- var sender = _b.sender, _e = _b.partner, partner = _e === void 0 ? null : _e, _f = _b.isNative, isNative = _f === void 0 ? false : _f;
273
+ StreamClient.prototype.createUnchecked = function (_a) {
274
+ 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, _e = _a.isNative, isNative = _e === void 0 ? false : _e;
251
275
  return __awaiter(this, void 0, void 0, function () {
252
- var mintPublicKey, recipientPublicKey, metadata, rentToExempt, createMetadataInstruction, _g, escrowTokens, senderTokens, partnerPublicKey, nativeInstructions, _h, createInstruction, commitment, ixs, hash, tx, signature;
253
- var _j;
254
- return __generator(this, function (_k) {
255
- switch (_k.label) {
276
+ var mintPublicKey, recipientPublicKey, metadata, rentToExempt, createMetadataInstruction, _f, escrowTokens, senderTokens, partnerPublicKey, nativeInstructions, _g, createInstruction, commitment, ixs, hash, tx, signature;
277
+ var _h;
278
+ return __generator(this, function (_j) {
279
+ switch (_j.label) {
256
280
  case 0:
257
- if (!sender.publicKey) {
258
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
259
- }
260
281
  mintPublicKey = new web3_js_1.PublicKey(mint);
261
282
  recipientPublicKey = new web3_js_1.PublicKey(recipient);
262
283
  metadata = web3_js_1.Keypair.generate();
263
284
  return [4 /*yield*/, this.connection.getMinimumBalanceForRentExemption(METADATA_ACC_SIZE)];
264
285
  case 1:
265
- rentToExempt = _k.sent();
286
+ rentToExempt = _j.sent();
266
287
  createMetadataInstruction = web3_js_1.SystemProgram.createAccount({
267
288
  programId: this.programId,
268
289
  space: METADATA_ACC_SIZE,
@@ -272,21 +293,23 @@ var SolanaStreamClient = /** @class */ (function (_super) {
272
293
  });
273
294
  return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
274
295
  case 2:
275
- _g = __read.apply(void 0, [_k.sent(), 1]), escrowTokens = _g[0];
276
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
296
+ _f = __read.apply(void 0, [_j.sent(), 1]), escrowTokens = _f[0];
297
+ return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
277
298
  case 3:
278
- senderTokens = _k.sent();
279
- partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
299
+ senderTokens = _j.sent();
300
+ partnerPublicKey = partner
301
+ ? new web3_js_1.PublicKey(partner)
302
+ : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
280
303
  if (!isNative) return [3 /*break*/, 5];
281
304
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, depositedAmount)];
282
305
  case 4:
283
- _h = _k.sent();
306
+ _g = _j.sent();
284
307
  return [3 /*break*/, 6];
285
308
  case 5:
286
- _h = [];
287
- _k.label = 6;
309
+ _g = [];
310
+ _j.label = 6;
288
311
  case 6:
289
- nativeInstructions = _h;
312
+ nativeInstructions = _g;
290
313
  createInstruction = (0, instructions_1.createUncheckedStreamInstruction)({
291
314
  start: new bn_js_1.default(start),
292
315
  depositedAmount: depositedAmount,
@@ -317,118 +340,136 @@ var SolanaStreamClient = /** @class */ (function (_super) {
317
340
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
318
341
  systemProgram: web3_js_1.SystemProgram.programId,
319
342
  });
320
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
321
- ixs = [createMetadataInstruction, createInstruction];
343
+ commitment = typeof this.commitment == "string"
344
+ ? this.commitment
345
+ : this.commitment.commitment;
346
+ ixs = [
347
+ createMetadataInstruction,
348
+ createInstruction,
349
+ ];
322
350
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
323
351
  case 7:
324
- hash = _k.sent();
325
- tx = (_j = new web3_js_1.Transaction({
352
+ hash = _j.sent();
353
+ tx = (_h = new web3_js_1.Transaction({
326
354
  feePayer: sender.publicKey,
327
355
  blockhash: hash.blockhash,
328
356
  lastValidBlockHeight: hash.lastValidBlockHeight,
329
- })).add.apply(_j, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
357
+ })).add.apply(_h, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
330
358
  tx.partialSign(metadata);
331
359
  return [4 /*yield*/, this.sign(sender, tx, hash)];
332
360
  case 8:
333
- signature = _k.sent();
361
+ signature = _j.sent();
334
362
  return [2 /*return*/, { ixs: ixs, tx: signature, metadata: metadata }];
335
363
  }
336
364
  });
337
365
  });
338
366
  };
339
367
  /**
340
- * Creates multiple stream/vesting contracts.
368
+ * Creates a new stream/vesting contract.
341
369
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
370
+ * @param {CreateMultiParams} data
371
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
372
+ * @param {MultiRecipient[]} data.recipientsData
373
+ * @param {string} data.mint - SPL Token mint.
374
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
375
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
376
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
377
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
378
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
379
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
380
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
381
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
382
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
383
+ * @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.
384
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
385
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
342
386
  */
343
- SolanaStreamClient.prototype.createMultiple = function (data, _a) {
344
- var sender = _a.sender, _b = _a.partner, partner = _b === void 0 ? null : _b, _c = _a.isNative, isNative = _c === void 0 ? false : _c;
387
+ StreamClient.prototype.createMultiple = function (data) {
345
388
  return __awaiter(this, void 0, void 0, function () {
346
- var recipients, metadatas, metadataToRecipient, errors, signatures, batch, recipients_1, recipients_1_1, recipientData, _d, tx, metadata, metadataPubKey, e_1_1, totalDepositedAmount, nativeInstructions, commitment, hash, prepareTransaction, signedBatch, prepareTx, batchTransactionsCalls, responses, successes, failures;
347
- var e_1, _e, _f;
389
+ var sender, recipientsData, metadatas, metadataToRecipient, errors, signatures, batch, recipientsData_1, recipientsData_1_1, recipientData, _a, tx, metadata, metadataPubKey, e_1_1, totalDepositedAmount, nativeInstructions, commitment, hash, prepareTransaction, signed_batch, prepareTx, batchTransactionsCalls, responses, successes, failures;
390
+ var e_1, _b, _c;
348
391
  var _this = this;
349
- return __generator(this, function (_g) {
350
- switch (_g.label) {
392
+ return __generator(this, function (_d) {
393
+ switch (_d.label) {
351
394
  case 0:
352
- recipients = data.recipients;
353
- if (!sender.publicKey) {
354
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
355
- }
395
+ sender = data.sender, recipientsData = data.recipientsData;
356
396
  metadatas = [];
357
397
  metadataToRecipient = {};
358
398
  errors = [];
359
399
  signatures = [];
360
400
  batch = [];
361
- _g.label = 1;
401
+ _d.label = 1;
362
402
  case 1:
363
- _g.trys.push([1, 6, 7, 8]);
364
- recipients_1 = __values(recipients), recipients_1_1 = recipients_1.next();
365
- _g.label = 2;
403
+ _d.trys.push([1, 6, 7, 8]);
404
+ recipientsData_1 = __values(recipientsData), recipientsData_1_1 = recipientsData_1.next();
405
+ _d.label = 2;
366
406
  case 2:
367
- if (!!recipients_1_1.done) return [3 /*break*/, 5];
368
- recipientData = recipients_1_1.value;
369
- return [4 /*yield*/, this.prepareStreamTransaction(recipientData, data, {
370
- sender: sender,
371
- partner: partner,
372
- })];
407
+ if (!!recipientsData_1_1.done) return [3 /*break*/, 5];
408
+ recipientData = recipientsData_1_1.value;
409
+ return [4 /*yield*/, this.prepareStreamTransaction(recipientData, data)];
373
410
  case 3:
374
- _d = _g.sent(), tx = _d.tx, metadata = _d.metadata;
411
+ _a = _d.sent(), tx = _a.tx, metadata = _a.metadata;
375
412
  metadataPubKey = metadata.publicKey.toBase58();
376
413
  metadataToRecipient[metadataPubKey] = recipientData;
377
414
  metadatas.push(metadata);
378
415
  batch.push({ tx: tx, recipient: recipientData.recipient });
379
- _g.label = 4;
416
+ _d.label = 4;
380
417
  case 4:
381
- recipients_1_1 = recipients_1.next();
418
+ recipientsData_1_1 = recipientsData_1.next();
382
419
  return [3 /*break*/, 2];
383
420
  case 5: return [3 /*break*/, 8];
384
421
  case 6:
385
- e_1_1 = _g.sent();
422
+ e_1_1 = _d.sent();
386
423
  e_1 = { error: e_1_1 };
387
424
  return [3 /*break*/, 8];
388
425
  case 7:
389
426
  try {
390
- if (recipients_1_1 && !recipients_1_1.done && (_e = recipients_1.return)) _e.call(recipients_1);
427
+ if (recipientsData_1_1 && !recipientsData_1_1.done && (_b = recipientsData_1.return)) _b.call(recipientsData_1);
391
428
  }
392
429
  finally { if (e_1) throw e_1.error; }
393
430
  return [7 /*endfinally*/];
394
431
  case 8:
395
- if (!isNative) return [3 /*break*/, 11];
396
- totalDepositedAmount = recipients.reduce(function (acc, recipient) { return recipient.amount.add(acc); }, new bn_js_1.default(0));
432
+ if (!data.isNative) return [3 /*break*/, 11];
433
+ totalDepositedAmount = recipientsData.reduce(function (acc, recipient) { return recipient.depositedAmount.add(acc); }, new bn_js_1.default(0));
397
434
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalDepositedAmount)];
398
435
  case 9:
399
- nativeInstructions = _g.sent();
400
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
436
+ nativeInstructions = _d.sent();
437
+ commitment = typeof this.commitment == "string"
438
+ ? this.commitment
439
+ : this.commitment.commitment;
401
440
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
402
441
  case 10:
403
- hash = _g.sent();
404
- prepareTransaction = (_f = new web3_js_1.Transaction({
442
+ hash = _d.sent();
443
+ prepareTransaction = (_c = new web3_js_1.Transaction({
405
444
  feePayer: sender.publicKey,
406
445
  blockhash: hash.blockhash,
407
446
  lastValidBlockHeight: hash.lastValidBlockHeight,
408
- })).add.apply(_f, __spreadArray([], __read(nativeInstructions), false));
447
+ })).add.apply(_c, __spreadArray([], __read(nativeInstructions), false));
409
448
  batch.push({ tx: prepareTransaction, recipient: sender.publicKey.toBase58() });
410
- _g.label = 11;
411
- case 11: return [4 /*yield*/, (0, utils_1.signAllTransactionWithRecipients)(sender, batch)];
449
+ _d.label = 11;
450
+ case 11: return [4 /*yield*/, signAllTransactionWithRecipients(sender, batch)];
412
451
  case 12:
413
- signedBatch = _g.sent();
414
- signedBatch.forEach(function (item, index) {
452
+ signed_batch = _d.sent();
453
+ signed_batch.forEach(function (item, index) {
415
454
  item.tx.lastValidBlockHeight = batch[index].tx.lastValidBlockHeight;
416
455
  });
417
- if (!isNative) return [3 /*break*/, 14];
418
- prepareTx = signedBatch.pop();
419
- return [4 /*yield*/, (0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx)];
456
+ if (!data.isNative) return [3 /*break*/, 14];
457
+ prepareTx = signed_batch.pop();
458
+ return [4 /*yield*/, sendAndConfirmStreamRawTransaction(this.connection, prepareTx)];
420
459
  case 13:
421
- _g.sent();
422
- _g.label = 14;
460
+ _d.sent();
461
+ _d.label = 14;
423
462
  case 14:
424
- batchTransactionsCalls = signedBatch.map(function (el) {
425
- return (0, utils_1.sendAndConfirmStreamRawTransaction)(_this.connection, el);
463
+ batchTransactionsCalls = signed_batch.map(function (el) {
464
+ return sendAndConfirmStreamRawTransaction(_this.connection, el);
426
465
  });
427
466
  return [4 /*yield*/, Promise.allSettled(batchTransactionsCalls)];
428
467
  case 15:
429
- responses = _g.sent();
468
+ responses = _d.sent();
430
469
  successes = responses
431
- .filter(function (el) { return el.status === "fulfilled"; })
470
+ .filter(function (el) {
471
+ return el.status === "fulfilled";
472
+ })
432
473
  .map(function (el) { return el.value; });
433
474
  signatures.push.apply(signatures, __spreadArray([], __read(successes.map(function (el) { return el.signature; })), false));
434
475
  failures = responses
@@ -441,35 +482,35 @@ var SolanaStreamClient = /** @class */ (function (_super) {
441
482
  });
442
483
  };
443
484
  /**
444
- * Attempts withdrawing from the specified stream.
485
+ * Attempts withdrawal from the specified stream.
486
+ * @param {WithdrawParams} data
487
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
488
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
489
+ * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
445
490
  */
446
- SolanaStreamClient.prototype.withdraw = function (_a, _b) {
447
- var id = _a.id, amount = _a.amount;
448
- var invoker = _b.invoker;
491
+ StreamClient.prototype.withdraw = function (_a) {
492
+ var invoker = _a.invoker, id = _a.id, amount = _a.amount;
449
493
  return __awaiter(this, void 0, void 0, function () {
450
494
  var ixs, streamPublicKey, escrow, data, streamflowTreasuryTokens, partnerTokens, commitment, hash, tx, signature;
451
- var _c;
452
- return __generator(this, function (_d) {
453
- switch (_d.label) {
495
+ var _b;
496
+ return __generator(this, function (_c) {
497
+ switch (_c.label) {
454
498
  case 0:
455
- if (!invoker.publicKey) {
456
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
457
- }
458
499
  ixs = [];
459
500
  streamPublicKey = new web3_js_1.PublicKey(id);
460
501
  return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
461
502
  case 1:
462
- escrow = _d.sent();
503
+ escrow = _c.sent();
463
504
  if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
464
505
  throw new Error("Couldn't get account info");
465
506
  }
466
507
  data = (0, utils_1.decodeStream)(escrow.data);
467
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
508
+ return [4 /*yield*/, ata(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
468
509
  case 2:
469
- streamflowTreasuryTokens = _d.sent();
470
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, data.partner)];
510
+ streamflowTreasuryTokens = _c.sent();
511
+ return [4 /*yield*/, ata(data.mint, data.partner)];
471
512
  case 3:
472
- partnerTokens = _d.sent();
513
+ partnerTokens = _c.sent();
473
514
  ixs.push((0, instructions_1.withdrawStreamInstruction)(amount, this.programId, {
474
515
  authority: invoker.publicKey,
475
516
  recipient: invoker.publicKey,
@@ -483,18 +524,20 @@ var SolanaStreamClient = /** @class */ (function (_super) {
483
524
  mint: data.mint,
484
525
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
485
526
  }));
486
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
527
+ commitment = typeof this.commitment == "string"
528
+ ? this.commitment
529
+ : this.commitment.commitment;
487
530
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
488
531
  case 4:
489
- hash = _d.sent();
490
- tx = (_c = new web3_js_1.Transaction({
532
+ hash = _c.sent();
533
+ tx = (_b = new web3_js_1.Transaction({
491
534
  feePayer: invoker.publicKey,
492
535
  blockhash: hash.blockhash,
493
536
  lastValidBlockHeight: hash.lastValidBlockHeight,
494
- })).add.apply(_c, __spreadArray([], __read(ixs), false));
537
+ })).add.apply(_b, __spreadArray([], __read(ixs), false));
495
538
  return [4 /*yield*/, this.sign(invoker, tx, hash)];
496
539
  case 5:
497
- signature = _d.sent();
540
+ signature = _c.sent();
498
541
  return [2 /*return*/, { ixs: ixs, tx: signature }];
499
542
  }
500
543
  });
@@ -502,33 +545,32 @@ var SolanaStreamClient = /** @class */ (function (_super) {
502
545
  };
503
546
  /**
504
547
  * Attempts canceling the specified stream.
548
+ * @param {CancelParams} data
549
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
550
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
505
551
  */
506
- SolanaStreamClient.prototype.cancel = function (_a, _b) {
507
- var id = _a.id;
508
- var invoker = _b.invoker;
552
+ StreamClient.prototype.cancel = function (_a) {
553
+ var invoker = _a.invoker, id = _a.id;
509
554
  return __awaiter(this, void 0, void 0, function () {
510
555
  var streamPublicKey, escrow_acc, data, streamflowTreasuryTokens, partnerTokens, ixs, commitment, hash, tx, signature;
511
- var _c;
512
- return __generator(this, function (_d) {
513
- switch (_d.label) {
556
+ var _b;
557
+ return __generator(this, function (_c) {
558
+ switch (_c.label) {
514
559
  case 0:
515
- if (!invoker.publicKey) {
516
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
517
- }
518
560
  streamPublicKey = new web3_js_1.PublicKey(id);
519
561
  return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
520
562
  case 1:
521
- escrow_acc = _d.sent();
563
+ escrow_acc = _c.sent();
522
564
  if (!(escrow_acc === null || escrow_acc === void 0 ? void 0 : escrow_acc.data)) {
523
565
  throw new Error("Couldn't get account info");
524
566
  }
525
567
  data = (0, utils_1.decodeStream)(escrow_acc === null || escrow_acc === void 0 ? void 0 : escrow_acc.data);
526
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
568
+ return [4 /*yield*/, ata(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
527
569
  case 2:
528
- streamflowTreasuryTokens = _d.sent();
529
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, data.partner)];
570
+ streamflowTreasuryTokens = _c.sent();
571
+ return [4 /*yield*/, ata(data.mint, data.partner)];
530
572
  case 3:
531
- partnerTokens = _d.sent();
573
+ partnerTokens = _c.sent();
532
574
  ixs = [];
533
575
  ixs.push((0, instructions_1.cancelStreamInstruction)(this.programId, {
534
576
  authority: invoker.publicKey,
@@ -545,18 +587,20 @@ var SolanaStreamClient = /** @class */ (function (_super) {
545
587
  mint: data.mint,
546
588
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
547
589
  }));
548
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
590
+ commitment = typeof this.commitment == "string"
591
+ ? this.commitment
592
+ : this.commitment.commitment;
549
593
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
550
594
  case 4:
551
- hash = _d.sent();
552
- tx = (_c = new web3_js_1.Transaction({
595
+ hash = _c.sent();
596
+ tx = (_b = new web3_js_1.Transaction({
553
597
  feePayer: invoker.publicKey,
554
598
  blockhash: hash.blockhash,
555
599
  lastValidBlockHeight: hash.lastValidBlockHeight,
556
- })).add.apply(_c, __spreadArray([], __read(ixs), false));
600
+ })).add.apply(_b, __spreadArray([], __read(ixs), false));
557
601
  return [4 /*yield*/, this.sign(invoker, tx, hash)];
558
602
  case 5:
559
- signature = _d.sent();
603
+ signature = _c.sent();
560
604
  return [2 /*return*/, { ixs: ixs, tx: signature }];
561
605
  }
562
606
  });
@@ -565,32 +609,32 @@ var SolanaStreamClient = /** @class */ (function (_super) {
565
609
  /**
566
610
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
567
611
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
612
+ * @param {TransferParams} data
613
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
614
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
615
+ * @param {string} data.recipientId - Address of a new recipient.
568
616
  */
569
- SolanaStreamClient.prototype.transfer = function (_a, _b) {
570
- var id = _a.id, newRecipientString = _a.newRecipient;
571
- var invoker = _b.invoker;
617
+ StreamClient.prototype.transfer = function (_a) {
618
+ var invoker = _a.invoker, id = _a.id, recipientId = _a.recipientId;
572
619
  return __awaiter(this, void 0, void 0, function () {
573
620
  var ixs, stream, newRecipient, escrow, mint, newRecipientTokens, commitment, hash, tx, signature;
574
- var _c;
575
- return __generator(this, function (_d) {
576
- switch (_d.label) {
621
+ var _b;
622
+ return __generator(this, function (_c) {
623
+ switch (_c.label) {
577
624
  case 0:
578
- if (!invoker.publicKey) {
579
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
580
- }
581
625
  ixs = [];
582
626
  stream = new web3_js_1.PublicKey(id);
583
- newRecipient = new web3_js_1.PublicKey(newRecipientString);
627
+ newRecipient = new web3_js_1.PublicKey(recipientId);
584
628
  return [4 /*yield*/, this.connection.getAccountInfo(stream)];
585
629
  case 1:
586
- escrow = _d.sent();
630
+ escrow = _c.sent();
587
631
  if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
588
632
  throw new Error("Couldn't get account info");
589
633
  }
590
634
  mint = (0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data).mint;
591
- return [4 /*yield*/, (0, utils_1.ata)(mint, newRecipient)];
635
+ return [4 /*yield*/, ata(mint, newRecipient)];
592
636
  case 2:
593
- newRecipientTokens = _d.sent();
637
+ newRecipientTokens = _c.sent();
594
638
  ixs.push((0, instructions_1.transferStreamInstruction)(this.programId, {
595
639
  authority: invoker.publicKey,
596
640
  newRecipient: newRecipient,
@@ -602,63 +646,65 @@ var SolanaStreamClient = /** @class */ (function (_super) {
602
646
  associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
603
647
  systemProgram: web3_js_1.SystemProgram.programId,
604
648
  }));
605
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
649
+ commitment = typeof this.commitment == "string"
650
+ ? this.commitment
651
+ : this.commitment.commitment;
606
652
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
607
653
  case 3:
608
- hash = _d.sent();
609
- tx = (_c = new web3_js_1.Transaction({
654
+ hash = _c.sent();
655
+ tx = (_b = new web3_js_1.Transaction({
610
656
  feePayer: invoker.publicKey,
611
657
  blockhash: hash.blockhash,
612
658
  lastValidBlockHeight: hash.lastValidBlockHeight,
613
- })).add.apply(_c, __spreadArray([], __read(ixs), false));
659
+ })).add.apply(_b, __spreadArray([], __read(ixs), false));
614
660
  return [4 /*yield*/, this.sign(invoker, tx, hash)];
615
661
  case 4:
616
- signature = _d.sent();
662
+ signature = _c.sent();
617
663
  return [2 /*return*/, { ixs: ixs, tx: signature }];
618
664
  }
619
665
  });
620
666
  });
621
667
  };
622
668
  /**
623
- * Tops up stream account with specified amount.
669
+ * Tops up stream account deposited amount.
670
+ * @param {TopupParams} data
671
+ * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
672
+ * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
673
+ * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
624
674
  */
625
- SolanaStreamClient.prototype.topup = function (_a, _b) {
626
- var id = _a.id, amount = _a.amount;
627
- var invoker = _b.invoker, isNative = _b.isNative;
675
+ StreamClient.prototype.topup = function (_a) {
676
+ var invoker = _a.invoker, id = _a.id, amount = _a.amount, isNative = _a.isNative;
628
677
  return __awaiter(this, void 0, void 0, function () {
629
- var ixs, streamPublicKey, escrow, _c, mint, partner, senderTokens, escrowTokens, streamflowTreasuryTokens, partnerTokens, nativeInstructions, _d, commitment, hash, tx, signature;
630
- var _e;
631
- return __generator(this, function (_f) {
632
- switch (_f.label) {
678
+ var ixs, streamPublicKey, escrow, _b, mint, partner, senderTokens, escrowTokens, streamflowTreasuryTokens, partnerTokens, nativeInstructions, _c, commitment, hash, tx, signature;
679
+ var _d;
680
+ return __generator(this, function (_e) {
681
+ switch (_e.label) {
633
682
  case 0:
634
- if (!invoker.publicKey) {
635
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
636
- }
637
683
  ixs = [];
638
684
  streamPublicKey = new web3_js_1.PublicKey(id);
639
685
  return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
640
686
  case 1:
641
- escrow = _f.sent();
687
+ escrow = _e.sent();
642
688
  if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
643
689
  throw new Error("Couldn't get account info");
644
690
  }
645
- _c = (0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data), mint = _c.mint, partner = _c.partner, senderTokens = _c.senderTokens, escrowTokens = _c.escrowTokens;
646
- return [4 /*yield*/, (0, utils_1.ata)(mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
691
+ _b = (0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data), mint = _b.mint, partner = _b.partner, senderTokens = _b.senderTokens, escrowTokens = _b.escrowTokens;
692
+ return [4 /*yield*/, ata(mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
647
693
  case 2:
648
- streamflowTreasuryTokens = _f.sent();
649
- return [4 /*yield*/, (0, utils_1.ata)(mint, partner)];
694
+ streamflowTreasuryTokens = _e.sent();
695
+ return [4 /*yield*/, ata(mint, partner)];
650
696
  case 3:
651
- partnerTokens = _f.sent();
697
+ partnerTokens = _e.sent();
652
698
  if (!isNative) return [3 /*break*/, 5];
653
699
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, invoker.publicKey, amount)];
654
700
  case 4:
655
- _d = _f.sent();
701
+ _c = _e.sent();
656
702
  return [3 /*break*/, 6];
657
703
  case 5:
658
- _d = [];
659
- _f.label = 6;
704
+ _c = [];
705
+ _e.label = 6;
660
706
  case 6:
661
- nativeInstructions = _d;
707
+ nativeInstructions = _c;
662
708
  ixs.push((0, instructions_1.topupStreamInstruction)(amount, this.programId, {
663
709
  sender: invoker.publicKey,
664
710
  senderTokens: senderTokens,
@@ -673,18 +719,20 @@ var SolanaStreamClient = /** @class */ (function (_super) {
673
719
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
674
720
  systemProgram: web3_js_1.SystemProgram.programId,
675
721
  }));
676
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
722
+ commitment = typeof this.commitment == "string"
723
+ ? this.commitment
724
+ : this.commitment.commitment;
677
725
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
678
726
  case 7:
679
- hash = _f.sent();
680
- tx = (_e = new web3_js_1.Transaction({
727
+ hash = _e.sent();
728
+ tx = (_d = new web3_js_1.Transaction({
681
729
  feePayer: invoker.publicKey,
682
730
  blockhash: hash.blockhash,
683
731
  lastValidBlockHeight: hash.lastValidBlockHeight,
684
- })).add.apply(_e, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
732
+ })).add.apply(_d, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
685
733
  return [4 /*yield*/, this.sign(invoker, tx, hash)];
686
734
  case 8:
687
- signature = _f.sent();
735
+ signature = _e.sent();
688
736
  return [2 /*return*/, { ixs: ixs, tx: signature }];
689
737
  }
690
738
  });
@@ -692,16 +740,16 @@ var SolanaStreamClient = /** @class */ (function (_super) {
692
740
  };
693
741
  /**
694
742
  * Fetch stream data by its id (address).
743
+ * @param {string} id - Identifier of a stream that is fetched.
695
744
  */
696
- SolanaStreamClient.prototype.getOne = function (_a) {
697
- var id = _a.id;
745
+ StreamClient.prototype.getOne = function (id) {
698
746
  return __awaiter(this, void 0, void 0, function () {
699
747
  var escrow;
700
- return __generator(this, function (_b) {
701
- switch (_b.label) {
748
+ return __generator(this, function (_a) {
749
+ switch (_a.label) {
702
750
  case 0: return [4 /*yield*/, this.connection.getAccountInfo(new web3_js_1.PublicKey(id), constants_1.TX_FINALITY_CONFIRMED)];
703
751
  case 1:
704
- escrow = _b.sent();
752
+ escrow = _a.sent();
705
753
  if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
706
754
  throw new Error("Couldn't get account info.");
707
755
  }
@@ -713,9 +761,13 @@ var SolanaStreamClient = /** @class */ (function (_super) {
713
761
  /**
714
762
  * Fetch streams/contracts by providing direction.
715
763
  * Streams are sorted by start time in ascending order.
764
+ * @param {GetAllParams} data
765
+ * @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
766
+ * @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
767
+ * @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
716
768
  */
717
- SolanaStreamClient.prototype.get = function (_a) {
718
- var wallet = _a.wallet, _b = _a.type, type = _b === void 0 ? types_2.StreamType.All : _b, _c = _a.direction, direction = _c === void 0 ? types_2.StreamDirection.All : _c;
769
+ StreamClient.prototype.get = function (_a) {
770
+ var wallet = _a.wallet, _b = _a.type, type = _b === void 0 ? types_1.StreamType.All : _b, _c = _a.direction, direction = _c === void 0 ? types_1.StreamDirection.All : _c;
719
771
  return __awaiter(this, void 0, void 0, function () {
720
772
  var accounts, outgoingAccounts, incomingAccounts, offset, streams, sortedStreams;
721
773
  return __generator(this, function (_d) {
@@ -723,17 +775,19 @@ var SolanaStreamClient = /** @class */ (function (_super) {
723
775
  case 0:
724
776
  accounts = [];
725
777
  if (!(direction === "all")) return [3 /*break*/, 3];
726
- return [4 /*yield*/, (0, utils_1.getProgramAccounts)(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_SENDER, this.programId)];
778
+ return [4 /*yield*/, getProgramAccounts(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_SENDER, this.programId)];
727
779
  case 1:
728
780
  outgoingAccounts = _d.sent();
729
- return [4 /*yield*/, (0, utils_1.getProgramAccounts)(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_RECIPIENT, this.programId)];
781
+ return [4 /*yield*/, getProgramAccounts(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_RECIPIENT, this.programId)];
730
782
  case 2:
731
783
  incomingAccounts = _d.sent();
732
784
  accounts = __spreadArray(__spreadArray([], __read(outgoingAccounts), false), __read(incomingAccounts), false);
733
785
  return [3 /*break*/, 5];
734
786
  case 3:
735
- offset = direction === "outgoing" ? constants_1.STREAM_STRUCT_OFFSET_SENDER : constants_1.STREAM_STRUCT_OFFSET_RECIPIENT;
736
- return [4 /*yield*/, (0, utils_1.getProgramAccounts)(this.connection, wallet, offset, this.programId)];
787
+ offset = direction === "outgoing"
788
+ ? constants_1.STREAM_STRUCT_OFFSET_SENDER
789
+ : constants_1.STREAM_STRUCT_OFFSET_RECIPIENT;
790
+ return [4 /*yield*/, getProgramAccounts(this.connection, wallet, offset, this.programId)];
737
791
  case 4:
738
792
  accounts = _d.sent();
739
793
  _d.label = 5;
@@ -758,31 +812,31 @@ var SolanaStreamClient = /** @class */ (function (_super) {
758
812
  });
759
813
  });
760
814
  };
761
- SolanaStreamClient.prototype.sign = function (invoker, tx, hash) {
815
+ StreamClient.prototype.sign = function (invoker, tx, hash) {
762
816
  return __awaiter(this, void 0, void 0, function () {
763
- var signedTx, rawTx, confirmationStrategy, signature;
817
+ var signedTransaction, rawTx, confirmationStrategy, signature;
764
818
  return __generator(this, function (_a) {
765
819
  switch (_a.label) {
766
820
  case 0:
767
- if (!(0, utils_1.isSignerWallet)(invoker)) return [3 /*break*/, 2];
821
+ if (!isAnchorWallet(invoker)) return [3 /*break*/, 2];
768
822
  return [4 /*yield*/, invoker.signTransaction(tx)];
769
823
  case 1:
770
- signedTx = _a.sent();
824
+ signedTransaction = _a.sent();
771
825
  return [3 /*break*/, 3];
772
826
  case 2:
773
827
  tx.partialSign(invoker);
774
- signedTx = tx;
828
+ signedTransaction = tx;
775
829
  _a.label = 3;
776
830
  case 3:
777
- rawTx = signedTx.serialize();
778
- if (!hash.lastValidBlockHeight || !signedTx.signature || !hash.blockhash)
831
+ rawTx = signedTransaction.serialize();
832
+ if (!hash.lastValidBlockHeight || !signedTransaction.signature || !hash.blockhash)
779
833
  throw Error("Error with transaction parameters.");
780
834
  confirmationStrategy = {
781
835
  lastValidBlockHeight: hash.lastValidBlockHeight,
782
- signature: bs58_1.default.encode(signedTx.signature),
836
+ signature: (0, bs58_1.encode)(signedTransaction.signature),
783
837
  blockhash: hash.blockhash,
784
838
  };
785
- return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx, confirmationStrategy, { skipPreflight: true })];
839
+ return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(this.connection, rawTx, confirmationStrategy)];
786
840
  case 4:
787
841
  signature = _a.sent();
788
842
  return [2 /*return*/, signature];
@@ -790,89 +844,47 @@ var SolanaStreamClient = /** @class */ (function (_super) {
790
844
  });
791
845
  });
792
846
  };
793
- /**
794
- * Attempts updating the stream auto withdrawal params and amount per period
795
- */
796
- SolanaStreamClient.prototype.update = function (data, _a) {
797
- var invoker = _a.invoker;
798
- return __awaiter(this, void 0, void 0, function () {
799
- var streamPublicKey, escrow, updateIx, commitment, hash, tx, signature;
800
- return __generator(this, function (_b) {
801
- switch (_b.label) {
802
- case 0:
803
- if (!invoker.publicKey) {
804
- throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
805
- }
806
- streamPublicKey = new web3_js_1.PublicKey(data.id);
807
- return [4 /*yield*/, this.connection.getAccountInfo(streamPublicKey)];
808
- case 1:
809
- escrow = _b.sent();
810
- if (!escrow) {
811
- throw new Error("Couldn't get account info");
812
- }
813
- updateIx = (0, instructions_1.updateStreamInstruction)(data, this.programId, {
814
- authority: invoker.publicKey,
815
- metadata: streamPublicKey,
816
- withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
817
- systemProgram: web3_js_1.SystemProgram.programId,
818
- });
819
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
820
- return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
821
- case 2:
822
- hash = _b.sent();
823
- tx = new web3_js_1.Transaction({
824
- feePayer: invoker.publicKey,
825
- blockhash: hash.blockhash,
826
- lastValidBlockHeight: hash.lastValidBlockHeight,
827
- }).add(updateIx);
828
- return [4 /*yield*/, this.sign(invoker, tx, hash)];
829
- case 3:
830
- signature = _b.sent();
831
- return [2 /*return*/, {
832
- ixs: [updateIx],
833
- tx: signature,
834
- }];
835
- }
836
- });
837
- });
838
- };
839
847
  /**
840
848
  * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
849
+ * @param {MultiRecipient} recipient - Wallet sending stream to
850
+ * @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
841
851
  */
842
- SolanaStreamClient.prototype.prepareStreamTransaction = function (recipient, streamParams, solanaExtendedConfig) {
852
+ StreamClient.prototype.prepareStreamTransaction = function (recipient, streamParams) {
843
853
  return __awaiter(this, void 0, void 0, function () {
844
- var mint, start, period, cliff, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, _a, automaticWithdrawal, _b, withdrawalFrequency, sender, _c, partner, ixs, commitment, recipientPublicKey, mintPublicKey, metadata, _d, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx;
854
+ var sender, mint, start, period, cliff, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, _a, automaticWithdrawal, _b, withdrawalFrequency, _c, partner, ixs, commitment, recipientPublicKey, mintPublicKey, metadata, _d, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx;
845
855
  var _e;
846
856
  return __generator(this, function (_f) {
847
857
  switch (_f.label) {
848
858
  case 0:
849
- mint = streamParams.tokenId, start = streamParams.start, period = streamParams.period, cliff = streamParams.cliff, canTopup = streamParams.canTopup, cancelableBySender = streamParams.cancelableBySender, cancelableByRecipient = streamParams.cancelableByRecipient, transferableBySender = streamParams.transferableBySender, transferableByRecipient = streamParams.transferableByRecipient, _a = streamParams.automaticWithdrawal, automaticWithdrawal = _a === void 0 ? false : _a, _b = streamParams.withdrawalFrequency, withdrawalFrequency = _b === void 0 ? 0 : _b;
850
- sender = solanaExtendedConfig.sender, _c = solanaExtendedConfig.partner, partner = _c === void 0 ? null : _c;
851
- if (!sender.publicKey) {
852
- throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
853
- }
859
+ sender = streamParams.sender, mint = streamParams.mint, start = streamParams.start, period = streamParams.period, cliff = streamParams.cliff, canTopup = streamParams.canTopup, cancelableBySender = streamParams.cancelableBySender, cancelableByRecipient = streamParams.cancelableByRecipient, transferableBySender = streamParams.transferableBySender, transferableByRecipient = streamParams.transferableByRecipient, _a = streamParams.automaticWithdrawal, automaticWithdrawal = _a === void 0 ? false : _a, _b = streamParams.withdrawalFrequency, withdrawalFrequency = _b === void 0 ? 0 : _b, _c = streamParams.partner, partner = _c === void 0 ? null : _c;
854
860
  ixs = [];
855
- commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
861
+ commitment = typeof this.commitment == "string"
862
+ ? this.commitment
863
+ : this.commitment.commitment;
856
864
  recipientPublicKey = new web3_js_1.PublicKey(recipient.recipient);
857
865
  mintPublicKey = new web3_js_1.PublicKey(mint);
858
866
  metadata = web3_js_1.Keypair.generate();
859
- _d = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId), 1), escrowTokens = _d[0];
860
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
867
+ return [4 /*yield*/, anchor_1.web3.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
861
868
  case 1:
862
- senderTokens = _f.sent();
863
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, recipientPublicKey)];
869
+ _d = __read.apply(void 0, [_f.sent(), 1]), escrowTokens = _d[0];
870
+ return [4 /*yield*/, ata(mintPublicKey, sender.publicKey)];
864
871
  case 2:
865
- recipientTokens = _f.sent();
866
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
872
+ senderTokens = _f.sent();
873
+ return [4 /*yield*/, ata(mintPublicKey, recipientPublicKey)];
867
874
  case 3:
868
- streamflowTreasuryTokens = _f.sent();
869
- partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
870
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, partnerPublicKey)];
875
+ recipientTokens = _f.sent();
876
+ return [4 /*yield*/, ata(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
871
877
  case 4:
878
+ streamflowTreasuryTokens = _f.sent();
879
+ partnerPublicKey = partner
880
+ ? new web3_js_1.PublicKey(partner)
881
+ : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
882
+ return [4 /*yield*/, ata(mintPublicKey, partnerPublicKey)];
883
+ case 5:
872
884
  partnerTokens = _f.sent();
873
885
  ixs.push((0, instructions_1.createStreamInstruction)({
874
886
  start: new bn_js_1.default(start),
875
- depositedAmount: recipient.amount,
887
+ depositedAmount: recipient.depositedAmount,
876
888
  period: new bn_js_1.default(period),
877
889
  amountPerPeriod: recipient.amountPerPeriod,
878
890
  cliff: new bn_js_1.default(cliff),
@@ -906,7 +918,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
906
918
  systemProgram: web3_js_1.SystemProgram.programId,
907
919
  }));
908
920
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
909
- case 5:
921
+ case 6:
910
922
  hash = _f.sent();
911
923
  tx = (_e = new web3_js_1.Transaction({
912
924
  feePayer: sender.publicKey,
@@ -919,6 +931,90 @@ var SolanaStreamClient = /** @class */ (function (_super) {
919
931
  });
920
932
  });
921
933
  };
922
- return SolanaStreamClient;
923
- }(BaseStreamClient_1.BaseStreamClient));
924
- exports.default = SolanaStreamClient;
934
+ return StreamClient;
935
+ }());
936
+ exports.default = StreamClient;
937
+ function getProgramAccounts(connection, wallet, offset, programId) {
938
+ return __awaiter(this, void 0, void 0, function () {
939
+ return __generator(this, function (_a) {
940
+ return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(programId, {
941
+ filters: [
942
+ {
943
+ memcmp: {
944
+ offset: offset,
945
+ bytes: wallet.toBase58(),
946
+ },
947
+ },
948
+ ],
949
+ })];
950
+ });
951
+ });
952
+ }
953
+ function ata(mint, account) {
954
+ return __awaiter(this, void 0, void 0, function () {
955
+ return __generator(this, function (_a) {
956
+ switch (_a.label) {
957
+ 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)];
958
+ case 1: return [2 /*return*/, _a.sent()];
959
+ }
960
+ });
961
+ });
962
+ }
963
+ function isAnchorWallet(wallet) {
964
+ return wallet.signTransaction !== undefined;
965
+ }
966
+ function signAllTransactionWithRecipients(sender, batch) {
967
+ return __awaiter(this, void 0, void 0, function () {
968
+ var isKeypair, isWallet, signedTxs_1;
969
+ return __generator(this, function (_a) {
970
+ switch (_a.label) {
971
+ case 0:
972
+ isKeypair = sender instanceof web3_js_1.Keypair;
973
+ isWallet = isAnchorWallet(sender);
974
+ if (!isKeypair) return [3 /*break*/, 1];
975
+ return [2 /*return*/, batch.map(function (t) {
976
+ t.tx.partialSign(sender);
977
+ return { tx: t.tx, recipient: t.recipient };
978
+ })];
979
+ case 1:
980
+ if (!isWallet) return [3 /*break*/, 3];
981
+ return [4 /*yield*/, sender.signAllTransactions(batch.map(function (t) { return t.tx; }))];
982
+ case 2:
983
+ signedTxs_1 = _a.sent();
984
+ return [2 /*return*/, batch.map(function (item, index) { return ({
985
+ recipient: item.recipient,
986
+ tx: signedTxs_1[index],
987
+ }); })];
988
+ case 3: return [2 /*return*/, []];
989
+ }
990
+ });
991
+ });
992
+ }
993
+ function sendAndConfirmStreamRawTransaction(connection, batchItem) {
994
+ return __awaiter(this, void 0, void 0, function () {
995
+ var rawTx, _a, lastValidBlockHeight, signature, recentBlockhash, confirmationStrategy, completedTxSignature, error_1;
996
+ return __generator(this, function (_b) {
997
+ switch (_b.label) {
998
+ case 0:
999
+ _b.trys.push([0, 2, , 3]);
1000
+ rawTx = batchItem.tx.serialize();
1001
+ _a = batchItem.tx, lastValidBlockHeight = _a.lastValidBlockHeight, signature = _a.signature, recentBlockhash = _a.recentBlockhash;
1002
+ if (!lastValidBlockHeight || !signature || !recentBlockhash)
1003
+ throw { recipient: batchItem.recipient, error: "no recent blockhash" };
1004
+ confirmationStrategy = {
1005
+ lastValidBlockHeight: lastValidBlockHeight,
1006
+ signature: (0, bs58_1.encode)(signature),
1007
+ blockhash: recentBlockhash,
1008
+ };
1009
+ return [4 /*yield*/, (0, web3_js_1.sendAndConfirmRawTransaction)(connection, rawTx, confirmationStrategy)];
1010
+ case 1:
1011
+ completedTxSignature = _b.sent();
1012
+ return [2 /*return*/, __assign(__assign({}, batchItem), { signature: completedTxSignature })];
1013
+ case 2:
1014
+ error_1 = _b.sent();
1015
+ throw { recipient: batchItem.recipient, error: error_1 };
1016
+ case 3: return [2 /*return*/];
1017
+ }
1018
+ });
1019
+ });
1020
+ }