@streamflow/stream 10.0.0-alpha.p311.10f340e → 10.0.0-alpha.p313.18b7be3
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 +8 -64
- package/dist/cjs/index.cjs +453 -3797
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -182
- package/dist/cjs/solana/index.cjs +407 -313
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1134 -17
- package/dist/esm/index.d.ts +3 -182
- package/dist/esm/index.js +271 -3629
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1134 -17
- package/dist/esm/solana/index.js +288 -244
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -43
- package/dist/cjs/BaseStreamClient-Dvs8yWEE.d.cts +0 -550
- package/dist/cjs/aptos/index.cjs +0 -450
- package/dist/cjs/aptos/index.cjs.map +0 -1
- package/dist/cjs/aptos/index.d.cts +0 -14
- package/dist/cjs/evm/index.cjs +0 -1909
- package/dist/cjs/evm/index.cjs.map +0 -1
- package/dist/cjs/evm/index.d.cts +0 -13
- package/dist/cjs/index-BHKWsVnx.d.cts +0 -849
- package/dist/cjs/index-CGNg22mO.d.cts +0 -203
- package/dist/cjs/index-Dk1hKzM3.d.cts +0 -213
- package/dist/cjs/index-dSxy_PVV.d.cts +0 -136
- package/dist/cjs/sui/index.cjs +0 -1015
- package/dist/cjs/sui/index.cjs.map +0 -1
- package/dist/cjs/sui/index.d.cts +0 -13
- package/dist/esm/BaseStreamClient-Dvs8yWEE.d.ts +0 -550
- package/dist/esm/aptos/index.d.ts +0 -14
- package/dist/esm/aptos/index.js +0 -437
- package/dist/esm/aptos/index.js.map +0 -1
- package/dist/esm/evm/index.d.ts +0 -13
- package/dist/esm/evm/index.js +0 -1896
- package/dist/esm/evm/index.js.map +0 -1
- package/dist/esm/index-CRXW7eZy.d.ts +0 -203
- package/dist/esm/index-CgDmuCzv.d.ts +0 -849
- package/dist/esm/index-DED7TgAo.d.ts +0 -136
- package/dist/esm/index-li6QZ_tF.d.ts +0 -213
- package/dist/esm/sui/index.d.ts +0 -13
- package/dist/esm/sui/index.js +0 -1005
- package/dist/esm/sui/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -55,16 +55,16 @@ Most common imports:
|
|
|
55
55
|
|
|
56
56
|
```javascript
|
|
57
57
|
import { BN } from "bn.js";
|
|
58
|
-
import {
|
|
58
|
+
import { getBN, getNumberFromBN } from "@streamflow/stream";
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
_Check the SDK for other types and utility functions._
|
|
62
62
|
|
|
63
63
|
## Create StreamClient instance
|
|
64
64
|
|
|
65
|
-
Before creating and manipulating streams, a
|
|
65
|
+
Before creating and manipulating streams, a Solana client instance must be created. All stream functions are methods on this instance.
|
|
66
66
|
|
|
67
|
-
###
|
|
67
|
+
### Solana client
|
|
68
68
|
|
|
69
69
|
```javascript
|
|
70
70
|
// Solana
|
|
@@ -73,41 +73,12 @@ const solanaClient = new StreamflowSolana.SolanaStreamClient(
|
|
|
73
73
|
"https://api.mainnet-beta.solana.com"
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
-
// Aptos
|
|
77
|
-
import { StreamflowAptos } from "@streamflow/stream";
|
|
78
|
-
const aptosClient = new StreamflowAptos.AptosStreamClient(
|
|
79
|
-
"https://fullnode.mainnet.aptoslabs.com/v1"
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
// Sui
|
|
83
|
-
import { StreamflowSui } from "@streamflow/stream";
|
|
84
|
-
const suiClient = new StreamflowSui.SuiStreamClient(
|
|
85
|
-
"https://fullnode.testnet.sui.io:443"
|
|
86
|
-
);
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Generic Stream Client
|
|
90
76
|
|
|
91
|
-
|
|
77
|
+
## Universal parameters
|
|
92
78
|
|
|
93
|
-
|
|
94
|
-
import { GenericStreamClient } from "@streamflow/stream";
|
|
95
|
-
|
|
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
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Chain-specific Parameters
|
|
105
|
-
|
|
106
|
-
Each method requires chain-specific parameters. Here are the common patterns:
|
|
79
|
+
Each method requires some shared parameters. Here are the common patterns:
|
|
107
80
|
These are defined in:
|
|
108
81
|
- [Solana Types](./solana/types.ts)
|
|
109
|
-
- [Aptos Types](./aptos/types.ts)
|
|
110
|
-
- [Sui Types](./sui/types.ts)
|
|
111
82
|
|
|
112
83
|
```javascript
|
|
113
84
|
// Solana parameters for Create
|
|
@@ -121,18 +92,6 @@ const solanaInteractParams = {
|
|
|
121
92
|
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
93
|
isNative: false // [optional] Whether Stream should be paid with Solana native token (wSOL)
|
|
123
94
|
};
|
|
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
|
-
};
|
|
136
95
|
```
|
|
137
96
|
|
|
138
97
|
|
|
@@ -140,7 +99,7 @@ const suiParams = {
|
|
|
140
99
|
|
|
141
100
|
## Create a Vesting Stream
|
|
142
101
|
|
|
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 cliff amount must not be too close to the total amount and it must not be a Dynamic token lock.
|
|
102
|
+
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
103
|
|
|
145
104
|
For more details creating a Stream with arbitrary configuration see [General Stream creation](#general-stream-creation).
|
|
146
105
|
For creating multiple Streams at once see [Create Multiple Streams](#create-multiple-streams-at-once).
|
|
@@ -282,7 +241,6 @@ const createStreamParams: Types.ICreateStreamData = {
|
|
|
282
241
|
partner: undefined, // (optional) Partner's wallet address (string | undefined).
|
|
283
242
|
};
|
|
284
243
|
|
|
285
|
-
// Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
|
|
286
244
|
try {
|
|
287
245
|
const { ixs, tx, metadata } = await client.create(createStreamParams, solanaCreateParams);
|
|
288
246
|
} catch (exception) {
|
|
@@ -370,8 +328,7 @@ const topupStreamParams: ITopUpData = {
|
|
|
370
328
|
amount: getBN(100, 9), // Specified amount to topup (increases deposited amount).
|
|
371
329
|
};
|
|
372
330
|
|
|
373
|
-
//
|
|
374
|
-
// Note: For Solana, you can add isNative: true for wSOL streams
|
|
331
|
+
// Note: You can add isNative: true for wSOL streams to the solanaInteractParams
|
|
375
332
|
try {
|
|
376
333
|
const { ixs, tx } = await client.topup(topupStreamParams, solanaInteractParams);
|
|
377
334
|
} catch (exception) {
|
|
@@ -387,7 +344,6 @@ const data: ITransferData = {
|
|
|
387
344
|
newRecipient: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier (address) of a stream to be transferred.
|
|
388
345
|
};
|
|
389
346
|
|
|
390
|
-
// Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
|
|
391
347
|
try {
|
|
392
348
|
const { tx } = await client.transfer(data, solanaInteractParams);
|
|
393
349
|
} catch (exception) {
|
|
@@ -402,7 +358,6 @@ const cancelStreamParams: ICancelData = {
|
|
|
402
358
|
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be canceled.
|
|
403
359
|
};
|
|
404
360
|
|
|
405
|
-
// Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
|
|
406
361
|
try {
|
|
407
362
|
const { ixs, tx } = await client.cancel(cancelStreamParams, solanaInteractParams);
|
|
408
363
|
} catch (exception) {
|
|
@@ -420,7 +375,6 @@ const updateStreamParams: IUpdateData = {
|
|
|
420
375
|
amountPerPeriod: getBN(10, 9), // [optional], allows to update release amount effective on next unlock
|
|
421
376
|
}
|
|
422
377
|
|
|
423
|
-
// Use appropriate chain-specific parameters (see Chain-specific Parameters section above)
|
|
424
378
|
try {
|
|
425
379
|
const { ixs, tx } = await client.update(updateStreamParams, solanaInteractParams);
|
|
426
380
|
} catch (exception) {
|
|
@@ -472,7 +426,7 @@ console.log(remaining);
|
|
|
472
426
|
```javascript
|
|
473
427
|
const data: IGetAllData = {
|
|
474
428
|
address: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99",
|
|
475
|
-
type: StreamType.All, // StreamType.Vesting, StreamType.Lock
|
|
429
|
+
type: StreamType.All, // StreamType.Vesting, StreamType.Lock, StreamType.Payment
|
|
476
430
|
direction: StreamDirection.All, // StreamDirection.Outgoing, StreamDirection.Incoming
|
|
477
431
|
};
|
|
478
432
|
|
|
@@ -518,16 +472,6 @@ Streamflow protocol program IDs
|
|
|
518
472
|
| Devet | HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ |
|
|
519
473
|
| Mainnet | strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m |
|
|
520
474
|
|
|
521
|
-
| Aptos | |
|
|
522
|
-
| ------- | ------------------------------------------------------------------ |
|
|
523
|
-
| Testnet | 0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688 |
|
|
524
|
-
| Mainnet | 0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0 |
|
|
525
|
-
|
|
526
|
-
| Sui | |
|
|
527
|
-
| ------- | ------------------------------------------------------------------ |
|
|
528
|
-
| Testnet | 0xf1916c119a6c917d4b36f96ffc0443930745789f3126a716e05a62223c48993a |
|
|
529
|
-
| Mainnet | 0xa283fd6b45f1103176e7ae27e870c89df7c8783b15345e2b13faa81ec25c4fa6 |
|
|
530
|
-
|
|
531
475
|
**All BN amounts are denominated in their smallest units.**
|
|
532
476
|
|
|
533
477
|
E.g, if the amount is 1 SOL than this amount in lamports is `1000 \* 10^9 = 1_000_000_000.`
|