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 Status
**Build command:** `./gradlew :features:wallet:impl:compileDebugKotlin` - **Compile**: ✅ BUILD SUCCESSFUL
**Result:** BUILD SUCCESSFUL in 7m 28s - **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) ### Core Wallet Infrastructure
- Changed from `javax.inject.Inject``dev.zacsweers.metro.Inject` - ✅ `CardanoWalletManager` - wallet state management with StateFlow
- Changed from `io.element.android.libraries.di.AppScope``dev.zacsweers.metro.AppScope` - ✅ `CardanoKeyStorage` - encrypted mnemonic storage with biometric protection
- Fixed `@ContributesBinding`, `@SingleIn`, `@AssistedInject`, `@Assisted` imports - ✅ `SeedPhraseManager` - BIP39 mnemonic generation/validation
- ✅ `BiometricAuthenticator` - biometric authentication wrapper
- ✅ `CardanoNetworkConfig` - testnet (preprod) configuration
### 2. ✅ Parcelize Plugin ### Transaction Building
- Added `id("kotlin-parcelize")` to wallet impl build.gradle.kts - ✅ `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 ### Payment Flow
- Fixed `KoiosBackendService` constructor (use `new KoiosBackendService(baseUrl)` not `BackendFactory.getKoiosBackendService()`) - ✅ `/pay` slash command parsing
- Fixed `Amount.quantity` type - it's a `BigInteger`, not a `String`, so use `.toLong()` not `.toLongOrNull()` - ✅ Payment entry UI with validation
- Fixed `Transaction.serializeToHex()` and `TransactionUtil.getTxHash()` usage - ✅ Payment confirmation UI with fee display
- Fixed `signedTx.body.fee.toLong()` usage - ✅ Payment progress UI with status tracking
- ✅ Payment event sending (using marker prefix format)
### 4. ✅ Timeline.sendRaw() Issue ### Timeline Integration
- **Solution:** The Matrix SDK doesn't expose raw event sending in the current version - ✅ `TimelineItemPaymentContent` - payment card data model
- **Workaround:** Changed to send payment data as a structured message with `$CARDANO_PAY$` prefix - ✅ `TimelineItemContentPaymentFactory` - payment event parsing
- The timeline UI will recognize this prefix and render a payment card - ✅ Custom event type handling via `MsgLikeKind.Other`
- This is a pragmatic Phase 1 solution; raw events can be added when SDK support arrives
### 5. ✅ MnemonicCode API ## Known Limitations
- Fixed `Words.ENGLISH.words` → use `MnemonicCode().wordList` directly
### 6. ✅ PaymentConfirmationNode Lifecycle ### sendRaw() SDK Binding
- Changed `lifecycleScope.launch``rememberCoroutineScope().launch` (Compose-friendly) 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.
- Changed `requireActivity()``LocalContext.current as? FragmentActivity`
### 7. ✅ Button Icon API **Impact**: Payment events appear as messages with special prefix instead of custom Matrix event types.
- Changed `leadingIcon = { Icon(...) }``leadingIcon = IconSource.Vector(icon)`
## Remaining Warnings (non-blocking) **Resolution**: When the Rust SDK adds Timeline.sendRaw() support, update:
- Deprecated `Account(Network, String, Int)` constructor - cardano-client-lib deprecation 1. `RustTimeline.kt` - implement actual call to `inner.sendRaw()`
- Deprecated `Icons.Filled.Send` - use `Icons.AutoMirrored.Filled.Send` instead 2. `DefaultPaymentEventSender.kt` - switch from marker prefix to raw events
- Single @Inject constructor suggestions 3. `TimelineItemContentFactory` - handle native custom events
- Deprecated `setUserAuthenticationValidityDurationSeconds` - Android API deprecation
## 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 Summary
- Test files reference old method signatures
- FakeCardanoKeyStorage and FakeWalletEntryPoint updated
- ~37 test errors to fix (API signature mismatches)
## Files Changed | Module | Tests | Status |
``` |--------|-------|--------|
features/wallet/impl/build.gradle.kts | CardanoNetworkConfigTest | 7 | ✅ Pass |
features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/ | CardanoWalletManagerTest | 9 | ✅ Pass |
├── DefaultWalletEntryPoint.kt | PaymentStatusPollerTest | 4 | ✅ Pass |
├── biometric/BiometricAuthenticator.kt | PaymentConfirmationPresenterTest | 4 | ✅ Pass |
├── cardano/CardanoWalletManager.kt | PaymentEntryPresenterTest | 8 | ✅ Pass |
├── cardano/DefaultTransactionBuilder.kt | PaymentProgressPresenterTest | 7 | ✅ Pass |
├── cardano/KoiosCardanoClient.kt | TimelineItemPaymentContentTest | 13 | ✅ Pass |
├── cardano/PaymentStatusPoller.kt | TimelineItemContentPaymentFactoryTest | 14 | ✅ Pass |
├── di/WalletModule.kt | + Other wallet tests | ~97 | ✅ Pass |
├── payment/DefaultPaymentEventSender.kt | **Total** | **163** | ✅ Pass |
├── payment/PaymentConfirmationNode.kt
├── payment/PaymentConfirmationView.kt
├── seedphrase/SeedPhraseManager.kt
├── slash/SlashCommandParser.kt
├── storage/CardanoKeyStorageImpl.kt
└── timeline/TimelineItemContentPaymentFactory.kt
features/wallet/test/build.gradle.kts ## Next Steps (Phase 2)
features/wallet/test/src/main/kotlin/io/element/android/features/wallet/test/
├── FakeWalletEntryPoint.kt
└── storage/FakeCardanoKeyStorage.kt
```
## 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 ## Commits
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
## Technical Notes - `feb99a2518` - fix(wallet): document sendRaw SDK limitation, fix all unit test failures — Phase 1 clean
### 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