element-x-ada/BLOCKERS.md
Kayos db4c262b27 feat(wallet): /pay slash command parser and composer integration (Task 5)
Implements Task 5 of Phase 1:

New files:
- ParsedPayCommand.kt: Sealed interface for parse results
  - WithAddressRecipient: Pay to Cardano address
  - WithMatrixRecipient: Pay to Matrix user (requires lookup)
  - AmountOnly: Amount specified, prompt for recipient
  - Empty: Open payment flow with no prefilled data
  - ParseError: Parse error with human-readable reason

- SlashCommandParser.kt: Full /pay command parser
  - Handles: /pay, /pay 10, /pay 10 ADA, /pay 10 tADA
  - Matrix recipients: /pay 10 ADA @user:server
  - Cardano addresses: /pay 10 ADA addr1...
  - Validates amounts (decimal support, max supply check)
  - Validates addresses (prefix, length, network match)
  - Comprehensive error messages

- SlashCommandParserTest.kt: 40+ unit tests covering all patterns

Modified files:
- ResolvedSuggestion.kt: Added Command type for slash commands
- SuggestionsProcessor.kt: /pay shows as autocomplete suggestion
- MarkdownTextEditorState.kt: Command insertion in text editor
- MessageComposerPresenter.kt: Command handling in InsertSuggestion

Note: MessageComposerPresenter sendMessage interception deferred to
Task 6 (requires PaymentFlowPresenter for navigation).
2026-03-27 10:38:46 -07:00

4.2 KiB

BLOCKERS.md - Phase 1 Implementation Blockers

Task 1: Module Scaffolding

Completed

  • Module structure created (api/impl/test)
  • Metro DI setup following Element X patterns
  • WalletEntryPoint and WalletState APIs defined
  • PaymentFlowNode placeholder with Appyx navigation
  • FakeWalletEntryPoint for testing
  • Cardano client library dependencies added
  • ProGuard rules configured
  • Basic unit tests added
  • Pushed to Gitea phase1-dev branch

Not Verified (No Android SDK in build environment)

  • ⚠️ ./gradlew :features:wallet:impl:assemble - compilation not tested
  • ⚠️ ./gradlew ktlintCheck --continue - code style not verified
  • ⚠️ ./gradlew :features:wallet:impl:test - unit tests not run

Action Required

When a developer with Android SDK runs this code:

  1. Run ./gradlew :features:wallet:impl:assemble to verify compilation
  2. Run ./gradlew ktlintCheck --continue and fix any code style issues
  3. Run ./gradlew :features:wallet:impl:test to verify tests pass

Resolved Decisions

Q1: Wallet Scope RESOLVED

Decision: Per-session (each Matrix account has its own wallet)

Each Matrix session maintains its own independent wallet. This aligns with Matrix's account-centric model and provides proper isolation between accounts.

Phase 3 Planned: Optional wallet sharing between accounts — will be implemented as a user preference, not default behavior.

Q2: Key Storage on Biometric Change RESOLVED

Decision: INVALIDATE keys and require re-authentication/re-setup

When biometric enrollment changes (fingerprints added/removed, face re-enrolled, etc.), stored wallet keys are invalidated. Users must re-authenticate and re-setup their wallet access. This is intentional security behavior, not a bug — it prevents unauthorized access if a device is compromised or biometrics are changed by an attacker.

Q3: Network Configuration RESOLVED

Decision: TESTNET first, with easy mainnet swap

Development and initial testing will target Cardano testnet. The network configuration must be a single constant or build flavor — no scattered hardcoded values throughout the codebase.

Implementation requirements:

  • Single source of truth: Constants.NETWORK_MODE or build variant
  • All network-dependent URLs/configs derived from this single value
  • Clean swap to mainnet via config change or release build flavor
  • No hunting through code for hardcoded "testnet" strings

Android Emulator

Development Android emulator is live and available:

Service Address
ADB 192.168.0.5:5555
noVNC (browser access) http://192.168.0.5:6080

Connect via: adb connect 192.168.0.5:5555


Task 5: /pay Slash Command Parser + SuggestionsProcessor Extension

Completed

  • ParsedPayCommand.kt - Sealed interface for parse results (WithAddressRecipient, WithMatrixRecipient, AmountOnly, Empty, ParseError)
  • SlashCommandParser.kt - Full parser implementation with:
    • Amount parsing (integers, decimals, up to 6 decimal places for lovelace precision)
    • Unit support (ADA, tADA for testnet, lovelace)
    • Matrix user ID validation (@user:server format)
    • Cardano address validation (addr1/addr_test1 prefixes, length checks, network mismatch detection)
    • Comprehensive error messages
  • ResolvedSuggestion.kt - Added Command(command: String, description: String) type
  • SuggestionsProcessor.kt - Added /pay command suggestion with filtering
  • MarkdownTextEditorState.kt - Added Command case to insertSuggestion()
  • MessageComposerPresenter.kt - Added Command handling in InsertSuggestion event
  • SlashCommandParserTest.kt - Comprehensive unit tests (40+ test cases)

What's Still Needed (Task 6)

  • ⚠️ MessageComposerPresenter interception of /pay on send (requires PaymentFlowPresenter from Task 6)
  • ⚠️ Navigation to payment flow when /pay is sent
  • ⚠️ Integration with PaymentFlowNode for actual payment execution

Testing Notes

  • Tests use plain JUnit with Truth assertions
  • Parser handles edge cases: whitespace, case sensitivity, decimal precision, network mismatches
  • Testnet support via tADA unit or addr_test1 addresses

Last updated: 2026-03-27