@streamflow/stream 6.4.2 → 6.4.4
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 +39 -53
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Most common imports:
|
|
|
23
23
|
|
|
24
24
|
```javascript
|
|
25
25
|
import { BN } from "bn.js";
|
|
26
|
-
import {
|
|
26
|
+
import { GenericStreamClient, getBN, getNumberFromBN } from "@streamflow/stream";
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
_Check the SDK for other types and utility functions._
|
|
@@ -35,10 +35,7 @@ Before creating and manipulating streams chain specific or generic StreamClient
|
|
|
35
35
|
### Solana
|
|
36
36
|
|
|
37
37
|
```javascript
|
|
38
|
-
import {
|
|
39
|
-
StreamflowSolana,
|
|
40
|
-
Types,
|
|
41
|
-
} from "@streamflow/stream";
|
|
38
|
+
import { StreamflowSolana } from "@streamflow/stream";
|
|
42
39
|
|
|
43
40
|
const solanaClient = new StreamflowSolana.SolanaStreamClient(
|
|
44
41
|
"https://api.mainnet-beta.solana.com"
|
|
@@ -48,10 +45,7 @@ const solanaClient = new StreamflowSolana.SolanaStreamClient(
|
|
|
48
45
|
### Aptos
|
|
49
46
|
|
|
50
47
|
```javascript
|
|
51
|
-
import {
|
|
52
|
-
StreamflowAptos,
|
|
53
|
-
Types,
|
|
54
|
-
} from "@streamflow/stream";
|
|
48
|
+
import { StreamflowAptos } from "@streamflow/stream";
|
|
55
49
|
|
|
56
50
|
const aptosClient = new StreamflowAptos.AptosStreamClient(
|
|
57
51
|
"https://fullnode.mainnet.aptoslabs.com/v1"
|
|
@@ -61,14 +55,11 @@ const aptosClient = new StreamflowAptos.AptosStreamClient(
|
|
|
61
55
|
### Ethereum
|
|
62
56
|
|
|
63
57
|
```javascript
|
|
64
|
-
import {
|
|
65
|
-
StreamflowEVM,
|
|
66
|
-
Types,
|
|
67
|
-
} from "@streamflow/stream";
|
|
58
|
+
import { StreamflowEVM } from "@streamflow/stream";
|
|
68
59
|
|
|
69
60
|
const ethereumClient = new StreamflowEVM.EvmStreamClient(
|
|
70
61
|
"YOUR_ETHEREUM_NODE_URL",
|
|
71
|
-
|
|
62
|
+
IChain.Ethereum,
|
|
72
63
|
signer // will be sender in a stream and authority for all stream related transactions
|
|
73
64
|
);
|
|
74
65
|
```
|
|
@@ -76,14 +67,11 @@ const ethereumClient = new StreamflowEVM.EvmStreamClient(
|
|
|
76
67
|
### Polygon
|
|
77
68
|
|
|
78
69
|
```javascript
|
|
79
|
-
import {
|
|
80
|
-
StreamflowEVM,
|
|
81
|
-
Types,
|
|
82
|
-
} from "@streamflow/stream";
|
|
70
|
+
import { StreamflowEVM } from "@streamflow/stream";
|
|
83
71
|
|
|
84
72
|
const polygonClient = new StreamflowEVM.EvmStreamClient(
|
|
85
73
|
"YOUR_POLYGON_NODE_URL",
|
|
86
|
-
|
|
74
|
+
IChain.Polygon,
|
|
87
75
|
signer // will be sender in a stream and authority for all stream related transactions
|
|
88
76
|
);
|
|
89
77
|
```
|
|
@@ -91,14 +79,11 @@ const polygonClient = new StreamflowEVM.EvmStreamClient(
|
|
|
91
79
|
### BNB
|
|
92
80
|
|
|
93
81
|
```javascript
|
|
94
|
-
import {
|
|
95
|
-
StreamflowEVM,
|
|
96
|
-
Types,
|
|
97
|
-
} from "@streamflow/stream";
|
|
82
|
+
import { StreamflowEVM } from "@streamflow/stream";
|
|
98
83
|
|
|
99
84
|
const bnbClient = new StreamflowEVM.EvmStreamClient(
|
|
100
85
|
"https://bsc-dataseed1.binance.org/",
|
|
101
|
-
|
|
86
|
+
IChain.BNB,
|
|
102
87
|
signer // will be sender in a stream and authority for all stream related transactions
|
|
103
88
|
);
|
|
104
89
|
```
|
|
@@ -106,10 +91,7 @@ const bnbClient = new StreamflowEVM.EvmStreamClient(
|
|
|
106
91
|
### Sui
|
|
107
92
|
|
|
108
93
|
```javascript
|
|
109
|
-
import {
|
|
110
|
-
StreamflowSui,
|
|
111
|
-
Types,
|
|
112
|
-
} from "@streamflow/stream";
|
|
94
|
+
import { StreamflowSui } from "@streamflow/stream";
|
|
113
95
|
|
|
114
96
|
const suiClient = new StreamflowSui.SuiStreamClient(
|
|
115
97
|
"https://fullnode.testnet.sui.io:443"
|
|
@@ -121,13 +103,13 @@ const suiClient = new StreamflowSui.SuiStreamClient(
|
|
|
121
103
|
GenericStreamClient provides isomorphic interface to work with streams agnostic of chain.
|
|
122
104
|
|
|
123
105
|
```javascript
|
|
124
|
-
import { GenericStreamClient
|
|
106
|
+
import { GenericStreamClient } from "@streamflow/stream";
|
|
125
107
|
|
|
126
108
|
const client =
|
|
127
109
|
new GenericStreamClient<Types.IChain.Solana>({
|
|
128
|
-
chain:
|
|
110
|
+
chain: IChain.Solana, // Blockchain
|
|
129
111
|
clusterUrl: "https://api.mainnet-beta.solana.com", // RPC cluster URL
|
|
130
|
-
cluster:
|
|
112
|
+
cluster: ICluster.Mainnet, // (optional) (default: Mainnet)
|
|
131
113
|
// ...rest chain specific params e.g. commitment for Solana
|
|
132
114
|
});
|
|
133
115
|
```
|
|
@@ -149,7 +131,7 @@ const createStreamParams: Types.ICreateStreamData = {
|
|
|
149
131
|
cliffAmount: new BN(10), // Amount unlocked at the "cliff" timestamp.
|
|
150
132
|
amountPerPeriod: getBN(5, 9), // Release rate: how many tokens are unlocked per each period.
|
|
151
133
|
name: "Transfer to Jane Doe.", // The stream name or subject.
|
|
152
|
-
canTopup: false, // setting to FALSE will effectively create a vesting contract.
|
|
134
|
+
canTopup: false, // Whether additional tokens can be deposited after creation, setting to FALSE will effectively create a vesting contract.
|
|
153
135
|
canUpdateRate: false, // settings to TRUE allows sender to update amountPerPeriod
|
|
154
136
|
cancelableBySender: true, // Whether or not sender can cancel the stream.
|
|
155
137
|
cancelableByRecipient: false, // Whether or not recipient can cancel the stream.
|
|
@@ -157,12 +139,12 @@ const createStreamParams: Types.ICreateStreamData = {
|
|
|
157
139
|
transferableByRecipient: false, // Whether or not recipient can transfer the stream.
|
|
158
140
|
automaticWithdrawal: true, // Whether or not a 3rd party (e.g. cron job, "cranker") can initiate a token withdraw/transfer.
|
|
159
141
|
withdrawalFrequency: 10, // 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.
|
|
160
|
-
partner:
|
|
142
|
+
partner: undefined, // (optional) Partner's wallet address (string | undefined).
|
|
161
143
|
};
|
|
162
144
|
|
|
163
145
|
const solanaParams = {
|
|
164
146
|
sender: wallet, // SignerWalletAdapter or Keypair of Sender account
|
|
165
|
-
isNative: false // [optional] [WILL CREATE A wSOL STREAM]
|
|
147
|
+
isNative: false // [optional] [WILL CREATE A wSOL STREAM] Whether Stream or Vesting should be paid with Solana native token or not
|
|
166
148
|
};
|
|
167
149
|
|
|
168
150
|
const aptosParams = {
|
|
@@ -194,7 +176,7 @@ const recipients = [
|
|
|
194
176
|
amountPerPeriod: getBN(1, 9), //amount released every specified period epoch
|
|
195
177
|
},
|
|
196
178
|
];
|
|
197
|
-
const
|
|
179
|
+
const createMultiStreamsParams: ICreateMultipleStreamData = {
|
|
198
180
|
recipients: recipients, // Solana recipient address.
|
|
199
181
|
tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL Token mint.
|
|
200
182
|
start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
|
|
@@ -207,7 +189,7 @@ const createStreamParams: Types.ICreateMultipleStreamData = {
|
|
|
207
189
|
transferableByRecipient: false, // Whether or not recipient can transfer the stream.
|
|
208
190
|
automaticWithdrawal: true, // Whether or not a 3rd party (e.g. cron job, "cranker") can initiate a token withdraw/transfer.
|
|
209
191
|
withdrawalFrequency: 10, // 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.
|
|
210
|
-
partner:
|
|
192
|
+
partner: undefined, // (optional) Partner's wallet address (string | undefined).
|
|
211
193
|
};
|
|
212
194
|
|
|
213
195
|
const solanaParams = {
|
|
@@ -236,11 +218,11 @@ Please note that transaction fees for the scheduled transfers are paid upfront b
|
|
|
236
218
|
|
|
237
219
|
## Identifying created contracts (streams or vesting)
|
|
238
220
|
|
|
239
|
-
All Stream Clients return `
|
|
221
|
+
All Stream Clients return `ICreateResult` object (`createMultiple` returns an Array) that has the following structure
|
|
240
222
|
|
|
241
223
|
```javascript
|
|
242
224
|
interface ICreateResult {
|
|
243
|
-
ixs: (TransactionInstruction |
|
|
225
|
+
ixs: (TransactionInstruction | TransactionPayload)[];
|
|
244
226
|
txId: string;
|
|
245
227
|
metadataId: MetadataId;
|
|
246
228
|
}
|
|
@@ -252,7 +234,7 @@ interface ICreateResult {
|
|
|
252
234
|
|
|
253
235
|
```javascript
|
|
254
236
|
const withdrawStreamParams: Types.IWithdrawData = {
|
|
255
|
-
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be withdrawn from.
|
|
237
|
+
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier (address) of a stream to be withdrawn from.
|
|
256
238
|
amount: getBN(100, 9), // Requested amount to withdraw. If stream is completed, the whole amount will be withdrawn.
|
|
257
239
|
};
|
|
258
240
|
|
|
@@ -282,14 +264,14 @@ try {
|
|
|
282
264
|
## Topup stream
|
|
283
265
|
|
|
284
266
|
```javascript
|
|
285
|
-
const topupStreamParams:
|
|
286
|
-
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be topped up.
|
|
267
|
+
const topupStreamParams: ITopUpData = {
|
|
268
|
+
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier (address) of a stream to be topped up.
|
|
287
269
|
amount: getBN(100, 9), // Specified amount to topup (increases deposited amount).
|
|
288
270
|
};
|
|
289
271
|
|
|
290
272
|
const solanaParams = {
|
|
291
273
|
invoker: wallet, // SignerWalletAdapter or Keypair signing the transaction
|
|
292
|
-
isNative: // [ONLY FOR wSOL STREAMS] [optional] Wether topup is with Native Solanas
|
|
274
|
+
isNative: true // [ONLY FOR wSOL STREAMS] [optional] Wether topup is with Native Solanas
|
|
293
275
|
};
|
|
294
276
|
|
|
295
277
|
const aptosParams = {
|
|
@@ -314,9 +296,9 @@ try {
|
|
|
314
296
|
## Transfer stream to another recipient
|
|
315
297
|
|
|
316
298
|
```javascript
|
|
317
|
-
const data:
|
|
318
|
-
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
|
|
319
|
-
newRecipient: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier of a stream to be transferred.
|
|
299
|
+
const data: ITransferData = {
|
|
300
|
+
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier (address) of the stream to be transferred
|
|
301
|
+
newRecipient: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier (address) of a stream to be transferred.
|
|
320
302
|
};
|
|
321
303
|
|
|
322
304
|
const solanaParams = {
|
|
@@ -345,7 +327,7 @@ try {
|
|
|
345
327
|
## Cancel stream
|
|
346
328
|
|
|
347
329
|
```javascript
|
|
348
|
-
const cancelStreamParams:
|
|
330
|
+
const cancelStreamParams: ICancelData = {
|
|
349
331
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be canceled.
|
|
350
332
|
};
|
|
351
333
|
|
|
@@ -375,7 +357,7 @@ try {
|
|
|
375
357
|
## Update a stream
|
|
376
358
|
|
|
377
359
|
```javascript
|
|
378
|
-
const updateStreamParams:
|
|
360
|
+
const updateStreamParams: IUpdateData = {
|
|
379
361
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to update.
|
|
380
362
|
enableAutomaticWithdrawal: true, // [optional], allows to enable AW if it wasn't, disable is not possible
|
|
381
363
|
withdrawFrequency: 60, // [optional], allows to update withdrawal frequency, may result in additional AW fees
|
|
@@ -406,7 +388,7 @@ try {
|
|
|
406
388
|
## Get one stream by its ID
|
|
407
389
|
|
|
408
390
|
```javascript
|
|
409
|
-
const data:
|
|
391
|
+
const data: IGetOneData = {
|
|
410
392
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream
|
|
411
393
|
};
|
|
412
394
|
|
|
@@ -424,8 +406,8 @@ const stream = await client.getOne({
|
|
|
424
406
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
|
|
425
407
|
});
|
|
426
408
|
|
|
427
|
-
const unlocked = stream.unlocked(tsInSeconds); //
|
|
428
|
-
console.log(getNumberFromBN(unlocked, 9));
|
|
409
|
+
const unlocked = stream.unlocked(tsInSeconds); // BN amount unlocked at the tsInSeconds
|
|
410
|
+
console.log(getNumberFromBN(unlocked, 9));
|
|
429
411
|
```
|
|
430
412
|
|
|
431
413
|
- Note: unlocked amount is determined based on configuration set on creation, no dynamic data is involved.
|
|
@@ -445,10 +427,10 @@ console.log(remaining);
|
|
|
445
427
|
## Get multiple streams for a specific wallet address
|
|
446
428
|
|
|
447
429
|
```javascript
|
|
448
|
-
const data:
|
|
430
|
+
const data: IGetAllData = {
|
|
449
431
|
address: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99",
|
|
450
|
-
type:
|
|
451
|
-
direction:
|
|
432
|
+
type: StreamType.All, // StreamType.Vesting, StreamType.Lock, StreamType.Payment
|
|
433
|
+
direction: StreamDirection.All, // StreamDirection.Outgoing, StreamDirection.Incoming
|
|
452
434
|
};
|
|
453
435
|
|
|
454
436
|
try {
|
|
@@ -515,3 +497,7 @@ E.g, if the amount is 1 SOL than this amount in lamports is `1000 \* 10^9 = 1_00
|
|
|
515
497
|
And `new BN(1_000_000_000)` is used.
|
|
516
498
|
|
|
517
499
|
Use `getBN` and `getNumberFromBN` utility functions for conversions between `BN` and `Number` types.
|
|
500
|
+
|
|
501
|
+
`getBN(1, 9)` is equal to `new BN(1_000_000_000)`
|
|
502
|
+
|
|
503
|
+
`getNumberFromBN(new BN(1_000_000_000), 9)` will return 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.4",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"lint": "eslint --fix .",
|
|
36
36
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b6e4a0db48cbba06bb358e34c42e0eef836a168c",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@streamflow/eslint-config": "6.4.
|
|
40
|
+
"@streamflow/eslint-config": "6.4.4",
|
|
41
41
|
"@types/bn.js": "5.1.1",
|
|
42
42
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
43
43
|
"@types/jest": "29.2.4",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"typescript": "^5.3.3"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@coral-xyz/borsh": "
|
|
51
|
-
"@manahippo/aptos-wallet-adapter": "1.0.
|
|
52
|
-
"@mysten/sui.js": "
|
|
50
|
+
"@coral-xyz/borsh": "0.30.1",
|
|
51
|
+
"@manahippo/aptos-wallet-adapter": "1.0.10",
|
|
52
|
+
"@mysten/sui.js": "0.54.1",
|
|
53
53
|
"@solana/buffer-layout": "4.0.1 ",
|
|
54
54
|
"@solana/spl-token": "0.3.6",
|
|
55
55
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
56
|
-
"@solana/web3.js": "1.
|
|
57
|
-
"@streamflow/common": "6.4.
|
|
56
|
+
"@solana/web3.js": "1.90.2",
|
|
57
|
+
"@streamflow/common": "6.4.4",
|
|
58
58
|
"@suiet/wallet-kit": "0.2.22",
|
|
59
|
-
"aptos": "1.
|
|
59
|
+
"aptos": "1.21.0",
|
|
60
60
|
"bn.js": "5.2.1",
|
|
61
61
|
"borsh": "^2.0.0",
|
|
62
62
|
"bs58": "5.0.0",
|