@zebec-network/zebec-stream-sdk 1.0.0 → 1.1.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 +80 -80
- package/dist/artifacts/zebec_stream.d.ts +548 -0
- package/dist/artifacts/zebec_stream.json +428 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +9 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/pda.d.ts +1 -0
- package/dist/pda.js +5 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +18 -0
- package/dist/{service.d.ts → services/streamService.d.ts} +21 -5
- package/dist/{service.js → services/streamService.js} +36 -6
- package/dist/services/tokenService.d.ts +44 -0
- package/dist/services/tokenService.js +211 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -42,24 +42,24 @@ const streamService = ZebecStreamService.create(provider, "devnet");
|
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
44
|
const streamParams = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
receiver: "ReceiverPublicKeyHere",
|
|
46
|
+
sender: "SenderPublicKeyHere",
|
|
47
|
+
streamToken: "TokenMintAddressHere",
|
|
48
|
+
amount: "1000", // Amount in token units
|
|
49
|
+
duration: 86400, // 1 day in seconds
|
|
50
|
+
streamFrequency: 3600, // 1 hour in seconds
|
|
51
|
+
streamName: "Monthly Salary",
|
|
52
|
+
startNow: true,
|
|
53
|
+
automaticWithdrawal: false,
|
|
54
|
+
cancelableByRecipient: true,
|
|
55
|
+
cancelableBySender: true,
|
|
56
|
+
isPausable: true,
|
|
57
|
+
transferableByRecipient: false,
|
|
58
|
+
transferableBySender: false,
|
|
59
|
+
canTopup: true,
|
|
60
|
+
rateUpdatable: false,
|
|
61
|
+
cliffPercentage: 0, // No cliff
|
|
62
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const transaction = await streamService.createStream(streamParams);
|
|
@@ -87,7 +87,7 @@ Creates a new payment stream.
|
|
|
87
87
|
**Parameters:**
|
|
88
88
|
|
|
89
89
|
- `receiver`: Address - The recipient's public key
|
|
90
|
-
- `sender`: Address - The sender's public key
|
|
90
|
+
- `sender`: Address - The sender's public key
|
|
91
91
|
- `streamToken`: Address - The SPL token mint address
|
|
92
92
|
- `amount`: Numeric - Amount to stream (in token units)
|
|
93
93
|
- `duration`: number - Stream duration in seconds
|
|
@@ -169,7 +169,7 @@ Retrieves global stream configuration.
|
|
|
169
169
|
- `withdrawerAccount`: Withdraw account address
|
|
170
170
|
- `whitelistedTokens`: Array of whitelisted token addresses
|
|
171
171
|
- `platformFee`: Platform fee percentage
|
|
172
|
-
- `baseFee`: Base fee percentage
|
|
172
|
+
- `baseFee`: Base fee percentage
|
|
173
173
|
- `frequencies`: Allowed stream frequencies
|
|
174
174
|
|
|
175
175
|
### Admin Operations
|
|
@@ -201,37 +201,37 @@ Adds tokens to the whitelist (admin only).
|
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
203
|
type StreamMetadataInfo = {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
204
|
+
parties: {
|
|
205
|
+
sender: PublicKey;
|
|
206
|
+
receiver: PublicKey;
|
|
207
|
+
};
|
|
208
|
+
financials: {
|
|
209
|
+
streamToken: PublicKey;
|
|
210
|
+
cliffPercentage: number;
|
|
211
|
+
depositedAmount: string;
|
|
212
|
+
withdrawnAmount: string;
|
|
213
|
+
};
|
|
214
|
+
schedule: {
|
|
215
|
+
startTime: number;
|
|
216
|
+
endTime: number;
|
|
217
|
+
lastWithdrawTime: number;
|
|
218
|
+
frequency: number;
|
|
219
|
+
duration: number;
|
|
220
|
+
pausedTimestamp: number;
|
|
221
|
+
pausedInterval: number;
|
|
222
|
+
canceledTimestamp: number;
|
|
223
|
+
};
|
|
224
|
+
permissions: {
|
|
225
|
+
cancelableBySender: boolean;
|
|
226
|
+
cancelableByRecipient: boolean;
|
|
227
|
+
automaticWithdrawal: boolean;
|
|
228
|
+
transferableBySender: boolean;
|
|
229
|
+
transferableByRecipient: boolean;
|
|
230
|
+
canTopup: boolean;
|
|
231
|
+
isPausable: boolean;
|
|
232
|
+
rateUpdatable: boolean;
|
|
233
|
+
};
|
|
234
|
+
streamName: string;
|
|
235
235
|
};
|
|
236
236
|
```
|
|
237
237
|
|
|
@@ -239,12 +239,12 @@ type StreamMetadataInfo = {
|
|
|
239
239
|
|
|
240
240
|
```typescript
|
|
241
241
|
type StreamConfigInfo = {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
admin: PublicKey;
|
|
243
|
+
withdrawerAccount: PublicKey;
|
|
244
|
+
whitelistedTokens: PublicKey[];
|
|
245
|
+
platformFee: number;
|
|
246
|
+
baseFee: number;
|
|
247
|
+
frequencies: number[];
|
|
248
248
|
};
|
|
249
249
|
```
|
|
250
250
|
|
|
@@ -258,8 +258,8 @@ For operations that require signing transactions:
|
|
|
258
258
|
import { createAnchorProvider } from "@zebec-network/stream-sdk";
|
|
259
259
|
|
|
260
260
|
const provider = createAnchorProvider(connection, wallet, {
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
commitment: "confirmed",
|
|
262
|
+
preflightCommitment: "confirmed",
|
|
263
263
|
});
|
|
264
264
|
```
|
|
265
265
|
|
|
@@ -280,15 +280,15 @@ const provider = createReadonlyProvider(connection, optionalWalletAddress);
|
|
|
280
280
|
```typescript
|
|
281
281
|
// 1. Create a stream
|
|
282
282
|
const createParams = {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
283
|
+
receiver: receiverAddress,
|
|
284
|
+
sender: senderAddress,
|
|
285
|
+
streamToken: tokenMintAddress,
|
|
286
|
+
amount: "1000",
|
|
287
|
+
duration: 86400, // 1 day
|
|
288
|
+
streamFrequency: 3600, // 1 hour
|
|
289
|
+
streamName: "Test Stream",
|
|
290
|
+
startNow: true,
|
|
291
|
+
// ... other parameters
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
const createTx = await streamService.createStream(createParams);
|
|
@@ -300,15 +300,15 @@ console.log("Stream info:", streamInfo);
|
|
|
300
300
|
|
|
301
301
|
// 3. Withdraw from stream
|
|
302
302
|
const withdrawTx = await streamService.withdrawStream({
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
streamMetadata,
|
|
304
|
+
receiver: receiverAddress,
|
|
305
305
|
});
|
|
306
306
|
await withdrawTx.execute();
|
|
307
307
|
|
|
308
308
|
// 4. Cancel stream
|
|
309
309
|
const cancelTx = await streamService.cancelStream({
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
streamMetadata,
|
|
311
|
+
user: senderAddress,
|
|
312
312
|
});
|
|
313
313
|
await cancelTx.execute();
|
|
314
314
|
```
|
|
@@ -317,15 +317,15 @@ await cancelTx.execute();
|
|
|
317
317
|
|
|
318
318
|
```typescript
|
|
319
319
|
try {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
const transaction = await streamService.createStream(params);
|
|
321
|
+
const signature = await transaction.execute();
|
|
322
|
+
console.log("Stream created:", signature);
|
|
323
323
|
} catch (error) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
324
|
+
if (error.message.includes("Invalid stream frequency")) {
|
|
325
|
+
console.error("Please use an allowed stream frequency");
|
|
326
|
+
} else {
|
|
327
|
+
console.error("Stream creation failed:", error);
|
|
328
|
+
}
|
|
329
329
|
}
|
|
330
330
|
```
|
|
331
331
|
|