@paylobster/cli 4.0.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/BUILD_SUMMARY.md +429 -0
- package/CHANGELOG.md +78 -0
- package/CONTRIBUTING.md +368 -0
- package/EXAMPLES.md +432 -0
- package/LICENSE +21 -0
- package/QUICKSTART.md +189 -0
- package/README.md +377 -0
- package/TEST_REPORT.md +191 -0
- package/bin/plob.js +9 -0
- package/bin/plob.ts +9 -0
- package/demo.sh +154 -0
- package/dist/bin/plob.d.ts +7 -0
- package/dist/bin/plob.d.ts.map +1 -0
- package/dist/bin/plob.js +10 -0
- package/dist/bin/plob.js.map +1 -0
- package/dist/src/commands/auth.d.ts +3 -0
- package/dist/src/commands/auth.d.ts.map +1 -0
- package/dist/src/commands/auth.js +75 -0
- package/dist/src/commands/auth.js.map +1 -0
- package/dist/src/commands/config.d.ts +3 -0
- package/dist/src/commands/config.d.ts.map +1 -0
- package/dist/src/commands/config.js +79 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/escrow.d.ts +3 -0
- package/dist/src/commands/escrow.d.ts.map +1 -0
- package/dist/src/commands/escrow.js +193 -0
- package/dist/src/commands/escrow.js.map +1 -0
- package/dist/src/commands/mandate.d.ts +8 -0
- package/dist/src/commands/mandate.d.ts.map +1 -0
- package/dist/src/commands/mandate.js +54 -0
- package/dist/src/commands/mandate.js.map +1 -0
- package/dist/src/commands/pay.d.ts +6 -0
- package/dist/src/commands/pay.d.ts.map +1 -0
- package/dist/src/commands/pay.js +77 -0
- package/dist/src/commands/pay.js.map +1 -0
- package/dist/src/commands/register.d.ts +3 -0
- package/dist/src/commands/register.d.ts.map +1 -0
- package/dist/src/commands/register.js +51 -0
- package/dist/src/commands/register.js.map +1 -0
- package/dist/src/commands/reputation.d.ts +3 -0
- package/dist/src/commands/reputation.d.ts.map +1 -0
- package/dist/src/commands/reputation.js +116 -0
- package/dist/src/commands/reputation.js.map +1 -0
- package/dist/src/commands/status.d.ts +3 -0
- package/dist/src/commands/status.d.ts.map +1 -0
- package/dist/src/commands/status.js +82 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +59 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/config.d.ts +26 -0
- package/dist/src/lib/config.d.ts.map +1 -0
- package/dist/src/lib/config.js +91 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/contracts.d.ts +18798 -0
- package/dist/src/lib/contracts.d.ts.map +1 -0
- package/dist/src/lib/contracts.js +361 -0
- package/dist/src/lib/contracts.js.map +1 -0
- package/dist/src/lib/display.d.ts +83 -0
- package/dist/src/lib/display.d.ts.map +1 -0
- package/dist/src/lib/display.js +293 -0
- package/dist/src/lib/display.js.map +1 -0
- package/dist/src/lib/types.d.ts +49 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/dist/src/lib/types.js +3 -0
- package/dist/src/lib/types.js.map +1 -0
- package/dist/src/lib/wallet.d.ts +30 -0
- package/dist/src/lib/wallet.d.ts.map +1 -0
- package/dist/src/lib/wallet.js +143 -0
- package/dist/src/lib/wallet.js.map +1 -0
- package/jest.config.js +15 -0
- package/package.json +55 -0
- package/src/__tests__/cli.test.ts +38 -0
- package/src/commands/auth.ts +75 -0
- package/src/commands/config.ts +84 -0
- package/src/commands/escrow.ts +222 -0
- package/src/commands/mandate.ts +56 -0
- package/src/commands/pay.ts +96 -0
- package/src/commands/register.ts +57 -0
- package/src/commands/reputation.ts +84 -0
- package/src/commands/status.ts +91 -0
- package/src/index.ts +63 -0
- package/src/lib/config.ts +90 -0
- package/src/lib/contracts.ts +392 -0
- package/src/lib/display.ts +265 -0
- package/src/lib/types.ts +57 -0
- package/src/lib/wallet.ts +146 -0
- package/tsconfig.json +21 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Contributing to PayLobster CLI
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to the PayLobster CLI! This document provides guidelines and instructions for contributors.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- Node.js >= 18.0.0
|
|
10
|
+
- npm or yarn
|
|
11
|
+
- TypeScript knowledge
|
|
12
|
+
- Basic understanding of blockchain/Web3
|
|
13
|
+
|
|
14
|
+
### Clone and Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone https://github.com/itsGustav/Pay-Lobster.git
|
|
18
|
+
cd Pay-Lobster/cli
|
|
19
|
+
npm install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Development Workflow
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Build the project
|
|
26
|
+
npm run build
|
|
27
|
+
|
|
28
|
+
# Run without building (using tsx)
|
|
29
|
+
npm run dev -- status
|
|
30
|
+
|
|
31
|
+
# Link for local testing
|
|
32
|
+
npm run link
|
|
33
|
+
|
|
34
|
+
# Run tests
|
|
35
|
+
npm test
|
|
36
|
+
|
|
37
|
+
# Watch mode for tests
|
|
38
|
+
npm test -- --watch
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Project Structure
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
cli/
|
|
45
|
+
├── bin/
|
|
46
|
+
│ └── plob.ts # Executable entry point
|
|
47
|
+
├── src/
|
|
48
|
+
│ ├── index.ts # Main CLI setup
|
|
49
|
+
│ ├── commands/ # Command implementations
|
|
50
|
+
│ │ ├── auth.ts
|
|
51
|
+
│ │ ├── config.ts
|
|
52
|
+
│ │ ├── escrow.ts
|
|
53
|
+
│ │ ├── mandate.ts
|
|
54
|
+
│ │ ├── pay.ts
|
|
55
|
+
│ │ ├── register.ts
|
|
56
|
+
│ │ ├── reputation.ts
|
|
57
|
+
│ │ └── status.ts
|
|
58
|
+
│ ├── lib/ # Shared utilities
|
|
59
|
+
│ │ ├── config.ts # Config management
|
|
60
|
+
│ │ ├── contracts.ts # Contract interactions
|
|
61
|
+
│ │ ├── display.ts # Output formatting
|
|
62
|
+
│ │ ├── types.ts # TypeScript types
|
|
63
|
+
│ │ └── wallet.ts # Wallet management
|
|
64
|
+
│ └── __tests__/ # Unit tests
|
|
65
|
+
└── package.json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Adding a New Command
|
|
69
|
+
|
|
70
|
+
### 1. Create Command File
|
|
71
|
+
|
|
72
|
+
Create `src/commands/mycommand.ts`:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { Command } from 'commander';
|
|
76
|
+
import { success, error, outputJSON } from '../lib/display';
|
|
77
|
+
import type { OutputOptions } from '../lib/types';
|
|
78
|
+
|
|
79
|
+
export function createMyCommand(): Command {
|
|
80
|
+
const cmd = new Command('mycommand')
|
|
81
|
+
.description('Description of your command');
|
|
82
|
+
|
|
83
|
+
cmd
|
|
84
|
+
.option('--required <value>', 'Required option')
|
|
85
|
+
.option('--json', 'Output as JSON')
|
|
86
|
+
.action(async (options: { required: string } & OutputOptions) => {
|
|
87
|
+
try {
|
|
88
|
+
// Your logic here
|
|
89
|
+
const result = { success: true };
|
|
90
|
+
|
|
91
|
+
if (outputJSON(result, options)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
success('Command completed!');
|
|
96
|
+
} catch (err) {
|
|
97
|
+
error(`Failed: ${err}`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return cmd;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2. Register in Main CLI
|
|
107
|
+
|
|
108
|
+
Edit `src/index.ts`:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { createMyCommand } from './commands/mycommand';
|
|
112
|
+
|
|
113
|
+
// ... existing code ...
|
|
114
|
+
|
|
115
|
+
program.addCommand(createMyCommand());
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 3. Add Tests
|
|
119
|
+
|
|
120
|
+
Create `src/__tests__/mycommand.test.ts`:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { describe, test, expect } from '@jest/globals';
|
|
124
|
+
import { createMyCommand } from '../commands/mycommand';
|
|
125
|
+
|
|
126
|
+
describe('mycommand', () => {
|
|
127
|
+
test('command is registered', () => {
|
|
128
|
+
const cmd = createMyCommand();
|
|
129
|
+
expect(cmd.name()).toBe('mycommand');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Adding Contract Interactions
|
|
135
|
+
|
|
136
|
+
### 1. Add ABI
|
|
137
|
+
|
|
138
|
+
In `src/lib/contracts.ts`, add the contract ABI:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const MY_CONTRACT_ABI = [
|
|
142
|
+
{
|
|
143
|
+
inputs: [{ name: 'param', type: 'string' }],
|
|
144
|
+
name: 'myFunction',
|
|
145
|
+
outputs: [{ name: 'result', type: 'uint256' }],
|
|
146
|
+
stateMutability: 'view',
|
|
147
|
+
type: 'function',
|
|
148
|
+
},
|
|
149
|
+
] as const;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 2. Add Helper Function
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
export async function callMyContract(param: string): Promise<bigint> {
|
|
156
|
+
const config = loadConfig();
|
|
157
|
+
const publicClient = getPublicClient(config.network);
|
|
158
|
+
const contracts = getContracts(config.network);
|
|
159
|
+
|
|
160
|
+
const result = await publicClient.readContract({
|
|
161
|
+
address: contracts.MY_CONTRACT,
|
|
162
|
+
abi: MY_CONTRACT_ABI,
|
|
163
|
+
functionName: 'myFunction',
|
|
164
|
+
args: [param],
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3. Add Contract Address
|
|
172
|
+
|
|
173
|
+
Update `getContracts()` function to include your contract address.
|
|
174
|
+
|
|
175
|
+
## Code Style Guidelines
|
|
176
|
+
|
|
177
|
+
### TypeScript
|
|
178
|
+
|
|
179
|
+
- Use strict TypeScript (`strict: true`)
|
|
180
|
+
- Prefer `async/await` over callbacks
|
|
181
|
+
- Use `const` for immutable values
|
|
182
|
+
- Type all function parameters and returns
|
|
183
|
+
|
|
184
|
+
### Error Handling
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// ✅ Good: Proper error handling
|
|
188
|
+
try {
|
|
189
|
+
const result = await someOperation();
|
|
190
|
+
success('Operation succeeded');
|
|
191
|
+
} catch (err) {
|
|
192
|
+
error(`Operation failed: ${err}`);
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ❌ Bad: Swallowing errors
|
|
197
|
+
try {
|
|
198
|
+
await someOperation();
|
|
199
|
+
} catch (err) {
|
|
200
|
+
// Silent failure
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### User Output
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// ✅ Good: Support both pretty and JSON output
|
|
208
|
+
if (outputJSON(data, options)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
success('Pretty output for humans');
|
|
212
|
+
|
|
213
|
+
// ❌ Bad: Only one output format
|
|
214
|
+
console.log(data);
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Exit Codes
|
|
218
|
+
|
|
219
|
+
- `0`: Success
|
|
220
|
+
- `1`: General error
|
|
221
|
+
- Never use other codes
|
|
222
|
+
|
|
223
|
+
## Testing Guidelines
|
|
224
|
+
|
|
225
|
+
### Unit Tests
|
|
226
|
+
|
|
227
|
+
Test pure functions and utilities:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
describe('formatAddress', () => {
|
|
231
|
+
test('shortens address correctly', () => {
|
|
232
|
+
const address = '0x1234567890123456789012345678901234567890';
|
|
233
|
+
const result = formatAddress(address);
|
|
234
|
+
expect(result).toBe('0x1234...7890');
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Integration Tests
|
|
240
|
+
|
|
241
|
+
For commands that interact with blockchain, mock the responses:
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
jest.mock('../lib/contracts', () => ({
|
|
245
|
+
getBalance: jest.fn().mockResolvedValue({
|
|
246
|
+
usdc: BigInt('1000000'),
|
|
247
|
+
eth: BigInt('1000000000000000000'),
|
|
248
|
+
}),
|
|
249
|
+
}));
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Manual Testing
|
|
253
|
+
|
|
254
|
+
Before submitting:
|
|
255
|
+
|
|
256
|
+
1. Test on Sepolia testnet
|
|
257
|
+
2. Try all command variations
|
|
258
|
+
3. Test error cases (invalid input, insufficient balance, etc.)
|
|
259
|
+
4. Verify `--json` output for all commands
|
|
260
|
+
5. Check exit codes
|
|
261
|
+
|
|
262
|
+
## Commit Guidelines
|
|
263
|
+
|
|
264
|
+
Follow conventional commits:
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
feat: add mandate revoke command
|
|
268
|
+
fix: correct USDC balance formatting
|
|
269
|
+
docs: update README with new examples
|
|
270
|
+
test: add tests for escrow commands
|
|
271
|
+
refactor: simplify wallet loading logic
|
|
272
|
+
chore: update dependencies
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Pull Request Process
|
|
276
|
+
|
|
277
|
+
1. **Fork and Branch**
|
|
278
|
+
```bash
|
|
279
|
+
git checkout -b feature/my-new-feature
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
2. **Make Changes**
|
|
283
|
+
- Write clean, documented code
|
|
284
|
+
- Add tests
|
|
285
|
+
- Update README if needed
|
|
286
|
+
|
|
287
|
+
3. **Test Thoroughly**
|
|
288
|
+
```bash
|
|
289
|
+
npm test
|
|
290
|
+
npm run build
|
|
291
|
+
npm run link
|
|
292
|
+
plob mycommand --test
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
4. **Commit**
|
|
296
|
+
```bash
|
|
297
|
+
git add .
|
|
298
|
+
git commit -m "feat: add my feature"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
5. **Push and PR**
|
|
302
|
+
```bash
|
|
303
|
+
git push origin feature/my-new-feature
|
|
304
|
+
```
|
|
305
|
+
Then create a Pull Request on GitHub
|
|
306
|
+
|
|
307
|
+
6. **PR Checklist**
|
|
308
|
+
- [ ] Tests pass
|
|
309
|
+
- [ ] Code builds without errors
|
|
310
|
+
- [ ] README updated (if applicable)
|
|
311
|
+
- [ ] Examples added (if new feature)
|
|
312
|
+
- [ ] Tested on Sepolia testnet
|
|
313
|
+
- [ ] JSON output works
|
|
314
|
+
- [ ] Error messages are clear
|
|
315
|
+
|
|
316
|
+
## Areas for Contribution
|
|
317
|
+
|
|
318
|
+
### High Priority
|
|
319
|
+
|
|
320
|
+
- [ ] Mandate contract integration (full implementation)
|
|
321
|
+
- [ ] Service discovery commands (search, compare)
|
|
322
|
+
- [ ] A2A messaging support
|
|
323
|
+
- [ ] Batch operations (bulk escrow creation/release)
|
|
324
|
+
- [ ] Improved keystore encryption
|
|
325
|
+
- [ ] Hardware wallet support (Ledger, Trezor)
|
|
326
|
+
|
|
327
|
+
### Medium Priority
|
|
328
|
+
|
|
329
|
+
- [ ] Transaction history viewer
|
|
330
|
+
- [ ] Gas estimation and optimization
|
|
331
|
+
- [ ] Multi-signature wallet support
|
|
332
|
+
- [ ] Dispute resolution commands
|
|
333
|
+
- [ ] Notification system (webhooks, email)
|
|
334
|
+
- [ ] Shell completion (bash, zsh, fish)
|
|
335
|
+
|
|
336
|
+
### Low Priority / Nice-to-Have
|
|
337
|
+
|
|
338
|
+
- [ ] TUI (Terminal UI) mode
|
|
339
|
+
- [ ] Interactive prompts for all commands
|
|
340
|
+
- [ ] CSV export for transactions
|
|
341
|
+
- [ ] Reputation analytics/charts
|
|
342
|
+
- [ ] Integration with popular agent frameworks
|
|
343
|
+
- [ ] Docker image
|
|
344
|
+
|
|
345
|
+
## Code Review Process
|
|
346
|
+
|
|
347
|
+
All PRs require:
|
|
348
|
+
|
|
349
|
+
1. Code review from at least one maintainer
|
|
350
|
+
2. All tests passing
|
|
351
|
+
3. No TypeScript errors
|
|
352
|
+
4. Documentation updated
|
|
353
|
+
|
|
354
|
+
Typical review time: 2-5 business days
|
|
355
|
+
|
|
356
|
+
## Questions?
|
|
357
|
+
|
|
358
|
+
- Open an issue on GitHub
|
|
359
|
+
- Join our Discord: https://discord.gg/paylobster
|
|
360
|
+
- Email: dev@paylobster.com
|
|
361
|
+
|
|
362
|
+
## License
|
|
363
|
+
|
|
364
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
Thank you for contributing to PayLobster! 🦞
|