element-x-ada/docs/build-logs/polish-result.md

4.3 KiB

Element X ADA Polish Tasks - Completed

Date: 2026-03-29


Task 1: isDM Detection — Fixed

Problem: The wallet button was using overly broad logic:

isDmRoom = roomInfo.isDm || roomInfo.activeMembersCount == 2L

This would show the wallet button in ANY 2-person room, including private rooms that aren't DMs.

Solution: Simplified to use only the proper isDm property:

isDmRoom = roomInfo.isDm

The RoomInfo.isDm extension property already implements the correct logic:

val RoomInfo.isDm get() = isDm(isDirect, activeMembersCount.toInt())

fun isDm(isDirect: Boolean, activeMembersCount: Int): Boolean {
    return isDirect && activeMembersCount <= 2
}

This ensures the wallet button only appears in genuine 1:1 DM rooms where:

  • isDirect is true (Matrix spec DM flag)
  • At most 2 active members

Commit: faa6f768f6 - fix(wallet): use proper isDm check for wallet button visibility


Task 2: Payment Card UI — Polished

Added: Truncated recipient/sender address display

The payment card now shows:

  • Header: Cardano icon + "Sent" or "Received" label + testnet badge
  • Amount: Large bold text (e.g., "10 ADA")
  • Address: "To: addr_tes...ytjqp" for sent / "From: addr_tes...pd0hq" for received
  • Status: Chip with spinner (pending), checkmark (confirmed), or X (failed)
  • Tx hash: Truncated (first 8...last 8), tappable to open CardanoScan
  • Explorer link: "View on CardanoScan →" for confirmed transactions

Changes:

  1. TimelineItemPaymentContent.kt:

    • Added truncatedToAddress and truncatedFromAddress computed properties
    • Added truncateAddress() helper (first 8 + last 6 chars)
  2. TimelineItemPaymentView.kt:

    • Added address row showing "To:" or "From:" with truncated address
  3. TimelineItemPaymentContentWrapper.kt:

    • Exposed new truncated address properties

Commit: 699807e1bd - feat(wallet): add recipient address to payment card UI


APK Available

Fresh arm64 build served at:

http://192.168.0.5:8888/app-fdroid-arm64-v8a-debug.apk

Size: ~210 MB


Code Quality Notes

  • Used existing RoomInfo.isDm extension rather than reinventing logic
  • Address truncation follows same pattern as tx hash (first N...last M)
  • Payment card remains clean and intentional — not a debug dump
  • All changes respect 160 char ktlint limit
  • No new dependencies added

Task 3: Cardano Address in Matrix Account Data — Implemented

Publishing (Write Side)

After wallet creation, import, or SSSS restore, the user's Cardano address is automatically published to Matrix account data:

  • Key: com.sulkta.cardano.address
  • Content: { "address": "addr1..." }
  • Public/unencrypted — this is a discovery mechanism, not a secret

Where it's called:

  • WalletSetupPresenter → after all wallet setup completion paths
  • Fire-and-forget — wallet setup doesn't fail if publish fails

Lookup (Read Side)

When entering a Matrix user ID in the /pay payment form:

  1. System looks up their com.sulkta.cardano.address account data
  2. If found → auto-fills recipient, shows "Address loaded from @user's profile ✓"
  3. If not found → shows "@user hasn't linked a wallet", allows manual entry

New UI States:

  • RecipientResolutionState.Resolving — spinner while looking up
  • RecipientResolutionState.Found — green card with checkmark and truncated address
  • RecipientResolutionState.NeedsManualEntry — red card prompting manual entry

New Files

  • CardanoAddressService.kt (wallet:api) — interface
  • DefaultCardanoAddressService.kt (wallet:impl) — implementation using OkHttp + SessionStore

Modified Files

  • WalletSetupPresenter.kt — calls publishAddressToMatrix() after wallet setup
  • PaymentEntryPresenter.kt — looks up recipient address on Matrix user input
  • PaymentEntryState.kt — added Resolving and Found states
  • PaymentEntryView.kt — added lookup progress and result cards

Commit: c35289a3bd


Final APK

Fresh arm64 build with all three tasks:

http://192.168.0.5:8888/app-fdroid-arm64-v8a-debug.apk

All Commits

  1. faa6f768f6 — fix(wallet): use proper isDm check for wallet button visibility
  2. 699807e1bd — feat(wallet): add recipient address to payment card UI
  3. c35289a3bd — feat(wallet): store Cardano address in Matrix account data for discovery