@streamflow/stream 9.0.3 → 10.0.0-alpha.p313.3ce4d29
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 +6 -62
- package/dist/cjs/index.cjs +421 -3786
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -186
- package/dist/cjs/solana/index.cjs +376 -301
- 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 -186
- package/dist/esm/index.js +239 -3617
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1134 -17
- package/dist/esm/solana/index.js +257 -232
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -43
- package/dist/cjs/BaseStreamClient-DOyJqO7R.d.cts +0 -551
- package/dist/cjs/aptos/index.cjs +0 -456
- 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 -1915
- package/dist/cjs/evm/index.cjs.map +0 -1
- package/dist/cjs/evm/index.d.cts +0 -13
- package/dist/cjs/index-BMZATAYa.d.cts +0 -213
- package/dist/cjs/index-BgGtpOPg.d.cts +0 -850
- package/dist/cjs/index-DYIamO0j.d.cts +0 -203
- package/dist/cjs/index-Y0HH2ugY.d.cts +0 -136
- package/dist/cjs/sui/index.cjs +0 -1021
- package/dist/cjs/sui/index.cjs.map +0 -1
- package/dist/cjs/sui/index.d.cts +0 -13
- package/dist/esm/BaseStreamClient-DOyJqO7R.d.ts +0 -551
- package/dist/esm/aptos/index.d.ts +0 -14
- package/dist/esm/aptos/index.js +0 -443
- 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 -1902
- package/dist/esm/evm/index.js.map +0 -1
- package/dist/esm/index-D54wSYym.d.ts +0 -203
- package/dist/esm/index-Dp5DXxr-.d.ts +0 -850
- package/dist/esm/index-DrzqsoIB.d.ts +0 -136
- package/dist/esm/index-elpYUBph.d.ts +0 -213
- package/dist/esm/sui/index.d.ts +0 -13
- package/dist/esm/sui/index.js +0 -1011
- 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
|
|
|
@@ -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) {
|
|
@@ -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.`
|