feat: add fallback display if no amountInUSD and add protocol fee#191
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds "protocol" as a supported fee type and updates the payment-route component to label it and change fee amount rendering logic (USD-first, currency-aware formatting) plus an ethers utils import for precise amount formatting. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)**/*⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (5)📓 Common learnings📚 Learning: 2025-10-13T19:12:34.359ZApplied to files:
📚 Learning: 2025-10-22T08:44:20.491ZApplied to files:
📚 Learning: 2025-10-28T12:17:14.899ZApplied to files:
📚 Learning: 2025-08-08T09:52:43.700ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Comment |
Greptile SummaryThis PR adds support for protocol fees and implements fallback display logic when USD amounts are unavailable. Key Changes:
Issues Found:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant PaymentRoute as Payment Route Component
participant FeeBreakdown as Fee Breakdown Data
User->>PaymentRoute: View invoice payment options
PaymentRoute->>FeeBreakdown: Check feeBreakdown array
alt feeBreakdown exists
loop For each fee
FeeBreakdown->>PaymentRoute: Get fee.type
alt type is "protocol"
PaymentRoute->>PaymentRoute: Display "Protocol Fee"
else type is "gas"
PaymentRoute->>PaymentRoute: Display "Gas Fee"
else type is "crosschain"
PaymentRoute->>PaymentRoute: Display "Crosschain Fee"
else type is "platform"
PaymentRoute->>PaymentRoute: Display "Platform Fee"
end
FeeBreakdown->>PaymentRoute: Check amountInUSD
alt amountInUSD exists
PaymentRoute->>PaymentRoute: Format as USD (6 decimals)
else amountInUSD is null/undefined
FeeBreakdown->>PaymentRoute: Get fee.amount & fee.currency
alt currency is ETH and amount > 1e12
PaymentRoute->>PaymentRoute: Convert wei to ETH (divide by 1e18)
PaymentRoute->>PaymentRoute: Display as ETH (6 decimals)
else currency is ETH
PaymentRoute->>PaymentRoute: Display as ETH (6 decimals)
else other currency
PaymentRoute->>PaymentRoute: Display in native currency (4 decimals)
end
end
PaymentRoute->>User: Show formatted fee
end
end
PaymentRoute->>User: Display complete fee breakdown tooltip
|
There was a problem hiding this comment.
Additional Comments (1)
-
src/lib/types/index.ts, line 20 (link)syntax:
amountInUSDshould be optional since the fallback logic inpayment-route.tsx:99checks for null/undefined.
2 files reviewed, 3 comments
src/app/(dashboard)/invoices/[ID]/_components/payment-route.tsx
Outdated
Show resolved
Hide resolved
02a3cff to
f469154
Compare
Merge activity
|

Protocol fee addition
Fallback Fix (Toolip was relying only in
amountInUsdwhich is not available in all cases)TL;DR
Added support for protocol fees and improved fee display formatting in the invoice payment route component.
What changed?
protocolto thefeeBreakdowntype definitionprotocolamountInUSDis not available by falling back to the native currency amountHow to test?
Why make this change?
This change improves the user experience by providing more accurate fee labeling and better formatting of fee amounts. It also adds support for protocol fees, which are a distinct fee type that needs to be properly represented in the UI.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.