Update isSingleChainSwap to return true for EVM-based swap providers#9193
Conversation
📝 WalkthroughWalkthroughThis PR modifies ChangesSingle-Chain Swap EVM Conditioning
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/USwapProvider.kt`:
- Line 45: USwapProvider.isSingleChainSwap currently ignores
tokenInBlockchainTypeUid and tokenOutBlockchainTypeUid and just returns isEvm;
either confirm that behavior is intentional or update the method to also check
that both tokens are on the same blockchain like AllBridgeProvider does (i.e.,
return isEvm && tokenInBlockchainTypeUid == tokenOutBlockchainTypeUid) so it
only treats swaps as single-chain when both tokens share the same blockchain UID
and the provider is EVM-based; modify the USwapProvider.isSingleChainSwap
implementation accordingly and run tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2ae85627-c81d-4eb3-9b7f-48a303b5cf5f
📒 Files selected for processing (1)
app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/USwapProvider.kt
| override val riskLevel = provider.riskLevel | ||
|
|
||
| override fun isSingleChainSwap(tokenInBlockchainTypeUid: String, tokenOutBlockchainTypeUid: String) = false | ||
| override fun isSingleChainSwap(tokenInBlockchainTypeUid: String, tokenOutBlockchainTypeUid: String) = isEvm |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for the interface definition and usage of isSingleChainSwap
# Find the interface definition
echo "=== Interface definition ==="
ast-grep --pattern $'interface $_ {
$$$
fun isSingleChainSwap($$$)
$$$
}'
# Find all implementations
echo -e "\n=== All implementations ==="
rg -n "fun isSingleChainSwap|override fun isSingleChainSwap" -A 2
# Find all call sites
echo -e "\n=== Call sites ==="
rg -n "\.isSingleChainSwap\(" -B 2 -A 2Repository: horizontalsystems/unstoppable-wallet-android
Length of output: 5786
Clarify whether USwapProvider should compare blockchain type UIDs.
The function ignores tokenInBlockchainTypeUid and tokenOutBlockchainTypeUid parameters, returning only isEvm. However, AllBridgeProvider implements the same interface method differently at line 154:
tokenInBlockchainTypeUid == tokenOutBlockchainTypeUid
This shows that some providers do evaluate both parameters to determine if a swap is single-chain. If USwapProvider should also validate that tokens are on the same blockchain (not just EVM), it should compare the parameters like AllBridgeProvider does. Verify this is intentional or update to match the pattern used by similar bridge/provider implementations.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@app/src/main/java/io/horizontalsystems/bankwallet/modules/multiswap/providers/USwapProvider.kt`
at line 45, USwapProvider.isSingleChainSwap currently ignores
tokenInBlockchainTypeUid and tokenOutBlockchainTypeUid and just returns isEvm;
either confirm that behavior is intentional or update the method to also check
that both tokens are on the same blockchain like AllBridgeProvider does (i.e.,
return isEvm && tokenInBlockchainTypeUid == tokenOutBlockchainTypeUid) so it
only treats swaps as single-chain when both tokens share the same blockchain UID
and the provider is EVM-based; modify the USwapProvider.isSingleChainSwap
implementation accordingly and run tests.
#9055
Summary by CodeRabbit