Skip to content

Conversation

@TaprootFreak
Copy link
Collaborator

Summary

This PR replaces the closed PR #702 with a cleaner implementation that properly supports linked addresses (userAddresses).

Changes:

  • Create useAddressItems hook for consistent address handling across all screens
  • Update buy.screen.tsx to support linked addresses
  • Update sell.screen.tsx to support linked addresses
  • Fix double div in swap.screen.tsx
  • Fix incorrect form rules in swap.screen.tsx (was validating non-existent fields)

How it works:

The new useAddressItems hook generates address items that include:

  • All addresses from linked wallets (userAddresses from useUserContext)
  • Current session address
  • "Switch address" option for wallet switching

This enables cross-chain operations where users can receive funds on linked addresses (e.g., Lightning via Bitcoin wallet).

Why this approach vs PR #702:

PR #702 tried to separate blockchain and address selection into two dropdowns, but:

  1. The AddressSelector only showed 2 hardcoded options (current address, switch)
  2. It didn't support userAddresses/linked addresses
  3. Code was duplicated 3x across screens

This PR keeps the single dropdown pattern (which works well) but adds userAddresses support consistently across buy, sell, and swap screens.

Test plan

  • Test buy flow with linked addresses
  • Test sell flow with linked addresses
  • Test swap flow (already had userAddresses support)
  • Verify "Switch address" option still works
  • Test blockchain switching via address selection

- Create useAddressItems hook for consistent address handling across screens
- Update buy.screen.tsx to support linked addresses (userAddresses)
- Update sell.screen.tsx to support linked addresses (userAddresses)
- Fix double div in swap.screen.tsx
- Fix incorrect form rules in swap.screen.tsx (bankAccount/asset/currency -> sourceAsset/targetAsset)

The hook generates address items that include:
- All addresses from linked wallets (userAddresses)
- Current session address
- 'Switch address' option for wallet switching

This enables cross-chain operations where users can receive funds on
linked addresses (e.g., Lightning via Bitcoin wallet).
@github-actions
Copy link

github-actions bot commented Jan 12, 2026

🤖 PR Review Bot

❌ TypeScript: 460 errors


⚠️ Security: 0 critical, 30 high vulnerabilities


This is an automated review. Please address the issues above.

- Remove duplicated userSessions, userAddressItems, sourceBlockchains,
  targetBlockchains, addressItems logic from swap.screen.tsx
- Use shared useAddressItems hook for consistent behavior across all screens
- Hook now returns availableBlockchains for asset filtering
- Remove unused userSessions from hook return value

This eliminates ~60 lines of duplicated code and ensures consistent
address/blockchain selection behavior across buy, sell, and swap screens.
@TaprootFreak
Copy link
Collaborator Author

redy for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants