@paylobster/cli 4.0.1 → 4.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.
Files changed (45) hide show
  1. package/README.md +78 -249
  2. package/dist/src/commands/cascade.d.ts +3 -0
  3. package/dist/src/commands/cascade.d.ts.map +1 -0
  4. package/dist/src/commands/cascade.js +242 -0
  5. package/dist/src/commands/cascade.js.map +1 -0
  6. package/dist/src/commands/compliance.d.ts +3 -0
  7. package/dist/src/commands/compliance.d.ts.map +1 -0
  8. package/dist/src/commands/compliance.js +121 -0
  9. package/dist/src/commands/compliance.js.map +1 -0
  10. package/dist/src/commands/credit-score.d.ts +3 -0
  11. package/dist/src/commands/credit-score.d.ts.map +1 -0
  12. package/dist/src/commands/credit-score.js +174 -0
  13. package/dist/src/commands/credit-score.js.map +1 -0
  14. package/dist/src/commands/dispute.d.ts +3 -0
  15. package/dist/src/commands/dispute.d.ts.map +1 -0
  16. package/dist/src/commands/dispute.js +241 -0
  17. package/dist/src/commands/dispute.js.map +1 -0
  18. package/dist/src/commands/intent.d.ts +3 -0
  19. package/dist/src/commands/intent.d.ts.map +1 -0
  20. package/dist/src/commands/intent.js +227 -0
  21. package/dist/src/commands/intent.js.map +1 -0
  22. package/dist/src/commands/oracle.d.ts +3 -0
  23. package/dist/src/commands/oracle.d.ts.map +1 -0
  24. package/dist/src/commands/oracle.js +114 -0
  25. package/dist/src/commands/oracle.js.map +1 -0
  26. package/dist/src/commands/revenue-share.d.ts +3 -0
  27. package/dist/src/commands/revenue-share.d.ts.map +1 -0
  28. package/dist/src/commands/revenue-share.js +185 -0
  29. package/dist/src/commands/revenue-share.js.map +1 -0
  30. package/dist/src/commands/stream.d.ts +3 -0
  31. package/dist/src/commands/stream.d.ts.map +1 -0
  32. package/dist/src/commands/stream.js +213 -0
  33. package/dist/src/commands/stream.js.map +1 -0
  34. package/dist/src/index.js +16 -0
  35. package/dist/src/index.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/commands/cascade.ts +280 -0
  38. package/src/commands/compliance.ts +123 -0
  39. package/src/commands/credit-score.ts +193 -0
  40. package/src/commands/dispute.ts +274 -0
  41. package/src/commands/intent.ts +261 -0
  42. package/src/commands/oracle.ts +116 -0
  43. package/src/commands/revenue-share.ts +213 -0
  44. package/src/commands/stream.ts +244 -0
  45. package/src/index.ts +16 -0
@@ -0,0 +1,244 @@
1
+ import { Command } from 'commander';
2
+ import { success, error, info, withSpinner, outputJSON, formatAddress, confirm, createTable } from '../lib/display';
3
+ import type { OutputOptions } from '../lib/types';
4
+
5
+ export function createStreamCommand(): Command {
6
+ const cmd = new Command('stream')
7
+ .description('Manage payment streams');
8
+
9
+ // plob stream create
10
+ cmd
11
+ .command('create')
12
+ .description('Create a new payment stream')
13
+ .requiredOption('--to <address>', 'Recipient address')
14
+ .requiredOption('--amount <amount>', 'Total amount in USDC')
15
+ .requiredOption('--duration <duration>', 'Duration (e.g., 30d, 1h, 60m)')
16
+ .option('--interval <interval>', 'Payment interval (e.g., 1d, 1h)', '1d')
17
+ .option('--json', 'Output as JSON')
18
+ .action(async (options: {
19
+ to: string;
20
+ amount: string;
21
+ duration: string;
22
+ interval: string;
23
+ } & OutputOptions) => {
24
+ try {
25
+ // Validate address
26
+ if (!options.to.startsWith('0x') || options.to.length !== 42) {
27
+ error('Invalid recipient address format');
28
+ process.exit(1);
29
+ }
30
+
31
+ // Validate amount
32
+ const amount = parseFloat(options.amount);
33
+ if (isNaN(amount) || amount <= 0) {
34
+ error('Invalid amount. Must be a positive number');
35
+ process.exit(1);
36
+ }
37
+
38
+ info(`Creating stream: ${options.amount} USDC over ${options.duration}`);
39
+ info(`To: ${formatAddress(options.to)}`);
40
+ info(`Interval: ${options.interval}`);
41
+
42
+ // TODO: Implement actual stream creation
43
+ const streamId = Math.floor(Math.random() * 1000000); // Placeholder
44
+
45
+ const txHash = await withSpinner(
46
+ 'Creating payment stream...',
47
+ async () => {
48
+ // Placeholder - implement actual contract call
49
+ await new Promise(resolve => setTimeout(resolve, 2000));
50
+ return '0x' + Math.random().toString(16).substring(2, 66);
51
+ }
52
+ );
53
+
54
+ if (outputJSON({
55
+ streamId,
56
+ txHash,
57
+ to: options.to,
58
+ amount: options.amount,
59
+ duration: options.duration,
60
+ interval: options.interval,
61
+ }, options)) {
62
+ return;
63
+ }
64
+
65
+ success('Payment stream created!');
66
+ info(`Stream ID: ${streamId}`);
67
+ info(`Transaction: ${txHash}`);
68
+ } catch (err) {
69
+ error(`Failed to create stream: ${err}`);
70
+ process.exit(1);
71
+ }
72
+ });
73
+
74
+ // plob stream cancel
75
+ cmd
76
+ .command('cancel')
77
+ .description('Cancel a payment stream')
78
+ .argument('<streamId>', 'Stream ID')
79
+ .option('--yes', 'Skip confirmation')
80
+ .option('--json', 'Output as JSON')
81
+ .action(async (streamId: string, options: { yes?: boolean } & OutputOptions) => {
82
+ try {
83
+ if (!options.yes) {
84
+ const confirmed = await confirm(`Cancel stream ${streamId}?`);
85
+ if (!confirmed) {
86
+ info('Cancelled');
87
+ process.exit(0);
88
+ }
89
+ }
90
+
91
+ const txHash = await withSpinner(
92
+ 'Cancelling stream...',
93
+ async () => {
94
+ // Placeholder - implement actual contract call
95
+ await new Promise(resolve => setTimeout(resolve, 1500));
96
+ return '0x' + Math.random().toString(16).substring(2, 66);
97
+ }
98
+ );
99
+
100
+ if (outputJSON({ streamId, txHash }, options)) {
101
+ return;
102
+ }
103
+
104
+ success(`Stream ${streamId} cancelled!`);
105
+ info(`Transaction: ${txHash}`);
106
+ } catch (err) {
107
+ error(`Failed to cancel stream: ${err}`);
108
+ process.exit(1);
109
+ }
110
+ });
111
+
112
+ // plob stream list
113
+ cmd
114
+ .command('list')
115
+ .description('List your payment streams')
116
+ .option('--json', 'Output as JSON')
117
+ .action(async (options: OutputOptions) => {
118
+ try {
119
+ // Placeholder data
120
+ const streams = [
121
+ {
122
+ id: 1,
123
+ to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
124
+ amount: '1000 USDC',
125
+ streamed: '300 USDC',
126
+ remaining: '700 USDC',
127
+ status: 'active',
128
+ },
129
+ {
130
+ id: 2,
131
+ to: '0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199',
132
+ amount: '500 USDC',
133
+ streamed: '500 USDC',
134
+ remaining: '0 USDC',
135
+ status: 'completed',
136
+ },
137
+ ];
138
+
139
+ if (outputJSON(streams, options)) {
140
+ return;
141
+ }
142
+
143
+ if (streams.length === 0) {
144
+ info('No streams found');
145
+ return;
146
+ }
147
+
148
+ const table = createTable({
149
+ head: ['ID', 'To', 'Amount', 'Streamed', 'Remaining', 'Status'],
150
+ });
151
+
152
+ for (const stream of streams) {
153
+ table.push([
154
+ stream.id,
155
+ formatAddress(stream.to),
156
+ stream.amount,
157
+ stream.streamed,
158
+ stream.remaining,
159
+ stream.status,
160
+ ]);
161
+ }
162
+
163
+ console.log(table.toString());
164
+ } catch (err) {
165
+ error(`Failed to list streams: ${err}`);
166
+ process.exit(1);
167
+ }
168
+ });
169
+
170
+ // plob stream get
171
+ cmd
172
+ .command('get')
173
+ .description('Get stream details')
174
+ .argument('<streamId>', 'Stream ID')
175
+ .option('--json', 'Output as JSON')
176
+ .action(async (streamId: string, options: OutputOptions) => {
177
+ try {
178
+ // Placeholder data
179
+ const stream = {
180
+ id: streamId,
181
+ from: '0x1234567890123456789012345678901234567890',
182
+ to: '0x0987654321098765432109876543210987654321',
183
+ totalAmount: '1000 USDC',
184
+ streamedAmount: '300 USDC',
185
+ remainingAmount: '700 USDC',
186
+ startTime: new Date().toISOString(),
187
+ duration: '30 days',
188
+ interval: '1 day',
189
+ status: 'active',
190
+ };
191
+
192
+ if (outputJSON(stream, options)) {
193
+ return;
194
+ }
195
+
196
+ console.log();
197
+ console.log('Stream ID: ', stream.id);
198
+ console.log('From: ', stream.from);
199
+ console.log('To: ', stream.to);
200
+ console.log('Total Amount: ', stream.totalAmount);
201
+ console.log('Streamed: ', stream.streamedAmount);
202
+ console.log('Remaining: ', stream.remainingAmount);
203
+ console.log('Start Time: ', stream.startTime);
204
+ console.log('Duration: ', stream.duration);
205
+ console.log('Interval: ', stream.interval);
206
+ console.log('Status: ', stream.status);
207
+ console.log();
208
+ } catch (err) {
209
+ error(`Failed to get stream: ${err}`);
210
+ process.exit(1);
211
+ }
212
+ });
213
+
214
+ // plob stream withdraw
215
+ cmd
216
+ .command('withdraw')
217
+ .description('Withdraw from a stream')
218
+ .argument('<streamId>', 'Stream ID')
219
+ .option('--json', 'Output as JSON')
220
+ .action(async (streamId: string, options: OutputOptions) => {
221
+ try {
222
+ const txHash = await withSpinner(
223
+ 'Withdrawing from stream...',
224
+ async () => {
225
+ // Placeholder - implement actual contract call
226
+ await new Promise(resolve => setTimeout(resolve, 1500));
227
+ return '0x' + Math.random().toString(16).substring(2, 66);
228
+ }
229
+ );
230
+
231
+ if (outputJSON({ streamId, txHash }, options)) {
232
+ return;
233
+ }
234
+
235
+ success('Withdrawal successful!');
236
+ info(`Transaction: ${txHash}`);
237
+ } catch (err) {
238
+ error(`Failed to withdraw: ${err}`);
239
+ process.exit(1);
240
+ }
241
+ });
242
+
243
+ return cmd;
244
+ }
package/src/index.ts CHANGED
@@ -9,6 +9,14 @@ import { createEscrowCommand } from './commands/escrow';
9
9
  import { createMandateCommand } from './commands/mandate';
10
10
  import { createPayCommand } from './commands/pay';
11
11
  import { createReputationCommand } from './commands/reputation';
12
+ import { createStreamCommand } from './commands/stream';
13
+ import { createDisputeCommand } from './commands/dispute';
14
+ import { createCreditScoreCommand } from './commands/credit-score';
15
+ import { createCascadeCommand } from './commands/cascade';
16
+ import { createIntentCommand } from './commands/intent';
17
+ import { createComplianceCommand } from './commands/compliance';
18
+ import { createOracleCommand } from './commands/oracle';
19
+ import { createRevenueShareCommand } from './commands/revenue-share';
12
20
  import chalk from 'chalk';
13
21
 
14
22
  // Load environment variables from .env file if present
@@ -44,6 +52,14 @@ program.addCommand(createEscrowCommand());
44
52
  program.addCommand(createMandateCommand());
45
53
  program.addCommand(createPayCommand());
46
54
  program.addCommand(createReputationCommand());
55
+ program.addCommand(createStreamCommand());
56
+ program.addCommand(createDisputeCommand());
57
+ program.addCommand(createCreditScoreCommand());
58
+ program.addCommand(createCascadeCommand());
59
+ program.addCommand(createIntentCommand());
60
+ program.addCommand(createComplianceCommand());
61
+ program.addCommand(createOracleCommand());
62
+ program.addCommand(createRevenueShareCommand());
47
63
 
48
64
  // Handle errors
49
65
  program.exitOverride((err) => {