@streamflow/stream 3.0.0 → 3.0.1-test.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
@@ -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,10 +76,10 @@ 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");
@@ -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
  },
@@ -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
  });
@@ -19,11 +19,11 @@ export default class StreamClient {
19
19
  * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
20
20
  * @param {string} data.mint - SPL Token mint.
21
21
  * @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).
22
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
23
23
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
24
24
  * @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.
25
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
26
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
27
27
  * @param {string} data.name - Stream name/subject.
28
28
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
29
29
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
@@ -45,8 +45,6 @@ export default class StreamClient {
45
45
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
46
46
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
47
47
  * @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
48
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
51
49
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
52
50
  * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
@@ -56,13 +54,13 @@ export default class StreamClient {
56
54
  * @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.
57
55
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
58
56
  */
59
- createMultiple({ sender, recipientsData, mint, start, period, cliff, cliffAmount, amountPerPeriod, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateMultiParams): Promise<CreateMultiResponse>;
57
+ createMultiple({ sender, recipientsData, mint, start, period, cliff, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: CreateMultiParams): Promise<CreateMultiResponse>;
60
58
  /**
61
59
  * Attempts withdrawal from the specified stream.
62
60
  * @param {WithdrawParams} data
63
61
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
64
62
  * @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.
63
+ * @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
64
  */
67
65
  withdraw({ invoker, id, amount, }: WithdrawParams): Promise<TxResponse>;
68
66
  /**
@@ -86,7 +84,7 @@ export default class StreamClient {
86
84
  * @param {TopupParams} data
87
85
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
88
86
  * @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).
87
+ * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
90
88
  */
91
89
  topup({ invoker, id, amount, }: TopupParams): Promise<TxResponse>;
92
90
  /**
@@ -83,11 +83,14 @@ var __values = (this && this.__values) || function(o) {
83
83
  };
84
84
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
85
85
  };
86
+ var __importDefault = (this && this.__importDefault) || function (mod) {
87
+ return (mod && mod.__esModule) ? mod : { "default": mod };
88
+ };
86
89
  Object.defineProperty(exports, "__esModule", { value: true });
87
- var spl_token_1 = require("@solana/spl-token");
90
+ var bn_js_1 = __importDefault(require("bn.js"));
88
91
  var buffer_1 = require("buffer");
89
92
  var anchor_1 = require("@project-serum/anchor");
90
- var spl_token_2 = require("@solana/spl-token");
93
+ var spl_token_1 = require("@solana/spl-token");
91
94
  var web3_js_1 = require("@solana/web3.js");
92
95
  var types_1 = require("./types");
93
96
  var utils_1 = require("./utils");
@@ -116,11 +119,11 @@ var StreamClient = /** @class */ (function () {
116
119
  * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
117
120
  * @param {string} data.mint - SPL Token mint.
118
121
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
119
- * @param {u64} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
122
+ * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
120
123
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
121
124
  * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
122
- * @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
123
- * @param {u64} data.amountPerPeriod - Amount unlocked per each period.
125
+ * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
126
+ * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
124
127
  * @param {string} data.name - Stream name/subject.
125
128
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
126
129
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
@@ -162,11 +165,11 @@ var StreamClient = /** @class */ (function () {
162
165
  case 5:
163
166
  partnerTokens = _g.sent();
164
167
  ixs.push((0, instructions_1.createStreamInstruction)({
165
- start: new spl_token_1.u64(start),
168
+ start: new bn_js_1.default(start),
166
169
  depositedAmount: depositedAmount,
167
- period: new spl_token_1.u64(period),
170
+ period: new bn_js_1.default(period),
168
171
  amountPerPeriod: amountPerPeriod,
169
- cliff: new spl_token_1.u64(cliff),
172
+ cliff: new bn_js_1.default(cliff),
170
173
  cliffAmount: cliffAmount,
171
174
  cancelableBySender: cancelableBySender,
172
175
  cancelableByRecipient: cancelableByRecipient,
@@ -175,7 +178,7 @@ var StreamClient = /** @class */ (function () {
175
178
  transferableByRecipient: transferableByRecipient,
176
179
  canTopup: canTopup,
177
180
  name: name,
178
- withdrawFrequency: new spl_token_1.u64(automaticWithdrawal ? withdrawalFrequency : period),
181
+ withdrawFrequency: new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period),
179
182
  }, this.programId, {
180
183
  sender: sender.publicKey,
181
184
  senderTokens: senderTokens,
@@ -191,8 +194,8 @@ var StreamClient = /** @class */ (function () {
191
194
  feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
192
195
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
193
196
  timelockProgram: this.programId,
194
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
195
- associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
197
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
198
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
196
199
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
197
200
  systemProgram: web3_js_1.SystemProgram.programId,
198
201
  }));
@@ -225,8 +228,6 @@ var StreamClient = /** @class */ (function () {
225
228
  * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
226
229
  * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
227
230
  * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
228
- * @param {u64} data.cliffAmount - Amount unlocked at the "cliff".
229
- * @param {u64} data.amountPerPeriod - Amount unlocked per each period.
230
231
  * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
231
232
  * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
232
233
  * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
@@ -237,9 +238,9 @@ var StreamClient = /** @class */ (function () {
237
238
  * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
238
239
  */
239
240
  StreamClient.prototype.createMultiple = function (_a) {
240
- var sender = _a.sender, recipientsData = _a.recipientsData, mint = _a.mint, start = _a.start, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _b = _a.automaticWithdrawal, automaticWithdrawal = _b === void 0 ? false : _b, _c = _a.withdrawalFrequency, withdrawalFrequency = _c === void 0 ? 0 : _c, _d = _a.partner, partner = _d === void 0 ? null : _d;
241
+ var sender = _a.sender, recipientsData = _a.recipientsData, mint = _a.mint, start = _a.start, period = _a.period, cliff = _a.cliff, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _b = _a.automaticWithdrawal, automaticWithdrawal = _b === void 0 ? false : _b, _c = _a.withdrawalFrequency, withdrawalFrequency = _c === void 0 ? 0 : _c, _d = _a.partner, partner = _d === void 0 ? null : _d;
241
242
  return __awaiter(this, void 0, void 0, function () {
242
- var mintPublicKey, batch, commitment, recipientsData_1, recipientsData_1_1, recipient, ixs, recipientPublicKey, metadata, _e, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx, e_1_1, signed_batch, sigs, i, buf, signature;
243
+ var mintPublicKey, batch, commitment, metadatas, recipientsData_1, recipientsData_1_1, recipient, ixs, recipientPublicKey, metadata, _e, escrowTokens, senderTokens, recipientTokens, streamflowTreasuryTokens, partnerPublicKey, partnerTokens, hash, tx, e_1_1, signed_batch, sigs, i, buf, signature;
243
244
  var e_1, _f, _g;
244
245
  return __generator(this, function (_h) {
245
246
  switch (_h.label) {
@@ -249,6 +250,7 @@ var StreamClient = /** @class */ (function () {
249
250
  commitment = typeof this.commitment == "string"
250
251
  ? this.commitment
251
252
  : this.commitment.commitment;
253
+ metadatas = [];
252
254
  _h.label = 1;
253
255
  case 1:
254
256
  _h.trys.push([1, 11, 12, 13]);
@@ -260,6 +262,7 @@ var StreamClient = /** @class */ (function () {
260
262
  ixs = [];
261
263
  recipientPublicKey = new web3_js_1.PublicKey(recipient.recipient);
262
264
  metadata = web3_js_1.Keypair.generate();
265
+ metadatas.push(metadata);
263
266
  return [4 /*yield*/, anchor_1.web3.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
264
267
  case 3:
265
268
  _e = __read.apply(void 0, [_h.sent(), 1]), escrowTokens = _e[0];
@@ -279,12 +282,12 @@ var StreamClient = /** @class */ (function () {
279
282
  case 7:
280
283
  partnerTokens = _h.sent();
281
284
  ixs.push((0, instructions_1.createStreamInstruction)({
282
- start: new spl_token_1.u64(start),
285
+ start: new bn_js_1.default(start),
283
286
  depositedAmount: recipient.depositedAmount,
284
- period: new spl_token_1.u64(period),
285
- amountPerPeriod: amountPerPeriod,
286
- cliff: new spl_token_1.u64(cliff),
287
- cliffAmount: cliffAmount,
287
+ period: new bn_js_1.default(period),
288
+ amountPerPeriod: recipient.amountPerPeriod,
289
+ cliff: new bn_js_1.default(cliff),
290
+ cliffAmount: recipient.cliffAmount,
288
291
  cancelableBySender: cancelableBySender,
289
292
  cancelableByRecipient: cancelableByRecipient,
290
293
  automaticWithdrawal: automaticWithdrawal,
@@ -292,7 +295,7 @@ var StreamClient = /** @class */ (function () {
292
295
  transferableByRecipient: transferableByRecipient,
293
296
  canTopup: canTopup,
294
297
  name: recipient.name,
295
- withdrawFrequency: new spl_token_1.u64(automaticWithdrawal ? withdrawalFrequency : period),
298
+ withdrawFrequency: new bn_js_1.default(automaticWithdrawal ? withdrawalFrequency : period),
296
299
  }, this.programId, {
297
300
  sender: sender.publicKey,
298
301
  senderTokens: senderTokens,
@@ -308,8 +311,8 @@ var StreamClient = /** @class */ (function () {
308
311
  feeOracle: constants_1.FEE_ORACLE_PUBLIC_KEY,
309
312
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
310
313
  timelockProgram: this.programId,
311
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
312
- associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
314
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
315
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
313
316
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
314
317
  systemProgram: web3_js_1.SystemProgram.programId,
315
318
  }));
@@ -368,7 +371,7 @@ var StreamClient = /** @class */ (function () {
368
371
  case 20:
369
372
  i++;
370
373
  return [3 /*break*/, 18];
371
- case 21: return [2 /*return*/, { txs: sigs }];
374
+ case 21: return [2 /*return*/, { txs: sigs, metadatas: metadatas }];
372
375
  }
373
376
  });
374
377
  });
@@ -378,7 +381,7 @@ var StreamClient = /** @class */ (function () {
378
381
  * @param {WithdrawParams} data
379
382
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
380
383
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
381
- * @param {u64} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
384
+ * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
382
385
  */
383
386
  StreamClient.prototype.withdraw = function (_a) {
384
387
  var invoker = _a.invoker, id = _a.id, amount = _a.amount;
@@ -414,7 +417,7 @@ var StreamClient = /** @class */ (function () {
414
417
  partner: data.partner,
415
418
  partnerTokens: partnerTokens,
416
419
  mint: data.mint,
417
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
420
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
418
421
  }));
419
422
  commitment = typeof this.commitment == "string"
420
423
  ? this.commitment
@@ -476,7 +479,7 @@ var StreamClient = /** @class */ (function () {
476
479
  partner: data.partner,
477
480
  partnerTokens: partnerTokens,
478
481
  mint: data.mint,
479
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
482
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
480
483
  }));
481
484
  commitment = typeof this.commitment == "string"
482
485
  ? this.commitment
@@ -532,8 +535,8 @@ var StreamClient = /** @class */ (function () {
532
535
  metadata: stream,
533
536
  mint: mint,
534
537
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
535
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
536
- associatedTokenProgram: spl_token_2.ASSOCIATED_TOKEN_PROGRAM_ID,
538
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
539
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
537
540
  systemProgram: web3_js_1.SystemProgram.programId,
538
541
  }));
539
542
  commitment = typeof this.commitment == "string"
@@ -559,7 +562,7 @@ var StreamClient = /** @class */ (function () {
559
562
  * @param {TopupParams} data
560
563
  * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
561
564
  * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
562
- * @param {u64} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
565
+ * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
563
566
  */
564
567
  StreamClient.prototype.topup = function (_a) {
565
568
  var invoker = _a.invoker, id = _a.id, amount = _a.amount;
@@ -594,7 +597,7 @@ var StreamClient = /** @class */ (function () {
594
597
  partner: partner,
595
598
  partnerTokens: partnerTokens,
596
599
  mint: mint,
597
- tokenProgram: spl_token_2.TOKEN_PROGRAM_ID,
600
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
598
601
  withdrawor: constants_1.WITHDRAWOR_PUBLIC_KEY,
599
602
  systemProgram: web3_js_1.SystemProgram.programId,
600
603
  }));
@@ -739,7 +742,7 @@ function ata(mint, account) {
739
742
  return __awaiter(this, void 0, void 0, function () {
740
743
  return __generator(this, function (_a) {
741
744
  switch (_a.label) {
742
- 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)];
745
+ 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)];
743
746
  case 1: return [2 /*return*/, _a.sent()];
744
747
  }
745
748
  });
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { default as StreamClient } from "./StreamClient";
3
3
  export * from "./utils";
4
4
  export * from "./types";
5
5
  export * from "./instructions";
6
- export { u64 as BN } from "@solana/spl-token";
6
+ export { default as BN } from "bn.js";
package/dist/index.js CHANGED
@@ -21,5 +21,5 @@ Object.defineProperty(exports, "StreamClient", { enumerable: true, get: function
21
21
  __exportStar(require("./utils"), exports);
22
22
  __exportStar(require("./types"), exports);
23
23
  __exportStar(require("./instructions"), exports);
24
- var spl_token_1 = require("@solana/spl-token");
25
- Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return spl_token_1.u64; } });
24
+ var bn_js_1 = require("bn.js");
25
+ Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return __importDefault(bn_js_1).default; } });
@@ -1,12 +1,12 @@
1
1
  import { PublicKey, TransactionInstruction } from "@solana/web3.js";
2
- import { u64 } from "@solana/spl-token";
2
+ import BN from "bn.js";
3
3
  interface CreateStreamData {
4
- start: u64;
5
- depositedAmount: u64;
6
- period: u64;
7
- amountPerPeriod: u64;
8
- cliff: u64;
9
- cliffAmount: u64;
4
+ start: BN;
5
+ depositedAmount: BN;
6
+ period: BN;
7
+ amountPerPeriod: BN;
8
+ cliff: BN;
9
+ cliffAmount: BN;
10
10
  cancelableBySender: boolean;
11
11
  cancelableByRecipient: boolean;
12
12
  automaticWithdrawal: boolean;
@@ -14,7 +14,7 @@ interface CreateStreamData {
14
14
  transferableByRecipient: boolean;
15
15
  canTopup: boolean;
16
16
  name: string;
17
- withdrawFrequency: u64;
17
+ withdrawFrequency: BN;
18
18
  }
19
19
  interface CreateStreamAccounts {
20
20
  sender: PublicKey;
@@ -50,7 +50,7 @@ interface WithdrawAccounts {
50
50
  mint: PublicKey;
51
51
  tokenProgram: PublicKey;
52
52
  }
53
- export declare const withdrawStreamInstruction: (amount: u64, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => TransactionInstruction;
53
+ export declare const withdrawStreamInstruction: (amount: BN, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => TransactionInstruction;
54
54
  interface CancelAccounts {
55
55
  authority: PublicKey;
56
56
  sender: PublicKey;
@@ -93,5 +93,5 @@ interface TopupAccounts {
93
93
  withdrawor: PublicKey;
94
94
  systemProgram: PublicKey;
95
95
  }
96
- export declare const topupStreamInstruction: (amount: u64, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction;
96
+ export declare const topupStreamInstruction: (amount: BN, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction;
97
97
  export {};
@@ -61,12 +61,12 @@ var createStreamInstruction = function (data, programId, accounts) {
61
61
  var encodedUIntArray = new TextEncoder().encode(data.name);
62
62
  var streamNameBuffer = buffer_1.Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
63
63
  var decodedData = {
64
- start_time: data.start.toBuffer(),
65
- net_amount_deposited: data.depositedAmount.toBuffer(),
66
- period: data.period.toBuffer(),
67
- amount_per_period: data.amountPerPeriod.toBuffer(),
68
- cliff: data.cliff.toBuffer(),
69
- cliff_amount: data.cliffAmount.toBuffer(),
64
+ start_time: data.start.toArrayLike(buffer_1.Buffer, "le", 8),
65
+ net_amount_deposited: data.depositedAmount.toArrayLike(buffer_1.Buffer, "le", 8),
66
+ period: data.period.toArrayLike(buffer_1.Buffer, "le", 8),
67
+ amount_per_period: data.amountPerPeriod.toArrayLike(buffer_1.Buffer, "le", 8),
68
+ cliff: data.cliff.toArrayLike(buffer_1.Buffer, "le", 8),
69
+ cliff_amount: data.cliffAmount.toArrayLike(buffer_1.Buffer, "le", 8),
70
70
  cancelable_by_sender: data.cancelableBySender,
71
71
  cancelable_by_recipient: data.cancelableByRecipient,
72
72
  automatic_withdrawal: data.automaticWithdrawal,
@@ -74,7 +74,7 @@ var createStreamInstruction = function (data, programId, accounts) {
74
74
  transferable_by_recipient: data.transferableByRecipient,
75
75
  can_topup: data.canTopup,
76
76
  stream_name: streamNameBuffer,
77
- withdraw_frequency: data.withdrawFrequency.toBuffer(),
77
+ withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer_1.Buffer, "le", 8),
78
78
  };
79
79
  var encodeLength = Layout.createStreamLayout.encode(decodedData, bufferData);
80
80
  bufferData = bufferData.slice(0, encodeLength);
@@ -109,7 +109,7 @@ var withdrawStreamInstruction = function (amount, programId, _a) {
109
109
  { pubkey: tokenProgram, isSigner: false, isWritable: false },
110
110
  ];
111
111
  var data = buffer_1.Buffer.alloc(Layout.withdrawStreamLayout.span);
112
- var decodedData = { amount: amount.toBuffer() };
112
+ var decodedData = { amount: amount.toArrayLike(buffer_1.Buffer, "le", 8) };
113
113
  var encodeLength = Layout.withdrawStreamLayout.encode(decodedData, data);
114
114
  data = data.slice(0, encodeLength);
115
115
  data = buffer_1.Buffer.concat([
@@ -194,7 +194,7 @@ var topupStreamInstruction = function (amount, programId, _a) {
194
194
  { pubkey: systemProgram, isSigner: false, isWritable: false },
195
195
  ];
196
196
  var data = buffer_1.Buffer.alloc(Layout.topupStreamLayout.span);
197
- var decodedData = { amount: amount.toBuffer() };
197
+ var decodedData = { amount: amount.toArrayLike(buffer_1.Buffer, "le", 8) };
198
198
  var encodeLength = Layout.topupStreamLayout.encode(decodedData, data);
199
199
  data = data.slice(0, encodeLength);
200
200
  data = buffer_1.Buffer.concat([
package/dist/types.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Wallet } from "@project-serum/anchor/src/provider";
3
3
  import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
4
4
  import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, TransactionInstruction } from "@solana/web3.js";
5
- import { u64 } from "@solana/spl-token";
5
+ import BN from "bn.js";
6
6
  export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
7
7
  export declare enum StreamDirection {
8
8
  Outgoing = "outgoing",
@@ -26,11 +26,11 @@ export interface CreateStreamData {
26
26
  recipient: string;
27
27
  mint: string;
28
28
  start: number;
29
- depositedAmount: u64;
29
+ depositedAmount: BN;
30
30
  period: number;
31
31
  cliff: number;
32
- cliffAmount: u64;
33
- amountPerPeriod: u64;
32
+ cliffAmount: BN;
33
+ amountPerPeriod: BN;
34
34
  name: string;
35
35
  canTopup: boolean;
36
36
  cancelableBySender: boolean;
@@ -42,8 +42,10 @@ export interface CreateStreamData {
42
42
  }
43
43
  export interface MultiRecipient {
44
44
  recipient: string;
45
- depositedAmount: u64;
45
+ depositedAmount: BN;
46
46
  name: string;
47
+ cliffAmount: BN;
48
+ amountPerPeriod: BN;
47
49
  }
48
50
  export interface CreateMultiData {
49
51
  recipientsData: MultiRecipient[];
@@ -51,8 +53,6 @@ export interface CreateMultiData {
51
53
  start: number;
52
54
  period: number;
53
55
  cliff: number;
54
- cliffAmount: u64;
55
- amountPerPeriod: u64;
56
56
  canTopup: boolean;
57
57
  cancelableBySender: boolean;
58
58
  cancelableByRecipient: boolean;
@@ -77,7 +77,7 @@ export interface CreateMultiParams extends CreateMultiData {
77
77
  }
78
78
  export interface WithdrawStreamData {
79
79
  id: string;
80
- amount: u64;
80
+ amount: BN;
81
81
  }
82
82
  export interface WithdrawStreamParams extends WithdrawStreamData {
83
83
  connection: Connection;
@@ -89,7 +89,7 @@ export interface WithdrawParams extends WithdrawStreamData {
89
89
  }
90
90
  export interface TopupStreamData {
91
91
  id: string;
92
- amount: u64;
92
+ amount: BN;
93
93
  }
94
94
  export interface TopupStreamParams extends TopupStreamData {
95
95
  connection: Connection;
@@ -142,7 +142,7 @@ export interface Stream {
142
142
  magic: number;
143
143
  version: number;
144
144
  createdAt: number;
145
- withdrawnAmount: u64;
145
+ withdrawnAmount: BN;
146
146
  canceledAt: number;
147
147
  end: number;
148
148
  lastWithdrawnAt: number;
@@ -154,20 +154,20 @@ export interface Stream {
154
154
  escrowTokens: string;
155
155
  streamflowTreasury: string;
156
156
  streamflowTreasuryTokens: string;
157
- streamflowFeeTotal: u64;
158
- streamflowFeeWithdrawn: u64;
157
+ streamflowFeeTotal: BN;
158
+ streamflowFeeWithdrawn: BN;
159
159
  streamflowFeePercent: number;
160
- partnerFeeTotal: u64;
161
- partnerFeeWithdrawn: u64;
160
+ partnerFeeTotal: BN;
161
+ partnerFeeWithdrawn: BN;
162
162
  partnerFeePercent: number;
163
163
  partner: string;
164
164
  partnerTokens: string;
165
165
  start: number;
166
- depositedAmount: u64;
166
+ depositedAmount: BN;
167
167
  period: number;
168
- amountPerPeriod: u64;
168
+ amountPerPeriod: BN;
169
169
  cliff: number;
170
- cliffAmount: u64;
170
+ cliffAmount: BN;
171
171
  cancelableBySender: boolean;
172
172
  cancelableByRecipient: boolean;
173
173
  automaticWithdrawal: boolean;
@@ -178,13 +178,13 @@ export interface Stream {
178
178
  withdrawalFrequency: number;
179
179
  }
180
180
  export interface DecodedStream {
181
- magic: u64;
182
- version: u64;
183
- createdAt: u64;
184
- withdrawnAmount: u64;
185
- canceledAt: u64;
186
- end: u64;
187
- lastWithdrawnAt: u64;
181
+ magic: BN;
182
+ version: BN;
183
+ createdAt: BN;
184
+ withdrawnAmount: BN;
185
+ canceledAt: BN;
186
+ end: BN;
187
+ lastWithdrawnAt: BN;
188
188
  sender: PublicKey;
189
189
  senderTokens: PublicKey;
190
190
  recipient: PublicKey;
@@ -193,20 +193,20 @@ export interface DecodedStream {
193
193
  escrowTokens: PublicKey;
194
194
  streamflowTreasury: PublicKey;
195
195
  streamflowTreasuryTokens: PublicKey;
196
- streamflowFeeTotal: u64;
197
- streamflowFeeWithdrawn: u64;
198
- streamflowFeePercent: u64;
199
- partnerFeeTotal: u64;
200
- partnerFeeWithdrawn: u64;
201
- partnerFeePercent: u64;
196
+ streamflowFeeTotal: BN;
197
+ streamflowFeeWithdrawn: BN;
198
+ streamflowFeePercent: BN;
199
+ partnerFeeTotal: BN;
200
+ partnerFeeWithdrawn: BN;
201
+ partnerFeePercent: BN;
202
202
  partner: PublicKey;
203
203
  partnerTokens: PublicKey;
204
- start: u64;
205
- depositedAmount: u64;
206
- period: u64;
207
- amountPerPeriod: u64;
208
- cliff: u64;
209
- cliffAmount: u64;
204
+ start: BN;
205
+ depositedAmount: BN;
206
+ period: BN;
207
+ amountPerPeriod: BN;
208
+ cliff: BN;
209
+ cliffAmount: BN;
210
210
  cancelableBySender: boolean;
211
211
  cancelableByRecipient: boolean;
212
212
  automaticWithdrawal: boolean;
@@ -214,7 +214,7 @@ export interface DecodedStream {
214
214
  transferableByRecipient: boolean;
215
215
  canTopup: boolean;
216
216
  name: string;
217
- withdrawFrequency: u64;
217
+ withdrawFrequency: BN;
218
218
  }
219
219
  export interface TransactionResponse {
220
220
  tx: TransactionSignature;
@@ -231,4 +231,5 @@ export interface CreateResponse extends TxResponse {
231
231
  }
232
232
  export interface CreateMultiResponse {
233
233
  txs: TransactionSignature[];
234
+ metadatas: Keypair[];
234
235
  }
package/dist/utils.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  /// <reference types="node" />
2
- import { u64 } from "@solana/spl-token";
2
+ import BN from "bn.js";
3
3
  import { Stream, DecodedStream } from "./types";
4
4
  export declare const decodeStream: (buf: Buffer) => DecodedStream;
5
5
  export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
6
6
  /**
7
7
  * Used for conversion of token amounts to their Big Number representation.
8
8
  * Get Big Number representation in the smallest units from the same value in the highest units.
9
- * @param {number} value - Number of tokens you want to convert to its u64 representation.
9
+ * @param {number} value - Number of tokens you want to convert to its BN representation.
10
10
  * @param {number} decimals - Number of decimals the token has.
11
11
  */
12
- export declare const getBN: (value: number, decimals: number) => u64;
12
+ export declare const getBN: (value: number, decimals: number) => BN;
13
13
  /**
14
14
  * Used for token amounts conversion from their Big Number representation to number.
15
- * Get value in the highest units from u64 representation of the same value in the smallest units.
16
- * @param {u64} value - Big Number representation of value in the smallest units.
15
+ * Get value in the highest units from BN representation of the same value in the smallest units.
16
+ * @param {BN} value - Big Number representation of value in the smallest units.
17
17
  * @param {number} decimals - Number of decimals the token has.
18
18
  */
19
- export declare const getNumberFromBN: (value: u64, decimals: number) => number;
19
+ export declare const getNumberFromBN: (value: BN, decimals: number) => number;
package/dist/utils.js CHANGED
@@ -1,21 +1,24 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getNumberFromBN = exports.getBN = exports.formatDecodedStream = exports.decodeStream = void 0;
4
7
  var web3_js_1 = require("@solana/web3.js");
5
- var spl_token_1 = require("@solana/spl-token");
8
+ var bn_js_1 = __importDefault(require("bn.js"));
6
9
  var layout_1 = require("./layout");
7
10
  var decoder = new TextDecoder("utf-8");
8
11
  var LE = "le"; //little endian
9
12
  var decodeStream = function (buf) {
10
13
  var raw = layout_1.streamLayout.decode(buf);
11
14
  return {
12
- magic: new spl_token_1.u64(raw.magic, LE),
13
- version: new spl_token_1.u64(raw.version, LE),
14
- createdAt: new spl_token_1.u64(raw.created_at, LE),
15
- withdrawnAmount: new spl_token_1.u64(raw.withdrawn_amount, LE),
16
- canceledAt: new spl_token_1.u64(raw.canceled_at, LE),
17
- end: new spl_token_1.u64(raw.end_time, LE),
18
- lastWithdrawnAt: new spl_token_1.u64(raw.last_withdrawn_at, LE),
15
+ magic: new bn_js_1.default(raw.magic, LE),
16
+ version: new bn_js_1.default(raw.version, LE),
17
+ createdAt: new bn_js_1.default(raw.created_at, LE),
18
+ withdrawnAmount: new bn_js_1.default(raw.withdrawn_amount, LE),
19
+ canceledAt: new bn_js_1.default(raw.canceled_at, LE),
20
+ end: new bn_js_1.default(raw.end_time, LE),
21
+ lastWithdrawnAt: new bn_js_1.default(raw.last_withdrawn_at, LE),
19
22
  sender: new web3_js_1.PublicKey(raw.sender),
20
23
  senderTokens: new web3_js_1.PublicKey(raw.sender_tokens),
21
24
  recipient: new web3_js_1.PublicKey(raw.recipient),
@@ -24,20 +27,20 @@ var decodeStream = function (buf) {
24
27
  escrowTokens: new web3_js_1.PublicKey(raw.escrow_tokens),
25
28
  streamflowTreasury: new web3_js_1.PublicKey(raw.streamflow_treasury),
26
29
  streamflowTreasuryTokens: new web3_js_1.PublicKey(raw.streamflow_treasury_tokens),
27
- streamflowFeeTotal: new spl_token_1.u64(raw.streamflow_fee_total, LE),
28
- streamflowFeeWithdrawn: new spl_token_1.u64(raw.streamflow_fee_withdrawn, LE),
29
- streamflowFeePercent: new spl_token_1.u64(raw.streamflow_fee_percent, LE),
30
- partnerFeeTotal: new spl_token_1.u64(raw.partner_fee_total, LE),
31
- partnerFeeWithdrawn: new spl_token_1.u64(raw.partner_fee_withdrawn, LE),
32
- partnerFeePercent: new spl_token_1.u64(raw.partner_fee_percent, LE),
30
+ streamflowFeeTotal: new bn_js_1.default(raw.streamflow_fee_total, LE),
31
+ streamflowFeeWithdrawn: new bn_js_1.default(raw.streamflow_fee_withdrawn, LE),
32
+ streamflowFeePercent: new bn_js_1.default(raw.streamflow_fee_percent, LE),
33
+ partnerFeeTotal: new bn_js_1.default(raw.partner_fee_total, LE),
34
+ partnerFeeWithdrawn: new bn_js_1.default(raw.partner_fee_withdrawn, LE),
35
+ partnerFeePercent: new bn_js_1.default(raw.partner_fee_percent, LE),
33
36
  partner: new web3_js_1.PublicKey(raw.partner),
34
37
  partnerTokens: new web3_js_1.PublicKey(raw.partner_tokens),
35
- start: new spl_token_1.u64(raw.start_time, LE),
36
- depositedAmount: new spl_token_1.u64(raw.net_amount_deposited, LE),
37
- period: new spl_token_1.u64(raw.period, LE),
38
- amountPerPeriod: new spl_token_1.u64(raw.amount_per_period, LE),
39
- cliff: new spl_token_1.u64(raw.cliff, LE),
40
- cliffAmount: new spl_token_1.u64(raw.cliff_amount, LE),
38
+ start: new bn_js_1.default(raw.start_time, LE),
39
+ depositedAmount: new bn_js_1.default(raw.net_amount_deposited, LE),
40
+ period: new bn_js_1.default(raw.period, LE),
41
+ amountPerPeriod: new bn_js_1.default(raw.amount_per_period, LE),
42
+ cliff: new bn_js_1.default(raw.cliff, LE),
43
+ cliffAmount: new bn_js_1.default(raw.cliff_amount, LE),
41
44
  cancelableBySender: Boolean(raw.cancelable_by_sender),
42
45
  cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
43
46
  automaticWithdrawal: Boolean(raw.automatic_withdrawal),
@@ -45,7 +48,7 @@ var decodeStream = function (buf) {
45
48
  transferableByRecipient: Boolean(raw.transferable_by_recipient),
46
49
  canTopup: Boolean(raw.can_topup),
47
50
  name: decoder.decode(raw.stream_name),
48
- withdrawFrequency: new spl_token_1.u64(raw.withdraw_frequency, LE),
51
+ withdrawFrequency: new bn_js_1.default(raw.withdraw_frequency, LE),
49
52
  };
50
53
  };
51
54
  exports.decodeStream = decodeStream;
@@ -95,24 +98,24 @@ exports.formatDecodedStream = formatDecodedStream;
95
98
  /**
96
99
  * Used for conversion of token amounts to their Big Number representation.
97
100
  * Get Big Number representation in the smallest units from the same value in the highest units.
98
- * @param {number} value - Number of tokens you want to convert to its u64 representation.
101
+ * @param {number} value - Number of tokens you want to convert to its BN representation.
99
102
  * @param {number} decimals - Number of decimals the token has.
100
103
  */
101
104
  var getBN = function (value, decimals) {
102
105
  return value > (Math.pow(2, 53) - 1) / Math.pow(10, decimals)
103
- ? new spl_token_1.u64(value).mul(new spl_token_1.u64(Math.pow(10, decimals)))
104
- : new spl_token_1.u64(value * Math.pow(10, decimals));
106
+ ? new bn_js_1.default(value).mul(new bn_js_1.default(Math.pow(10, decimals)))
107
+ : new bn_js_1.default(value * Math.pow(10, decimals));
105
108
  };
106
109
  exports.getBN = getBN;
107
110
  /**
108
111
  * Used for token amounts conversion from their Big Number representation to number.
109
- * Get value in the highest units from u64 representation of the same value in the smallest units.
110
- * @param {u64} value - Big Number representation of value in the smallest units.
112
+ * Get value in the highest units from BN representation of the same value in the smallest units.
113
+ * @param {BN} value - Big Number representation of value in the smallest units.
111
114
  * @param {number} decimals - Number of decimals the token has.
112
115
  */
113
116
  var getNumberFromBN = function (value, decimals) {
114
- return value.gt(new spl_token_1.u64(Math.pow(2, 53) - 1))
115
- ? value.div(new spl_token_1.u64(Math.pow(10, decimals))).toNumber()
117
+ return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1))
118
+ ? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber()
116
119
  : value.toNumber() / Math.pow(10, decimals);
117
120
  };
118
121
  exports.getNumberFromBN = getNumberFromBN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "3.0.0",
3
+ "version": "3.0.1-test.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/",