@streamflow/stream 8.8.1 → 8.9.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
@@ -1,9 +1,41 @@
1
- ## JS SDK to interact with Streamflow protocol.
1
+ ## JS SDK to interact with the Streamflow protocol.
2
2
 
3
3
  This package allows you to `create`, `createMultiple`, `withdraw`, `cancel`, `topup`, `transfer`, `update` a token stream.
4
4
 
5
5
  You can also `getOne` stream and `get` multiple streams.
6
6
 
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Documentation](#documentation)
11
+ - [Import SDK](#import-sdk)
12
+ - [Create StreamClient instance](#create-streamclient-instance)
13
+ - [Chain-specific clients](#chain-specific-clients)
14
+ - [Generic Stream Client](#generic-stream-client)
15
+ - [Chain-specific Parameters](#chain-specific-parameters)
16
+ - [Create a Vesting Stream](#create-a-vesting-stream)
17
+ - [Streamflow App Vesting criteria](#streamflow-app-vesting-criteria)
18
+ - [Example for creating a Vesting Stream](#example-for-creating-a-vesting-stream)
19
+ - [Create a Token Lock](#create-a-token-lock)
20
+ - [Streamflow app token lock criteria](#streamflow-app-token-lock-criteria)
21
+ - [Example for creating a token lock](#example-for-creating-a-token-lock)
22
+ - [General Stream creation](#general-stream-creation)
23
+ - [Create multiple streams at once](#create-multiple-streams-at-once)
24
+ - [Identifying created Streams](#identifying-created-streams)
25
+ - [Withdraw from stream](#withdraw-from-stream)
26
+ - [Automatic withdrawal](#automatic-withdrawal)
27
+ - [Topup stream](#topup-stream)
28
+ - [Transfer stream to another recipient](#transfer-stream-to-another-recipient)
29
+ - [Cancel stream](#cancel-stream)
30
+ - [Update a stream](#update-a-stream)
31
+ - [Get one stream by its ID](#get-one-stream-by-its-id)
32
+ - [Fetching unlocked amount](#fetching-unlocked-amount)
33
+ - [Reading withdrawn amount and remaining funds](#reading-withdrawn-amount-and-remaining-funds)
34
+ - [Get multiple streams for a specific wallet address](#get-multiple-streams-for-a-specific-wallet-address)
35
+ - [Search Solana Streams](#search-solana-streams)
36
+ - [Handling errors](#handling-errors)
37
+ - [Additional notes](#additional-notes)
38
+
7
39
  ---
8
40
 
9
41
  ## Installation
@@ -30,95 +62,203 @@ _Check the SDK for other types and utility functions._
30
62
 
31
63
  ## Create StreamClient instance
32
64
 
33
- Before creating and manipulating streams chain specific or generic StreamClient instance must be created. All streams functions are methods on this instance.
65
+ Before creating and manipulating streams, a chain-specific or generic StreamClient instance must be created. All stream functions are methods on this instance.
34
66
 
35
- ### Solana
67
+ ### Chain-specific clients
36
68
 
37
69
  ```javascript
70
+ // Solana
38
71
  import { StreamflowSolana } from "@streamflow/stream";
39
-
40
72
  const solanaClient = new StreamflowSolana.SolanaStreamClient(
41
73
  "https://api.mainnet-beta.solana.com"
42
74
  );
43
- ```
44
75
 
45
- ### Aptos
46
-
47
- ```javascript
76
+ // Aptos
48
77
  import { StreamflowAptos } from "@streamflow/stream";
49
-
50
78
  const aptosClient = new StreamflowAptos.AptosStreamClient(
51
79
  "https://fullnode.mainnet.aptoslabs.com/v1"
52
80
  );
81
+
82
+ // Sui
83
+ import { StreamflowSui } from "@streamflow/stream";
84
+ const suiClient = new StreamflowSui.SuiStreamClient(
85
+ "https://fullnode.testnet.sui.io:443"
86
+ );
53
87
  ```
54
88
 
55
- ### Ethereum
89
+ ### Generic Stream Client
90
+
91
+ GenericStreamClient provides an isomorphic interface to work with streams agnostic of chain.
56
92
 
57
93
  ```javascript
58
- import { StreamflowEVM } from "@streamflow/stream";
94
+ import { GenericStreamClient } from "@streamflow/stream";
59
95
 
60
- const ethereumClient = new StreamflowEVM.EvmStreamClient(
61
- "YOUR_ETHEREUM_NODE_URL",
62
- IChain.Ethereum,
63
- signer // will be sender in a stream and authority for all stream related transactions
64
- );
96
+ const client = new GenericStreamClient<Types.IChain.Solana>({
97
+ chain: IChain.Solana, // Blockchain
98
+ clusterUrl: "https://api.mainnet-beta.solana.com", // RPC cluster URL
99
+ cluster: ICluster.Mainnet, // (optional) (default: Mainnet)
100
+ // ...rest chain specific params e.g. commitment for Solana
101
+ });
65
102
  ```
66
103
 
67
- ### Polygon
104
+ ## Chain-specific Parameters
105
+
106
+ Each method requires chain-specific parameters. Here are the common patterns:
107
+ These are defined in:
108
+ - [Solana Types](./solana/types.ts)
109
+ - [Aptos Types](./aptos/types.ts)
110
+ - [Sui Types](./sui/types.ts)
68
111
 
69
112
  ```javascript
70
- import { StreamflowEVM } from "@streamflow/stream";
113
+ // Solana parameters for Create
114
+ const solanaCreateParams = {
115
+ sender: wallet, // SignerWalletAdapter or Keypair of Sender account, can be only PublicKey if you are not using the client to initiate the signing and execution of the transaction
116
+ isNative: false // [optional] Whether Stream should be paid with Solana native token (wSOL)
117
+ };
71
118
 
72
- const polygonClient = new StreamflowEVM.EvmStreamClient(
73
- "YOUR_POLYGON_NODE_URL",
74
- IChain.Polygon,
75
- signer // will be sender in a stream and authority for all stream related transactions
76
- );
119
+ // Solana parameters for Withdraw, TopUp, Update, Cancel etc.
120
+ const solanaInteractParams = {
121
+ invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction, can be only PublicKey if you are not using the client to initiate the signing and execution of the transaction
122
+ isNative: false // [optional] Whether Stream should be paid with Solana native token (wSOL)
123
+ };
124
+
125
+ // Aptos parameters
126
+ const aptosParams = {
127
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
128
+ tokenId: "0x1::aptos_coin::AptosCoin" // Aptos Coin type
129
+ };
130
+
131
+ // Sui parameters
132
+ const suiParams = {
133
+ senderWallet: wallet, // WalletContextState | Keypair
134
+ tokenId: "0x2::sui::SUI" // Sui token type
135
+ };
77
136
  ```
78
137
 
79
- ### BNB
80
138
 
81
- ```javascript
82
- import { StreamflowEVM } from "@streamflow/stream";
139
+ > NOTE: All timestamp parameters are in seconds.
83
140
 
84
- const bnbClient = new StreamflowEVM.EvmStreamClient(
85
- "https://bsc-dataseed1.binance.org/",
86
- IChain.BNB,
87
- signer // will be sender in a stream and authority for all stream related transactions
88
- );
141
+ ## Create a Vesting Stream
142
+
143
+ Vesting Streams are a type of Stream used to linearly unlock a given amount of tokens over a period of time. You can specify the amount, cliff, start time and releasePeriod along with other configuration that controls who can transfer or cancel the contract. For a Stream to be considered Vesting in the Streamflow App it has to match the criteria from the `isVesting` helper function (or `buildStreamType` returns `StreamType.Vesting`). The stream must not allow top-ups, the cliff amount must not be too close to the total amount and it must not be a Dynamic token lock.
144
+
145
+ For more details creating a Stream with arbitrary configuration see [General Stream creation](#general-stream-creation).
146
+ For creating multiple Streams at once see [Create Multiple Streams](#create-multiple-streams-at-once).
147
+
148
+ ### Streamflow App Vesting criteria
149
+
150
+ The categorization criteria and other helper functions are defined in [contractUtils.ts](./common/contractUtils.ts)
151
+
152
+ ```javascript
153
+ return (
154
+ !streamData.canTopup &&
155
+ !isCliffCloseToDepositedAmount(streamData) &&
156
+ !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage)
157
+ );
89
158
  ```
90
159
 
91
- ### Sui
160
+ ### Example for creating a Vesting Stream
161
+ The following code will create a Vesting Stream that unlocks 20% of the locked tokens at the start with the remaining 80% unlocked daily over a period of 2 weeks.
92
162
 
93
163
  ```javascript
94
- import { StreamflowSui } from "@streamflow/stream";
164
+ const tokenDecimals = 9;
165
+ const totalAmount = getBN(1000, tokenDecimals);
166
+ const cliffAmount = getBN(200, tokenDecimals); // optional
95
167
 
96
- const suiClient = new StreamflowSui.SuiStreamClient(
97
- "https://fullnode.testnet.sui.io:443"
98
- );
168
+ const day = 60 * 60 * 24; // in seconds
169
+ const twoWeeks = day * 14;
170
+
171
+ const remainingAmount = totalAmount.sub(cliffAmount);
172
+ const amountPerPeriod = remainingAmount.divn(twoWeeks);
173
+
174
+ const createVestingParams: Types.ICreateStreamData = {
175
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Recipient address.
176
+ tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // Token mint address.
177
+ start: 1643363040, // In this case start time will be the time of unlock
178
+ amount: totalAmount,
179
+ period: day, // 1 day for daily unlocks
180
+ cliff: 1643363040, // Cliff should match start
181
+ cliffAmount: cliffAmount, // Amount unlocked at the "cliff" timestamp.
182
+ amountPerPeriod: amountPerPeriod,
183
+ name: "Transfer to Jane Doe.", // The stream name or subject.
184
+ canTopup: false,
185
+ };
186
+
187
+ // Using the client to trigger the transaction signing and execution
188
+ try {
189
+ const { ixs, tx, metadata } = await client.create(createVestingParams, solanaCreateParams);
190
+ } catch (exception) {
191
+ // handle exception
192
+ }
193
+
194
+ // Creating the transaction yourself
195
+ // note: in this case you do not have to pass a Signer or Keypair in solanaCreateParams, you can pass only the PublicKey
196
+ const { ixs } = await client.prepareCreateStreamInstructions(createVestingParams, solanaCreateParams)
99
197
  ```
100
198
 
101
- ### Generic Stream Client
199
+ ## Create a Token Lock
200
+
201
+ A token lock is a Stream that has specific configuration making the unlock happen (almost) instantenously at a certain point in time. For a Stream to be considered a Token Lock in the Streamflow App it must match the criteria defined in the `isTokenLock` function (or for the `buildStreamType` type function to return `StreamType.Lock`). The Stream must not allow top-ups or auto-withdrawal and it can not be transferable by the sender or cancelable by either the sneder or the recipient. The `cliffAmount` must be equal to or greater than `depositedAmount.subn(1)`. Dynamic (price-based) locks conform to a different criteria.
102
202
 
103
- GenericStreamClient provides isomorphic interface to work with streams agnostic of chain.
203
+ ### Streamflow app token lock criteria
204
+
205
+ The categorization criteria and other helper functions are defined in [contractUtils.ts](./common/contractUtils.ts)
104
206
 
105
207
  ```javascript
106
- import { GenericStreamClient } from "@streamflow/stream";
208
+ return (
209
+ !streamData.canTopup &&
210
+ !streamData.automaticWithdrawal &&
211
+ !streamData.cancelableBySender &&
212
+ !streamData.cancelableByRecipient &&
213
+ !streamData.transferableBySender &&
214
+ (isCliffCloseToDepositedAmount(streamData) ||
215
+ isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage))
216
+ );
107
217
 
108
- const client =
109
- new GenericStreamClient<Types.IChain.Solana>({
110
- chain: IChain.Solana, // Blockchain
111
- clusterUrl: "https://api.mainnet-beta.solana.com", // RPC cluster URL
112
- cluster: ICluster.Mainnet, // (optional) (default: Mainnet)
113
- // ...rest chain specific params e.g. commitment for Solana
114
- });
218
+ const isCliffCloseToDepositedAmount = (streamData: { depositedAmount: BN; cliffAmount: BN }): boolean => {
219
+ return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN(1)));
115
220
  ```
116
221
 
117
- All the examples below will contain generic method options descriptions and chain specific params.
222
+ ### Example for creating a token lock
223
+ ```javascript
224
+ const tokenDecimals = 9;
225
+ const totalAmount = getBN(1000, tokenDecimals);
226
+ const cliffAmount = totalAmount.subn(1);
118
227
 
228
+ const createTokenLockParams: Types.ICreateStreamData = {
229
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Recipient address.
230
+ tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // Token mint address.
231
+ start: 1643363040, // In this case start time will be the time of unlock
232
+ amount: totalAmount,
233
+ period: 1, // 1 second
234
+ cliff: 1643363040, // Cliff should match start
235
+ cliffAmount: cliffAmount, // Amount unlocked at the "cliff" timestamp.
236
+ amountPerPeriod: new BN(1), // Remaining "1" which is smallest token denominator will be unlocked in 1 second
237
+ name: "Transfer to Jane Doe.", // The stream name or subject.
238
+ // The settings below are only necessary if you wish the Stream to be labelled as a Token Lock on the Streamflow App (or if you use the smae criteria for categorization of Streams)
239
+ canTopup: false,
240
+ cancelableBySender: false,
241
+ cancelableByRecipient: false,
242
+ transferableBySender: false,
243
+ transferableByRecipient: false,
244
+ };
119
245
 
120
- > NOTE: All timestamp parameters are in seconds.
121
- ## Create stream
246
+ // Using the client to trigger the transaction signing and execution
247
+ try {
248
+ const { ixs, tx, metadata } = await client.create(createTokenLockParams, solanaCreateParams);
249
+ } catch (exception) {
250
+ // handle exception
251
+ }
252
+
253
+ // Creating the transaction yourself
254
+ // note: in this case you do not have to pass a Signer or Keypair in solanaCreateParams, you can pass only the PublicKey
255
+ const { ixs } = await client.prepareCreateStreamInstructions(createTokenLockParams, solanaCreateParams)
256
+ ```
257
+
258
+
259
+ ## General Stream creation
260
+
261
+ This covers arbitrary configuration for creating a Stream - depending on the configuration it may fall into different categories in the Streamflow App if the Streamflow protocol is used. For more details on automatic withdrawal see [Automatic Withdrawal](#automatic-withdrawal).
122
262
 
123
263
  ```javascript
124
264
  const createStreamParams: Types.ICreateStreamData = {
@@ -142,23 +282,9 @@ const createStreamParams: Types.ICreateStreamData = {
142
282
  partner: undefined, // (optional) Partner's wallet address (string | undefined).
143
283
  };
144
284
 
145
- const solanaParams = {
146
- sender: wallet, // SignerWalletAdapter or Keypair of Sender account
147
- isNative: false // [optional] [WILL CREATE A wSOL STREAM] Whether Stream or Vesting should be paid with Solana native token or not
148
- };
149
-
150
- const aptosParams = {
151
- senderWallet: wallet, // AptosWalletAdapter Wallet of sender
152
- };
153
-
154
- const suiParams = {
155
- senderWallet: wallet, // WalletContextState | Keypair
156
- };
157
-
158
- const ethereumParams = undefined;
159
-
285
+ // Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
160
286
  try {
161
- const { ixs, tx, metadata } = await client.create(createStreamParams, solanaParams); // second argument differ depending on a chain
287
+ const { ixs, tx, metadata } = await client.create(createStreamParams, solanaCreateParams);
162
288
  } catch (exception) {
163
289
  // handle exception
164
290
  }
@@ -169,7 +295,7 @@ try {
169
295
  ```javascript
170
296
  const recipients = [
171
297
  {
172
- recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Solana recipient address.
298
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Recipient address.
173
299
  amount: getBN(100, 9), // depositing 100 tokens with 9 decimals mint.
174
300
  name: "January Payroll", // The stream name/subject.
175
301
  cliffAmount: getBN(10, 9), // amount released on cliff for this recipient
@@ -177,8 +303,8 @@ const recipients = [
177
303
  },
178
304
  ];
179
305
  const createMultiStreamsParams: ICreateMultipleStreamData = {
180
- recipients: recipients, // Solana recipient address.
181
- tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL Token mint.
306
+ recipients: recipients, // Array of recipient objects.
307
+ tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // Token mint address.
182
308
  start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
183
309
  period: 1, // Time step (period) in seconds per which the unlocking occurs.
184
310
  cliff: 1643363160, // Vesting contract "cliff" timestamp in seconds.
@@ -192,23 +318,8 @@ const createMultiStreamsParams: ICreateMultipleStreamData = {
192
318
  partner: undefined, // (optional) Partner's wallet address (string | undefined).
193
319
  };
194
320
 
195
- const solanaParams = {
196
- sender: wallet, // SignerWalletAdapter or Keypair of Sender account
197
- isNative: // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
198
- };
199
-
200
- const aptosParams = {
201
- senderWallet: wallet, // AptosWalletAdapter Wallet of sender
202
- };
203
-
204
- const suiParams = {
205
- senderWallet: wallet, // WalletContextState | Keypair
206
- };
207
-
208
- const ethereumParams = undefined;
209
-
210
321
  try {
211
- const { txs } = await client.createMultiple(createMultiStreamsParams, solanaParams);
322
+ const { txs } = await client.createMultiple(createMultiStreamsParams, solanaCreateParams);
212
323
  } catch (exception) {
213
324
  // handle exception
214
325
  }
@@ -216,7 +327,7 @@ try {
216
327
 
217
328
  Please note that transaction fees for the scheduled transfers are paid upfront by the stream creator (sender).
218
329
 
219
- ## Identifying created contracts (streams or vesting)
330
+ ## Identifying created Streams
220
331
 
221
332
  All Stream Clients return `ICreateResult` object (`createMultiple` returns an Array) that has the following structure
222
333
 
@@ -232,35 +343,25 @@ interface ICreateResult {
232
343
 
233
344
  ## Withdraw from stream
234
345
 
346
+ To fetch the unlocked amount from a Stream see [Fetching unlocked amount](#fetching-unlocked-amount)
347
+
235
348
  ```javascript
236
349
  const withdrawStreamParams: Types.IWithdrawData = {
237
350
  id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier (address) of a stream to be withdrawn from.
238
351
  amount: getBN(100, 9), // Requested amount to withdraw. If stream is completed, the whole amount will be withdrawn.
239
352
  };
240
353
 
241
- const solanaParams = {
242
- invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
243
- };
244
-
245
- const aptosParams = {
246
- senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
247
- tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
248
- };
249
-
250
- const suiParams = {
251
- senderWallet: wallet, // WalletContextState | Keypair
252
- tokenId: "0x2::sui::SUI"
253
- };
254
-
255
- const ethereumParams = undefined;
256
-
257
354
  try {
258
- const { ixs, tx } = await client.withdraw(withdrawStreamParams, solanaParams);
355
+ const { ixs, tx } = await client.withdraw(withdrawStreamParams, solanaInteractParams);
259
356
  } catch (exception) {
260
357
  // handle exception
261
358
  }
262
359
  ```
263
360
 
361
+ ## Automatic withdrawal
362
+
363
+ This configuration controls whether automatic withdrawal are enabled for a Stream. `automaticWithdrawal` enables or disables this functionality. If set to `true` it will be possible for 3rd parties to withdraw the Stream on the recipient's behalf. This is also controlled by `withdrawalFrequency`. Setting `withdrawalFrequency` to `>0` will cause our own withdrawor to automatically withdraw funds to the recipient's wallet with the specifed frequency. Passing `0` will make our withdrawor ignore the Stream for auto-withdrawing, but it will be possible for others to initiate the witdrawal process.
364
+
264
365
  ## Topup stream
265
366
 
266
367
  ```javascript
@@ -269,25 +370,10 @@ const topupStreamParams: ITopUpData = {
269
370
  amount: getBN(100, 9), // Specified amount to topup (increases deposited amount).
270
371
  };
271
372
 
272
- const solanaParams = {
273
- invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
274
- isNative: true // [ONLY FOR wSOL STREAMS] [optional] Wether topup is with Native Solanas
275
- };
276
-
277
- const aptosParams = {
278
- senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
279
- tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
280
- };
281
-
282
- const suiParams = {
283
- senderWallet: wallet, // WalletContextState | Keypair
284
- tokenId: "0x2::sui::SUI"
285
- };
286
-
287
- const ethereumParams = undefined;
288
-
373
+ // Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
374
+ // Note: For Solana, you can add isNative: true for wSOL streams
289
375
  try {
290
- const { ixs, tx } = await client.topup(topupStreamParams, solanaParams);
376
+ const { ixs, tx } = await client.topup(topupStreamParams, solanaInteractParams);
291
377
  } catch (exception) {
292
378
  // handle exception
293
379
  }
@@ -301,24 +387,9 @@ const data: ITransferData = {
301
387
  newRecipient: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier (address) of a stream to be transferred.
302
388
  };
303
389
 
304
- const solanaParams = {
305
- invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
306
- };
307
-
308
- const aptosParams = {
309
- senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
310
- tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
311
- };
312
-
313
- const suiParams = {
314
- senderWallet: wallet, // WalletContextState | Keypair
315
- tokenId: "0x2::sui::SUI"
316
- };
317
-
318
- const ethereumParams = undefined;
319
-
390
+ // Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
320
391
  try {
321
- const { tx } = await client.transfer(data, solanaParams);
392
+ const { tx } = await client.transfer(data, solanaInteractParams);
322
393
  } catch (exception) {
323
394
  // handle exception
324
395
  }
@@ -331,24 +402,9 @@ const cancelStreamParams: ICancelData = {
331
402
  id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be canceled.
332
403
  };
333
404
 
334
- const solanaParams = {
335
- invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
336
- };
337
-
338
- const aptosParams = {
339
- senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
340
- tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
341
- };
342
-
343
- const suiParams = {
344
- senderWallet: wallet, // WalletContextState | Keypair
345
- tokenId: "0x2::sui::SUI"
346
- };
347
-
348
- const ethereumParams = undefined;
349
-
405
+ // Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
350
406
  try {
351
- const { ixs, tx } = await client.cancel(cancelStreamParams, solanaParams);
407
+ const { ixs, tx } = await client.cancel(cancelStreamParams, solanaInteractParams);
352
408
  } catch (exception) {
353
409
  // handle exception
354
410
  }
@@ -364,22 +420,9 @@ const updateStreamParams: IUpdateData = {
364
420
  amountPerPeriod: getBN(10, 9), // [optional], allows to update release amount effective on next unlock
365
421
  }
366
422
 
367
- const solanaParams = {
368
- invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
369
- };
370
-
371
- const aptosParams = {
372
- senderWallet: wallet, // AptosWalletAdapter Wallet of wallet signing the transaction
373
- };
374
-
375
- const suiParams = {
376
- senderWallet: wallet, // WalletContextState | Keypair
377
- };
378
-
379
- const ethereumParams = undefined;
380
-
423
+ // Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
381
424
  try {
382
- const { ixs, tx } = await client.update(updateStreamParams, solanaParams);
425
+ const { ixs, tx } = await client.update(updateStreamParams, solanaInteractParams);
383
426
  } catch (exception) {
384
427
  // handle exception
385
428
  }
@@ -419,7 +462,7 @@ const stream = await client.getOne({
419
462
  id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
420
463
  });
421
464
  const withdrawn = stream.withdrawnAmount; // bn amount withdrawn already
422
- console.log(getNumberFromBN(wihtdrawn, 9));
465
+ console.log(getNumberFromBN(withdrawn, 9));
423
466
  const remaining = stream.remaining(9); // amount of remaining funds
424
467
  console.log(remaining);
425
468
  ```
@@ -475,11 +518,6 @@ Streamflow protocol program IDs
475
518
  | Devet | HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ |
476
519
  | Mainnet | strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m |
477
520
 
478
- | EVM | Ethereum(Goerli on Tesnet),Polygon,BNB |
479
- | ------- | ------------------------------------------ |
480
- | Testnet | 0x5Db7a43D20De64E3a3BC765334a477026FD13E7d |
481
- | Mainnet | 0x94d4646Bd307Bf91CB1893BC64d976BF9E60D9B2 |
482
-
483
521
  | Aptos | |
484
522
  | ------- | ------------------------------------------------------------------ |
485
523
  | Testnet | 0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688 |