From a9c05a2b664e2d0fcaf3fd01d0b9ba89f579f5a4 Mon Sep 17 00:00:00 2001 From: Kayos Date: Fri, 27 Mar 2026 12:35:51 -0700 Subject: [PATCH] docs: add Phase 1 status report BUILD FAILED - Multiple critical issues found: - Timeline.sendRaw() doesn't exist in SDK - Koios backend API usage wrong - DI import paths wrong - Parcelize imports wrong - Compose API mismatches See PHASE1-STATUS.md for full details and remediation plan. --- PHASE1-STATUS.md | 182 ++++++++++++++++++ .../impl/biometric/BiometricAuthenticator.kt | 2 +- .../impl/cardano/CardanoWalletManager.kt | 4 +- .../impl/cardano/DefaultTransactionBuilder.kt | 2 +- .../wallet/impl/cardano/KoiosCardanoClient.kt | 2 +- .../impl/cardano/PaymentStatusPoller.kt | 2 +- .../features/wallet/impl/di/WalletModule.kt | 6 +- .../impl/payment/DefaultPaymentEventSender.kt | 2 +- .../impl/seedphrase/SeedPhraseManager.kt | 4 +- .../wallet/impl/slash/SlashCommandParser.kt | 2 +- .../impl/storage/CardanoKeyStorageImpl.kt | 2 +- .../TimelineItemContentPaymentFactory.kt | 2 +- 12 files changed, 197 insertions(+), 15 deletions(-) create mode 100644 PHASE1-STATUS.md diff --git a/PHASE1-STATUS.md b/PHASE1-STATUS.md new file mode 100644 index 0000000000..3f2d3d2eec --- /dev/null +++ b/PHASE1-STATUS.md @@ -0,0 +1,182 @@ +# Phase 1 Status Report +**Date:** 2026-03-27 +**Auditor:** Kayos (automated audit) + +## Executive Summary + +**BUILD STATUS: ❌ FAILED** + +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. + +--- + +## Audit Findings + +### Issues Fixed (Pushed to Gitea) + +1. **DI Package Typo** ✅ FIXED + - `dev.zacsweeny.metro` → `dev.zacsweers.metro` (missing 's') + - Files: KoiosCardanoClient, DefaultTransactionBuilder, PaymentStatusPoller, WalletModule + +2. **Missing Dependency** ✅ FIXED + - Added `implementation(projects.features.wallet.impl)` to messages:impl build.gradle.kts + +3. **Event Type Inconsistency** ✅ FIXED + - Standardized to `co.sulkta.payment.request` everywhere + - Updated TimelineItemPaymentContent.EVENT_TYPE and tests + +4. **Scope Inconsistency** ✅ FIXED + - PaymentStatusPoller changed from AppScope to SessionScope (matches CardanoClient scope) + +5. **Sealed Interface Inheritance** ✅ FIXED + - TimelineItemPaymentContent can't inherit from sealed TimelineItemEventContent (different modules) + - Created TimelineItemPaymentContentWrapper adapter in messages:impl + +6. **cardano-client-lib API** ✅ PARTIALLY FIXED + - Changed `getNetworks()` to `getNetwork()` returning `Network` instead of `Networks` + +### Critical Issues Remaining (Blocks Compilation) + +#### 1. DI Import Paths Wrong +**Impact:** ~20 compilation errors +**Files:** Most wallet/impl files + +The code uses: +```kotlin +import dev.zacsweers.metro.SessionScope // WRONG +import dev.zacsweers.metro.Inject // WRONG +``` + +Should be: +```kotlin +import io.element.android.libraries.di.SessionScope +import javax.inject.Inject +``` + +**Status:** Partially fixed, but more instances remain + +#### 2. Timeline.sendRaw() Doesn't Exist +**Impact:** Critical - payment sending broken +**Files:** DefaultPaymentEventSender.kt + +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 + +```kotlin +Button( + onClick = { ... }, + icon = { Icon(...) } // WRONG: Button doesn't have icon parameter +) +``` + +Element X's Button API differs from what was assumed. + +#### 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* diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/biometric/BiometricAuthenticator.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/biometric/BiometricAuthenticator.kt index 8904ff7e27..19c66b3537 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/biometric/BiometricAuthenticator.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/biometric/BiometricAuthenticator.kt @@ -11,7 +11,7 @@ import androidx.biometric.BiometricManager import androidx.biometric.BiometricPrompt import androidx.core.content.ContextCompat import androidx.fragment.app.FragmentActivity -import dev.zacsweers.metro.Inject +import javax.inject.Inject import kotlinx.coroutines.suspendCancellableCoroutine import kotlin.coroutines.resume diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/CardanoWalletManager.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/CardanoWalletManager.kt index 7193830418..3da2caaef0 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/CardanoWalletManager.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/CardanoWalletManager.kt @@ -8,9 +8,9 @@ package io.element.android.features.wallet.impl.cardano import com.bloxbean.cardano.client.account.Account import com.bloxbean.cardano.client.crypto.bip32.HdKeyPair -import dev.zacsweers.metro.AppScope +import io.element.android.libraries.di.AppScope import dev.zacsweers.metro.ContributesBinding -import dev.zacsweers.metro.Inject +import javax.inject.Inject import dev.zacsweers.metro.SingleIn import io.element.android.features.wallet.api.WalletState import io.element.android.features.wallet.api.storage.CardanoKeyStorage diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/DefaultTransactionBuilder.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/DefaultTransactionBuilder.kt index 97b5a69e35..954b0b0eb2 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/DefaultTransactionBuilder.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/DefaultTransactionBuilder.kt @@ -14,7 +14,7 @@ import com.bloxbean.cardano.client.function.helper.SignerProviders import com.bloxbean.cardano.client.quicktx.QuickTxBuilder import com.bloxbean.cardano.client.quicktx.Tx import dev.zacsweers.metro.ContributesBinding -import dev.zacsweers.metro.SessionScope +import io.element.android.libraries.di.SessionScope import io.element.android.features.wallet.api.CardanoClient import io.element.android.features.wallet.api.CardanoException import io.element.android.features.wallet.api.PaymentRequest diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/KoiosCardanoClient.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/KoiosCardanoClient.kt index 570a7584ed..2f71f2273f 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/KoiosCardanoClient.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/KoiosCardanoClient.kt @@ -9,7 +9,7 @@ package io.element.android.features.wallet.impl.cardano import com.bloxbean.cardano.client.backend.api.BackendService import com.bloxbean.cardano.client.backend.factory.BackendFactory import dev.zacsweers.metro.ContributesBinding -import dev.zacsweers.metro.SessionScope +import io.element.android.libraries.di.SessionScope import io.element.android.features.wallet.api.CardanoClient import io.element.android.features.wallet.api.CardanoException import io.element.android.features.wallet.api.ProtocolParameters diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/PaymentStatusPoller.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/PaymentStatusPoller.kt index 7e8aa07cab..a6437dfb30 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/PaymentStatusPoller.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/cardano/PaymentStatusPoller.kt @@ -7,7 +7,7 @@ package io.element.android.features.wallet.impl.cardano import dev.zacsweers.metro.ContributesBinding -import dev.zacsweers.metro.SessionScope +import io.element.android.libraries.di.SessionScope import dev.zacsweers.metro.SingleIn import io.element.android.features.wallet.api.CardanoClient import io.element.android.features.wallet.api.PaymentStatusPoller diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/di/WalletModule.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/di/WalletModule.kt index eaabdbfb8c..f8d75e1eba 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/di/WalletModule.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/di/WalletModule.kt @@ -6,11 +6,11 @@ package io.element.android.features.wallet.impl.di -import dev.zacsweers.metro.AppScope +import dev.zacsweers.metro.BindingContainer import dev.zacsweers.metro.ContributesTo -import dev.zacsweers.metro.ObjectFactory import dev.zacsweers.metro.Provides import dev.zacsweers.metro.SingleIn +import io.element.android.libraries.di.AppScope import kotlinx.serialization.json.Json /** @@ -20,7 +20,7 @@ import kotlinx.serialization.json.Json * annotation on KoiosCardanoClient. */ @ContributesTo(AppScope::class) -@ObjectFactory +@BindingContainer interface WalletModule { companion object { @Provides diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/payment/DefaultPaymentEventSender.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/payment/DefaultPaymentEventSender.kt index 8b153ef355..100199e659 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/payment/DefaultPaymentEventSender.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/payment/DefaultPaymentEventSender.kt @@ -7,7 +7,7 @@ package io.element.android.features.wallet.impl.payment import dev.zacsweers.metro.ContributesBinding -import dev.zacsweers.metro.SessionScope +import io.element.android.libraries.di.SessionScope import io.element.android.features.wallet.api.PaymentCardStatus import io.element.android.features.wallet.api.PaymentEventSender import io.element.android.features.wallet.api.PaymentRequest diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/seedphrase/SeedPhraseManager.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/seedphrase/SeedPhraseManager.kt index 08d67d1294..5132b5f9fb 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/seedphrase/SeedPhraseManager.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/seedphrase/SeedPhraseManager.kt @@ -8,9 +8,9 @@ package io.element.android.features.wallet.impl.seedphrase import com.bloxbean.cardano.client.crypto.bip39.MnemonicCode import com.bloxbean.cardano.client.crypto.bip39.Words -import dev.zacsweers.metro.AppScope +import io.element.android.libraries.di.AppScope import dev.zacsweers.metro.ContributesBinding -import dev.zacsweers.metro.Inject +import javax.inject.Inject import timber.log.Timber import java.security.SecureRandom diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/slash/SlashCommandParser.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/slash/SlashCommandParser.kt index a457fb6f36..cac8201907 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/slash/SlashCommandParser.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/slash/SlashCommandParser.kt @@ -7,7 +7,7 @@ package io.element.android.features.wallet.impl.slash import io.element.android.libraries.matrix.api.core.UserId -import dev.zacsweers.metro.Inject +import javax.inject.Inject import java.math.BigDecimal /** diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/storage/CardanoKeyStorageImpl.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/storage/CardanoKeyStorageImpl.kt index a312c436aa..a6ab218efb 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/storage/CardanoKeyStorageImpl.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/storage/CardanoKeyStorageImpl.kt @@ -14,7 +14,7 @@ import android.security.keystore.KeyProperties import android.util.Base64 import com.bloxbean.cardano.client.account.Account import com.bloxbean.cardano.client.crypto.bip39.MnemonicCode -import dev.zacsweers.metro.AppScope +import io.element.android.libraries.di.AppScope import dev.zacsweers.metro.ContributesBinding import io.element.android.features.wallet.api.storage.CardanoKeyStorage import io.element.android.features.wallet.api.storage.WalletCreationResult diff --git a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/timeline/TimelineItemContentPaymentFactory.kt b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/timeline/TimelineItemContentPaymentFactory.kt index 0547d36c35..dd7460cd22 100644 --- a/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/timeline/TimelineItemContentPaymentFactory.kt +++ b/features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/timeline/TimelineItemContentPaymentFactory.kt @@ -6,7 +6,7 @@ package io.element.android.features.wallet.impl.timeline -import dev.zacsweers.metro.Inject +import javax.inject.Inject import io.element.android.features.wallet.api.PaymentCardStatus import io.element.android.features.wallet.api.timeline.TimelineItemPaymentContent import io.element.android.features.wallet.impl.payment.DefaultPaymentEventSender