forked from TrusTrove/TrusTrove-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-contract-issues.sh
More file actions
331 lines (258 loc) · 14.1 KB
/
Copy pathcreate-contract-issues.sh
File metadata and controls
331 lines (258 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#!/bin/bash
# Run from inside TrusTrove-contract repo root
# Usage: bash create-contract-issues.sh
REPO="TrusTrove/TrusTrove-contract"
echo "Creating issues for $REPO..."
# ── REGISTRY CONTRACT ─────────────────────────────────────────────────────────
gh issue create --repo $REPO \
--title "feat(registry): add batch registration support for multiple issuers" \
--label "enhancement,good first issue,complexity:medium" \
--body "## Summary
The current \`register_issuer\` function registers one address at a time. Add a \`batch_register_issuers\` function that accepts a \`Vec<(Address, Map<String, String>)>\` and registers multiple issuers in a single transaction.
## Acceptance Criteria
- [ ] \`batch_register_issuers(env, entries: Vec<(Address, Map<String, String>)>) -> u32\` returns count of registered issuers
- [ ] Skips already-registered addresses without panicking (returns count of newly registered only)
- [ ] Emits \`issuer_registered\` event for each newly registered address
- [ ] Unit tests cover: empty vec, all new, all duplicate, mixed
## Context
This is needed for onboarding flows where an admin registers multiple SME partners at once.
## Tech Stack
Rust · Soroban SDK · soroban-sdk Vec and Map types"
echo "✓ Issue 1 created"
gh issue create --repo $REPO \
--title "feat(registry): add metadata update function for registered profiles" \
--label "enhancement,good first issue,complexity:low" \
--body "## Summary
After registration, issuers and buyers cannot update their profile metadata (company name, contact info, etc). Add an \`update_metadata\` function.
## Acceptance Criteria
- [ ] \`update_metadata(env, address: Address, metadata: Map<String, String>) -> bool\`
- [ ] address.require_auth() — only the address itself can update its own metadata
- [ ] Panics with \`NotFound\` if address is not registered
- [ ] Emits \`metadata_updated\` event
- [ ] Unit tests cover: self-update succeeds, unregistered panics, wrong auth panics
## Tech Stack
Rust · Soroban SDK"
echo "✓ Issue 2 created"
gh issue create --repo $REPO \
--title "test(registry): achieve 100% branch coverage on registry_contract" \
--label "testing,good first issue,complexity:low" \
--body "## Summary
The registry contract currently has unit tests for happy paths only. This issue covers writing tests for all error branches.
## Acceptance Criteria
- [ ] Test \`AlreadyRegistered\` error on duplicate issuer registration
- [ ] Test \`AlreadyRegistered\` error on duplicate buyer registration
- [ ] Test \`NotFound\` error on \`get_profile\` for unknown address
- [ ] Test \`NotAuthorized\` error on \`revoke\` called by non-admin
- [ ] Test \`is_verified\` returns false for unknown address (no panic)
- [ ] All tests pass with \`cargo test -p trusttrove-registry\`
## Tech Stack
Rust · soroban-sdk testutils · Env::default() · mock_all_auths()"
echo "✓ Issue 3 created"
# ── INVOICE CONTRACT ──────────────────────────────────────────────────────────
gh issue create --repo $REPO \
--title "feat(invoice): implement invoice expiry mechanism for Listed invoices" \
--label "enhancement,complexity:medium" \
--body "## Summary
Invoices in \`Listed\` status can sit unfunded indefinitely. Add an expiry mechanism: if a Listed invoice is not funded within 7 days (configurable), it auto-transitions to a new \`Expired\` status.
## Acceptance Criteria
- [ ] Add \`Expired\` variant to \`InvoiceStatus\` enum
- [ ] Add \`expire_listing(env, invoice_id: BytesN<32>) -> bool\` function
- [ ] Validates: status must be \`Listed\`, current timestamp > listed_at + expiry_window
- [ ] Admin OR issuer can call this function
- [ ] Emits \`invoice_expired\` event
- [ ] Unit tests cover: early call panics, correct expiry succeeds
## Tech Stack
Rust · Soroban SDK · env.ledger().timestamp()"
echo "✓ Issue 4 created"
gh issue create --repo $REPO \
--title "feat(invoice): add get_invoice_count_by_status read function" \
--label "enhancement,good first issue,complexity:low" \
--body "## Summary
The frontend needs to display counts per status (e.g., '12 Listed, 3 Funded, 8 Repaid') without loading all invoices. Add a read function that returns counts per status.
## Acceptance Criteria
- [ ] \`get_counts(env) -> Map<String, u32>\` returns a map of status name to count
- [ ] Read-only — no auth required
- [ ] Counts are maintained as storage entries updated on every status transition
- [ ] Unit test verifies counts update correctly through full lifecycle
## Tech Stack
Rust · Soroban SDK · persistent storage"
echo "✓ Issue 5 created"
gh issue create --repo $REPO \
--title "test(invoice): write full lifecycle integration test for invoice_contract" \
--label "testing,complexity:high" \
--body "## Summary
Write a single end-to-end integration test that exercises the complete invoice lifecycle in one test function using the Soroban test environment.
## Test Flow
1. Deploy registry, invoice, escrow, and pool contracts
2. Register issuer and buyer
3. Create invoice
4. List for financing
5. Fund via pool
6. Mark as shipped
7. Confirm delivery (both parties)
8. Repay
9. Assert final status == Repaid
10. Assert pool yield increased
## Acceptance Criteria
- [ ] Test lives in \`contracts/invoice/src/test.rs\`
- [ ] All four contracts deployed and wired in the test environment
- [ ] Assertions at every stage verify correct status transition
- [ ] Test passes with \`cargo test -p trusttrove-invoice\`
## Tech Stack
Rust · soroban-sdk testutils · env.register_contract()"
echo "✓ Issue 6 created"
gh issue create --repo $REPO \
--title "feat(invoice): add early repayment support with partial discount refund" \
--label "enhancement,complexity:high" \
--body "## Summary
Currently buyers must repay the full face value on or before the due date. Add support for early repayment where the buyer pays face value but receives a partial refund of the discount proportional to how early they paid.
## Example
- Invoice face value: 10,000 USDC
- Discount: 200 bps (2%) = 200 USDC
- Funded at day 0, due at day 60
- Buyer repays at day 30
- Discount earned by pool: 100 USDC (50%)
- Discount refunded to buyer: 100 USDC (50%)
## Acceptance Criteria
- [ ] \`repay_early(env, invoice_id: BytesN<32>) -> bool\`
- [ ] Calculates pro-rata refund based on days elapsed vs total term
- [ ] Transfers full face value from buyer to pool
- [ ] Pool refunds partial discount to buyer
- [ ] Unit tests verify refund calculation at 25%, 50%, 75% of term
## Tech Stack
Rust · Soroban SDK · u128 arithmetic"
echo "✓ Issue 7 created"
# ── ESCROW CONTRACT ───────────────────────────────────────────────────────────
gh issue create --repo $REPO \
--title "test(escrow): write unit tests for all escrow_contract functions" \
--label "testing,good first issue,complexity:low" \
--body "## Summary
The escrow contract is missing comprehensive unit tests. Write tests for all functions.
## Required Tests
- [ ] \`test_lock_stores_record_and_transfers_usdc\`
- [ ] \`test_lock_fails_if_already_locked\`
- [ ] \`test_lock_only_callable_by_pool\`
- [ ] \`test_release_to_issuer_sends_correct_amount\`
- [ ] \`test_release_to_pool_sends_correct_amount\`
- [ ] \`test_handle_default_returns_funds_to_pool\`
- [ ] \`test_handle_default_returns_false_if_no_record\`
- [ ] \`test_get_locked_returns_zero_for_unknown_id\`
## Tech Stack
Rust · soroban-sdk testutils · token::StellarAssetClient for mock USDC"
echo "✓ Issue 8 created"
gh issue create --repo $REPO \
--title "feat(escrow): add escrow record history log for audit trail" \
--label "enhancement,complexity:medium" \
--body "## Summary
Once an escrow record is deleted (after release or default), there is no on-chain record it existed. Add an append-only history log that records every escrow action for audit purposes.
## Acceptance Criteria
- [ ] Add \`EscrowEvent\` struct: \`{ invoice_id, action: EscrowAction, amount, timestamp }\`
- [ ] \`EscrowAction\` enum: \`Locked | ReleasedToIssuer | ReleasedToPool | DefaultHandled\`
- [ ] Append to \`Vec<EscrowEvent>\` in persistent storage on every action
- [ ] Add \`get_history(env, invoice_id: BytesN<32>) -> Vec<EscrowEvent>\` read function
- [ ] Unit tests verify history entries are created correctly
## Tech Stack
Rust · Soroban SDK · contracttype · persistent storage"
echo "✓ Issue 9 created"
# ── POOL CONTRACT ─────────────────────────────────────────────────────────────
gh issue create --repo $REPO \
--title "feat(pool): add per-LP yield tracking and claim history" \
--label "enhancement,complexity:high" \
--body "## Summary
LPs currently see their total yield earned but cannot see a breakdown of which invoice repayments contributed yield to their position. Add per-LP yield event history.
## Acceptance Criteria
- [ ] Add \`YieldEvent\` struct: \`{ invoice_id, yield_amount, timestamp, lp_share_bps }\`
- [ ] On \`receive_repayment\`: calculate each LP's proportional yield share and append to their history
- [ ] Add \`get_lp_yield_history(env, lp: Address) -> Vec<YieldEvent>\`
- [ ] Unit tests verify yield history is accurate after multiple repayments with multiple LPs
## Tech Stack
Rust · Soroban SDK · u128 proportional math"
echo "✓ Issue 10 created"
gh issue create --repo $REPO \
--title "feat(pool): add maximum utilization rate cap to protect liquidity" \
--label "enhancement,complexity:medium" \
--body "## Summary
The pool can currently fund invoices until 100% of liquidity is deployed, leaving no buffer for withdrawals. Add a configurable maximum utilization rate (default 85%) above which new invoice funding is rejected.
## Acceptance Criteria
- [ ] Add \`max_utilization_bps: u32\` to pool initialization (default 8500 = 85%)
- [ ] \`fund_invoice\` panics with \`UtilizationCapExceeded\` if funding would push utilization above cap
- [ ] Add \`set_max_utilization(env, admin, new_cap_bps: u32)\` admin function
- [ ] \`get_stats\` includes \`max_utilization_bps\` in the returned struct
- [ ] Unit tests verify cap enforcement
## Tech Stack
Rust · Soroban SDK"
echo "✓ Issue 11 created"
gh issue create --repo $REPO \
--title "test(pool): write deposit, withdraw, and yield distribution unit tests" \
--label "testing,good first issue,complexity:medium" \
--body "## Summary
Write comprehensive unit tests for the pool contract covering share math and yield distribution.
## Required Tests
- [ ] \`test_first_deposit_issues_one_to_one_shares\`
- [ ] \`test_second_deposit_issues_proportional_shares\`
- [ ] \`test_withdraw_returns_correct_usdc\`
- [ ] \`test_withdraw_fails_if_insufficient_liquidity\`
- [ ] \`test_yield_increases_share_price_after_repayment\`
- [ ] \`test_two_lps_receive_proportional_yield\`
- [ ] \`test_utilization_rate_calculates_correctly\`
- [ ] \`test_lp_position_reflects_current_share_price\`
## Tech Stack
Rust · soroban-sdk testutils · mock USDC token"
echo "✓ Issue 12 created"
# ── DEVOPS / CI ───────────────────────────────────────────────────────────────
gh issue create --repo $REPO \
--title "chore(ci): add cargo clippy lint check to GitHub Actions workflow" \
--label "devops,good first issue,complexity:low" \
--body "## Summary
The current CI workflow runs \`cargo test\` but does not run \`cargo clippy\`. Add a clippy step that fails the build on any warnings.
## Acceptance Criteria
- [ ] Add clippy step to \`.github/workflows/ci.yml\`
- [ ] Command: \`cargo clippy --all-targets --all-features -- -D warnings\`
- [ ] Clippy runs after build, before tests
- [ ] CI fails if clippy produces any warnings
- [ ] All existing clippy warnings in the codebase are resolved
## Tech Stack
GitHub Actions · cargo clippy"
echo "✓ Issue 13 created"
gh issue create --repo $REPO \
--title "docs(contracts): write inline rustdoc comments for all public functions" \
--label "documentation,good first issue,complexity:low" \
--body "## Summary
None of the public contract functions have rustdoc comments. Add \`///\` doc comments to every public function across all four contracts.
## Requirements
Each doc comment must include:
- One-line summary
- \`# Arguments\` section listing each parameter
- \`# Returns\` section
- \`# Panics\` section listing all panic conditions with error variant names
- \`# Example\` section with a usage snippet where applicable
## Contracts to document
- [ ] registry_contract — all 7 functions
- [ ] invoice_contract — all 11 functions
- [ ] escrow_contract — all 5 functions
- [ ] pool_contract — all 9 functions
## Tech Stack
Rust rustdoc syntax"
echo "✓ Issue 14 created"
gh issue create --repo $REPO \
--title "chore(scripts): add contract verification script for deployed testnet contracts" \
--label "devops,good first issue,complexity:low" \
--body "## Summary
After deployment, there is no automated way to verify that contracts are initialized correctly. Add a \`scripts/verify.sh\` that invokes read functions on each deployed contract and prints the results.
## Script Should Verify
- [ ] \`registry_contract\`: call \`get_admin\` and print result
- [ ] \`invoice_contract\`: call \`get_counts\` and print result
- [ ] \`pool_contract\`: call \`get_stats\` and print result
- [ ] \`escrow_contract\`: confirm contract exists by calling \`get_locked\` with a dummy ID
## Acceptance Criteria
- [ ] Script reads contract IDs from \`.env.example\`
- [ ] Uses Stellar CLI \`contract invoke\` for each call
- [ ] Prints pass/fail for each check
- [ ] Script exits with code 1 if any check fails
## Tech Stack
Bash · Stellar CLI"
echo "✓ Issue 15 created"
echo ""
echo "==========================================="
echo "All 15 issues created for $REPO"
echo "==========================================="