Repository navigation
feat: detect the usdt network when sending #1573
Description
Problem or use case
Sending USDT makes the user choose the recipient's network, and the app ignores any network a request names:
isUsdtPaymentInput(AppViewModel.kt) only recognisesethereum:URIs and 42-character0xaddresses. Tron and Solana addresses fall through tocoreService.decodefrom the scanner, clipboard and manual entry, and fail there.handleUsdtPaymentInputnavigates withRoutes.UsdtPayment(recipient, amount). The route has no destination field.UsdtWalletScreen.ktstarts onUsdtDestination.ARBITRUMand setsARBITRUMagain whenever a parsed request has achainId.- The USDT send sheet's own scan and paste validate against the currently selected network instead of switching to the request's network.
- Scanning a Polygon request today shows "Unable To Read QR", because core rejects every chain except Arbitrum.
UX goal: the user scans or pastes a USDT request and Bitkit picks the network. This applies to sending only. Receive and the Paykit endpoints the user publishes stay Arbitrum-only.
Proposed solution
Depends on synonymdev/bitkit-core#176, which returns the detected destination from usdtParsePaymentRequest.
- Recognise Tron and Solana addresses as USDT input in the scanner, clipboard (
canDecodeClipboard,onClipboardAutoRead) and manual entry (validateUsdtAddressWithFeedback). - Add the destination to
Routes.UsdtPaymentand set it inhandleUsdtPaymentInput. - Start
UsdtWalletScreenon the detected destination, and stop forcingARBITRUMwhen achainIdis present. - Make scan and paste inside the USDT send sheet switch to the detected network.
- Keep Arbitrum selected and the picker available for a bare
0xaddress, which carries no network. - Show a clear error when the detected network is not available, separate from "invalid address".
- Show
usdt__network_warningonly when the network was not detected. - Update the journeys that assert today's Arbitrum-only behaviour:
usdt-payment-links-and-scans.xmlandusdt-send-review-and-details.xml. Port them to iOS.
Alternatives considered
None.
Additional context
Merge before starting:
- feat: detect the usdt network from send requests bitkit-core#176
- fix: improve USDT payment and bridge feedback #1531: same USDT send files (
UsdtWalletScreen,UsdtSendContent,UsdtViewModel,UsdtRepo,AppViewModel) and journeys. Adds the route min/max/liquidity errors a detected route can hit. - fix: improve usdt payment feedback and layout #1564: edits
usdt-payment-links-and-scans.xmlandusdt-send-review-and-details.xml. - fix: stabilize usdt wallet and payment layouts #1565: edits
UsdtWalletScreen.kt.
Coordinate with #1454, which changes the same scan validation entry points in AppViewModel.
Paykit contact payments stay on MethodId.UsdtArbitrum and are out of scope.
iOS: synonymdev/bitkit-ios#1011.
Design: the Send (USDT) note says "Try to recognize network from address, if not possible user can select other network." The file has no frames for a detected-network state, an unsupported-network error or a scanned non-Arbitrum QR. The network sheet lists Arbitrum One, Polygon and Tron, while Confirm Details shows "Binance Chain" as the recipient network. Until the design covers these, build from the existing frames.
Activity