@streamflow/stream 5.6.6 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,23 +16,23 @@ export default class SolanaStreamClient extends BaseStreamClient {
16
16
  * Creates a new stream/vesting contract.
17
17
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
18
18
  */
19
- create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
19
+ create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
20
20
  /**
21
21
  * Creates a new stream/vesting contract using unchecked instruction.
22
22
  *
23
- * Unchecked instruction differes from the regular in:
23
+ * Unchecked instruction differs from the regular in:
24
24
  * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
25
25
  * as sender/recipient/partner or there are risks of funds being locked in the contract)
26
26
  * - initialized contract PDA off chain
27
27
  *
28
28
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
29
29
  */
30
- createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
30
+ createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative }: ICreateStreamSolanaExt): Promise<ICreateResult>;
31
31
  /**
32
32
  * Creates multiple stream/vesting contracts.
33
33
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
34
34
  */
35
- createMultiple(data: ICreateMultipleStreamData, { sender, isNative }: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
35
+ createMultiple(data: ICreateMultipleStreamData, { sender, metadataPubKeys, isNative }: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
36
36
  /**
37
37
  * Attempts withdrawing from the specified stream.
38
38
  */
@@ -87,17 +87,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
87
87
  }
88
88
  return to.concat(ar || Array.prototype.slice.call(from));
89
89
  };
90
- var __values = (this && this.__values) || function(o) {
91
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
92
- if (m) return m.call(o);
93
- if (o && typeof o.length === "number") return {
94
- next: function () {
95
- if (o && i >= o.length) o = void 0;
96
- return { value: o && o[i++], done: !o };
97
- }
98
- };
99
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
100
- };
101
90
  var __importDefault = (this && this.__importDefault) || function (mod) {
102
91
  return (mod && mod.__esModule) ? mod : { "default": mod };
103
92
  };
@@ -142,9 +131,9 @@ var SolanaStreamClient = /** @class */ (function (_super) {
142
131
  */
143
132
  SolanaStreamClient.prototype.create = function (_a, _b) {
144
133
  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, partner = _a.partner;
145
- var sender = _b.sender, _e = _b.isNative, isNative = _e === void 0 ? false : _e;
134
+ var sender = _b.sender, metadataPubKeys = _b.metadataPubKeys, _e = _b.isNative, isNative = _e === void 0 ? false : _e;
146
135
  return __awaiter(this, void 0, void 0, function () {
147
- var ixs, mintPublicKey, recipientPublicKey, metadata, _f, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, nativeInstructions, _g, commitment, hash, tx, signature;
136
+ var ixs, mintPublicKey, recipientPublicKey, metadata, metadataPubKey, _f, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, nativeInstructions, _g, commitment, hash, tx, signature;
148
137
  var _h;
149
138
  return __generator(this, function (_j) {
150
139
  switch (_j.label) {
@@ -155,32 +144,37 @@ var SolanaStreamClient = /** @class */ (function (_super) {
155
144
  ixs = [];
156
145
  mintPublicKey = isNative ? spl_token_1.NATIVE_MINT : new web3_js_1.PublicKey(mint);
157
146
  recipientPublicKey = new web3_js_1.PublicKey(recipient);
158
- metadata = web3_js_1.Keypair.generate();
159
- return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
160
- case 1:
161
- _f = __read.apply(void 0, [_j.sent(), 1]), escrowTokens = _f[0];
147
+ metadata = null;
148
+ if (!metadataPubKeys) {
149
+ metadata = web3_js_1.Keypair.generate();
150
+ metadataPubKey = metadata.publicKey;
151
+ }
152
+ else {
153
+ metadataPubKey = metadataPubKeys[0];
154
+ }
155
+ _f = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadataPubKey.toBuffer()], this.programId), 1), escrowTokens = _f[0];
162
156
  return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
163
- case 2:
157
+ case 1:
164
158
  senderTokens = _j.sent();
165
159
  return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, recipientPublicKey)];
166
- case 3:
160
+ case 2:
167
161
  recipientTokens = _j.sent();
168
162
  return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
169
- case 4:
163
+ case 3:
170
164
  streamflowTreasuryTokens = _j.sent();
171
165
  partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
172
166
  return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, partnerPublicKey)];
173
- case 5:
167
+ case 4:
174
168
  partnerTokens = _j.sent();
175
- if (!isNative) return [3 /*break*/, 7];
169
+ if (!isNative) return [3 /*break*/, 6];
176
170
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, depositedAmount)];
177
- case 6:
171
+ case 5:
178
172
  _g = _j.sent();
179
- return [3 /*break*/, 8];
180
- case 7:
173
+ return [3 /*break*/, 7];
174
+ case 6:
181
175
  _g = [];
182
- _j.label = 8;
183
- case 8:
176
+ _j.label = 7;
177
+ case 7:
184
178
  nativeInstructions = _g;
185
179
  ixs.push((0, instructions_1.createStreamInstruction)({
186
180
  start: new bn_js_1.default(start),
@@ -201,7 +195,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
201
195
  sender: sender.publicKey,
202
196
  senderTokens: senderTokens,
203
197
  recipient: new web3_js_1.PublicKey(recipient),
204
- metadata: metadata.publicKey,
198
+ metadata: metadataPubKey,
205
199
  escrowTokens: escrowTokens,
206
200
  recipientTokens: recipientTokens,
207
201
  streamflowTreasury: constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY,
@@ -219,18 +213,20 @@ var SolanaStreamClient = /** @class */ (function (_super) {
219
213
  }));
220
214
  commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
221
215
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
222
- case 9:
216
+ case 8:
223
217
  hash = _j.sent();
224
218
  tx = (_h = new web3_js_1.Transaction({
225
219
  feePayer: sender.publicKey,
226
220
  blockhash: hash.blockhash,
227
221
  lastValidBlockHeight: hash.lastValidBlockHeight,
228
222
  })).add.apply(_h, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
229
- tx.partialSign(metadata);
223
+ if (metadata) {
224
+ tx.partialSign(metadata);
225
+ }
230
226
  return [4 /*yield*/, this.sign(sender, tx, hash)];
231
- case 10:
227
+ case 9:
232
228
  signature = _j.sent();
233
- return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadata.publicKey.toBase58() }];
229
+ return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
234
230
  }
235
231
  });
236
232
  });
@@ -238,7 +234,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
238
234
  /**
239
235
  * Creates a new stream/vesting contract using unchecked instruction.
240
236
  *
241
- * Unchecked instruction differes from the regular in:
237
+ * Unchecked instruction differs from the regular in:
242
238
  * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
243
239
  * as sender/recipient/partner or there are risks of funds being locked in the contract)
244
240
  * - initialized contract PDA off chain
@@ -247,9 +243,9 @@ var SolanaStreamClient = /** @class */ (function (_super) {
247
243
  */
248
244
  SolanaStreamClient.prototype.createUnchecked = function (_a, _b) {
249
245
  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, partner = _a.partner;
250
- var sender = _b.sender, _e = _b.isNative, isNative = _e === void 0 ? false : _e;
246
+ var sender = _b.sender, metadataPubKeys = _b.metadataPubKeys, _e = _b.isNative, isNative = _e === void 0 ? false : _e;
251
247
  return __awaiter(this, void 0, void 0, function () {
252
- var mintPublicKey, recipientPublicKey, metadata, rentToExempt, createMetadataInstruction, _f, escrowTokens, senderTokens, partnerPublicKey, nativeInstructions, _g, createInstruction, commitment, ixs, hash, tx, signature;
248
+ var mintPublicKey, recipientPublicKey, metadata, metadataPubKey, rentToExempt, createMetadataInstruction, _f, escrowTokens, senderTokens, partnerPublicKey, nativeInstructions, _g, createInstruction, commitment, ixs, hash, tx, signature;
253
249
  var _h;
254
250
  return __generator(this, function (_j) {
255
251
  switch (_j.label) {
@@ -259,7 +255,14 @@ var SolanaStreamClient = /** @class */ (function (_super) {
259
255
  }
260
256
  mintPublicKey = new web3_js_1.PublicKey(mint);
261
257
  recipientPublicKey = new web3_js_1.PublicKey(recipient);
262
- metadata = web3_js_1.Keypair.generate();
258
+ metadata = null;
259
+ if (!metadataPubKeys) {
260
+ metadata = web3_js_1.Keypair.generate();
261
+ metadataPubKey = metadata.publicKey;
262
+ }
263
+ else {
264
+ metadataPubKey = metadataPubKeys[0];
265
+ }
263
266
  return [4 /*yield*/, this.connection.getMinimumBalanceForRentExemption(METADATA_ACC_SIZE)];
264
267
  case 1:
265
268
  rentToExempt = _j.sent();
@@ -268,24 +271,22 @@ var SolanaStreamClient = /** @class */ (function (_super) {
268
271
  space: METADATA_ACC_SIZE,
269
272
  lamports: rentToExempt,
270
273
  fromPubkey: sender === null || sender === void 0 ? void 0 : sender.publicKey,
271
- newAccountPubkey: metadata.publicKey,
274
+ newAccountPubkey: metadataPubKey,
272
275
  });
273
- return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
274
- case 2:
275
- _f = __read.apply(void 0, [_j.sent(), 1]), escrowTokens = _f[0];
276
+ _f = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadataPubKey.toBuffer()], this.programId), 1), escrowTokens = _f[0];
276
277
  return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
277
- case 3:
278
+ case 2:
278
279
  senderTokens = _j.sent();
279
280
  partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
280
- if (!isNative) return [3 /*break*/, 5];
281
+ if (!isNative) return [3 /*break*/, 4];
281
282
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, depositedAmount)];
282
- case 4:
283
+ case 3:
283
284
  _g = _j.sent();
284
- return [3 /*break*/, 6];
285
- case 5:
285
+ return [3 /*break*/, 5];
286
+ case 4:
286
287
  _g = [];
287
- _j.label = 6;
288
- case 6:
288
+ _j.label = 5;
289
+ case 5:
289
290
  nativeInstructions = _g;
290
291
  createInstruction = (0, instructions_1.createUncheckedStreamInstruction)({
291
292
  start: new bn_js_1.default(start),
@@ -307,7 +308,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
307
308
  }, this.programId, {
308
309
  sender: sender.publicKey,
309
310
  senderTokens: senderTokens,
310
- metadata: metadata.publicKey,
311
+ metadata: metadataPubKey,
311
312
  escrowTokens: escrowTokens,
312
313
  mint: new web3_js_1.PublicKey(mint),
313
314
  feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
@@ -320,18 +321,20 @@ var SolanaStreamClient = /** @class */ (function (_super) {
320
321
  commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
321
322
  ixs = [createMetadataInstruction, createInstruction];
322
323
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
323
- case 7:
324
+ case 6:
324
325
  hash = _j.sent();
325
326
  tx = (_h = new web3_js_1.Transaction({
326
327
  feePayer: sender.publicKey,
327
328
  blockhash: hash.blockhash,
328
329
  lastValidBlockHeight: hash.lastValidBlockHeight,
329
330
  })).add.apply(_h, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
330
- tx.partialSign(metadata);
331
+ if (metadata) {
332
+ tx.partialSign(metadata);
333
+ }
331
334
  return [4 /*yield*/, this.sign(sender, tx, hash)];
332
- case 8:
335
+ case 7:
333
336
  signature = _j.sent();
334
- return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadata.publicKey.toBase58() }];
337
+ return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
335
338
  }
336
339
  });
337
340
  });
@@ -341,13 +344,13 @@ var SolanaStreamClient = /** @class */ (function (_super) {
341
344
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
342
345
  */
343
346
  SolanaStreamClient.prototype.createMultiple = function (data, _a) {
344
- var sender = _a.sender, _b = _a.isNative, isNative = _b === void 0 ? false : _b;
347
+ var sender = _a.sender, metadataPubKeys = _a.metadataPubKeys, _b = _a.isNative, isNative = _b === void 0 ? false : _b;
345
348
  return __awaiter(this, void 0, void 0, function () {
346
- var recipients, metadatas, metadataToRecipient, errors, signatures, batch, recipients_1, recipients_1_1, recipientData, _c, tx, metadata, metadataPubKey, e_1_1, totalDepositedAmount, nativeInstructions, commitment, hash, prepareTransaction, signedBatch, prepareTx, batchTransactionsCalls, responses, successes, failures, metadataIds;
347
- var e_1, _d, _e;
349
+ var recipients, metadatas, metadataToRecipient, errors, signatures, batch, i, recipientData, _c, tx, metadataPubKey, totalDepositedAmount, nativeInstructions, commitment, hash, prepareTransaction, signedBatch, prepareTx, batchTransactionsCalls, responses, successes, failures;
350
+ var _d;
348
351
  var _this = this;
349
- return __generator(this, function (_f) {
350
- switch (_f.label) {
352
+ return __generator(this, function (_e) {
353
+ switch (_e.label) {
351
354
  case 0:
352
355
  recipients = data.recipients;
353
356
  if (!sender.publicKey) {
@@ -358,74 +361,61 @@ var SolanaStreamClient = /** @class */ (function (_super) {
358
361
  errors = [];
359
362
  signatures = [];
360
363
  batch = [];
361
- _f.label = 1;
364
+ metadataPubKeys = metadataPubKeys || [];
365
+ i = 0;
366
+ _e.label = 1;
362
367
  case 1:
363
- _f.trys.push([1, 6, 7, 8]);
364
- recipients_1 = __values(recipients), recipients_1_1 = recipients_1.next();
365
- _f.label = 2;
366
- case 2:
367
- if (!!recipients_1_1.done) return [3 /*break*/, 5];
368
- recipientData = recipients_1_1.value;
368
+ if (!(i < recipients.length)) return [3 /*break*/, 4];
369
+ recipientData = recipients[i];
369
370
  return [4 /*yield*/, this.prepareStreamTransaction(recipientData, data, {
370
371
  sender: sender,
372
+ metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : undefined,
371
373
  })];
372
- case 3:
373
- _c = _f.sent(), tx = _c.tx, metadata = _c.metadata;
374
- metadataPubKey = metadata.publicKey.toBase58();
375
- metadataToRecipient[metadataPubKey] = recipientData;
376
- metadatas.push(metadata);
374
+ case 2:
375
+ _c = _e.sent(), tx = _c.tx, metadataPubKey = _c.metadataPubKey;
376
+ metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
377
+ metadatas.push(metadataPubKey.toBase58());
377
378
  batch.push({ tx: tx, recipient: recipientData.recipient });
378
- _f.label = 4;
379
+ _e.label = 3;
380
+ case 3:
381
+ i++;
382
+ return [3 /*break*/, 1];
379
383
  case 4:
380
- recipients_1_1 = recipients_1.next();
381
- return [3 /*break*/, 2];
382
- case 5: return [3 /*break*/, 8];
383
- case 6:
384
- e_1_1 = _f.sent();
385
- e_1 = { error: e_1_1 };
386
- return [3 /*break*/, 8];
387
- case 7:
388
- try {
389
- if (recipients_1_1 && !recipients_1_1.done && (_d = recipients_1.return)) _d.call(recipients_1);
390
- }
391
- finally { if (e_1) throw e_1.error; }
392
- return [7 /*endfinally*/];
393
- case 8:
394
- if (!isNative) return [3 /*break*/, 11];
384
+ if (!isNative) return [3 /*break*/, 7];
395
385
  totalDepositedAmount = recipients.reduce(function (acc, recipient) { return recipient.amount.add(acc); }, new bn_js_1.default(0));
396
386
  return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalDepositedAmount)];
397
- case 9:
398
- nativeInstructions = _f.sent();
387
+ case 5:
388
+ nativeInstructions = _e.sent();
399
389
  commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
400
390
  return [4 /*yield*/, this.connection.getLatestBlockhash(commitment)];
401
- case 10:
402
- hash = _f.sent();
403
- prepareTransaction = (_e = new web3_js_1.Transaction({
391
+ case 6:
392
+ hash = _e.sent();
393
+ prepareTransaction = (_d = new web3_js_1.Transaction({
404
394
  feePayer: sender.publicKey,
405
395
  blockhash: hash.blockhash,
406
396
  lastValidBlockHeight: hash.lastValidBlockHeight,
407
- })).add.apply(_e, __spreadArray([], __read(nativeInstructions), false));
397
+ })).add.apply(_d, __spreadArray([], __read(nativeInstructions), false));
408
398
  batch.push({ tx: prepareTransaction, recipient: sender.publicKey.toBase58() });
409
- _f.label = 11;
410
- case 11: return [4 /*yield*/, (0, utils_1.signAllTransactionWithRecipients)(sender, batch)];
411
- case 12:
412
- signedBatch = _f.sent();
399
+ _e.label = 7;
400
+ case 7: return [4 /*yield*/, (0, utils_1.signAllTransactionWithRecipients)(sender, batch)];
401
+ case 8:
402
+ signedBatch = _e.sent();
413
403
  signedBatch.forEach(function (item, index) {
414
404
  item.tx.lastValidBlockHeight = batch[index].tx.lastValidBlockHeight;
415
405
  });
416
- if (!isNative) return [3 /*break*/, 14];
406
+ if (!isNative) return [3 /*break*/, 10];
417
407
  prepareTx = signedBatch.pop();
418
408
  return [4 /*yield*/, (0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, prepareTx)];
419
- case 13:
420
- _f.sent();
421
- _f.label = 14;
422
- case 14:
409
+ case 9:
410
+ _e.sent();
411
+ _e.label = 10;
412
+ case 10:
423
413
  batchTransactionsCalls = signedBatch.map(function (el) {
424
414
  return (0, utils_1.sendAndConfirmStreamRawTransaction)(_this.connection, el);
425
415
  });
426
416
  return [4 /*yield*/, Promise.allSettled(batchTransactionsCalls)];
427
- case 15:
428
- responses = _f.sent();
417
+ case 11:
418
+ responses = _e.sent();
429
419
  successes = responses
430
420
  .filter(function (el) { return el.status === "fulfilled"; })
431
421
  .map(function (el) { return el.value; });
@@ -434,8 +424,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
434
424
  .filter(function (el) { return el.status === "rejected"; })
435
425
  .map(function (el) { return (__assign(__assign({}, el.reason), { contractErrorCode: _this.extractErrorCode(el.reason.error) || undefined })); });
436
426
  errors.push.apply(errors, __spreadArray([], __read(failures), false));
437
- metadataIds = metadatas.map(function (pk) { return pk.publicKey.toBase58(); });
438
- return [2 /*return*/, { txs: signatures, metadatas: metadataIds, metadataToRecipient: metadataToRecipient, errors: errors }];
427
+ return [2 /*return*/, { txs: signatures, metadatas: metadatas, metadataToRecipient: metadataToRecipient, errors: errors }];
439
428
  }
440
429
  });
441
430
  });
@@ -844,13 +833,13 @@ var SolanaStreamClient = /** @class */ (function (_super) {
844
833
  */
845
834
  SolanaStreamClient.prototype.prepareStreamTransaction = function (recipient, streamParams, solanaExtendedConfig) {
846
835
  return __awaiter(this, void 0, void 0, function () {
847
- var mint, start, period, cliff, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, _a, automaticWithdrawal, _b, withdrawalFrequency, partner, sender, ixs, commitment, recipientPublicKey, mintPublicKey, metadata, _c, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx;
836
+ var mint, start, period, cliff, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, _a, automaticWithdrawal, _b, withdrawalFrequency, partner, sender, metadataPubKeys, ixs, commitment, recipientPublicKey, mintPublicKey, metadata, metadataPubKey, _c, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx;
848
837
  var _d;
849
838
  return __generator(this, function (_e) {
850
839
  switch (_e.label) {
851
840
  case 0:
852
841
  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, partner = streamParams.partner;
853
- sender = solanaExtendedConfig.sender;
842
+ sender = solanaExtendedConfig.sender, metadataPubKeys = solanaExtendedConfig.metadataPubKeys;
854
843
  if (!sender.publicKey) {
855
844
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
856
845
  }
@@ -858,8 +847,15 @@ var SolanaStreamClient = /** @class */ (function (_super) {
858
847
  commitment = typeof this.commitment == "string" ? this.commitment : this.commitment.commitment;
859
848
  recipientPublicKey = new web3_js_1.PublicKey(recipient.recipient);
860
849
  mintPublicKey = new web3_js_1.PublicKey(mint);
861
- metadata = web3_js_1.Keypair.generate();
862
- _c = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId), 1), escrowTokens = _c[0];
850
+ metadata = null;
851
+ if (!metadataPubKeys) {
852
+ metadata = web3_js_1.Keypair.generate();
853
+ metadataPubKey = metadata.publicKey;
854
+ }
855
+ else {
856
+ metadataPubKey = metadataPubKeys[0];
857
+ }
858
+ _c = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadataPubKey.toBuffer()], this.programId), 1), escrowTokens = _c[0];
863
859
  return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
864
860
  case 1:
865
861
  senderTokens = _e.sent();
@@ -892,7 +888,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
892
888
  sender: sender.publicKey,
893
889
  senderTokens: senderTokens,
894
890
  recipient: new web3_js_1.PublicKey(recipient.recipient),
895
- metadata: metadata.publicKey,
891
+ metadata: metadataPubKey,
896
892
  escrowTokens: escrowTokens,
897
893
  recipientTokens: recipientTokens,
898
894
  streamflowTreasury: constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY,
@@ -916,8 +912,10 @@ var SolanaStreamClient = /** @class */ (function (_super) {
916
912
  blockhash: hash.blockhash,
917
913
  lastValidBlockHeight: hash.lastValidBlockHeight,
918
914
  })).add.apply(_d, __spreadArray([], __read(ixs), false));
919
- tx.partialSign(metadata);
920
- return [2 /*return*/, { tx: tx, metadata: metadata }];
915
+ if (metadata) {
916
+ tx.partialSign(metadata);
917
+ }
918
+ return [2 /*return*/, { tx: tx, metadataPubKey: metadataPubKey }];
921
919
  }
922
920
  });
923
921
  });
@@ -10,6 +10,7 @@ export interface Account {
10
10
  }
11
11
  export interface ICreateStreamSolanaExt {
12
12
  sender: SignerWalletAdapter | Keypair;
13
+ metadataPubKeys?: PublicKey[];
13
14
  partner?: string | null;
14
15
  isNative?: boolean;
15
16
  }
@@ -5,7 +5,7 @@ exports.SUI_MODULE_ERROR_MAP = exports.SUI_ERROR_MATCH_REGEX = exports.SUI_FEE_T
5
5
  var types_1 = require("../common/types");
6
6
  // TODO: remove Devnet and Local addresses as they are not deployed, they are just a copy Testnet values
7
7
  exports.SUI_PROGRAM_IDS = (_a = {},
8
- _a[types_1.ICluster.Mainnet] = "0x527b334ab7216f01a5f0521ffb3dfff0cc4df06b65b2cd0d0864e05b13cf911a",
8
+ _a[types_1.ICluster.Mainnet] = "0x19007172b22fcfc00c22f1598a9cec7ab52de2b0ea0d111813bc1295a136fc10",
9
9
  _a[types_1.ICluster.Devnet] = "0xf1916c119a6c917d4b36f96ffc0443930745789f3126a716e05a62223c48993a",
10
10
  _a[types_1.ICluster.Testnet] = "0xf1916c119a6c917d4b36f96ffc0443930745789f3126a716e05a62223c48993a",
11
11
  _a[types_1.ICluster.Local] = "0xf1916c119a6c917d4b36f96ffc0443930745789f3126a716e05a62223c48993a",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "5.6.6",
3
+ "version": "5.7.0",
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/",
@@ -11,7 +11,7 @@
11
11
  "lint": "eslint .",
12
12
  "prepublishOnly": "npm run lint && npm test && npm run build"
13
13
  },
14
- "gitHead": "6497aa20fc011f9a1f145a4daf4e5c5d8792aec2",
14
+ "gitHead": "71ae90550965736e265896bbbe67b08c8209261a",
15
15
  "devDependencies": {
16
16
  "@types/bn.js": "5.1.1",
17
17
  "@types/ethereum-checksum-address": "^0.0.0",