-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add cbbtc recurring #4949
Feat/add cbbtc recurring #4949
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request introduces changes to handle tokens with 8 decimal places across multiple components. The modifications primarily focus on updating the logic for processing donation amounts, input validation, and token configuration. The changes ensure that the application can correctly handle tokens with different decimal precisions, specifically expanding support for tokens with 6 and 8 decimal places in the donation and input mechanisms. Changes
Sequence DiagramsequenceDiagram
participant User
participant AmountInput
participant DonationModal
participant TokenConfig
User->>AmountInput: Enter donation amount
AmountInput->>AmountInput: Validate decimal places
AmountInput->>DonationModal: Submit amount
DonationModal->>TokenConfig: Check token decimals
TokenConfig-->>DonationModal: Return decimal configuration
DonationModal->>DonationModal: Convert and scale amount
DonationModal->>User: Confirm donation
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx (1)
245-261
: Add a comment explaining the token conversion logic.The code correctly handles the conversion of token amounts with 8 decimals to 18 decimals for super token compatibility. However, adding a comment would help explain why this conversion is necessary.
Consider adding a comment like:
+ // Convert token amounts to 18 decimals for super token compatibility. + // For tokens with 6 or 8 decimals, we first convert to a human-readable number + // by dividing by the token's decimals, then convert back to wei using 18 decimals. if ( selectedRecurringToken.token.decimals === 6 || selectedRecurringToken.token.decimals === 8 ) {src/components/views/donate/Recurring/RecurringDonationCard.tsx (1)
157-161
: Document the scale factor calculation.While the scale factors are correctly implemented, their purpose and calculation method should be documented for maintainability.
Consider adding a comment explaining the scale factors:
+ // Scale factors are used to adjust the flow rate calculations: + // - For 6 decimal tokens: 10000n (1e4) to handle the decimal difference (18 - 6 = 12, so 1e12/1e8 = 1e4) + // - For 8 decimal tokens: 100n (1e2) to handle the decimal difference (18 - 8 = 10, so 1e10/1e8 = 1e2) + // - For other tokens: 1n (no scaling needed as they typically have 18 decimals) const scaleFactor = selectedRecurringToken?.token.decimals === 6 ? 10000n : selectedRecurringToken?.token.decimals === 8 ? 100n : 1n;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/components/AmountInput/AmountInput.tsx
(2 hunks)src/components/views/donate/Recurring/RecurringDonationCard.tsx
(2 hunks)src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx
(1 hunks)src/config/production.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (4)
src/components/AmountInput/AmountInput.tsx (2)
54-60
: LGTM! The decimal place handling is well-implemented.The logic correctly handles the display formatting for tokens with 8 decimals while maintaining backward compatibility for other tokens.
80-86
: LGTM! Input validation aligns with display formatting.The input validation logic is consistent with the display formatting, ensuring that users can't enter more decimal places than allowed for the token type.
src/components/views/donate/Recurring/RecurringDonationCard.tsx (1)
144-150
: LGTM! Token amount reset is consistent.The code correctly resets amounts when switching to tokens with 8 decimals, maintaining consistency with the existing behavior for 6 decimal tokens.
src/config/production.tsx (1)
641-655
: LGTM! The cbBTC token configuration is complete.The configuration correctly defines both the underlying cbBTC token with 8 decimals and its corresponding super token with 18 decimals. All required fields are properly set.
Summary by CodeRabbit
Release Notes
New Features
Improvements
Bug Fixes