You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
event, blocked-user denial within TTL bound, cache expiry re-query,
29
28
cleanup job deletes-only-expired.
30
-
=======
29
+
31
30
## 2026-08-26
32
31
33
32
- Fixed registration race conditions in `AuthService.register()` by eliminating application-side pre-checks (`findByWallet`, `checkUsernameExists`) and relying directly on DB-level UNIQUE constraints (`users.wallet_address`, `users.username`).
34
33
- Added idempotent migration `20260826130000_ensure_users_unique_constraints.sql` to ensure unique indexes exist on `users.wallet_address` and `users.username`.
35
34
- Updated `UsersRepository.createProfile()` to catch PostgreSQL unique constraint violation error `23505` and map to structured 409 `ConflictException` (`AUTH_WALLET_EXISTS`, `AUTH_USERNAME_TAKEN`).
36
35
- Added cleanup handlers (`deleteAvatar`, `deleteUserById`) in `AuthService.register()` and `UsersRepository` to ensure failed registrations do not leave orphaned avatar files or partial user records.
37
36
- Added unit tests covering DB unique constraint error mapping, parallel race conditions for duplicate wallet and username registrations, sequential re-registration compatibility, and avatar/user cleanup on failure.
38
-
>>>>>>> Stashed changes
39
37
40
38
## 2026-07-23
41
39
@@ -127,120 +125,7 @@ pure chore/docs commits). Direct pushes to main must also be logged here.
127
125
128
126
---
129
127
130
-
<<<<<<< Updated upstream
131
128
> Note (2026-07-16): this file previously contained StepFi-Contracts
132
129
> content copied from the wrong repo. Replaced with real StepFi-API
133
130
> history backfilled from `git log`. Entries older than 2026-06-18 are
134
131
> in git history but were never tracked here.
135
-
=======
136
-
## Completed
137
-
138
-
### Workspace Cleanup
139
-
- Removed dead code: `lp-contract` (superseded by `liquidity-pool-contract`)
-`node_modules` cached via `actions/cache@v4` keyed on `package-lock.json` hash
170
-
- CI status badge added to `README.md` pointing at the workflow
171
-
172
-
### Vendor Approval Lifecycle
173
-
- Created database migration `20260817000001_add_vendor_status.sql` adding `status` column constrained to `pending`, `approved`, `suspended`, `rejected`, defaulting to `pending` and backfilling existing rows.
174
-
- Added `buildApproveVendorXdr` and `buildSuspendVendorXdr` methods to `VendorRegistryContractClient` and `IVendorRegistryClient` to construct unsigned Soroban transaction XDRs.
175
-
- Created `AdminGuard` to enforce allowlisted wallet access via `ADMIN_WALLETS` (401 for unauthenticated, 403 for non-admin).
176
-
- Created `AuditAction` decorator and `AuditInterceptor` for audit-logging privileged admin operations.
177
-
- Added `POST /vendors/:id/approve` and `POST /vendors/:id/suspend` endpoints returning unsigned XDRs, guarded with `JwtAuthGuard` and `AdminGuard`, decorated with full Swagger annotations and returning HTTP 409 Conflict for invalid vendor status transitions (`VENDOR_NOT_PENDING`, `VENDOR_NOT_APPROVED`).
178
-
- Integrated status updates into `TransactionStatusCheckerProcessor` to update local Supabase `vendors` status only after on-chain transaction confirmation.
179
-
### Learner Profile Auto-Creation
180
-
- Added automatic creation of `learner_profiles` records upon first sign-in in `AuthService.findOrCreateUser()`, ensuring `GET /learners/me` resolves immediately after authentication.
181
-
- Updated `auth.service.spec.ts` unit tests to cover table query and insertion handling for `learner_profiles`.
182
-
183
-
184
-
---
185
-
186
-
## In Progress
187
-
188
-
- None currently.
189
-
190
-
---
191
-
192
-
## Next Up (In Order)
193
-
194
-
1.**LoanType enum** — Add `LoanType::LearnerInstallment` variant to `creditline-contract/src/types.rs`
195
-
2.**Per-installment tracking** — Add `paid: bool` and `paid_at: u64` fields to `RepaymentInstallment` struct
196
-
3.**repay_installment()** — New function targeting a specific installment by index (instead of just reducing remaining balance)
197
-
4.**Learner grace period** — Make `grace_period_seconds` per-loan (not just global via parameters)
198
-
5.**Vouching contract** — New `vouching-contract` crate: `vouch()`, `revoke_vouch()`, `get_vouches()`, `get_vouch_count()`
199
-
6.**Reputation rules** — Update `creditline-contract` to call different reputation adjustments for `LoanType::LearnerInstallment`
200
-
7.**Testnet deployment** — Deploy all contracts, capture IDs, add to StepFi-API `.env`
201
-
8.**End-to-end validation** — Verify loan lifecycle on testnet via Stellar CLI
202
-
203
-
---
204
-
205
-
## Open Questions
206
-
207
-
- What token is used for loans — native XLM or a USDC anchor? (Affects token contract address in `initialize()`)
208
-
- Should the vouching contract be a standalone crate or logic added to `creditline-contract`? (Leaning toward standalone for modularity)
209
-
- What is the correct `grace_period_seconds` for learner installment loans? (Longer than standard BNPL — possibly 7-14 days per installment)
210
-
- Should sponsor pool deposits go through `liquidity-pool-contract` or a new `sponsor-pool-contract`?
211
-
212
-
---
213
-
214
-
## Architecture Decisions
215
-
216
-
-**5 contracts, not 6** — `lp-contract` was dead code, removed. `liquidity-pool-contract` is the canonical LP implementation.
217
-
-**Vendor over Merchant** — Renamed to reflect StepFi's learning-focused domain.
218
-
-**TTL approach** — Using 60-day threshold / 120-day extension constants. Off-chain indexer is responsible for bumping TTL on active loan entries.
219
-
-**Upgrade pattern** — All contracts have `upgrade()` gated by admin `require_auth()`. Admin address is set at `initialize()` and transferable via `set_admin()`.
220
-
-**Loan sharding** — 32 shards (`loan_id % 32`) in creditline-contract to distribute persistent storage keys and avoid hot-key contention.
221
-
-**Reentrancy** — Boolean `LOCKED` flag in instance storage. Cheaper than mutex, sufficient for Soroban's single-threaded execution model.
222
-
223
-
---
224
-
225
-
## Contract Deployment Status
226
-
227
-
| Contract | Testnet Deployed | Contract ID | Last Deployed |
228
-
|---|---|---|---|
229
-
|`reputation-contract`| ❌ No | — | — |
230
-
|`parameters-contract`| ❌ No | — | — |
231
-
|`vendor-registry-contract`| ❌ No | — | — |
232
-
|`liquidity-pool-contract`| ❌ No | — | — |
233
-
|`creditline-contract`| ❌ No | — | — |
234
-
235
-
> Update this table after running `scripts/deploy-testnet.sh`
236
-
237
-
---
238
-
239
-
## Session Notes
240
-
241
-
- Always run `cargo build` after any contract change before committing.
242
-
- Always run `cargo test` before marking any contract feature complete.
243
-
- Never modify storage key structures of a contract that has been deployed — it breaks existing data. Use a migration pattern or deploy a new contract.
244
-
- The `creditline-contract` depends on all other contracts — it must be initialized last.
245
-
- Do not add new workspace members to `Cargo.toml` without creating the full contract file structure first.
0 commit comments