@streamflow/stream 3.0.0 → 3.0.1-3.1

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
@@ -35,23 +35,23 @@ Most common imports:
35
35
 
36
36
  ```javascript
37
37
  import {
38
- StreamClient,
39
- Stream,
40
- CreateParams,
41
- CreateMultiParams,
42
- WithdrawParams,
43
- TransferParams,
44
- TopupParams,
45
- CancelParams,
46
- GetAllParams,
47
- StreamDirection,
48
- StreamType,
49
- Cluster,
50
- TxResponse,
51
- CreateResponse,
52
- BN,
53
- getBN,
54
- getNumberFromBN,
38
+ StreamClient,
39
+ Stream,
40
+ CreateParams,
41
+ CreateMultiParams,
42
+ WithdrawParams,
43
+ TransferParams,
44
+ TopupParams,
45
+ CancelParams,
46
+ GetAllParams,
47
+ StreamDirection,
48
+ StreamType,
49
+ Cluster,
50
+ TxResponse,
51
+ CreateResponse,
52
+ BN,
53
+ getBN,
54
+ getNumberFromBN,
55
55
  } from "@streamflow/stream";
56
56
  ```
57
57
 
@@ -66,9 +66,9 @@ All streams functions are methods on this instance.
66
66
  import { StreamClient } from "@streamflow/stream";
67
67
 
68
68
  const StreamClient = new StreamClient(
69
- "https://api.mainnet-beta.solana.com",
70
- Cluster.Mainnet,
71
- "confirmed"
69
+ "https://api.mainnet-beta.solana.com",
70
+ Cluster.Mainnet,
71
+ "confirmed"
72
72
  );
73
73
  ```
74
74
 
@@ -76,30 +76,30 @@ const StreamClient = new StreamClient(
76
76
 
77
77
  ```javascript
78
78
  const createStreamParams = {
79
- sender: wallet, // Wallet/Keypair signing the transaction, creating and sending the stream.
80
- recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Solana recipient address.
81
- mint: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL Token mint.
82
- start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
83
- depositedAmount: getBN(1000000000000, 9), // Deposited amount of tokens (using smallest denomination).
84
- period: 1, // Time step (period) in seconds per which the unlocking occurs.
85
- cliff: 1643363160, // Vesting contract "cliff" timestamp in seconds.
86
- cliffAmount: new BN(100000000000), // Amount (smallest denomination) unlocked at the "cliff" timestamp.
87
- amountPerPeriod: getBN(5000000000, 9), // Release rate: how many tokens are unlocked per each period.
88
- name: "Transfer to Jane Doe.", // The stream name or subject.
89
- canTopup: false, // setting to FALSE will effectively create a vesting contract.
90
- cancelableBySender: true, // Whether or not sender can cancel the stream.
91
- cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
92
- transferableBySender: true, // Whether or not sender can transfer the stream.
93
- transferableByRecipient: false, // Whether or not recipient can transfer the stream.
94
- automaticWithdrawal: true, // [WIP] Whether or not a 3rd party (e.g. cron job, "cranker") can initiate a token withdraw/transfer.
95
- withdrawalFrequency: 10, // [WIP] 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.
96
- partner: null, // (optional) Partner's wallet address (string | null).
79
+ sender: wallet, // Wallet/Keypair signing the transaction, creating and sending the stream.
80
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Solana recipient address.
81
+ mint: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL Token mint.
82
+ start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
83
+ depositedAmount: getBN(1000000000000, 9), // Deposited amount of tokens (using smallest denomination).
84
+ period: 1, // Time step (period) in seconds per which the unlocking occurs.
85
+ cliff: 1643363160, // Vesting contract "cliff" timestamp in seconds.
86
+ cliffAmount: new BN(100000000000), // Amount (smallest denomination) unlocked at the "cliff" timestamp.
87
+ amountPerPeriod: getBN(5000000000, 9), // Release rate: how many tokens are unlocked per each period.
88
+ name: "Transfer to Jane Doe.", // The stream name or subject.
89
+ canTopup: false, // setting to FALSE will effectively create a vesting contract.
90
+ cancelableBySender: true, // Whether or not sender can cancel the stream.
91
+ cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
92
+ transferableBySender: true, // Whether or not sender can transfer the stream.
93
+ transferableByRecipient: false, // Whether or not recipient can transfer the stream.
94
+ automaticWithdrawal: true, // [WIP] Whether or not a 3rd party (e.g. cron job, "cranker") can initiate a token withdraw/transfer.
95
+ withdrawalFrequency: 10, // [WIP] 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.
96
+ partner: null, // (optional) Partner's wallet address (string | null).
97
97
  };
98
98
 
99
99
  try {
100
- const { ixs, tx, metadata } = await StreamClient.create(createStreamParams);
100
+ const { ixs, tx, metadata } = await StreamClient.create(createStreamParams);
101
101
  } catch (exception) {
102
- // handle exception
102
+ // handle exception
103
103
  }
104
104
  ```
105
105
 
@@ -107,35 +107,35 @@ try {
107
107
 
108
108
  ```javascript
109
109
  const recipients = [
110
- {
111
- recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Solana recipient address.
112
- depositedAmount: getBN(1000000000000, 9), // Deposited amount of tokens (in the smallest units).
113
- name: "January Payroll", // The stream name/subject.
114
- },
110
+ {
111
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Solana recipient address.
112
+ depositedAmount: getBN(1000000000000, 9), // Deposited amount of tokens (in the smallest units).
113
+ name: "January Payroll", // The stream name/subject.
114
+ },
115
115
  ];
116
116
 
117
117
  const createMultiStreamsParams = {
118
- sender: wallet, // Wallet/Keypair signing the transaction, creating and sending the stream.
119
- recipientsData: recipients, // Array of Solana recipient address.
120
- mint: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL Token mint.
121
- start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
122
- period: 1, // Time step (period) in seconds per which the unlocking occurs.
123
- cliff: 1643363160, // Vesting contract "cliff" timestamp in seconds.
124
- cliffAmount: getBN(100000000000, 9), // Amount unlocked at the "cliff" timestamp.
125
- amountPerPeriod: getBN(5000000000, 9), // Release rate: how many tokens are unlocked per each period.
126
- canTopup: true, // setting to FALSE will effectively create a vesting contract.
127
- cancelableBySender: true, // Whether or not sender can cancel the stream.
128
- cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
129
- transferableBySender: true, // Whether or not sender can transfer the stream.
130
- transferableByRecipient: false, // Whether or not recipient can transfer the stream.
131
- automaticWithdrawal: false, // Whether or not a 3rd party can initiate withdraw in the name of recipient (currently not used, set it to FALSE).
132
- partner: null, // (optional) Partner's wallet address (string | null).
118
+ sender: wallet, // Wallet/Keypair signing the transaction, creating and sending the stream.
119
+ recipientsData: recipients, // Array of Solana recipient address.
120
+ mint: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL Token mint.
121
+ start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
122
+ period: 1, // Time step (period) in seconds per which the unlocking occurs.
123
+ cliff: 1643363160, // Vesting contract "cliff" timestamp in seconds.
124
+ cliffAmount: getBN(100000000000, 9), // Amount unlocked at the "cliff" timestamp.
125
+ amountPerPeriod: getBN(5000000000, 9), // Release rate: how many tokens are unlocked per each period.
126
+ canTopup: true, // setting to FALSE will effectively create a vesting contract.
127
+ cancelableBySender: true, // Whether or not sender can cancel the stream.
128
+ cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
129
+ transferableBySender: true, // Whether or not sender can transfer the stream.
130
+ transferableByRecipient: false, // Whether or not recipient can transfer the stream.
131
+ automaticWithdrawal: false, // Whether or not a 3rd party can initiate withdraw in the name of recipient (currently not used, set it to FALSE).
132
+ partner: null, // (optional) Partner's wallet address (string | null).
133
133
  };
134
134
 
135
135
  try {
136
- const { txs } = await StreamClient.createMultiple(createMultiStreamsParams);
136
+ const { txs } = await StreamClient.createMultiple(createMultiStreamsParams);
137
137
  } catch (exception) {
138
- // handle exception
138
+ // handle exception
139
139
  }
140
140
  ```
141
141
 
@@ -147,15 +147,15 @@ Please note that transaction fees for the scheduled transfers are paid upfront b
147
147
 
148
148
  ```javascript
149
149
  const withdrawStreamParams = {
150
- invoker: wallet, // Wallet/Keypair signing the transaction.
151
- id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be withdrawn from.
152
- amount: getBN(100000000000, 9), // Requested amount to withdraw. If stream is completed, the whole amount will be withdrawn.
150
+ invoker: wallet, // Wallet/Keypair signing the transaction.
151
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be withdrawn from.
152
+ amount: getBN(100000000000, 9), // Requested amount to withdraw. If stream is completed, the whole amount will be withdrawn.
153
153
  };
154
154
 
155
155
  try {
156
- const { ixs, tx } = await StreamClient.withdraw(withdrawStreamParams);
156
+ const { ixs, tx } = await StreamClient.withdraw(withdrawStreamParams);
157
157
  } catch (exception) {
158
- // handle exception
158
+ // handle exception
159
159
  }
160
160
  ```
161
161
 
@@ -163,15 +163,15 @@ try {
163
163
 
164
164
  ```javascript
165
165
  const topupStreamParams = {
166
- invoker: wallet, // Wallet/Keypair signing the transaction.
167
- id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be topped up.
168
- amount: getBN(100000000000, 9), // Specified amount to topup (increases deposited amount).
166
+ invoker: wallet, // Wallet/Keypair signing the transaction.
167
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be topped up.
168
+ amount: getBN(100000000000, 9), // Specified amount to topup (increases deposited amount).
169
169
  };
170
170
 
171
171
  try {
172
- const { ixs, tx } = await StreamClient.topup(topupStreamParams);
172
+ const { ixs, tx } = await StreamClient.topup(topupStreamParams);
173
173
  } catch (exception) {
174
- // handle exception
174
+ // handle exception
175
175
  }
176
176
  ```
177
177
 
@@ -179,15 +179,15 @@ try {
179
179
 
180
180
  ```javascript
181
181
  const data = {
182
- invoker: wallet, // Wallet/Keypair signing the transaction.
183
- id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
184
- recipientId: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier of a stream to be transferred.
182
+ invoker: wallet, // Wallet/Keypair signing the transaction.
183
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
184
+ recipientId: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier of a stream to be transferred.
185
185
  };
186
186
 
187
187
  try {
188
- const { tx } = await StreamClient.transfer(data);
188
+ const { tx } = await StreamClient.transfer(data);
189
189
  } catch (exception) {
190
- // handle exception
190
+ // handle exception
191
191
  }
192
192
  ```
193
193
 
@@ -195,14 +195,14 @@ try {
195
195
 
196
196
  ```javascript
197
197
  const cancelStreamParams = {
198
- invoker: wallet, // Wallet/Keypair signing the transaction.
199
- id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be canceled.
198
+ invoker: wallet, // Wallet/Keypair signing the transaction.
199
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be canceled.
200
200
  };
201
201
 
202
202
  try {
203
- const { ixs, tx } = await StreamClient.cancel(cancelStreamParams);
203
+ const { ixs, tx } = await StreamClient.cancel(cancelStreamParams);
204
204
  } catch (exception) {
205
- // handle exception
205
+ // handle exception
206
206
  }
207
207
  ```
208
208
 
@@ -210,11 +210,11 @@ try {
210
210
 
211
211
  ```javascript
212
212
  try {
213
- const stream = await StreamClient.getOne(
214
- "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA" // Identifier of a stream that is fetched.
215
- );
213
+ const stream = await StreamClient.getOne(
214
+ "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA" // Identifier of a stream that is fetched.
215
+ );
216
216
  } catch (exception) {
217
- // handle exception
217
+ // handle exception
218
218
  }
219
219
  ```
220
220
 
@@ -222,13 +222,13 @@ try {
222
222
 
223
223
  ```javascript
224
224
  try {
225
- const streams = StreamClient.get({
226
- wallet: wallet, // Wallet signing the transaction.
227
- type: StreamType.All, // (optional) Type, default is StreamType.All
228
- direction: StreamDirection.All, // (optional) Direction, default is StreamDirection.All)
229
- });
225
+ const streams = StreamClient.get({
226
+ wallet: wallet, // Wallet signing the transaction.
227
+ type: StreamType.All, // (optional) Type, default is StreamType.All
228
+ direction: StreamDirection.All, // (optional) Direction, default is StreamDirection.All)
229
+ });
230
230
  } catch (exception) {
231
- // handle exception
231
+ // handle exception
232
232
  }
233
233
  ```
234
234
 
@@ -250,4 +250,6 @@ Use `getBN` and `getNumberFromBN` utility functions for conversions between `BN`
250
250
 
251
251
  **Streamflow Community** (free and open source version, with a limited feature set) is available [here](https://github.com/streamflow-finance/js-sdk/tree/community).
252
252
 
253
+ `npx typedoc packages/stream/index.ts`
254
+
253
255
  WAGMI.
package/dist/Stream.js CHANGED
@@ -76,19 +76,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
76
76
  return (mod && mod.__esModule) ? mod : { "default": mod };
77
77
  };
78
78
  Object.defineProperty(exports, "__esModule", { value: true });
79
- var spl_token_1 = require("@solana/spl-token");
79
+ var bn_js_1 = __importDefault(require("bn.js"));
80
80
  var buffer_1 = require("buffer");
81
81
  var anchor_1 = require("@project-serum/anchor");
82
- var spl_token_2 = require("@solana/spl-token");
82
+ var spl_token_1 = require("@solana/spl-token");
83
83
  var web3_js_1 = require("@solana/web3.js");
84
84
  var types_1 = require("./types");
85
85
  var utils_1 = require("./utils");
86
86
  var constants_1 = require("./constants");
87
- var idl_1 = __importDefault(require("./idl"));
87
+ var timelock_1 = __importDefault(require("./idl/timelock"));
88
88
  var encoder = new TextEncoder();
89
89
  var initProgram = function (connection, wallet, cluster) {
90
90
  var provider = new anchor_1.Provider(connection, wallet, {});
91
- return new anchor_1.Program(idl_1.default, constants_1.PROGRAM_ID[cluster], provider);
91
+ return new anchor_1.Program(timelock_1.default, constants_1.PROGRAM_ID[cluster], provider);
92
92
  };
93
93
  var Stream = /** @class */ (function () {
94
94
  function Stream() {
@@ -151,7 +151,7 @@ var Stream = /** @class */ (function () {
151
151
  nameUtf8EncodedArr = encoder.encode(name);
152
152
  return [4 /*yield*/, program.rpc.create(
153
153
  // Order of the parameters must match the ones in the program
154
- new spl_token_1.u64(start), depositedAmount, new spl_token_1.u64(period), amountPerPeriod, new spl_token_1.u64(cliff), cliffAmount, cancelableBySender, cancelableByRecipient, automaticWithdrawal, transferableBySender, transferableByRecipient, canTopup, nameUtf8EncodedArr, new spl_token_1.u64(automaticWithdrawal ? withdrawalFrequency : period), {
154
+ new bn_js_1.default(start), depositedAmount, new bn_js_1.default(period), amountPerPeriod, new bn_js_1.default(cliff), cliffAmount, cancelableBySender, cancelableByRecipient, automaticWithdrawal, transferableBySender, transferableByRecipient, canTopup, nameUtf8EncodedArr, new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period), {
155
155
  accounts: {
156
156
  sender: sender.publicKey,
157
157
  senderTokens: senderTokens,
@@ -167,8 +167,8 @@ var Stream = /** @class */ (function () {
167
167
  feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
168
168
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
169
169
  timelockProgram: program.programId,
170
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
171
- associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
170
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
171
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
172
172
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
173
173
  systemProgram: web3_js_1.SystemProgram.programId,
174
174
  },
@@ -224,7 +224,7 @@ var Stream = /** @class */ (function () {
224
224
  partner: data.partner,
225
225
  partnerTokens: partnerTokens,
226
226
  mint: data.mint,
227
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
227
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
228
228
  },
229
229
  })];
230
230
  case 4:
@@ -278,7 +278,7 @@ var Stream = /** @class */ (function () {
278
278
  partner: data.partner,
279
279
  partnerTokens: partnerTokens,
280
280
  mint: data.mint,
281
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
281
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
282
282
  },
283
283
  })];
284
284
  case 4:
@@ -326,8 +326,8 @@ var Stream = /** @class */ (function () {
326
326
  metadata: stream,
327
327
  mint: mint,
328
328
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
329
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
330
- associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
329
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
330
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
331
331
  systemProgram: anchor_1.web3.SystemProgram.programId,
332
332
  },
333
333
  })];
@@ -380,7 +380,7 @@ var Stream = /** @class */ (function () {
380
380
  partner: partner,
381
381
  partnerTokens: partnerTokens,
382
382
  mint: mint,
383
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
383
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
384
384
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
385
385
  systemProgram: anchor_1.web3.SystemProgram.programId,
386
386
  },
@@ -410,7 +410,7 @@ var Stream = /** @class */ (function () {
410
410
  if (!(escrow === null || escrow === void 0 ? void 0 : escrow.data)) {
411
411
  throw new Error("Couldn't get account info.");
412
412
  }
413
- return [2 /*return*/, (0, utils_1.formatDecodedStream)((0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data))];
413
+ return [2 /*return*/, new types_1.Contract((0, utils_1.decodeStream)(escrow === null || escrow === void 0 ? void 0 : escrow.data))];
414
414
  }
415
415
  });
416
416
  });
@@ -454,7 +454,7 @@ var Stream = /** @class */ (function () {
454
454
  streams = {};
455
455
  accounts.forEach(function (account) {
456
456
  var _a;
457
- var decoded = (0, utils_1.formatDecodedStream)((0, utils_1.decodeStream)(account.account.data));
457
+ var decoded = new types_1.Contract((0, utils_1.decodeStream)(account.account.data));
458
458
  streams = __assign(__assign({}, streams), (_a = {}, _a[account.pubkey.toBase58()] = decoded, _a));
459
459
  });
460
460
  sortedStreams = Object.entries(streams).sort(function (_a, _b) {
@@ -495,7 +495,7 @@ function ata(mint, account) {
495
495
  return __awaiter(this, void 0, void 0, function () {
496
496
  return __generator(this, function (_a) {
497
497
  switch (_a.label) {
498
- case 0: return [4 /*yield*/, spl_token_2.Token.getAssociatedTokenAddress(spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_2.TOKEN_PROGRAM_ID, mint, account, true)];
498
+ 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)];
499
499
  case 1: return [2 /*return*/, _a.sent()];
500
500
  }
501
501
  });
@@ -9,8 +9,9 @@ export default class StreamClient {
9
9
  /**
10
10
  * Create Stream instance
11
11
  */
12
- constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig);
12
+ constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig, programId?: string);
13
13
  getConnection(): web3.Connection;
14
+ getProgramId(): string;
14
15
  /**
15
16
  * Creates a new stream/vesting contract.
16
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).
@@ -19,11 +20,11 @@ export default class StreamClient {
19
20
  * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
20
21
  * @param {string} data.mint - SPL Token mint.
21
22
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
22
- * @param {u64} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
23
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
23
24
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
24
25
  * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
25
- * @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
26
- * @param {u64} data.amountPerPeriod - Amount unlocked per each period.
26
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
27
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
27
28
  * @param {string} data.name - Stream name/subject.
28
29
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
29
30
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
@@ -32,9 +33,42 @@ export default class StreamClient {
32
33
  * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
33
34
  * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
34
35
  * @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.
36
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
35
37
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
36
38
  */
37
- create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateParams): Promise<CreateResponse>;
39
+ create({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
40
+ /**
41
+ * Creates a new stream/vesting contract using unchecked instruction.
42
+ *
43
+ * Unchecked instruction differes from the regular in:
44
+ * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
45
+ * as sender/recipient/partner or there are risks of funds being locked in the contract)
46
+ * - initialized contract PDA off chain
47
+ *
48
+ * If you are not sure if you should use create or create_unchecked, go for create to be safer.
49
+ *
50
+ * @param {CreateParams} data
51
+ * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
52
+ * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
53
+ * @param {string} data.mint - SPL Token mint.
54
+ * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
55
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
56
+ * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
57
+ * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
58
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
59
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
60
+ * @param {string} data.name - Stream name/subject.
61
+ * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
62
+ * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
63
+ * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
64
+ * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
65
+ * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
66
+ * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
67
+ * @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.
68
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
69
+ * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
70
+ */
71
+ createUnchecked({ sender, recipient, mint, start, depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, isNative, }: CreateParams): Promise<CreateResponse>;
38
72
  /**
39
73
  * Creates a new stream/vesting contract.
40
74
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -45,8 +79,6 @@ export default class StreamClient {
45
79
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
46
80
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
47
81
  * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
48
- * @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
49
- * @param {u64} data.amountPerPeriod - Amount unlocked per each period.
50
82
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
51
83
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
52
84
  * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
@@ -54,15 +86,16 @@ export default class StreamClient {
54
86
  * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
55
87
  * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
56
88
  * @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.
89
+ * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
57
90
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
58
91
  */
59
- createMultiple({ sender, recipientsData, mint, start, period, cliff, cliffAmount, amountPerPeriod, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateMultiParams): Promise<CreateMultiResponse>;
92
+ createMultiple(data: CreateMultiParams): Promise<CreateMultiResponse>;
60
93
  /**
61
94
  * Attempts withdrawal from the specified stream.
62
95
  * @param {WithdrawParams} data
63
96
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
64
97
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
65
- * @param {u64} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
98
+ * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
66
99
  */
67
100
  withdraw({ invoker, id, amount, }: WithdrawParams): Promise<TxResponse>;
68
101
  /**
@@ -86,9 +119,9 @@ export default class StreamClient {
86
119
  * @param {TopupParams} data
87
120
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
88
121
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
89
- * @param {u64} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
122
+ * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
90
123
  */
91
- topup({ invoker, id, amount, }: TopupParams): Promise<TxResponse>;
124
+ topup({ invoker, id, amount, isNative, }: TopupParams): Promise<TxResponse>;
92
125
  /**
93
126
  * Fetch stream data by its id (address).
94
127
  * @param {string} id - Identifier of a stream that is fetched.
@@ -104,4 +137,10 @@ export default class StreamClient {
104
137
  */
105
138
  get({ wallet, type, direction, }: GetAllParams): Promise<[string, StreamData][]>;
106
139
  private sign;
140
+ /**
141
+ * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
142
+ * @param {MultiRecipient} recipient - Wallet sending stream to
143
+ * @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
144
+ */
145
+ private prepareStreamTransaction;
107
146
  }