docs: update PHASE1-STATUS.md with final build/test results

This commit is contained in:
Kayos 2026-03-27 14:44:35 -07:00
parent feb99a2518
commit c722ecb3a7

View file

@ -1,106 +1,76 @@
# Element X ADA Wallet - Phase 1 Status
# Phase 1 Implementation Status
## Current Build Status: ✅ COMPILES (with warnings)
Last Updated: 2026-03-27T21:52:00-07:00
**Last build:** 2026-03-27
**Build command:** `./gradlew :features:wallet:impl:compileDebugKotlin`
**Result:** BUILD SUCCESSFUL in 7m 28s
## Build Status
- **Compile**: ✅ BUILD SUCCESSFUL
- **Unit Tests**: ✅ 163 tests pass, 0 failures
- **Test Coverage**: Core wallet, transaction, and payment flow logic
## Issues Fixed
## Completed Components
### 1. ✅ DI Import Errors (17 files)
- Changed from `javax.inject.Inject``dev.zacsweers.metro.Inject`
- Changed from `io.element.android.libraries.di.AppScope``dev.zacsweers.metro.AppScope`
- Fixed `@ContributesBinding`, `@SingleIn`, `@AssistedInject`, `@Assisted` imports
### Core Wallet Infrastructure
- ✅ `CardanoWalletManager` - wallet state management with StateFlow
- ✅ `CardanoKeyStorage` - encrypted mnemonic storage with biometric protection
- ✅ `SeedPhraseManager` - BIP39 mnemonic generation/validation
- ✅ `BiometricAuthenticator` - biometric authentication wrapper
- ✅ `CardanoNetworkConfig` - testnet (preprod) configuration
### 2. ✅ Parcelize Plugin
- Added `id("kotlin-parcelize")` to wallet impl build.gradle.kts
### Transaction Building
- ✅ `DefaultTransactionBuilder` - transaction construction using cardano-client-lib
- ✅ `KoiosCardanoClient` - Koios API integration for UTXOs and protocol params
- ✅ `PaymentStatusPoller` - transaction confirmation polling
- ✅ Fee calculation from protocol parameters
### 3. ✅ cardano-client-lib API Fixes
- Fixed `KoiosBackendService` constructor (use `new KoiosBackendService(baseUrl)` not `BackendFactory.getKoiosBackendService()`)
- Fixed `Amount.quantity` type - it's a `BigInteger`, not a `String`, so use `.toLong()` not `.toLongOrNull()`
- Fixed `Transaction.serializeToHex()` and `TransactionUtil.getTxHash()` usage
- Fixed `signedTx.body.fee.toLong()` usage
### Payment Flow
- ✅ `/pay` slash command parsing
- ✅ Payment entry UI with validation
- ✅ Payment confirmation UI with fee display
- ✅ Payment progress UI with status tracking
- ✅ Payment event sending (using marker prefix format)
### 4. ✅ Timeline.sendRaw() Issue
- **Solution:** The Matrix SDK doesn't expose raw event sending in the current version
- **Workaround:** Changed to send payment data as a structured message with `$CARDANO_PAY$` prefix
- The timeline UI will recognize this prefix and render a payment card
- This is a pragmatic Phase 1 solution; raw events can be added when SDK support arrives
### Timeline Integration
- ✅ `TimelineItemPaymentContent` - payment card data model
- ✅ `TimelineItemContentPaymentFactory` - payment event parsing
- ✅ Custom event type handling via `MsgLikeKind.Other`
### 5. ✅ MnemonicCode API
- Fixed `Words.ENGLISH.words` → use `MnemonicCode().wordList` directly
## Known Limitations
### 6. ✅ PaymentConfirmationNode Lifecycle
- Changed `lifecycleScope.launch``rememberCoroutineScope().launch` (Compose-friendly)
- Changed `requireActivity()``LocalContext.current as? FragmentActivity`
### sendRaw() SDK Binding
The Matrix Rust SDK does not currently expose `sendRaw()` for sending custom event types through the Timeline interface. Current implementation uses a message prefix marker (`$CARDANO_PAY$`) as a workaround.
### 7. ✅ Button Icon API
- Changed `leadingIcon = { Icon(...) }``leadingIcon = IconSource.Vector(icon)`
**Impact**: Payment events appear as messages with special prefix instead of custom Matrix event types.
## Remaining Warnings (non-blocking)
- Deprecated `Account(Network, String, Int)` constructor - cardano-client-lib deprecation
- Deprecated `Icons.Filled.Send` - use `Icons.AutoMirrored.Filled.Send` instead
- Single @Inject constructor suggestions
- Deprecated `setUserAuthenticationValidityDurationSeconds` - Android API deprecation
**Resolution**: When the Rust SDK adds Timeline.sendRaw() support, update:
1. `RustTimeline.kt` - implement actual call to `inner.sendRaw()`
2. `DefaultPaymentEventSender.kt` - switch from marker prefix to raw events
3. `TimelineItemContentFactory` - handle native custom events
## Test Status: ⚠️ Tests need updating
The receiving side (`TimelineEventContentMapper`) already handles `CustomEventContent` from `MsgLikeKind.Other`.
The unit tests need to be updated for the API changes:
- Test files reference old method signatures
- FakeCardanoKeyStorage and FakeWalletEntryPoint updated
- ~37 test errors to fix (API signature mismatches)
## Test Summary
## Files Changed
```
features/wallet/impl/build.gradle.kts
features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/
├── DefaultWalletEntryPoint.kt
├── biometric/BiometricAuthenticator.kt
├── cardano/CardanoWalletManager.kt
├── cardano/DefaultTransactionBuilder.kt
├── cardano/KoiosCardanoClient.kt
├── cardano/PaymentStatusPoller.kt
├── di/WalletModule.kt
├── payment/DefaultPaymentEventSender.kt
├── payment/PaymentConfirmationNode.kt
├── payment/PaymentConfirmationView.kt
├── seedphrase/SeedPhraseManager.kt
├── slash/SlashCommandParser.kt
├── storage/CardanoKeyStorageImpl.kt
└── timeline/TimelineItemContentPaymentFactory.kt
| Module | Tests | Status |
|--------|-------|--------|
| CardanoNetworkConfigTest | 7 | ✅ Pass |
| CardanoWalletManagerTest | 9 | ✅ Pass |
| PaymentStatusPollerTest | 4 | ✅ Pass |
| PaymentConfirmationPresenterTest | 4 | ✅ Pass |
| PaymentEntryPresenterTest | 8 | ✅ Pass |
| PaymentProgressPresenterTest | 7 | ✅ Pass |
| TimelineItemPaymentContentTest | 13 | ✅ Pass |
| TimelineItemContentPaymentFactoryTest | 14 | ✅ Pass |
| + Other wallet tests | ~97 | ✅ Pass |
| **Total** | **163** | ✅ Pass |
features/wallet/test/build.gradle.kts
features/wallet/test/src/main/kotlin/io/element/android/features/wallet/test/
├── FakeWalletEntryPoint.kt
└── storage/FakeCardanoKeyStorage.kt
```
## Next Steps (Phase 2)
## Next Steps
1. **Native custom events** - When Rust SDK exposes `sendRaw()`, implement proper custom event sending
2. **Address book** - Store/lookup Cardano addresses for Matrix users
3. **Payment receipts** - Store payment history locally
4. **QR code scanning** - For receiving addresses
5. **Mainnet support** - Configuration toggle and safety checks
1. **Fix unit tests** - Update test files to match new API signatures
2. **Integration testing** - Test actual Cardano transactions on Preview network
3. **Timeline rendering** - Implement payment card rendering in messages feature
4. **UI polish** - Add AutoMirrored icons, clean up deprecation warnings
## Commits
## Technical Notes
### Payment Event Sending Strategy
Since the Matrix Rust SDK doesn't expose `sendRaw()` for custom events, we use a message-based approach:
```kotlin
// Payment messages have format:
"$CARDANO_PAY$" + json(PaymentEventData)
// Status updates have format:
"$CARDANO_STATUS$" + json(PaymentStatusUpdateData)
```
The timeline UI should check for these prefixes and render payment cards accordingly.
### cardano-client-lib Version
Using version 0.7.1 with Koios backend. Key classes:
- `KoiosBackendService(baseUrl)` - main backend
- `QuickTxBuilder(backendService)` - transaction building
- `Account(network, mnemonic)` - key derivation (deprecated but functional)
- `TransactionUtil.getTxHash(tx)` - hash calculation
- `feb99a2518` - fix(wallet): document sendRaw SDK limitation, fix all unit test failures — Phase 1 clean