Fix ~60 compile errors - build now succeeds
- Fixed DI imports: javax.inject -> dev.zacsweers.metro - Fixed cardano-client-lib API: KoiosBackendService constructor, Amount.quantity type - Added kotlin-parcelize plugin - Workaround for Timeline.sendRaw(): use message prefix approach - Fixed MnemonicCode wordlist access - Fixed Compose lifecycle/context handling - Updated test fakes BUILD SUCCESSFUL - unit tests still need updating for new APIs
This commit is contained in:
parent
b12b1e4770
commit
bd883e9c3a
19 changed files with 279 additions and 706 deletions
241
PHASE1-STATUS.md
241
PHASE1-STATUS.md
|
|
@ -1,185 +1,106 @@
|
|||
# Phase 1 Status Report
|
||||
**Date:** 2026-03-27
|
||||
**Auditor:** Kayos (automated audit)
|
||||
**Build Environment:** Docker on Lucy (mingc/android-build-box)
|
||||
# Element X ADA Wallet - Phase 1 Status
|
||||
|
||||
## Executive Summary
|
||||
## Current Build Status: ✅ COMPILES (with warnings)
|
||||
|
||||
**BUILD STATUS: ⚠️ PARTIAL**
|
||||
- ✅ `features:wallet:api` - **COMPILES SUCCESSFULLY**
|
||||
- ❌ `features:wallet:impl` - **FAILS (~60 errors)**
|
||||
**Last build:** 2026-03-27
|
||||
**Build command:** `./gradlew :features:wallet:impl:compileDebugKotlin`
|
||||
**Result:** BUILD SUCCESSFUL in 7m 28s
|
||||
|
||||
The Phase 1 code has fundamental issues that prevent compilation. The code makes API assumptions that don't match the actual Element X and cardano-client-lib APIs. This requires significant rework before it can be tested on device.
|
||||
## Issues Fixed
|
||||
|
||||
---
|
||||
### 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
|
||||
|
||||
## Audit Findings
|
||||
### 2. ✅ Parcelize Plugin
|
||||
- Added `id("kotlin-parcelize")` to wallet impl build.gradle.kts
|
||||
|
||||
### Issues Fixed (Pushed to Gitea)
|
||||
### 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
|
||||
|
||||
1. **DI Package Typo** ✅ FIXED
|
||||
- `dev.zacsweeny.metro` → `dev.zacsweers.metro` (missing 's')
|
||||
- Files: KoiosCardanoClient, DefaultTransactionBuilder, PaymentStatusPoller, WalletModule
|
||||
### 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
|
||||
|
||||
2. **Missing Dependency** ✅ FIXED
|
||||
- Added `implementation(projects.features.wallet.impl)` to messages:impl build.gradle.kts
|
||||
### 5. ✅ MnemonicCode API
|
||||
- Fixed `Words.ENGLISH.words` → use `MnemonicCode().wordList` directly
|
||||
|
||||
3. **Event Type Inconsistency** ✅ FIXED
|
||||
- Standardized to `co.sulkta.payment.request` everywhere
|
||||
- Updated TimelineItemPaymentContent.EVENT_TYPE and tests
|
||||
### 6. ✅ PaymentConfirmationNode Lifecycle
|
||||
- Changed `lifecycleScope.launch` → `rememberCoroutineScope().launch` (Compose-friendly)
|
||||
- Changed `requireActivity()` → `LocalContext.current as? FragmentActivity`
|
||||
|
||||
4. **Scope Inconsistency** ✅ FIXED
|
||||
- PaymentStatusPoller changed from AppScope to SessionScope (matches CardanoClient scope)
|
||||
### 7. ✅ Button Icon API
|
||||
- Changed `leadingIcon = { Icon(...) }` → `leadingIcon = IconSource.Vector(icon)`
|
||||
|
||||
5. **Sealed Interface Inheritance** ✅ FIXED
|
||||
- TimelineItemPaymentContent can't inherit from sealed TimelineItemEventContent (different modules)
|
||||
- Created TimelineItemPaymentContentWrapper adapter in messages:impl
|
||||
## 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
|
||||
|
||||
6. **cardano-client-lib API** ✅ PARTIALLY FIXED
|
||||
- Changed `getNetworks()` to `getNetwork()` returning `Network` instead of `Networks`
|
||||
## Test Status: ⚠️ Tests need updating
|
||||
|
||||
### Critical Issues Remaining (Blocks Compilation)
|
||||
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)
|
||||
|
||||
#### 1. DI Import Paths Wrong
|
||||
**Impact:** ~20 compilation errors
|
||||
**Files:** Most wallet/impl files
|
||||
## 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
|
||||
|
||||
The code uses:
|
||||
```kotlin
|
||||
import dev.zacsweers.metro.SessionScope // WRONG
|
||||
import dev.zacsweers.metro.Inject // WRONG
|
||||
features/wallet/test/build.gradle.kts
|
||||
features/wallet/test/src/main/kotlin/io/element/android/features/wallet/test/
|
||||
├── FakeWalletEntryPoint.kt
|
||||
└── storage/FakeCardanoKeyStorage.kt
|
||||
```
|
||||
|
||||
Should be:
|
||||
```kotlin
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import javax.inject.Inject
|
||||
```
|
||||
## Next Steps
|
||||
|
||||
**Status:** Partially fixed, but more instances remain
|
||||
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
|
||||
|
||||
#### 2. Timeline.sendRaw() Doesn't Exist
|
||||
**Impact:** Critical - payment sending broken
|
||||
**Files:** DefaultPaymentEventSender.kt
|
||||
## Technical Notes
|
||||
|
||||
The code assumes:
|
||||
```kotlin
|
||||
timeline.sendRaw(eventType, content) // DOESN'T EXIST
|
||||
```
|
||||
|
||||
The Matrix Rust SDK's Timeline API doesn't expose raw event sending. The BLOCKERS.md claimed this was resolved in SDK version 26.03.24, but grep shows no `sendRaw` method in the Element X libraries/matrix module.
|
||||
|
||||
**Required Fix:** Either:
|
||||
- Find the actual API for sending custom events (if it exists)
|
||||
- Use a workaround (message with structured body?)
|
||||
- Wait for SDK to add this capability
|
||||
|
||||
#### 3. Koios Backend API Wrong
|
||||
**Impact:** Balance/UTxO fetching broken
|
||||
**File:** KoiosCardanoClient.kt
|
||||
|
||||
The code uses:
|
||||
```kotlin
|
||||
BackendFactory.getKoiosBackendService() // DOESN'T EXIST
|
||||
```
|
||||
|
||||
cardano-client-lib doesn't have a `BackendFactory` class. The actual API is:
|
||||
```kotlin
|
||||
val backendService = KoiosBackendService(CardanoNetworkConfig.KOIOS_BASE_URL)
|
||||
```
|
||||
|
||||
#### 4. Parcelize Plugin Missing
|
||||
**Impact:** ~15 compilation errors
|
||||
**Files:** ParsedPayCommand.kt, PaymentEntryNode.kt, PaymentConfirmationNode.kt, PaymentProgressNode.kt
|
||||
|
||||
The build.gradle.kts has `id("kotlin-parcelize")` but the imports use wrong paths:
|
||||
```kotlin
|
||||
import kotlinx.parcelize.Parcelize // Correct
|
||||
import android.os.parcelize.Parcelize // Used incorrectly in some places
|
||||
```
|
||||
|
||||
#### 5. Compose API Mismatches
|
||||
**Impact:** UI won't compile
|
||||
**File:** PaymentConfirmationView.kt
|
||||
### Payment Event Sending Strategy
|
||||
Since the Matrix Rust SDK doesn't expose `sendRaw()` for custom events, we use a message-based approach:
|
||||
|
||||
```kotlin
|
||||
Button(
|
||||
onClick = { ... },
|
||||
icon = { Icon(...) } // WRONG: Button doesn't have icon parameter
|
||||
)
|
||||
// Payment messages have format:
|
||||
"$CARDANO_PAY$" + json(PaymentEventData)
|
||||
|
||||
// Status updates have format:
|
||||
"$CARDANO_STATUS$" + json(PaymentStatusUpdateData)
|
||||
```
|
||||
|
||||
Element X's Button API differs from what was assumed.
|
||||
The timeline UI should check for these prefixes and render payment cards accordingly.
|
||||
|
||||
#### 6. SeedPhraseManager ENGLISH Wordlist Reference
|
||||
**Impact:** Mnemonic generation broken
|
||||
**File:** SeedPhraseManager.kt
|
||||
|
||||
```kotlin
|
||||
MnemonicCode.ENGLISH // DOESN'T EXIST
|
||||
```
|
||||
|
||||
The correct API uses the MnemonicCode class differently.
|
||||
|
||||
---
|
||||
|
||||
## Architecture Assessment
|
||||
|
||||
### What's Correct
|
||||
- Module structure (api/impl/test) follows Element X patterns
|
||||
- Basic DI approach using Metro with @ContributesBinding
|
||||
- Network configuration centralized in CardanoNetworkConfig
|
||||
- Security design for key storage (Keystore, biometric, per-session)
|
||||
- Timeline payment card concept
|
||||
|
||||
### What Needs Rework
|
||||
1. **Payment Event Sending** - Fundamental approach needs re-evaluation since `sendRaw` doesn't exist
|
||||
2. **Koios Client** - API usage completely wrong, needs rewrite to actual cardano-client-lib API
|
||||
3. **Import Statements** - Systematic cleanup of DI and parcelize imports
|
||||
4. **Compose Components** - Match Element X's actual component APIs
|
||||
|
||||
---
|
||||
|
||||
## Recommendations
|
||||
|
||||
### Immediate Actions Required
|
||||
1. **Verify SDK Capabilities** - Check if Matrix Rust SDK actually supports custom event types at all. If not, Phase 1 needs fundamental redesign.
|
||||
|
||||
2. **Fix Koios Client** - Rewrite KoiosCardanoClient to use actual cardano-client-lib API:
|
||||
```kotlin
|
||||
val backendService = KoiosBackendService(CardanoNetworkConfig.KOIOS_BASE_URL)
|
||||
val addressService = AddressService(backendService)
|
||||
// etc.
|
||||
```
|
||||
|
||||
3. **Element X API Review** - Before writing more code, do a thorough review of:
|
||||
- Timeline event APIs
|
||||
- Button/UI component APIs
|
||||
- DI patterns used in existing features
|
||||
|
||||
### Phase 1 Assessment
|
||||
|
||||
**Ready for device testing?** ❌ NO
|
||||
|
||||
The code cannot compile. Estimated work to fix:
|
||||
- Import cleanup: ~1 hour
|
||||
- Koios client rewrite: ~2 hours
|
||||
- Payment event sending redesign: ~4-8 hours (depends on SDK capabilities)
|
||||
- UI component fixes: ~1 hour
|
||||
- Testing: ~2 hours
|
||||
|
||||
**Total estimated fix time:** 10-14 hours of focused work
|
||||
|
||||
---
|
||||
|
||||
## Commits Made
|
||||
|
||||
1. `fix(wallet): resolve audit findings - DI typos, missing dependency, event type consistency`
|
||||
2. `fix(wallet): resolve sealed interface inheritance issue`
|
||||
3. `fix(wallet): fix cardano-client-lib API compatibility`
|
||||
|
||||
All changes pushed to `phase1-dev` branch on Gitea.
|
||||
|
||||
---
|
||||
|
||||
*Report generated automatically by Phase 1 audit subagent*
|
||||
### 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue