Skip to content

fix: remove unreachable code and duplication in fee services#4036

Merged
johnnyluo merged 1 commit into
mainfrom
aminsato/cleanup-fee-service-dead-code
Apr 12, 2026
Merged

fix: remove unreachable code and duplication in fee services#4036
johnnyluo merged 1 commit into
mainfrom
aminsato/cleanup-fee-service-dead-code

Conversation

@aminsato
Copy link
Copy Markdown
Collaborator

@aminsato aminsato commented Apr 12, 2026

Summary

  • Remove unreachable return BasicFee(...) after return GasFees(...) in SuiFeeService.calculateDefaultFees
  • Remove unused BasicFee import from SuiFeeService
  • Deduplicate UtxoFeeService.calculateFees by delegating to calculateDefaultFees instead of duplicating its body (matches the pattern used by TonFeeService and CosmosFeeService)

Test plan

  • Verify SUI fee estimation works correctly
  • Verify UTXO fee estimation works correctly for BTC, Doge, Zcash, Cardano

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved fee calculation logic consistency and removed unused code references for better maintainability.

SuiFeeService had an unreachable BasicFee return after a GasFees return
in calculateDefaultFees. UtxoFeeService had calculateFees duplicating
calculateDefaultFees body instead of delegating to it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 73284183-4918-452f-a30f-6b1e2708d017

📥 Commits

Reviewing files that changed from the base of the PR and between 0100569 and 11b57fd.

📒 Files selected for processing (2)
  • data/src/main/kotlin/com/vultisig/wallet/data/blockchain/sui/SuiFeeService.kt
  • data/src/main/kotlin/com/vultisig/wallet/data/blockchain/utxo/UtxoFeeService.kt
💤 Files with no reviewable changes (1)
  • data/src/main/kotlin/com/vultisig/wallet/data/blockchain/sui/SuiFeeService.kt

📝 Walkthrough

Walkthrough

Two fee service files were refactored to remove dead code and consolidate logic. SuiFeeService eliminated an unreachable return statement and its corresponding import, while UtxoFeeService simplified calculateFees to delegate to the existing calculateDefaultFees method.

Changes

Cohort / File(s) Summary
Fee Service Cleanup
data/src/main/kotlin/com/vultisig/wallet/data/blockchain/sui/SuiFeeService.kt
Removed unused BasicFee import and deleted unreachable return BasicFee(amount = estimatedFees) statement after a preceding return GasFees(...) call.
UTXO Fee Logic Consolidation
data/src/main/kotlin/com/vultisig/wallet/data/blockchain/utxo/UtxoFeeService.kt
Refactored calculateFees(transaction) to delegate to calculateDefaultFees(transaction) instead of duplicating fee calculation logic inline.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hops through code, finds dust to sweep,
Dead returns and imports deep,
One delegates, one cleans the way,
Simpler fees now rule the day!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: removing unreachable code in SuiFeeService and eliminating duplication in UtxoFeeService by consolidating fee calculation logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aminsato/cleanup-fee-service-dead-code

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@johnnyluo johnnyluo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnnyluo johnnyluo added this pull request to the merge queue Apr 12, 2026
Merged via the queue into main with commit 459efe4 Apr 12, 2026
2 checks passed
@johnnyluo johnnyluo deleted the aminsato/cleanup-fee-service-dead-code branch April 12, 2026 12:29
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