@streamflow/stream 5.10.4 → 6.0.0-alpha.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.
package/README.md CHANGED
@@ -465,5 +465,3 @@ E.g, if the amount is 1 SOL than this amount in lamports is `1000 \* 10^9 = 1_00
465
465
  And `new BN(1_000_000_000)` is used.
466
466
 
467
467
  Use `getBN` and `getNumberFromBN` utility functions for conversions between `BN` and `Number` types.
468
-
469
- WAGMI.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var ethers_1 = require("ethers");
7
- var __1 = require("../../");
7
+ var index_1 = require("../../index");
8
8
  var GenericStreamClient_1 = __importDefault(require("../../common/GenericStreamClient"));
9
9
  var types_1 = require("../../common/types");
10
10
  describe("GenericStreamClient", function () {
@@ -13,29 +13,29 @@ describe("GenericStreamClient", function () {
13
13
  chain: types_1.IChain.Aptos,
14
14
  cluster: types_1.ICluster.Devnet,
15
15
  clusterUrl: "https://cluster",
16
- expected: __1.StreamflowAptos.AptosStreamClient,
16
+ expected: index_1.StreamflowAptos.AptosStreamClient,
17
17
  },
18
18
  {
19
19
  chain: types_1.IChain.Solana,
20
20
  cluster: types_1.ICluster.Devnet,
21
21
  clusterUrl: "https://cluster",
22
- expected: __1.StreamflowSolana.SolanaStreamClient,
22
+ expected: index_1.StreamflowSolana.SolanaStreamClient,
23
23
  },
24
24
  {
25
25
  chain: types_1.IChain.Ethereum,
26
26
  cluster: types_1.ICluster.Devnet,
27
27
  clusterUrl: "https://cluster",
28
28
  signer: ethers_1.Wallet.createRandom(),
29
- expected: __1.StreamflowEVM.EvmStreamClient,
29
+ expected: index_1.StreamflowEVM.EvmStreamClient,
30
30
  },
31
31
  {
32
32
  chain: types_1.IChain.Sui,
33
33
  cluster: types_1.ICluster.Devnet,
34
34
  clusterUrl: "https://cluster",
35
- expected: __1.StreamflowSui.SuiStreamClient,
35
+ expected: index_1.StreamflowSui.SuiStreamClient,
36
36
  },
37
37
  ])(".init($chain)", function (config) {
38
- it("should successfully create GenericStreamInstance", function () {
38
+ it("should successfully create GenericStreamClient instance", function () {
39
39
  var instance = new GenericStreamClient_1.default(config);
40
40
  expect(instance).toBeInstanceOf(GenericStreamClient_1.default);
41
41
  expect(instance.nativeStreamClient).toBeInstanceOf(config.expected);
@@ -1,6 +1,7 @@
1
1
  import { TransactionInstruction } from "@solana/web3.js";
2
2
  import { Types } from "aptos";
3
3
  import BN from "bn.js";
4
+ export { IChain, ICluster, ContractError } from "@streamflow/common";
4
5
  export interface IRecipient {
5
6
  recipient: string;
6
7
  amount: BN;
@@ -83,12 +84,6 @@ export interface IMultiTransactionResult {
83
84
  metadataToRecipient: Record<MetadataId, IRecipient>;
84
85
  errors: ICreateMultiError[];
85
86
  }
86
- export declare enum ICluster {
87
- Mainnet = "mainnet",
88
- Devnet = "devnet",
89
- Testnet = "testnet",
90
- Local = "local"
91
- }
92
87
  export declare enum StreamDirection {
93
88
  Outgoing = "outgoing",
94
89
  Incoming = "incoming",
@@ -100,14 +95,6 @@ export declare enum StreamType {
100
95
  Vesting = "vesting",
101
96
  Lock = "lock"
102
97
  }
103
- export declare enum IChain {
104
- Solana = "Solana",
105
- Aptos = "Aptos",
106
- Ethereum = "Ethereum",
107
- BNB = "BNB",
108
- Polygon = "Polygon",
109
- Sui = "Sui"
110
- }
111
98
  /**
112
99
  * Error codes raised by all protocols except for Solana
113
100
  */
@@ -245,16 +232,3 @@ export interface Stream {
245
232
  unlocked(currentTimestamp: number): BN;
246
233
  remaining(decimals: number): number;
247
234
  }
248
- /**
249
- * Error wrapper for calls made to the contract on chain
250
- */
251
- export declare class ContractError extends Error {
252
- contractErrorCode: string | null;
253
- /**
254
- * Constructs the Error Wrapper
255
- * @param error Original error raised probably by the chain SDK
256
- * @param code extracted code from the error if managed to parse it
257
- */
258
- constructor(error: Error, code?: string | null);
259
- }
260
- export {};
@@ -1,29 +1,10 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ContractError = exports.SolanaContractErrorCode = exports.ContractErrorCode = exports.IChain = exports.StreamType = exports.StreamDirection = exports.ICluster = void 0;
19
- // Utility types
20
- var ICluster;
21
- (function (ICluster) {
22
- ICluster["Mainnet"] = "mainnet";
23
- ICluster["Devnet"] = "devnet";
24
- ICluster["Testnet"] = "testnet";
25
- ICluster["Local"] = "local";
26
- })(ICluster || (exports.ICluster = ICluster = {}));
3
+ exports.SolanaContractErrorCode = exports.ContractErrorCode = exports.StreamType = exports.StreamDirection = exports.ContractError = exports.ICluster = exports.IChain = void 0;
4
+ var common_1 = require("@streamflow/common");
5
+ Object.defineProperty(exports, "IChain", { enumerable: true, get: function () { return common_1.IChain; } });
6
+ Object.defineProperty(exports, "ICluster", { enumerable: true, get: function () { return common_1.ICluster; } });
7
+ Object.defineProperty(exports, "ContractError", { enumerable: true, get: function () { return common_1.ContractError; } });
27
8
  var StreamDirection;
28
9
  (function (StreamDirection) {
29
10
  StreamDirection["Outgoing"] = "outgoing";
@@ -37,15 +18,6 @@ var StreamType;
37
18
  StreamType["Vesting"] = "vesting";
38
19
  StreamType["Lock"] = "lock";
39
20
  })(StreamType || (exports.StreamType = StreamType = {}));
40
- var IChain;
41
- (function (IChain) {
42
- IChain["Solana"] = "Solana";
43
- IChain["Aptos"] = "Aptos";
44
- IChain["Ethereum"] = "Ethereum";
45
- IChain["BNB"] = "BNB";
46
- IChain["Polygon"] = "Polygon";
47
- IChain["Sui"] = "Sui";
48
- })(IChain || (exports.IChain = IChain = {}));
49
21
  /**
50
22
  * Error codes raised by all protocols except for Solana
51
23
  */
@@ -138,25 +110,3 @@ var SolanaContractErrorCode;
138
110
  /** Meta account is not rent exempt */
139
111
  SolanaContractErrorCode["MetadataNotRentExempt"] = "MetadataNotRentExempt";
140
112
  })(SolanaContractErrorCode || (exports.SolanaContractErrorCode = SolanaContractErrorCode = {}));
141
- /**
142
- * Error wrapper for calls made to the contract on chain
143
- */
144
- var ContractError = /** @class */ (function (_super) {
145
- __extends(ContractError, _super);
146
- /**
147
- * Constructs the Error Wrapper
148
- * @param error Original error raised probably by the chain SDK
149
- * @param code extracted code from the error if managed to parse it
150
- */
151
- function ContractError(error, code) {
152
- var _this = _super.call(this, error.message) || this; // Call the base class constructor with the error message
153
- _this.contractErrorCode = code !== null && code !== void 0 ? code : null;
154
- // Copy properties from the original error
155
- Object.setPrototypeOf(_this, ContractError.prototype);
156
- _this.name = "ContractError"; // Set the name property
157
- _this.stack = error.stack;
158
- return _this;
159
- }
160
- return ContractError;
161
- }(Error));
162
- exports.ContractError = ContractError;
@@ -67,9 +67,7 @@ exports.getBN = getBN;
67
67
  * @param {number} decimals - Number of decimals the token has.
68
68
  */
69
69
  var getNumberFromBN = function (value, decimals) {
70
- return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1))
71
- ? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber()
72
- : value.toNumber() / Math.pow(10, decimals);
70
+ return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1)) ? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber() : value.toNumber() / Math.pow(10, decimals);
73
71
  };
74
72
  exports.getNumberFromBN = getNumberFromBN;
75
73
  /**
@@ -150,7 +150,9 @@ var EvmStreamClient = /** @class */ (function (_super) {
150
150
  return [4 /*yield*/, this.approveTokens(streamData.tokenId, sum)];
151
151
  case 3:
152
152
  _c.sent();
153
- return [4 /*yield*/, (_b = this.writeContract).create.apply(_b, __spreadArray(__spreadArray([], __read(args), false), [{ value: fees.value }], false))];
153
+ return [4 /*yield*/, (_b = this.writeContract).create.apply(_b, __spreadArray(__spreadArray([], __read(args), false), [{
154
+ value: fees.value,
155
+ }], false))];
154
156
  case 4:
155
157
  result = _c.sent();
156
158
  return [4 /*yield*/, result.wait()];
@@ -203,8 +205,7 @@ var EvmStreamClient = /** @class */ (function (_super) {
203
205
  signatures.push.apply(signatures, __spreadArray([], __read(successes.map(function (el) { return el.hash; })), false));
204
206
  metadatas = confirmations.map(function (result) {
205
207
  return result.status === "fulfilled"
206
- ? _this.formatMetadataId(result.value.events.find(function (item) { return item.event === "ContractCreated"; })
207
- .args[0])
208
+ ? _this.formatMetadataId(result.value.events.find(function (item) { return item.event === "ContractCreated"; }).args[0])
208
209
  : null;
209
210
  });
210
211
  metadataToRecipient = metadatas.reduce(function (acc, value, index) {
@@ -2,3 +2,4 @@ export { default, default as EvmStreamClient } from "./StreamClient";
2
2
  export * from "./utils";
3
3
  export * from "./types";
4
4
  export * as constants from "./constants";
5
+ export { default as ercAbi } from "./abi";
package/dist/evm/index.js CHANGED
@@ -29,10 +29,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.constants = exports.EvmStreamClient = exports.default = void 0;
32
+ exports.ercAbi = exports.constants = exports.EvmStreamClient = exports.default = void 0;
33
33
  var StreamClient_1 = require("./StreamClient");
34
34
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
35
35
  Object.defineProperty(exports, "EvmStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
36
36
  __exportStar(require("./utils"), exports);
37
37
  __exportStar(require("./types"), exports);
38
38
  exports.constants = __importStar(require("./constants"));
39
+ var abi_1 = require("./abi");
40
+ Object.defineProperty(exports, "ercAbi", { enumerable: true, get: function () { return __importDefault(abi_1).default; } });
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@ export * as StreamflowAptos from "./aptos";
2
2
  export * as StreamflowEVM from "./evm";
3
3
  export * as StreamflowSolana from "./solana";
4
4
  export * as StreamflowSui from "./sui";
5
- export * as Types from "./common/types";
5
+ export * from "./common/types";
6
6
  export * from "./common/utils";
7
7
  export * from "./common/constants";
8
+ export * from "./common/contractUtils";
8
9
  export { default as GenericStreamClient } from "./common/GenericStreamClient";
package/dist/index.js CHANGED
@@ -29,13 +29,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.GenericStreamClient = exports.Types = exports.StreamflowSui = exports.StreamflowSolana = exports.StreamflowEVM = exports.StreamflowAptos = void 0;
32
+ exports.GenericStreamClient = exports.StreamflowSui = exports.StreamflowSolana = exports.StreamflowEVM = exports.StreamflowAptos = void 0;
33
33
  exports.StreamflowAptos = __importStar(require("./aptos"));
34
34
  exports.StreamflowEVM = __importStar(require("./evm"));
35
35
  exports.StreamflowSolana = __importStar(require("./solana"));
36
36
  exports.StreamflowSui = __importStar(require("./sui"));
37
- exports.Types = __importStar(require("./common/types"));
37
+ __exportStar(require("./common/types"), exports);
38
38
  __exportStar(require("./common/utils"), exports);
39
39
  __exportStar(require("./common/constants"), exports);
40
+ __exportStar(require("./common/contractUtils"), exports);
40
41
  var GenericStreamClient_1 = require("./common/GenericStreamClient");
41
42
  Object.defineProperty(exports, "GenericStreamClient", { enumerable: true, get: function () { return __importDefault(GenericStreamClient_1).default; } });
@@ -129,6 +129,7 @@ var bn_js_1 = __importDefault(require("bn.js"));
129
129
  var buffer_1 = require("buffer");
130
130
  var spl_token_1 = require("@solana/spl-token");
131
131
  var web3_js_1 = require("@solana/web3.js");
132
+ var solana_1 = require("@streamflow/common/solana");
132
133
  var borsh = __importStar(require("borsh"));
133
134
  var types_1 = require("./types");
134
135
  var utils_1 = require("./utils");
@@ -150,8 +151,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
150
151
  var _this = _super.call(this) || this;
151
152
  _this.commitment = commitment;
152
153
  _this.connection = new web3_js_1.Connection(clusterUrl, _this.commitment);
153
- _this.programId =
154
- programId !== "" ? new web3_js_1.PublicKey(programId) : new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]);
154
+ _this.programId = programId !== "" ? new web3_js_1.PublicKey(programId) : new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]);
155
155
  return _this;
156
156
  }
157
157
  SolanaStreamClient.prototype.getConnection = function () {
@@ -181,28 +181,30 @@ var SolanaStreamClient = /** @class */ (function (_super) {
181
181
  recipientPublicKey = new web3_js_1.PublicKey(recipient);
182
182
  _f = this.getOrCreateStreamMetadata(metadataPubKeys), metadata = _f.metadata, metadataPubKey = _f.metadataPubKey;
183
183
  _g = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadataPubKey.toBuffer()], this.programId), 1), escrowTokens = _g[0];
184
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
184
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, sender.publicKey)];
185
185
  case 1:
186
186
  senderTokens = _o.sent();
187
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, recipientPublicKey)];
187
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, recipientPublicKey)];
188
188
  case 2:
189
189
  recipientTokens = _o.sent();
190
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
190
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
191
191
  case 3:
192
192
  streamflowTreasuryTokens = _o.sent();
193
193
  partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
194
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, partnerPublicKey)];
194
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, partnerPublicKey)];
195
195
  case 4:
196
196
  partnerTokens = _o.sent();
197
197
  if (!isNative) return [3 /*break*/, 7];
198
- return [4 /*yield*/, this.getTotalFee({ address: partner !== null && partner !== void 0 ? partner : sender.publicKey.toBase58() })];
198
+ return [4 /*yield*/, this.getTotalFee({
199
+ address: partner !== null && partner !== void 0 ? partner : sender.publicKey.toBase58(),
200
+ })];
199
201
  case 5:
200
202
  totalFee = _o.sent();
201
203
  totalAmount = (0, utils_2.calculateTotalAmountToDeposit)(depositedAmount, totalFee);
202
204
  _j = (_h = ixs.push).apply;
203
205
  _k = [ixs];
204
206
  _l = [[]];
205
- return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalAmount)];
207
+ return [4 /*yield*/, (0, solana_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalAmount)];
206
208
  case 6:
207
209
  _j.apply(_h, _k.concat([__spreadArray.apply(void 0, _l.concat([__read.apply(void 0, [(_o.sent())]), false]))]));
208
210
  _o.label = 7;
@@ -254,7 +256,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
254
256
  if (metadata) {
255
257
  tx.partialSign(metadata);
256
258
  }
257
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, sender, tx, hash)];
259
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, sender, tx, hash)];
258
260
  case 9:
259
261
  signature = _o.sent();
260
262
  return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
@@ -298,12 +300,12 @@ var SolanaStreamClient = /** @class */ (function (_super) {
298
300
  newAccountPubkey: metadataPubKey,
299
301
  });
300
302
  _g = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadataPubKey.toBuffer()], this.programId), 1), escrowTokens = _g[0];
301
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
303
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, sender.publicKey)];
302
304
  case 2:
303
305
  senderTokens = _k.sent();
304
306
  partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
305
307
  if (!isNative) return [3 /*break*/, 4];
306
- return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, depositedAmount)];
308
+ return [4 /*yield*/, (0, solana_1.prepareWrappedAccount)(this.connection, sender.publicKey, depositedAmount)];
307
309
  case 3:
308
310
  _h = _k.sent();
309
311
  return [3 /*break*/, 5];
@@ -355,7 +357,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
355
357
  if (metadata) {
356
358
  tx.partialSign(metadata);
357
359
  }
358
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, sender, tx, hash)];
360
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, sender, tx, hash)];
359
361
  case 7:
360
362
  signature = _k.sent();
361
363
  return [2 /*return*/, { ixs: ixs, txId: signature, metadataId: metadataPubKey.toBase58() }];
@@ -400,7 +402,11 @@ var SolanaStreamClient = /** @class */ (function (_super) {
400
402
  _c = _s.sent(), ixs = _c.ixs, metadata = _c.metadata, metadataPubKey = _c.metadataPubKey;
401
403
  metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
402
404
  metadatas.push(metadataPubKey.toBase58());
403
- instructionsBatch.push({ ixs: ixs, metadata: metadata, recipient: recipientData.recipient });
405
+ instructionsBatch.push({
406
+ ixs: ixs,
407
+ metadata: metadata,
408
+ recipient: recipientData.recipient,
409
+ });
404
410
  _s.label = 3;
405
411
  case 3:
406
412
  i++;
@@ -433,7 +439,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
433
439
  }
434
440
  if (!isNative) return [3 /*break*/, 7];
435
441
  totalDepositedAmount = recipients.reduce(function (acc, recipient) { return recipient.amount.add(acc); }, new bn_js_1.default(0));
436
- return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalDepositedAmount)];
442
+ return [4 /*yield*/, (0, solana_1.prepareWrappedAccount)(this.connection, sender.publicKey, totalDepositedAmount)];
437
443
  case 6:
438
444
  nativeInstructions = _s.sent();
439
445
  prepareTransaction = (_q = new web3_js_1.Transaction({
@@ -441,7 +447,10 @@ var SolanaStreamClient = /** @class */ (function (_super) {
441
447
  blockhash: hash.blockhash,
442
448
  lastValidBlockHeight: hash.lastValidBlockHeight,
443
449
  })).add.apply(_q, __spreadArray([], __read(nativeInstructions), false));
444
- batch.push({ tx: prepareTransaction, recipient: sender.publicKey.toBase58() });
450
+ batch.push({
451
+ tx: prepareTransaction,
452
+ recipient: sender.publicKey.toBase58(),
453
+ });
445
454
  _s.label = 7;
446
455
  case 7: return [4 /*yield*/, (0, utils_1.signAllTransactionWithRecipients)(sender, batch)];
447
456
  case 8:
@@ -469,9 +478,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
469
478
  _f = (_e = responses.push).apply;
470
479
  _g = [responses];
471
480
  _h = [[]];
472
- return [4 /*yield*/, Promise.allSettled([
473
- (0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, batchTx),
474
- ])];
481
+ return [4 /*yield*/, Promise.allSettled([(0, utils_1.sendAndConfirmStreamRawTransaction)(this.connection, batchTx)])];
475
482
  case 13:
476
483
  _f.apply(_e, _g.concat([__spreadArray.apply(void 0, _h.concat([__read.apply(void 0, [(_s.sent())]), false]))]));
477
484
  _s.label = 14;
@@ -491,9 +498,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
491
498
  return [7 /*endfinally*/];
492
499
  case 18: return [3 /*break*/, 21];
493
500
  case 19:
494
- batchTransactionsCalls = signedBatch.map(function (el) {
495
- return (0, utils_1.sendAndConfirmStreamRawTransaction)(_this.connection, el);
496
- });
501
+ batchTransactionsCalls = signedBatch.map(function (el) { return (0, utils_1.sendAndConfirmStreamRawTransaction)(_this.connection, el); });
497
502
  _k = (_j = responses.push).apply;
498
503
  _l = [responses];
499
504
  _m = [[]];
@@ -539,10 +544,10 @@ var SolanaStreamClient = /** @class */ (function (_super) {
539
544
  throw new Error("Couldn't get account info");
540
545
  }
541
546
  data = (0, utils_1.decodeStream)(escrow.data);
542
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
547
+ return [4 /*yield*/, (0, solana_1.ata)(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
543
548
  case 2:
544
549
  streamflowTreasuryTokens = _d.sent();
545
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, data.partner)];
550
+ return [4 /*yield*/, (0, solana_1.ata)(data.mint, data.partner)];
546
551
  case 3:
547
552
  partnerTokens = _d.sent();
548
553
  return [4 /*yield*/, this.checkAssociatedTokenAccounts(data, { invoker: invoker, checkTokenAccounts: checkTokenAccounts }, ixs)];
@@ -570,7 +575,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
570
575
  blockhash: hash.blockhash,
571
576
  lastValidBlockHeight: hash.lastValidBlockHeight,
572
577
  })).add.apply(_c, __spreadArray([], __read(ixs), false));
573
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
578
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
574
579
  case 6:
575
580
  signature = _d.sent();
576
581
  return [2 /*return*/, { ixs: ixs, txId: signature }];
@@ -601,10 +606,10 @@ var SolanaStreamClient = /** @class */ (function (_super) {
601
606
  throw new Error("Couldn't get account info");
602
607
  }
603
608
  data = (0, utils_1.decodeStream)(escrowAcc === null || escrowAcc === void 0 ? void 0 : escrowAcc.data);
604
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
609
+ return [4 /*yield*/, (0, solana_1.ata)(data.mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
605
610
  case 2:
606
611
  streamflowTreasuryTokens = _d.sent();
607
- return [4 /*yield*/, (0, utils_1.ata)(data.mint, data.partner)];
612
+ return [4 /*yield*/, (0, solana_1.ata)(data.mint, data.partner)];
608
613
  case 3:
609
614
  partnerTokens = _d.sent();
610
615
  ixs = [];
@@ -635,7 +640,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
635
640
  blockhash: hash.blockhash,
636
641
  lastValidBlockHeight: hash.lastValidBlockHeight,
637
642
  })).add.apply(_c, __spreadArray([], __read(ixs), false));
638
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
643
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
639
644
  case 6:
640
645
  signature = _d.sent();
641
646
  return [2 /*return*/, { ixs: ixs, txId: signature }];
@@ -669,7 +674,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
669
674
  throw new Error("Couldn't get account info");
670
675
  }
671
676
  mint = (0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data).mint;
672
- return [4 /*yield*/, (0, utils_1.ata)(mint, newRecipient)];
677
+ return [4 /*yield*/, (0, solana_1.ata)(mint, newRecipient)];
673
678
  case 2:
674
679
  newRecipientTokens = _d.sent();
675
680
  ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 100001 }));
@@ -693,7 +698,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
693
698
  blockhash: hash.blockhash,
694
699
  lastValidBlockHeight: hash.lastValidBlockHeight,
695
700
  })).add.apply(_c, __spreadArray([], __read(ixs), false));
696
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
701
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
697
702
  case 4:
698
703
  signature = _d.sent();
699
704
  return [2 /*return*/, { ixs: ixs, txId: signature }];
@@ -725,14 +730,14 @@ var SolanaStreamClient = /** @class */ (function (_super) {
725
730
  throw new Error("Couldn't get account info");
726
731
  }
727
732
  _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;
728
- return [4 /*yield*/, (0, utils_1.ata)(mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
733
+ return [4 /*yield*/, (0, solana_1.ata)(mint, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
729
734
  case 2:
730
735
  streamflowTreasuryTokens = _f.sent();
731
- return [4 /*yield*/, (0, utils_1.ata)(mint, partner)];
736
+ return [4 /*yield*/, (0, solana_1.ata)(mint, partner)];
732
737
  case 3:
733
738
  partnerTokens = _f.sent();
734
739
  if (!isNative) return [3 /*break*/, 5];
735
- return [4 /*yield*/, (0, instructions_1.prepareWrappedAccount)(this.connection, invoker.publicKey, amount)];
740
+ return [4 /*yield*/, (0, solana_1.prepareWrappedAccount)(this.connection, invoker.publicKey, amount)];
736
741
  case 4:
737
742
  _d = _f.sent();
738
743
  return [3 /*break*/, 6];
@@ -764,7 +769,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
764
769
  blockhash: hash.blockhash,
765
770
  lastValidBlockHeight: hash.lastValidBlockHeight,
766
771
  })).add.apply(_e, __spreadArray(__spreadArray([], __read(nativeInstructions), false), __read(ixs), false));
767
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
772
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
768
773
  case 8:
769
774
  signature = _f.sent();
770
775
  return [2 /*return*/, { ixs: ixs, txId: signature }];
@@ -806,17 +811,17 @@ var SolanaStreamClient = /** @class */ (function (_super) {
806
811
  publicKey = new web3_js_1.PublicKey(address);
807
812
  accounts = [];
808
813
  if (!(direction === "all")) return [3 /*break*/, 3];
809
- return [4 /*yield*/, (0, utils_1.getProgramAccounts)(this.connection, publicKey, constants_1.STREAM_STRUCT_OFFSET_SENDER, this.programId)];
814
+ return [4 /*yield*/, (0, solana_1.getProgramAccounts)(this.connection, publicKey, constants_1.STREAM_STRUCT_OFFSET_SENDER, this.programId)];
810
815
  case 1:
811
816
  outgoingAccounts = _d.sent();
812
- return [4 /*yield*/, (0, utils_1.getProgramAccounts)(this.connection, publicKey, constants_1.STREAM_STRUCT_OFFSET_RECIPIENT, this.programId)];
817
+ return [4 /*yield*/, (0, solana_1.getProgramAccounts)(this.connection, publicKey, constants_1.STREAM_STRUCT_OFFSET_RECIPIENT, this.programId)];
813
818
  case 2:
814
819
  incomingAccounts = _d.sent();
815
820
  accounts = __spreadArray(__spreadArray([], __read(outgoingAccounts), false), __read(incomingAccounts), false);
816
821
  return [3 /*break*/, 5];
817
822
  case 3:
818
823
  offset = direction === "outgoing" ? constants_1.STREAM_STRUCT_OFFSET_SENDER : constants_1.STREAM_STRUCT_OFFSET_RECIPIENT;
819
- return [4 /*yield*/, (0, utils_1.getProgramAccounts)(this.connection, publicKey, offset, this.programId)];
824
+ return [4 /*yield*/, (0, solana_1.getProgramAccounts)(this.connection, publicKey, offset, this.programId)];
820
825
  case 4:
821
826
  accounts = _d.sent();
822
827
  _d.label = 5;
@@ -874,7 +879,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
874
879
  blockhash: hash.blockhash,
875
880
  lastValidBlockHeight: hash.lastValidBlockHeight,
876
881
  }).add(updateIx);
877
- return [4 /*yield*/, (0, utils_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
882
+ return [4 /*yield*/, (0, solana_1.signAndExecuteTransaction)(this.connection, invoker, tx, hash)];
878
883
  case 3:
879
884
  signature = _b.sent();
880
885
  return [2 /*return*/, {
@@ -942,17 +947,17 @@ var SolanaStreamClient = /** @class */ (function (_super) {
942
947
  mintPublicKey = new web3_js_1.PublicKey(mint);
943
948
  _c = this.getOrCreateStreamMetadata(metadataPubKeys), metadata = _c.metadata, metadataPubKey = _c.metadataPubKey;
944
949
  _d = __read(web3_js_1.PublicKey.findProgramAddressSync([buffer_1.Buffer.from("strm"), metadataPubKey.toBuffer()], this.programId), 1), escrowTokens = _d[0];
945
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, sender.publicKey)];
950
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, sender.publicKey)];
946
951
  case 1:
947
952
  senderTokens = _e.sent();
948
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, recipientPublicKey)];
953
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, recipientPublicKey)];
949
954
  case 2:
950
955
  recipientTokens = _e.sent();
951
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
956
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY)];
952
957
  case 3:
953
958
  streamflowTreasuryTokens = _e.sent();
954
959
  partnerPublicKey = partner ? new web3_js_1.PublicKey(partner) : constants_1.STREAMFLOW_TREASURY_PUBLIC_KEY;
955
- return [4 /*yield*/, (0, utils_1.ata)(mintPublicKey, partnerPublicKey)];
960
+ return [4 /*yield*/, (0, solana_1.ata)(mintPublicKey, partnerPublicKey)];
956
961
  case 4:
957
962
  partnerTokens = _e.sent();
958
963
  ixs.push((0, instructions_1.createStreamInstruction)({
@@ -1001,34 +1006,25 @@ var SolanaStreamClient = /** @class */ (function (_super) {
1001
1006
  SolanaStreamClient.prototype.checkAssociatedTokenAccounts = function (data, _a, ixs) {
1002
1007
  var invoker = _a.invoker, checkTokenAccounts = _a.checkTokenAccounts;
1003
1008
  return __awaiter(this, void 0, void 0, function () {
1004
- var checkedKeys, accountArrays, response, i;
1005
- return __generator(this, function (_b) {
1006
- switch (_b.label) {
1009
+ var owners, _b, _c, _d, _e;
1010
+ return __generator(this, function (_f) {
1011
+ switch (_f.label) {
1007
1012
  case 0:
1008
1013
  if (!checkTokenAccounts) {
1009
1014
  return [2 /*return*/];
1010
1015
  }
1011
- checkedKeys = new Set();
1012
- accountArrays = [
1013
- [data.sender, data.senderTokens],
1014
- [data.recipient, data.recipientTokens],
1015
- [data.partner, data.partnerTokens],
1016
- [data.streamflowTreasury, data.streamflowTreasuryTokens],
1017
- ].filter(function (value) {
1018
- if (checkedKeys.has(value[1].toBase58())) {
1019
- return false;
1020
- }
1021
- checkedKeys.add(value[1].toBase58());
1022
- return true;
1023
- });
1024
- return [4 /*yield*/, this.connection.getMultipleAccountsInfo(accountArrays.map(function (item) { return item[1]; }))];
1016
+ owners = Array.from(new Set([
1017
+ data.sender.toBase58(),
1018
+ data.recipient.toBase58(),
1019
+ data.partner.toBase58(),
1020
+ data.streamflowTreasury.toBase58(),
1021
+ ]), function (address) { return new web3_js_1.PublicKey(address); });
1022
+ _c = (_b = ixs.push).apply;
1023
+ _d = [ixs];
1024
+ _e = [[]];
1025
+ return [4 /*yield*/, (0, solana_1.checkOrCreateAtaBatch)(this.connection, owners, data.mint, invoker)];
1025
1026
  case 1:
1026
- response = _b.sent();
1027
- for (i = 0; i < response.length; i++) {
1028
- if (!response[i]) {
1029
- ixs.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(invoker.publicKey, accountArrays[i][1], accountArrays[i][0], data.mint));
1030
- }
1031
- }
1027
+ _c.apply(_b, _d.concat([__spreadArray.apply(void 0, _e.concat([__read.apply(void 0, [(_f.sent())]), false]))]));
1032
1028
  return [2 /*return*/];
1033
1029
  }
1034
1030
  });
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { PublicKey } from "@solana/web3.js";
3
2
  export declare const TX_FINALITY_CONFIRMED = "confirmed";
4
3
  export declare const STREAM_STRUCT_OFFSET_SENDER = 49;
@@ -26,7 +26,11 @@ exports.FEES_METADATA_SEED = Buffer.from("strm_fees");
26
26
  exports.DEFAULT_STREAMFLOW_FEE = 0.99;
27
27
  exports.AIRDROP_AMOUNT = 1; // 1 SOL is the cap on the testnet
28
28
  exports.PARTNER_SCHEMA = {
29
- struct: { pubkey: { array: { type: "u8", len: 32 } }, partner_fee: "f32", strm_fee: "f32" },
29
+ struct: {
30
+ pubkey: { array: { type: "u8", len: 32 } },
31
+ partner_fee: "f32",
32
+ strm_fee: "f32",
33
+ },
30
34
  };
31
35
  exports.PARTNERS_SCHEMA = { array: { type: exports.PARTNER_SCHEMA } };
32
36
  exports.SOLANA_ERROR_MATCH_REGEX = /custom program error: (0x\d{2})/;
@@ -1,4 +1,4 @@
1
- import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
1
+ import { PublicKey, TransactionInstruction } from "@solana/web3.js";
2
2
  import BN from "bn.js";
3
3
  import { IUpdateData } from "../common/types";
4
4
  interface CreateStreamData {
@@ -135,5 +135,4 @@ interface TopupAccounts {
135
135
  systemProgram: PublicKey;
136
136
  }
137
137
  export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction;
138
- export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
139
138
  export {};