@streamflow/stream 4.0.0-Alpha.2 → 4.0.0-beta.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
@@ -25,9 +25,12 @@ You can also `getOne` stream and `get` multiple streams.
25
25
 
26
26
  ## Installation
27
27
 
28
- `npm i @streamflow/stream @solana/web3.js @project-serum/anchor`
28
+ `npm i -s @streamflow/stream`
29
+
30
+ or
31
+
32
+ `yarn add @streamflow/stream`
29
33
 
30
- > _Anchor is needed for the `Wallet` type. We plan on removing this dependency in upcoming releases._
31
34
 
32
35
  ## Import SDK
33
36
 
@@ -35,21 +38,10 @@ Most common imports:
35
38
 
36
39
  ```javascript
37
40
  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,
41
+ GenericStreamClient,
42
+ StreamflowSolana,
43
+ StreamflowAptos,
44
+ Types,
53
45
  getBN,
54
46
  getNumberFromBN,
55
47
  } from "@streamflow/stream";
@@ -59,45 +51,82 @@ _Check the SDK for other types and utility functions._
59
51
 
60
52
  ## Create StreamClient instance
61
53
 
62
- Before creating and manipulating streams StreamClient instance must be created.
54
+ Before creating and manipulating streams chain specific or generic StreamClient instance must be created.
63
55
  All streams functions are methods on this instance.
64
56
 
57
+ ### Solana
65
58
  ```javascript
66
- import { StreamClient } from "@streamflow/stream";
59
+ import { StreamflowSolana, Types } from "@streamflow/stream";
67
60
 
68
- const StreamClient = new StreamClient(
69
- "https://api.mainnet-beta.solana.com",
70
- Cluster.Mainnet,
71
- "confirmed"
61
+ const streamClient = new StreamflowSolana.SolanaStreamClient(
62
+ "https://api.mainnet-beta.solana.com", // RPC cluster URL
63
+ Types.ICluster.Mainnet, // (optional) (default: Mainnet) Solana cluster
64
+ "confirmed", // (optional) (default: confirmed) Transaction commitment
72
65
  );
73
66
  ```
67
+ ### Aptos
68
+ ```javascript
69
+ import { StreamflowAptos, Types } from "@streamflow/stream";
70
+
71
+ const StreamClient = new StreamflowAptos.AptosStreamClient(
72
+ "https://fullnode.mainnet.aptoslabs.com/v1", // RPC cluster URL
73
+ Types.ICluster.Mainnet, // (optional) (default: Mainnet) Aptos cluster
74
+ "10000", // (optional) (default: "10000") maxGas for transactions
75
+ );
76
+ ```
77
+ ### Generic Stream Client
78
+ Provides isomorphic interface to work with streams agnostic of chain.
79
+ ```javascript
80
+ import { GenericStreamClient, Types } from "@streamflow/stream";
81
+
82
+ const StreamClient = new StreamClient({
83
+ chain: Types.IChain.Aptos, // Blockchain
84
+ clusterUrl: "https://fullnode.mainnet.aptoslabs.com/v1", // RPC cluster URL
85
+ cluster: Types.ICluster.Mainnet, // (optional) (default: Mainnet)
86
+ // ...rest chain specific params e.g. commitment for Solana
87
+ });
88
+ ```
89
+
90
+ All the examples below will contain generic method options descriptions and chain specific params.
74
91
 
92
+
93
+ > NOTE: All timestamp parameters are in seconds.
75
94
  ## Create stream
76
95
 
77
96
  ```javascript
78
97
  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.
98
+ tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL token mint or Aptos Coin type
99
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Recipient address (base58 string for Solana)
100
+ amount: getBN(1_000_000, 9), // Deposited amount of tokens (using smallest denomination).
101
+ amountPerPeriod: getBN(1_000, 9), // Release rate: how many tokens are unlocked per each period.
85
102
  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.
103
+ cliffAmount: getBN(100_000, 9),// Amount (smallest denomination) unlocked at the "cliff" timestamp.
88
104
  name: "Transfer to Jane Doe.", // The stream name or subject.
105
+ period: 1, // Time step (period) in seconds per which the unlocking occurs.
106
+ start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
89
107
  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).
108
+ cancelableBySender: true, // Wether or not sender can cancel the stream.
109
+ cancelableByRecipient: false, // Wether or not recipient can cancel the stream.
110
+ transferableBySender: true, // Wether or not sender can transfer the stream.
111
+ transferableByRecipient: false, // Wether or not recipient can transfer the stream.
112
+ automaticWithdrawal: true, // [optional] Wether or not a 3rd party (e.g. cron job, "cranker") can initiate a token withdraw/transfer.
113
+ withdrawalFrequency: 10, // [optional] 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.
114
+ canPause: false, // [optional] [WIP] Wether stream is Pausable
115
+ canUpdateRate: fakse, // [optional] [WIP] Wether stream rate can be updated
116
+ };
117
+
118
+ const solanaParams = {
119
+ sender: wallet, // SignerWalletAdapter or Keypair of Sender account
120
+ partner: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // [optional] Partner Solana address
121
+ isNative: // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
122
+ };
123
+
124
+ const aptosParams = {
125
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
97
126
  };
98
127
 
99
128
  try {
100
- const { ixs, tx, metadata } = await StreamClient.create(createStreamParams);
129
+ const { ixs, tx, metadata } = await solanaStreamClient.create(createStreamParams, solanaParams);
101
130
  } catch (exception) {
102
131
  // handle exception
103
132
  }
@@ -108,52 +137,68 @@ try {
108
137
  ```javascript
109
138
  const recipients = [
110
139
  {
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.
140
+ recipient: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // Recipient address (base58 string for Solana)
141
+ amount: getBN(1_000_000, 9), // Deposited amount of tokens (using smallest denomination).
142
+ name: "Transfer to Jane Doe.", // The stream name or subject.
143
+ cliffAmount: getBN(100_000, 9),// Amount (smallest denomination) unlocked at the "cliff" timestamp.
144
+ amountPerPeriod: getBN(1_000, 9), // Release rate: how many tokens are unlocked per each period.
114
145
  },
146
+ // ... Other Recipient options
115
147
  ];
116
148
 
117
149
  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.
150
+ tokenId: "DNw99999M7e24g99999999WJirKeZ5fQc6KY999999gK", // SPL token mint or Aptos Coin type
123
151
  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).
152
+ period: 1, // Time step (period) in seconds per which the unlocking occurs.
153
+ start: 1643363040, // Timestamp (in seconds) when the stream/token vesting starts.
154
+ canTopup: false, // setting to FALSE will effectively create a vesting contract.
155
+ cancelableBySender: true, // Wether or not sender can cancel the stream.
156
+ cancelableByRecipient: false, // Wether or not recipient can cancel the stream.
157
+ transferableBySender: true, // Wether or not sender can transfer the stream.
158
+ transferableByRecipient: false, // Wether or not recipient can transfer the stream.
159
+ automaticWithdrawal: true, // [optional] Wether or not a 3rd party (e.g. cron job, "cranker") can initiate a token withdraw/transfer.
160
+ withdrawalFrequency: 10, // [optional] 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.
161
+ canPause: false, // [optional] [WIP] Wether stream is Pausable
162
+ canUpdateRate: false, // [optional] [WIP] Wether stream rate can be updated
163
+ };
164
+
165
+ const solanaParams = {
166
+ sender: wallet, // SignerWalletAdapter or Keypair of Sender account
167
+ partner: "4ih00075bKjVg000000tLdk4w42NyG3Mv0000dc0M00", // [optional] Partner Solana address
168
+ isNative: // [optional] [WILL CREATE A wSOL STREAM] Wether Stream or Vesting should be paid with Solana native token or not
169
+ };
170
+
171
+ const aptosParams = {
172
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
133
173
  };
134
174
 
135
175
  try {
136
- const { txs } = await StreamClient.createMultiple(createMultiStreamsParams);
176
+ const { txs } = await StreamClient.createMultiple(createMultiStreamsParams, solanaParams);
137
177
  } catch (exception) {
138
178
  // handle exception
139
179
  }
140
180
  ```
141
181
 
142
- \_Disclaimer: Support for scheduled, automatic token withdrawals/transfers is under development and scheduled to launch in Q1. Once launched, it will be enabled retroactively for all streams that have `automaticWithdrawal` set to `true`.
143
-
144
- Please note that transaction fees for the scheduled transfers are paid upfront by the stream creator (sender).\_
145
-
146
182
  ## Withdraw from stream
147
183
 
148
184
  ```javascript
149
185
  const withdrawStreamParams = {
150
- invoker: wallet, // Wallet/Keypair signing the transaction.
151
186
  id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be withdrawn from.
152
187
  amount: getBN(100000000000, 9), // Requested amount to withdraw. If stream is completed, the whole amount will be withdrawn.
153
188
  };
154
189
 
190
+ const solanaParams = {
191
+ invoker: wallet, // Wallet/Keypair signing the transaction.
192
+ };
193
+
194
+ const aptosParams = {
195
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
196
+ tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
197
+ };
198
+
199
+
155
200
  try {
156
- const { ixs, tx } = await StreamClient.withdraw(withdrawStreamParams);
201
+ const { ixs, tx } = await StreamClient.withdraw(withdrawStreamParams, solanaParams);
157
202
  } catch (exception) {
158
203
  // handle exception
159
204
  }
@@ -168,8 +213,18 @@ const topupStreamParams = {
168
213
  amount: getBN(100000000000, 9), // Specified amount to topup (increases deposited amount).
169
214
  };
170
215
 
216
+ const solanaParams = {
217
+ invoker: wallet, // Wallet/Keypair signing the transaction.
218
+ isNative: // [ONLY FOR wSOL STREAMS] [optional] Wether topup is with Native Solanas
219
+ };
220
+
221
+ const aptosParams = {
222
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
223
+ tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
224
+ };
225
+
171
226
  try {
172
- const { ixs, tx } = await StreamClient.topup(topupStreamParams);
227
+ const { ixs, tx } = await StreamClient.topup(topupStreamParams, solanaParams);
173
228
  } catch (exception) {
174
229
  // handle exception
175
230
  }
@@ -179,13 +234,22 @@ try {
179
234
 
180
235
  ```javascript
181
236
  const data = {
237
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",// Identifier of a stream to be transferred.
238
+ recipientId: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // New Recipient address
239
+ };
240
+
241
+ const solanaParams = {
182
242
  invoker: wallet, // Wallet/Keypair signing the transaction.
183
- id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA",
184
- recipientId: "99h00075bKjVg000000tLdk4w42NyG3Mv0000dc0M99", // Identifier of a stream to be transferred.
185
243
  };
186
244
 
245
+ const aptosParams = {
246
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
247
+ tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
248
+ };
249
+
250
+
187
251
  try {
188
- const { tx } = await StreamClient.transfer(data);
252
+ const { tx } = await StreamClient.transfer(data, solanaParams);
189
253
  } catch (exception) {
190
254
  // handle exception
191
255
  }
@@ -195,12 +259,20 @@ try {
195
259
 
196
260
  ```javascript
197
261
  const cancelStreamParams = {
198
- invoker: wallet, // Wallet/Keypair signing the transaction.
199
262
  id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to be canceled.
200
263
  };
201
264
 
265
+ const solanaParams = {
266
+ invoker: wallet, // Wallet/Keypair signing the transaction.
267
+ };
268
+
269
+ const aptosParams = {
270
+ senderWallet: wallet, // AptosWalletAdapter Wallet of sender
271
+ tokenId: "0x1::aptos_coin::AptosCoin", // Aptos Coin type
272
+ };
273
+
202
274
  try {
203
- const { ixs, tx } = await StreamClient.cancel(cancelStreamParams);
275
+ const { ixs, tx } = await StreamClient.cancel(cancelStreamParams, solanaParams);
204
276
  } catch (exception) {
205
277
  // handle exception
206
278
  }
@@ -210,15 +282,16 @@ try {
210
282
 
211
283
  ```javascript
212
284
  try {
213
- const stream = await StreamClient.getOne(
214
- "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA" // Identifier of a stream that is fetched.
215
- );
285
+ const stream = await StreamClient.getOne({
286
+ id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA" // Identifier of a stream that is fetched.
287
+ });
216
288
  } catch (exception) {
217
289
  // handle exception
218
290
  }
219
291
  ```
220
292
 
221
293
  ## Get multiple streams for a specific wallet address
294
+ **NOTE: ONLY SUPPORTED FOR SOLANA CLIENT**
222
295
 
223
296
  ```javascript
224
297
  try {
@@ -234,11 +307,14 @@ try {
234
307
 
235
308
  ## Additional notes
236
309
 
237
- Default import `import Stream from '@streamflow/stream'` is an import of older SDK version that uses Anchor and doesn't support raw instructions, nor multi streams creation.
310
+ Streamflow protocol Solana program ID (devnet): `HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ`
311
+
312
+ Streamflow protocol Solana program ID (mainnet): `strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m`
313
+
314
+ Streamflow protocol Aptos program ID (testnet): `0xc6737de143d91b2f99a7e490d4f8348fdfa3bdd1eb8737a27d0455f8a3625688`
238
315
 
239
- Streamflow protocol program ID (devnet): `HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ`
316
+ Streamflow protocol Aptos program ID (mainnet): `0x9009d93d52576bf9ac6dc6cf10b870610bcb316342fef6eff80662fbbfce51b0`
240
317
 
241
- Streamflow protocol program ID (mainnet): `strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m`
242
318
 
243
319
  **All BN amounts are denominated in their smallest units.**
244
320
 
@@ -62,7 +62,7 @@ describe("AptosStreamClient", function () {
62
62
  it("should correctly set passed params", function () {
63
63
  var pid = "PID";
64
64
  var gas = "30";
65
- var instance = new StreamClient_1.default(types_1.ICluster.Devnet, gas, pid);
65
+ var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
66
66
  expect(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
67
67
  expect(instance.getProgramId()).toBe(pid);
68
68
  });
@@ -70,9 +70,9 @@ describe("AptosStreamClient", function () {
70
70
  describe("create", function () {
71
71
  var pid = "PID";
72
72
  var gas = "30";
73
- var instance = new StreamClient_1.default(types_1.ICluster.Devnet, gas, pid);
73
+ var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
74
74
  beforeEach(function () {
75
- instance = new StreamClient_1.default(types_1.ICluster.Devnet, gas, pid);
75
+ instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
76
76
  });
77
77
  test("should create a stream with passed parameters", function () { return __awaiter(void 0, void 0, void 0, function () {
78
78
  var mockSigner, mockWallet, mockRecipient, mockData, mockReturn, result, callParam, args;
@@ -1,17 +1,42 @@
1
1
  import { BaseStreamClient } from "../common/BaseStreamClient";
2
- import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, ITopUpData, ITransferData, IWithdrawData } from "../common/types";
3
- import { ICreateStreamAptosExt, IMultiTransactionResult, ITransactionAptosExt, ITransactionResult } from "./types";
2
+ import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IWithdrawData } from "../common/types";
3
+ import { Contract, ICreateStreamAptosExt, IMultiTransactionResult, ITransactionAptosExt, ITransactionResult } from "./types";
4
4
  export default class AptosStreamClient extends BaseStreamClient {
5
5
  private programId;
6
6
  private maxGas;
7
- constructor(cluster?: ICluster, maxGas?: string, programId?: string);
7
+ private client;
8
+ constructor(clusterUrl: string, cluster?: ICluster, maxGas?: string, programId?: string);
9
+ /**
10
+ * Creates a new stream/vesting contract.
11
+ */
8
12
  create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<ITransactionResult>;
13
+ /**
14
+ * Creates multiple stream/vesting contracts.
15
+ */
9
16
  createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamAptosExt): Promise<IMultiTransactionResult>;
17
+ /**
18
+ * Attempts withdrawing from the specified stream.
19
+ */
10
20
  withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
11
- cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
12
- transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
13
- topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<any>;
14
- getOne(): Promise<any>;
21
+ /**
22
+ * Attempts canceling the specified stream.
23
+ */
24
+ cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
25
+ /**
26
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
27
+ */
28
+ transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
29
+ /**
30
+ * Tops up stream account with specified amount.
31
+ */
32
+ topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionAptosExt): Promise<ITransactionResult>;
33
+ /**
34
+ * Fetch stream data by its id (address).
35
+ */
36
+ getOne({ id }: IGetOneData): Promise<Contract>;
37
+ /**
38
+ * Returns StreamClient protocol program ID.
39
+ */
15
40
  getProgramId(): string;
16
41
  getMaxGas(): {
17
42
  max_gas_amount: string;
@@ -55,16 +55,21 @@ var aptos_1 = require("aptos");
55
55
  var BaseStreamClient_1 = require("../common/BaseStreamClient");
56
56
  var types_1 = require("../common/types");
57
57
  var constants_1 = require("./constants");
58
+ var types_2 = require("./types");
58
59
  var AptosStreamClient = /** @class */ (function (_super) {
59
60
  __extends(AptosStreamClient, _super);
60
- function AptosStreamClient(cluster, maxGas, programId) {
61
+ function AptosStreamClient(clusterUrl, cluster, maxGas, programId) {
61
62
  if (cluster === void 0) { cluster = types_1.ICluster.Mainnet; }
62
63
  if (maxGas === void 0) { maxGas = "10000"; }
63
64
  var _this = _super.call(this) || this;
64
65
  _this.programId = programId ? programId : constants_1.APTOS_PROGRAM_IDS[cluster];
65
66
  _this.maxGas = maxGas;
67
+ _this.client = new aptos_1.AptosClient(clusterUrl);
66
68
  return _this;
67
69
  }
70
+ /**
71
+ * Creates a new stream/vesting contract.
72
+ */
68
73
  AptosStreamClient.prototype.create = function (streamData, _a) {
69
74
  var senderWallet = _a.senderWallet;
70
75
  return __awaiter(this, void 0, void 0, function () {
@@ -106,6 +111,9 @@ var AptosStreamClient = /** @class */ (function (_super) {
106
111
  });
107
112
  });
108
113
  };
114
+ /**
115
+ * Creates multiple stream/vesting contracts.
116
+ */
109
117
  AptosStreamClient.prototype.createMultiple = function (multipleStreamData, _a) {
110
118
  var _b;
111
119
  var senderWallet = _a.senderWallet;
@@ -158,6 +166,9 @@ var AptosStreamClient = /** @class */ (function (_super) {
158
166
  });
159
167
  });
160
168
  };
169
+ /**
170
+ * Attempts withdrawing from the specified stream.
171
+ */
161
172
  AptosStreamClient.prototype.withdraw = function (withdrawData, _a) {
162
173
  var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
163
174
  return __awaiter(this, void 0, void 0, function () {
@@ -179,6 +190,9 @@ var AptosStreamClient = /** @class */ (function (_super) {
179
190
  });
180
191
  });
181
192
  };
193
+ /**
194
+ * Attempts canceling the specified stream.
195
+ */
182
196
  AptosStreamClient.prototype.cancel = function (cancelData, _a) {
183
197
  var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
184
198
  return __awaiter(this, void 0, void 0, function () {
@@ -200,6 +214,9 @@ var AptosStreamClient = /** @class */ (function (_super) {
200
214
  });
201
215
  });
202
216
  };
217
+ /**
218
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
219
+ */
203
220
  AptosStreamClient.prototype.transfer = function (transferData, _a) {
204
221
  var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
205
222
  return __awaiter(this, void 0, void 0, function () {
@@ -221,6 +238,9 @@ var AptosStreamClient = /** @class */ (function (_super) {
221
238
  });
222
239
  });
223
240
  };
241
+ /**
242
+ * Tops up stream account with specified amount.
243
+ */
224
244
  AptosStreamClient.prototype.topup = function (topupData, _a) {
225
245
  var senderWallet = _a.senderWallet, tokenId = _a.tokenId;
226
246
  return __awaiter(this, void 0, void 0, function () {
@@ -242,19 +262,41 @@ var AptosStreamClient = /** @class */ (function (_super) {
242
262
  });
243
263
  });
244
264
  };
245
- AptosStreamClient.prototype.getOne = function () {
265
+ /**
266
+ * Fetch stream data by its id (address).
267
+ */
268
+ AptosStreamClient.prototype.getOne = function (_a) {
269
+ var _b;
270
+ var id = _a.id;
246
271
  return __awaiter(this, void 0, void 0, function () {
247
- return __generator(this, function (_a) {
248
- throw new Error("Not implemented.");
272
+ var contractResources, contract, tokenIdMatch, tokenId, data;
273
+ return __generator(this, function (_c) {
274
+ switch (_c.label) {
275
+ case 0: return [4 /*yield*/, this.client.getAccountResources(id)];
276
+ case 1:
277
+ contractResources = _c.sent();
278
+ contract = contractResources.find(function (r) { return r.type.includes("protocol::Contract"); });
279
+ if (!contract) {
280
+ throw new Error("Contract with id ".concat(id, " could not be found!"));
281
+ }
282
+ tokenIdMatch = contract.type.match(/0x[0-9a-f]+::protocol::Contract<(.*)>/);
283
+ tokenId = (_b = tokenIdMatch === null || tokenIdMatch === void 0 ? void 0 : tokenIdMatch[1]) !== null && _b !== void 0 ? _b : "";
284
+ data = contract.data;
285
+ return [2 /*return*/, new types_2.Contract(data, tokenId)];
286
+ }
249
287
  });
250
288
  });
251
289
  };
290
+ /**
291
+ * Returns StreamClient protocol program ID.
292
+ */
252
293
  AptosStreamClient.prototype.getProgramId = function () {
253
294
  return this.programId;
254
295
  };
255
296
  AptosStreamClient.prototype.getMaxGas = function () {
256
297
  return { max_gas_amount: this.maxGas };
257
298
  };
299
+ // Utility function to prepare transaction payloads for multiple recipients.
258
300
  AptosStreamClient.prototype.generateMultiPayloads = function (multipleStreamData) {
259
301
  var _this = this;
260
302
  return multipleStreamData.recipients.map(function (recipient) {
@@ -1,2 +1,2 @@
1
- export { default } from "./StreamClient";
1
+ export { default, default as AptosStreamClient } from "./StreamClient";
2
2
  export * from "./types";
@@ -17,7 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.default = void 0;
20
+ exports.AptosStreamClient = exports.default = void 0;
21
21
  var StreamClient_1 = require("./StreamClient");
22
22
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
23
+ Object.defineProperty(exports, "AptosStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
23
24
  __exportStar(require("./types"), exports);
@@ -1,10 +1,10 @@
1
1
  import { ICreateStreamData, ICreateMultipleStreamData, IWithdrawData, ICancelData, ITransferData, ITopUpData, IGetOneData } from "./types";
2
2
  export declare abstract class BaseStreamClient {
3
- abstract create(streamData: ICreateStreamData, ...chainSpecificParams: any[]): Promise<any>;
4
- abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, ...chainSpecificParams: any[]): Promise<any>;
5
- abstract withdraw(withdrawData: IWithdrawData, ...chainSpecificParams: any[]): Promise<any>;
6
- abstract cancel(cancelData: ICancelData, ...chainSpecificParams: any[]): Promise<any>;
7
- abstract transfer(transferData: ITransferData, ...chainSpecificParams: any[]): Promise<any>;
8
- abstract topup(topupData: ITopUpData, ...chainSpecificParams: any[]): Promise<any>;
9
- abstract getOne(getOneData: IGetOneData, ...chainSpecificParams: any[]): Promise<any>;
3
+ protected abstract create(streamData: ICreateStreamData, chainSpecificParams: any): Promise<any>;
4
+ protected abstract createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: any): Promise<any>;
5
+ protected abstract withdraw(withdrawData: IWithdrawData, chainSpecificParams: any): Promise<any>;
6
+ protected abstract cancel(cancelData: ICancelData, chainSpecificParams: any): Promise<any>;
7
+ protected abstract transfer(transferData: ITransferData, chainSpecificParams: any): Promise<any>;
8
+ protected abstract topup(topupData: ITopUpData, chainSpecificParams: any): Promise<any>;
9
+ protected abstract getOne(getOneData: IGetOneData, chainSpecificParams: any): Promise<any>;
10
10
  }
@@ -3,17 +3,18 @@ import SolanaStreamClient from "../solana/StreamClient";
3
3
  import AptosStreamClient from "../aptos/StreamClient";
4
4
  import { BaseStreamClient } from "./BaseStreamClient";
5
5
  import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IWithdrawData } from "./types";
6
- import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "../solana";
7
- import { ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos";
6
+ import { CreateMultiResponse, CreateResponse, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, Stream, TxResponse } from "../solana";
7
+ import { ICreateStreamAptosExt, IMultiTransactionResult, ITransactionAptosExt, ITransactionResult } from "../aptos";
8
8
  export interface SolanaStreamClientOptions {
9
9
  chain: IChain.Solana;
10
10
  clusterUrl: string;
11
- commitment?: Commitment | ConnectionConfig;
12
11
  cluster?: ICluster;
13
12
  programId?: string;
13
+ commitment?: Commitment | ConnectionConfig;
14
14
  }
15
15
  export interface AptosStreamClientOptions {
16
16
  chain: IChain.Aptos;
17
+ clusterUrl: string;
17
18
  cluster?: ICluster;
18
19
  programId?: string;
19
20
  maxGas?: string;
@@ -23,12 +24,33 @@ export default class GenericStreamClient extends BaseStreamClient {
23
24
  nativeStreamClient: SolanaStreamClient | AptosStreamClient;
24
25
  chain: IChain;
25
26
  constructor(options: GenericStreamClientOptions);
26
- create(streamData: ICreateStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<import("../solana").CreateResponse> | Promise<import("../aptos").ITransactionResult>;
27
- createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<import("../solana").CreateMultiResponse> | Promise<import("../aptos").IMultiTransactionResult>;
28
- withdraw(withdrawData: IWithdrawData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<import("../solana").TxResponse> | Promise<import("../aptos").ITransactionResult>;
29
- cancel(cancelData: ICancelData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<any>;
30
- transfer(transferData: ITransferData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<any>;
31
- topup(topupData: ITopUpData, chainSpecificParams: ITransactionAptosExt | ITopUpStreamSolanaExt): Promise<any>;
32
- getOne(getOneData: IGetOneData): Promise<any>;
27
+ /**
28
+ * Creates a new stream/vesting contract.
29
+ */
30
+ create(streamData: ICreateStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<CreateResponse | ITransactionResult>;
31
+ /**
32
+ * Creates multiple stream/vesting contracts.
33
+ */
34
+ createMultiple(multipleStreamData: ICreateMultipleStreamData, chainSpecificParams: ICreateStreamAptosExt | ICreateStreamSolanaExt): Promise<CreateMultiResponse | IMultiTransactionResult>;
35
+ /**
36
+ * Attempts withdrawing from the specified stream.
37
+ */
38
+ withdraw(withdrawData: IWithdrawData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
39
+ /**
40
+ * Attempts canceling the specified stream.
41
+ */
42
+ cancel(cancelData: ICancelData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
43
+ /**
44
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
45
+ */
46
+ transfer(transferData: ITransferData, chainSpecificParams: ITransactionAptosExt | IInteractStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
47
+ /**
48
+ * Tops up stream account with specified amount.
49
+ */
50
+ topup(topupData: ITopUpData, chainSpecificParams: ITransactionAptosExt | ITopUpStreamSolanaExt): Promise<TxResponse | ITransactionResult>;
51
+ /**
52
+ * Fetch stream data by its id (address).
53
+ */
54
+ getOne(getOneData: IGetOneData): Promise<Stream>;
33
55
  }
34
56
  export {};
@@ -31,10 +31,13 @@ var GenericStreamClient = /** @class */ (function (_super) {
31
31
  _this.nativeStreamClient = new StreamClient_1.default(options.clusterUrl, options.cluster, options.commitment, options.programId);
32
32
  }
33
33
  else {
34
- _this.nativeStreamClient = new StreamClient_2.default(options.cluster, options.maxGas, options.programId);
34
+ _this.nativeStreamClient = new StreamClient_2.default(options.clusterUrl, options.cluster, options.maxGas, options.programId);
35
35
  }
36
36
  return _this;
37
37
  }
38
+ /**
39
+ * Creates a new stream/vesting contract.
40
+ */
38
41
  GenericStreamClient.prototype.create = function (streamData, chainSpecificParams) {
39
42
  if (this.nativeStreamClient instanceof StreamClient_1.default) {
40
43
  var params = chainSpecificParams;
@@ -45,6 +48,9 @@ var GenericStreamClient = /** @class */ (function (_super) {
45
48
  return this.nativeStreamClient.create(streamData, params);
46
49
  }
47
50
  };
51
+ /**
52
+ * Creates multiple stream/vesting contracts.
53
+ */
48
54
  GenericStreamClient.prototype.createMultiple = function (multipleStreamData, chainSpecificParams) {
49
55
  if (this.nativeStreamClient instanceof StreamClient_1.default) {
50
56
  var params = chainSpecificParams;
@@ -55,6 +61,9 @@ var GenericStreamClient = /** @class */ (function (_super) {
55
61
  return this.nativeStreamClient.createMultiple(multipleStreamData, params);
56
62
  }
57
63
  };
64
+ /**
65
+ * Attempts withdrawing from the specified stream.
66
+ */
58
67
  GenericStreamClient.prototype.withdraw = function (withdrawData, chainSpecificParams) {
59
68
  if (this.nativeStreamClient instanceof StreamClient_1.default) {
60
69
  var params = chainSpecificParams;
@@ -65,6 +74,9 @@ var GenericStreamClient = /** @class */ (function (_super) {
65
74
  return this.nativeStreamClient.withdraw(withdrawData, params);
66
75
  }
67
76
  };
77
+ /**
78
+ * Attempts canceling the specified stream.
79
+ */
68
80
  GenericStreamClient.prototype.cancel = function (cancelData, chainSpecificParams) {
69
81
  if (this.nativeStreamClient instanceof StreamClient_1.default) {
70
82
  var params = chainSpecificParams;
@@ -75,6 +87,9 @@ var GenericStreamClient = /** @class */ (function (_super) {
75
87
  return this.nativeStreamClient.cancel(cancelData, params);
76
88
  }
77
89
  };
90
+ /**
91
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
92
+ */
78
93
  GenericStreamClient.prototype.transfer = function (transferData, chainSpecificParams) {
79
94
  if (this.nativeStreamClient instanceof StreamClient_1.default) {
80
95
  var params = chainSpecificParams;
@@ -85,6 +100,9 @@ var GenericStreamClient = /** @class */ (function (_super) {
85
100
  return this.nativeStreamClient.transfer(transferData, params);
86
101
  }
87
102
  };
103
+ /**
104
+ * Tops up stream account with specified amount.
105
+ */
88
106
  GenericStreamClient.prototype.topup = function (topupData, chainSpecificParams) {
89
107
  if (this.nativeStreamClient instanceof StreamClient_1.default) {
90
108
  var params = chainSpecificParams;
@@ -95,6 +113,9 @@ var GenericStreamClient = /** @class */ (function (_super) {
95
113
  return this.nativeStreamClient.topup(topupData, params);
96
114
  }
97
115
  };
116
+ /**
117
+ * Fetch stream data by its id (address).
118
+ */
98
119
  GenericStreamClient.prototype.getOne = function (getOneData) {
99
120
  return this.nativeStreamClient.getOne(getOneData);
100
121
  };
@@ -15,26 +15,6 @@ export default class SolanaStreamClient extends BaseStreamClient {
15
15
  /**
16
16
  * Creates a new stream/vesting contract.
17
17
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
18
- * @param {CreateParams} data
19
- * @param {WalletAdapter | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
20
- * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
21
- * @param {string} data.mint - SPL Token mint.
22
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
23
- * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
24
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
25
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
26
- * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
27
- * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
28
- * @param {string} data.name - Stream name/subject.
29
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
30
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
31
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
32
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
33
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
34
- * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
35
- * @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.
36
- * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
37
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
38
18
  */
39
19
  create({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateResponse>;
40
20
  /**
@@ -46,101 +26,42 @@ export default class SolanaStreamClient extends BaseStreamClient {
46
26
  * - initialized contract PDA off chain
47
27
  *
48
28
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
49
- *
50
- * @param {CreateParams} data
51
- * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
52
- * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
53
- * @param {string} data.mint - SPL Token mint.
54
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
55
- * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
56
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
57
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
58
- * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
59
- * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
60
- * @param {string} data.name - Stream name/subject.
61
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
62
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
63
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
64
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
65
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
66
- * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
67
- * @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.
68
- * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
69
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
70
29
  */
71
30
  createUnchecked({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, }: ICreateStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateResponse>;
72
31
  /**
73
- * Creates a new stream/vesting contract.
32
+ * Creates multiple stream/vesting contracts.
74
33
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
75
- * @param {CreateMultiParams} data
76
- * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
77
- * @param {MultiRecipient[]} data.recipientsData
78
- * @param {string} data.mint - SPL Token mint.
79
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
80
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
81
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
82
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
83
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
84
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
85
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
86
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
87
- * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
88
- * @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.
89
- * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
90
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
91
34
  */
92
35
  createMultiple(data: ICreateMultipleStreamData, { sender, partner, isNative }: ICreateStreamSolanaExt): Promise<CreateMultiResponse>;
93
36
  /**
94
- * Attempts withdrawal from the specified stream.
95
- * @param {WithdrawParams} data
96
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
97
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
98
- * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
37
+ * Attempts withdrawing from the specified stream.
99
38
  */
100
39
  withdraw({ id, amount }: IWithdrawData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
101
40
  /**
102
41
  * Attempts canceling the specified stream.
103
- * @param {CancelParams} data
104
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
105
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
106
42
  */
107
43
  cancel({ id }: ICancelData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
108
44
  /**
109
45
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
110
46
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
111
- * @param {TransferParams} data
112
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
113
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
114
- * @param {string} data.recipientId - Address of a new recipient.
115
47
  */
116
48
  transfer({ id, newRecipient: newRecipientString }: ITransferData, { invoker }: IInteractStreamSolanaExt): Promise<TxResponse>;
117
49
  /**
118
- * Tops up stream account deposited amount.
119
- * @param {TopupParams} data
120
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
121
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
122
- * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
50
+ * Tops up stream account with specified amount.
123
51
  */
124
52
  topup({ id, amount }: ITopUpData, { invoker, isNative }: ITopUpStreamSolanaExt): Promise<TxResponse>;
125
53
  /**
126
54
  * Fetch stream data by its id (address).
127
- * @param {string} id - Identifier of a stream that is fetched.
128
55
  */
129
56
  getOne({ id }: IGetOneData): Promise<StreamData>;
130
57
  /**
131
58
  * Fetch streams/contracts by providing direction.
132
59
  * Streams are sorted by start time in ascending order.
133
- * @param {GetAllParams} data
134
- * @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
135
- * @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
136
- * @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
137
60
  */
138
61
  get({ wallet, type, direction, }: GetAllParams): Promise<[string, StreamData][]>;
139
62
  private sign;
140
63
  /**
141
64
  * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
142
- * @param {MultiRecipient} recipient - Wallet sending stream to
143
- * @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
144
65
  */
145
66
  private prepareStreamTransaction;
146
67
  }
@@ -139,26 +139,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
139
139
  /**
140
140
  * Creates a new stream/vesting contract.
141
141
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
142
- * @param {CreateParams} data
143
- * @param {WalletAdapter | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
144
- * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
145
- * @param {string} data.mint - SPL Token mint.
146
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
147
- * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
148
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
149
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
150
- * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
151
- * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
152
- * @param {string} data.name - Stream name/subject.
153
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
154
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
155
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
156
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
157
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
158
- * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
159
- * @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.
160
- * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
161
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
162
142
  */
163
143
  SolanaStreamClient.prototype.create = function (_a, _b) {
164
144
  var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d;
@@ -173,7 +153,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
173
153
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
174
154
  }
175
155
  ixs = [];
176
- mintPublicKey = isNative ? new web3_js_1.PublicKey(mint) : spl_token_1.NATIVE_MINT;
156
+ mintPublicKey = isNative ? spl_token_1.NATIVE_MINT : new web3_js_1.PublicKey(mint);
177
157
  recipientPublicKey = new web3_js_1.PublicKey(recipient);
178
158
  metadata = web3_js_1.Keypair.generate();
179
159
  return [4 /*yield*/, web3_js_1.PublicKey.findProgramAddress([buffer_1.Buffer.from("strm"), metadata.publicKey.toBuffer()], this.programId)];
@@ -264,27 +244,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
264
244
  * - initialized contract PDA off chain
265
245
  *
266
246
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
267
- *
268
- * @param {CreateParams} data
269
- * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
270
- * @param {string} data.recipient - Solana address of the recipient. Associated token account will be derived using this address and token mint address.
271
- * @param {string} data.mint - SPL Token mint.
272
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
273
- * @param {BN} data.depositedAmount - Initially deposited amount of tokens (in the smallest units).
274
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
275
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
276
- * @param {BN} data.cliffAmount - Amount unlocked at the "cliff".
277
- * @param {BN} data.amountPerPeriod - Amount unlocked per each period.
278
- * @param {string} data.name - Stream name/subject.
279
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
280
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
281
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
282
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
283
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
284
- * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
285
- * @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.
286
- * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
287
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
288
247
  */
289
248
  SolanaStreamClient.prototype.createUnchecked = function (_a, _b) {
290
249
  var recipient = _a.recipient, mint = _a.tokenId, start = _a.start, depositedAmount = _a.amount, period = _a.period, cliff = _a.cliff, cliffAmount = _a.cliffAmount, amountPerPeriod = _a.amountPerPeriod, name = _a.name, canTopup = _a.canTopup, cancelableBySender = _a.cancelableBySender, cancelableByRecipient = _a.cancelableByRecipient, transferableBySender = _a.transferableBySender, transferableByRecipient = _a.transferableByRecipient, _c = _a.automaticWithdrawal, automaticWithdrawal = _c === void 0 ? false : _c, _d = _a.withdrawalFrequency, withdrawalFrequency = _d === void 0 ? 0 : _d;
@@ -378,24 +337,8 @@ var SolanaStreamClient = /** @class */ (function (_super) {
378
337
  });
379
338
  };
380
339
  /**
381
- * Creates a new stream/vesting contract.
340
+ * Creates multiple stream/vesting contracts.
382
341
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
383
- * @param {CreateMultiParams} data
384
- * @param {Wallet | Keypair} data.sender - Wallet signing the transaction. Its address should match the authorized wallet (sender) or transaction will fail.
385
- * @param {MultiRecipient[]} data.recipientsData
386
- * @param {string} data.mint - SPL Token mint.
387
- * @param {number} data.start - Timestamp (in seconds) when the stream/token vesting starts.
388
- * @param {number} data.period - Time step (period) in seconds per which the unlocking occurs.
389
- * @param {number} data.cliff - Vesting contract "cliff" timestamp in seconds.
390
- * @param {boolean} data.canTopup - TRUE for streams, FALSE for vesting contracts.
391
- * @param {boolean} data.cancelableBySender - Whether or not sender can cancel the stream.
392
- * @param {boolean} data.cancelableByRecipient - Whether or not recipient can cancel the stream.
393
- * @param {boolean} data.transferableBySender - Whether or not sender can transfer the stream.
394
- * @param {boolean} data.transferableByRecipient - Whether or not recipient can transfer the stream.
395
- * @param {boolean} data.automaticWithdrawal - Whether or not a 3rd party can initiate withdraw in the name of recipient.
396
- * @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.
397
- * @param {boolean} [data.isNative = false] - When true Automatically wraps SOLs to WrappedSOL and creates wSOL stream
398
- * @param {string | null} [data.partner = null] - Partner's wallet address (optional).
399
342
  */
400
343
  SolanaStreamClient.prototype.createMultiple = function (data, _a) {
401
344
  var sender = _a.sender, _b = _a.partner, partner = _b === void 0 ? null : _b, _c = _a.isNative, isNative = _c === void 0 ? false : _c;
@@ -495,11 +438,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
495
438
  });
496
439
  };
497
440
  /**
498
- * Attempts withdrawal from the specified stream.
499
- * @param {WithdrawParams} data
500
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (recipient) or transaction will fail.
501
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be withdrawn from.
502
- * @param {BN} data.amount - Requested amount (in the smallest units) to withdraw (while streaming). If stream is completed, the whole amount will be withdrawn.
441
+ * Attempts withdrawing from the specified stream.
503
442
  */
504
443
  SolanaStreamClient.prototype.withdraw = function (_a, _b) {
505
444
  var id = _a.id, amount = _a.amount;
@@ -560,9 +499,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
560
499
  };
561
500
  /**
562
501
  * Attempts canceling the specified stream.
563
- * @param {CancelParams} data
564
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
565
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be canceled.
566
502
  */
567
503
  SolanaStreamClient.prototype.cancel = function (_a, _b) {
568
504
  var id = _a.id;
@@ -626,10 +562,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
626
562
  /**
627
563
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
628
564
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
629
- * @param {TransferParams} data
630
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match authorized wallet (sender or recipient) or transaction will fail.
631
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be transferred.
632
- * @param {string} data.recipientId - Address of a new recipient.
633
565
  */
634
566
  SolanaStreamClient.prototype.transfer = function (_a, _b) {
635
567
  var id = _a.id, newRecipientString = _a.newRecipient;
@@ -685,11 +617,7 @@ var SolanaStreamClient = /** @class */ (function (_super) {
685
617
  });
686
618
  };
687
619
  /**
688
- * Tops up stream account deposited amount.
689
- * @param {TopupParams} data
690
- * @param {Wallet | Keypair} data.invoker - Wallet signing the transaction. It's address should match current stream sender or transaction will fail.
691
- * @param {string} data.id - Identifier of a stream (escrow account with metadata) to be topped up.
692
- * @param {BN} data.amount - Specified amount (in the smallest units) to topup (increases deposited amount).
620
+ * Tops up stream account with specified amount.
693
621
  */
694
622
  SolanaStreamClient.prototype.topup = function (_a, _b) {
695
623
  var id = _a.id, amount = _a.amount;
@@ -761,7 +689,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
761
689
  };
762
690
  /**
763
691
  * Fetch stream data by its id (address).
764
- * @param {string} id - Identifier of a stream that is fetched.
765
692
  */
766
693
  SolanaStreamClient.prototype.getOne = function (_a) {
767
694
  var id = _a.id;
@@ -783,10 +710,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
783
710
  /**
784
711
  * Fetch streams/contracts by providing direction.
785
712
  * Streams are sorted by start time in ascending order.
786
- * @param {GetAllParams} data
787
- * @param {PublicKey} data.wallet - PublicKey of the wallet for which the streams/contracts are fetched.
788
- * @param {StreamType} [data.type = StreamType.All] - It can be one of: stream, vesting, all.
789
- * @param {StreamDirection} [data.direction = StreamDirection.All] - It can be one of: incoming, outgoing, all.
790
713
  */
791
714
  SolanaStreamClient.prototype.get = function (_a) {
792
715
  var wallet = _a.wallet, _b = _a.type, type = _b === void 0 ? types_2.StreamType.All : _b, _c = _a.direction, direction = _c === void 0 ? types_2.StreamDirection.All : _c;
@@ -865,8 +788,6 @@ var SolanaStreamClient = /** @class */ (function (_super) {
865
788
  };
866
789
  /**
867
790
  * Forms instructions from params, creates a raw transaction and fetch recent blockhash.
868
- * @param {MultiRecipient} recipient - Wallet sending stream to
869
- * @param {CreateMultiParams} streamParams - Parameters of stream user wants to create.
870
791
  */
871
792
  SolanaStreamClient.prototype.prepareStreamTransaction = function (recipient, streamParams, solanaExtendedConfig) {
872
793
  return __awaiter(this, void 0, void 0, function () {
@@ -1,4 +1,4 @@
1
- export { default } from "./StreamClient";
1
+ export { default, default as SolanaStreamClient } from "./StreamClient";
2
2
  export * from "./utils";
3
3
  export * from "./types";
4
4
  export * from "./instructions";
@@ -29,9 +29,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.BN = exports.timelockIDL = exports.constants = exports.default = void 0;
32
+ exports.BN = exports.timelockIDL = exports.constants = exports.SolanaStreamClient = exports.default = void 0;
33
33
  var StreamClient_1 = require("./StreamClient");
34
34
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
35
+ Object.defineProperty(exports, "SolanaStreamClient", { enumerable: true, get: function () { return __importDefault(StreamClient_1).default; } });
35
36
  __exportStar(require("./utils"), exports);
36
37
  __exportStar(require("./types"), exports);
37
38
  __exportStar(require("./instructions"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "4.0.0-Alpha.2",
3
+ "version": "4.0.0-beta.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/",