Skip to content
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

Add comarketing #4891

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Add comarketing #4891

merged 1 commit into from
Dec 5, 2024

Conversation

kkatusic
Copy link
Collaborator

@kkatusic kkatusic commented Dec 5, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Q/acc sections in the platform with new links and translations in Catalan, English, and Spanish.
    • Introduced new constants for QACC and QACC News URLs.
  • Improvements

    • Enhanced language translations across multiple languages for better clarity and user engagement.
    • Improved token handling in donation processes to accommodate various decimal configurations.
  • Bug Fixes

    • Corrected error messages and refined logic for handling token withdrawals and deposits.
  • Chores

    • Updated dependencies and configuration files to ensure compatibility and performance.

@kkatusic kkatusic self-assigned this Dec 5, 2024
Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giveth-dapps-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 10:44am

@kkatusic kkatusic changed the base branch from develop to main December 5, 2024 10:39
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

This pull request includes updates to localization files for Catalan, English, and Spanish languages, adding new keys related to "Q/acc" and "Q/acc News" while enhancing existing translations for clarity. Additionally, a new redirect rule is introduced in the Next.js configuration, and the package.json file is updated with new version numbers and dependency versions. A new ABI file for USDT is created, and various components are modified to improve token handling and rendering logic. The overall changes focus on enhancing user interface language and functionality without altering existing logic.

Changes

File Path Change Summary
lang/ca.json, lang/en.json, lang/es.json Added new keys: "component.title.qacc" and "component.title.qacc_news"; updated existing translations for clarity and accuracy.
next.config.js Added redirect from /comarketing to /assets/Giveth-Co-Marketing-Slides.pdf, non-permanent.
package.json Updated version to 2.34.0; modified viem from ^2.21.16 to ^2.21.19 and wagmi from ^2.12.16 to ^2.12.17.
src/artifacts/usdtMainnetABI.json Created new ABI file defining functions and events for USDT smart contract.
src/components/Footer/Footer.tsx Added links for QACC and QACC_NEWS; modified gap property in LeftContainer.
src/components/views/donate/OneTime/SelectTokenModal/SelectTokenModal.tsx Introduced sQuery variable for improved clarity in filtering logic.
src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx Added ethers import; updated onDeposit function to handle token decimal precision.
src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx Updated selectedToken type to `ISuperToken
src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx Changed token prop to superToken in Item component; refined error handling for withdrawal.
src/components/views/donate/Recurring/RecurringDonationCard.tsx Added formatDonation import; updated logic for token amounts based on decimal precision.
src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx Simplified access to token properties; streamlined amount and price calculations.
src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx Updated donation logic to handle tokens with 6 decimals.
src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx Introduced underlyingTokens state; modified filtering logic to check underlying token balances.
src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx Added superToken prop to IStreamInfoProps interface; updated rendering logic to use superToken.
src/components/views/givfarm/GIVfarmBottom.tsx Removed Col component wrapping StakeTogetherCard.
src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx Added useMemo for superToken; updated monthly flow rate display using formatDonation.
src/config/production.tsx Added new super token configuration for "Super Bridged USD Coin"; updated existing token IDs for consistency.
src/hooks/useCreateEvmDonation.tsx Updated txHash state type to accept Address; modified transaction receipt handling.
src/hooks/usePassport.ts Updated fetchUserMBDScore to enforce stricter type for address parameter.
src/lib/constants/links.ts Added new constants QACC and QACC_NEWS; modified non-production link logic.
src/lib/helpers.ts Updated ERC20 transfer handling to use usdtMainnetABI for USDT; improved type handling for decimals.
src/lib/transaction.ts Clarified transaction status handling in waitForTransaction; enforced stricter type checking for txHash in retryFetchEVMTransaction.
src/wagmiConfigs.ts Enhanced wagmiConfig to conditionally use Infura for mainnet; added import for mainnet.

Possibly related PRs

Suggested reviewers

  • CarlosQ96
  • MohammadPCh

🐰 In the land of code where rabbits play,
New keys for Q/acc brighten the day.
With links in the footer, so easy to find,
Our platform grows richer, with updates aligned.
Hopping along, we refine and enhance,
In the world of Giveth, we take our chance! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5c134c7 and 458041e.

⛔ Files ignored due to path filters (4)
  • public/assets/Giveth-Co-Marketing-Slides.pdf is excluded by !**/*.pdf
  • public/images/tokens/cbBTC.png is excluded by !**/*.png
  • public/images/tokens/cbBTC.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (25)
  • lang/ca.json (1 hunks)
  • lang/en.json (1 hunks)
  • lang/es.json (1 hunks)
  • next.config.js (1 hunks)
  • package.json (2 hunks)
  • src/artifacts/usdtMainnetABI.json (1 hunks)
  • src/components/Footer/Footer.tsx (2 hunks)
  • src/components/views/donate/OneTime/SelectTokenModal/SelectTokenModal.tsx (1 hunks)
  • src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx (2 hunks)
  • src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx (1 hunks)
  • src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx (1 hunks)
  • src/components/views/donate/Recurring/RecurringDonationCard.tsx (5 hunks)
  • src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx (2 hunks)
  • src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx (4 hunks)
  • src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx (5 hunks)
  • src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx (4 hunks)
  • src/components/views/givfarm/GIVfarmBottom.tsx (1 hunks)
  • src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx (6 hunks)
  • src/config/production.tsx (2 hunks)
  • src/hooks/useCreateEvmDonation.tsx (2 hunks)
  • src/hooks/usePassport.ts (1 hunks)
  • src/lib/constants/links.ts (1 hunks)
  • src/lib/helpers.ts (2 hunks)
  • src/lib/transaction.ts (1 hunks)
  • src/wagmiConfigs.ts (2 hunks)
🔇 Additional comments (32)
src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx (2)

32-32: Inconsistent token property access patterns

The code shows inconsistent patterns for accessing token properties:

  • decimals is accessed directly with fallback: token.decimals || 18
  • symbol still uses the underlying token with fallback: token.underlyingToken?.symbol || token.symbol

This inconsistency suggests that either:

  1. The symbol access should be simplified like decimals, or
  2. The decimals change might have missed considering the underlying token.

Let's verify the token structure usage across the codebase:

Also applies to: 34-34


47-47: Verify decimal precision in price calculation

The price calculation uses the same token decimals for formatting. Ensure this is correct, as some tokens (like USDT) might have different decimal places (6) compared to the standard 18.

Let's verify the price calculation decimal handling:

✅ Verification successful

Token decimals are properly handled across the codebase

The verification shows that the codebase correctly handles different token decimals:

  • USDC and similar tokens with 6 decimals are explicitly handled in multiple places:
    • src/components/views/donate/Recurring/RecurringDonationCard.tsx has specific handling for tokens with 6 decimals
    • src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx checks for 6 decimal tokens
  • The default fallback of 18 decimals is consistently used across the codebase when token.decimals is undefined
  • Price calculations in formatUnits() consistently use the token's actual decimals value
  • Token configurations in src/config/production.tsx properly define decimals for different tokens (USDC with 6 decimals, ETH with 18, etc.)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check price calculation decimal handling for different tokens
# Expected: Find evidence of proper decimal handling for various token types

# Search for price calculation patterns
echo "=== Price calculation patterns ==="
ast-grep --pattern 'formatUnits($_, token.decimals)'

# Search for token definitions to verify decimal values
echo "=== Token decimal definitions ==="
rg -A 2 "decimals.*[0-9]+"

Length of output: 15071

src/components/views/donate/Recurring/RecurringDonationCard.tsx (3)

180-181: LGTM: Correct scaling factor application

The scale factor is properly applied in the monthly stream calculation, ensuring accurate amounts for tokens with different decimal places.


145-148: Verify the UX impact of resetting amounts for 6 decimal tokens

The code resets both amount and perMonthAmount when a 6 decimal token is selected. While this is a safe approach, it might affect user experience if they switch between tokens.

✅ Verification successful

Resetting amounts for 6 decimal tokens is consistent with token conversion logic

The reset of amounts in RecurringDonationCard is correct and necessary as it's part of a broader token decimal normalization strategy:

  • The reset happens before applying a scaling factor of 10000n for 6 decimal tokens
  • Other components (RecurringDonationModal and DepositSuperToken) also handle 6 decimal tokens specially by converting them to 18 decimals
  • This ensures consistent handling of different token decimals throughout the donation flow
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find other instances where 6 decimal tokens are handled specially
rg -l "decimals === 6" 

Length of output: 253


Script:

#!/bin/bash
# Check how other components handle 6 decimal tokens
rg "decimals === 6" -A 5 -B 2

Length of output: 3580


163-164: Ensure consistent token ID case handling across the codebase

The token ID is converted to lowercase here. This is good practice, but we should verify that this is handled consistently everywhere to prevent case-sensitivity issues.

✅ Verification successful

Token ID case handling is consistently implemented across the codebase

The codebase shows a consistent pattern of converting token IDs to lowercase when used as keys or in comparisons. This is evident in:

  • Token price handling in services (src/services/token.ts)
  • Token streams mapping in RecurringDonationCard and SelectTokenModal
  • Token comparison operations in various components
  • Token price fetching and storage operations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all token ID comparisons in the codebase
ast-grep --pattern 'token.id $$$'

Length of output: 35


Script:

#!/bin/bash
# Search for token.id usage with ripgrep for better pattern matching
rg "token\.id" -t typescript -t javascript --no-heading -n

# Also search for tokenId pattern as it might be used alternatively
rg "tokenId" -t typescript -t javascript --no-heading -n

Length of output: 187


Script:

#!/bin/bash
# Search for token.id usage without file type restrictions
rg "token\.id" --no-heading -n

# Also search for tokenId pattern
rg "tokenId" --no-heading -n

# Search for toLowerCase() calls near token patterns
rg "token.*toLowerCase\(\)" -A 2 -B 2 --no-heading -n

Length of output: 20251

src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx (2)

14-14: LGTM! Type safety improvement

The addition of the superToken prop with explicit IToken type enhances type safety.


65-66: Verify token symbol consistency

The component now uses superToken.symbol consistently across multiple locations. However, let's verify that this token information is always available to prevent potential runtime errors.

Also applies to: 81-81

✅ Verification successful

Token symbol access is properly safeguarded

The superToken is a required prop in the StreamInfo component's interface (IStreamInfoProps), and the component is used in contexts where superToken is properly validated:

  • In WithDrawSuperToken and DepositSuperToken, there are explicit null checks with error throwing
  • The superToken is derived from configuration or found via helper functions before being passed to the component
  • The type system enforces the presence of the token information
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential undefined token symbol access
ast-grep --pattern 'superToken.symbol'

Length of output: 530


Script:

#!/bin/bash
# Let's check how superToken is defined and passed to these components
ast-grep --pattern 'const superToken = $_'

# Also check for type definitions
ast-grep --pattern 'type $_Props = {
  $$$
  superToken: $_
  $$$
}'

# And check for prop destructuring
ast-grep --pattern 'function $_({ $$$, superToken, $$$ }: $_)'

Length of output: 2145


Script:

#!/bin/bash
# Let's check the type definition of SUPER_FLUID_TOKENS and findSuperTokenByTokenAddress
ast-grep --pattern 'SUPER_FLUID_TOKENS: $_'

# Also check for null checks before accessing superToken.symbol
ast-grep --pattern 'if (!superToken) {
  $$$
}'

# And check the implementation of findSuperTokenByTokenAddress
ast-grep --pattern 'function findSuperTokenByTokenAddress($_) {
  $$$
}'

# Let's also see where StreamInfo component is defined
ast-grep --pattern 'function StreamInfo($_) {
  $$$
}'

Length of output: 857


Script:

#!/bin/bash
# Let's check how StreamInfo is used and how superToken is passed to it
rg "StreamInfo" -A 2

# And check the actual file content where superToken is used
cat src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx

Length of output: 9153

src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx (1)

131-133: LGTM! Improved token matching

The case-insensitive token ID comparison makes the matching more robust.

src/components/views/donate/OneTime/SelectTokenModal/SelectTokenModal.tsx (1)

151-157: LGTM! Improved search query handling

The introduction of sQuery and case-insensitive token filtering improves code readability and search functionality.

src/wagmiConfigs.ts (1)

44-51: LGTM! Security-conscious implementation of Infura transport

The implementation correctly uses an environment variable for the Infura API key and provides a fallback to the default transport when needed.

src/lib/transaction.ts (1)

60-60: LGTM! Enhanced type safety for transaction hash

The type assertion as \0x${string}`` ensures the transaction hash follows the correct hexadecimal format, preventing potential runtime errors.

package.json (1)

3-3: Verify compatibility of updated dependencies

The version updates for viem and wagmi are minor/patch versions, which should be backward compatible. However, let's verify there are no breaking changes that could affect the recent modifications to transaction handling.

Also applies to: 75-76

✅ Verification successful

Based on the changelog outputs, I can generate the final response since I have enough information to verify the dependency compatibility.

Dependencies are compatible with recent transaction handling changes

The version updates for viem (2.21.16 -> 2.21.19) and wagmi (2.12.16 -> 2.12.17) contain only patch changes with no breaking changes:

  • viem changes are focused on adding new chains, fixing minor issues, and updating dependencies
  • wagmi changes are primarily connector updates and dependency maintenance

The modifications are safe to proceed with as they maintain backward compatibility and don't affect transaction handling functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in the updated dependencies

# Check viem changelog between versions
gh api repos/wagmi-dev/viem/releases | jq -r '.[] | select(.tag_name | contains("2.21.")) | .body'

# Check wagmi changelog between versions
gh api repos/wagmi-dev/wagmi/releases | jq -r '.[] | select(.tag_name | contains("2.12.")) | .body'

Length of output: 32950

src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx (3)

22-28: Optimize token lookup with useMemo

Good addition of useMemo for superToken computation. This prevents unnecessary lookups on each render.


49-49: Improve token amount formatting and display

The changes improve token handling by:

  1. Using superToken symbol instead of raw token symbol
  2. Using formatDonation helper for consistent formatting across the app

Also applies to: 67-67, 71-72


119-123: Enhance modal rendering safety

Good addition of the superToken existence check before rendering ModifySuperTokenModal. This prevents potential runtime errors.

src/lib/constants/links.ts (1)

59-60: Verify QACC links accessibility

The QACC links have been added correctly to the constants. However, we should verify these endpoints are accessible and properly configured.

✅ Verification successful

QACC links are accessible and properly configured

Both endpoints return HTTP 200 status codes with proper headers, confirming they are accessible and correctly set up:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if QACC endpoints are accessible
curl -I https://qacc.giveth.io/
curl -I https://qacc.giveth.io/news

Length of output: 2718

src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx (2)

16-16: Type enhancement for better token support

Good improvement to support both ISuperToken and IToken types. This makes the component more flexible.


Line range hint 89-106: Verify token type handling

The useMemo logic for handling different token types looks good, but we should verify all code paths are properly tested.

Consider adding type guards or assertions to make the token type handling more explicit:

- props.selectedToken.isSuperToken
+ 'isSuperToken' in props.selectedToken
src/components/views/givfarm/GIVfarmBottom.tsx (1)

191-191: LGTM! Clean structural improvement.

The removal of the unnecessary Col wrapper simplifies the component structure without affecting functionality, as the PoolRow component already handles the grid layout.

next.config.js (1)

100-104: Verify the existence of the co-marketing PDF file.

The redirect rule is properly structured, but we should verify that the destination PDF file exists in the assets directory.

✅ Verification successful

PDF file exists at the expected location

The co-marketing PDF file is present at public/assets/Giveth-Co-Marketing-Slides.pdf, which matches the destination path specified in the redirect rule.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the PDF file exists in the assets directory
fd -t f "Giveth-Co-Marketing-Slides.pdf" public/assets/

Length of output: 100

src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx (2)

5-5: LGTM! Required import for token handling.

The ethers import is necessary for the new token decimal conversion functionality.


147-147: Verify the amount conversion for all token decimals.

The current implementation specifically handles 6-decimal tokens. We should verify this works correctly for all token decimals used in the system.

✅ Verification successful

Let me analyze the code further to understand how token decimals are handled.


Let me check one more aspect to understand the token decimal handling in the codebase.


Based on the analysis of the codebase, I can now provide the final response:

The amount conversion is properly handled for all token decimals

The implementation correctly handles tokens with different decimal places:

  • For 6-decimal tokens, there's specific conversion logic that properly scales the amount
  • For all other tokens, the system defaults to 18 decimals, which is standard for most ERC20 tokens
  • The conversion between different decimal places is handled consistently throughout the codebase using parseUnits with the correct decimal parameter
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all token definitions to verify their decimal places
echo "Searching for token decimal definitions..."
rg -A 5 "decimals.*=.*[0-9]+" 

Length of output: 6597


Script:

#!/bin/bash
# Let's check how the amount is handled in the ModifySuperToken component and related files
ast-grep --pattern 'parseUnits($$$)'

# Also check for any token decimal conversions
ast-grep --pattern 'decimals.*===.*6'

Length of output: 513


Script:

#!/bin/bash
# Let's check the token conversion logic in the component
ast-grep --pattern 'if ($token.decimals === 6) {
  $$$
}'

# Also check for any default decimal handling
rg "decimals.*\|\|.*18" -A 3

Length of output: 4960

src/components/Footer/Footer.tsx (1)

244-244: Consider maintaining consistent gap spacing

The gap property was changed from 72px to 0px. This might affect the visual spacing between link columns.

✅ Verification successful

Let me gather more context about the gap property usage in the Footer component and related files.


Gap property change appears intentional and consistent with responsive design

Looking at the context, the gap: 0 0px is part of a media query for laptopL breakpoint, while other sections of the Footer have different gap values (20px, 40px, 30px, 8px) for different screen sizes and elements. This suggests the zero gap is an intentional part of the responsive design pattern, not an inconsistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if this gap is consistent with other footer implementations
rg -A 2 'gap:\s*0\s+0px;' 

Length of output: 146


Script:

#!/bin/bash
# Check for all gap property usages in Footer.tsx and related files
rg -A 2 'gap:' src/components/Footer/

# Also check for any other Footer components or similar patterns
fd Footer src/components/ --exec rg -l 'gap:'

Length of output: 1112

src/hooks/useCreateEvmDonation.tsx (1)

21-21: LGTM: Type safety improvements

The changes improve type safety by:

  1. Expanding txHash state to handle Address type
  2. Ensuring type compatibility with useWaitForTransactionReceipt hook

Also applies to: 33-33

src/hooks/usePassport.ts (1)

238-240: LGTM: Type safety improvement

The change ensures type safety by explicitly casting the address parameter to the expected format required by scoreUserAddress function.

src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx (2)

231-251: Ensure consistent decimal handling for 6-decimal tokens

The conversion logic for 6-decimal tokens to 18 decimals is correct, but there are a few considerations:

Let's verify if there are other 6-decimal tokens that need this handling:

Consider extracting the decimal conversion logic into a utility function for reusability and better maintainability:

+const convertTo18Decimals = (amount: bigint, decimals: number): bigint => {
+  const divisor = BigInt(10 ** decimals);
+  const currentAmount = Number(amount) / Number(divisor);
+  return ethers.utils.parseUnits(currentAmount.toString(), 18).toBigInt();
+};

-if (selectedRecurringToken.token.decimals === 6) {
-  const divisor = BigInt(10 ** selectedRecurringToken.token.decimals);
-  const currentAmount = Number(amount) / Number(divisor);
-  newAmount = ethers.utils.parseUnits(currentAmount.toString(), 18).toBigInt();
-
-  const currentPerMonth = Number(perMonthAmount) / Number(divisor);
-  newPerMonthAmount = ethers.utils.parseUnits(currentPerMonth.toString(), 18).toBigInt();
+if (selectedRecurringToken.token.decimals === 6) {
+  newAmount = convertTo18Decimals(amount, selectedRecurringToken.token.decimals);
+  newPerMonthAmount = convertTo18Decimals(perMonthAmount, selectedRecurringToken.token.decimals);
}
✅ Verification successful

Decimal handling for 6-decimal tokens is consistently implemented

The search results confirm that the 6-decimal token handling is already consistently implemented across the codebase:

  • Token configurations in production.tsx define USDC tokens with 6 decimals
  • Similar decimal conversion logic is implemented in:
    • RecurringDonationCard.tsx
    • DepositSuperToken.tsx
    • RecurringDonationModal.tsx

The current implementation is correct and aligns with other parts of the codebase. While the refactoring suggestion for better maintainability is valid, it's not a critical concern as the conversion logic is consistently handled.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for token declarations with 6 decimals
ast-grep --pattern 'decimals = 6' 
rg -A 2 'decimals.*6'

Length of output: 1784


271-272: Verify flow rate calculations with converted amounts

The flow rate calculations are using the converted amounts correctly, but we should ensure the precision is maintained throughout the calculations.

Let's verify if there are any existing flow rate calculations that might need similar handling:

Also applies to: 305-307

✅ Verification successful

Flow rate calculations are correctly handling precision

The flow rate calculations in the RecurringDonationModal are correctly handling precision for both 6-decimal and 18-decimal tokens. The code first adjusts the newPerMonthAmount based on token decimals before calculating the flow rate, and then properly divides by the monthly seconds constant. The calculations maintain precision throughout by using BigInt operations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other flow rate calculations
rg -A 3 'flowRate.*=.*perMonthAmount'

Length of output: 39


Script:

#!/bin/bash
# Let's try a broader search for flow rate calculations
rg -i "flowrate|flow.*rate" -A 3

# Also search for specific variable name
rg "_flowRate" -A 3

Length of output: 66484


Script:

#!/bin/bash
# Let's search for flow rate calculation patterns specifically in the RecurringDonationModal
ast-grep --pattern 'let _flowRate = $$$'

Length of output: 522

src/config/production.tsx (2)

529-539: LGTM! New super token configuration for Bridged USDC

The configuration for the bridged USDC super token (USDC.e) follows the standard structure and naming conventions.


549-549: Verify the updated token contract addresses

Several token contract addresses have been updated:

  • Super USD Coin
  • Glo Dollar
  • Super Glo Dollar

Also applies to: 558-558, 564-564

✅ Verification successful

Let me gather more context about these token configurations to ensure there are no inconsistencies.


Based on the gathered information, I can now generate the final response:

Token contract addresses have been verified

The updated token addresses are consistently defined in the configuration with their correct corresponding names and symbols:

  • Super USD Coin (USDCx): 0x35adeb0638eb192755b6e52544650603fe65a006
  • Glo Dollar (USDGLO): 0x4f604735c1cf31399c6e711d5962b2b3e0225ad3
  • Super Glo Dollar (USDGLOx): 0x9f41d0aa24e599fd8d0c180ee3c0f609dc41c622

The tokens are properly integrated into the codebase's token handling system, with appropriate references in donation, balance checking, and token management functionalities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the token contracts are deployed and have the expected properties

# Check if the contracts exist and verify their properties
for address in "0x35adeb0638eb192755b6e52544650603fe65a006" "0x4f604735c1cf31399c6e711d5962b2b3e0225ad3" "0x9f41d0aa24e599fd8d0c180ee3c0f609dc41c622"; do
  echo "Checking contract at $address"
  # Look for contract creation transactions
  rg -A 2 "creation of.*$address"
  # Look for any references to these addresses in the codebase
  rg -A 2 "$address"
done

Length of output: 1776


Script:

#!/bin/bash
# Search for any previous/old token addresses that might have been replaced
rg -B 2 -A 2 "Super USD Coin|Glo Dollar|Super Glo Dollar" src/config/

# Look for any token-related configuration or validation logic
ast-grep --pattern 'const tokens = {
  $$$
}'

# Check for any token address validation or verification logic
rg -A 2 "validateToken|verifyToken|tokenAddress"

Length of output: 16067

lang/en.json (1)

100-101: LGTM! New localization entries for Q/acc

Added localization strings for Q/acc section titles. The entries follow the existing naming convention and structure.

lang/es.json (1)

727-728: LGTM! New localization keys added correctly

The new keys for Q/acc follow proper localization practices by:

  • Keeping brand names in English
  • Following the established key naming convention
  • Maintaining alphabetical ordering
lang/ca.json (1)

101-102: LGTM! The new translation keys are properly integrated.

The additions follow the established naming conventions and appropriately preserve the English terms "Q/acc" and "Q/acc News" as proper nouns.


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (11)
src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx (3)

Line range hint 83-84: Fix error message typo.

The error message "address not found1" appears to have an unintentional "1" suffix.

-				throw new Error('address not found1');
+				throw new Error('Address not found');

Line range hint 144-152: Align comment with implementation regarding buffer time.

The comment suggests a 40-second buffer, but the code implements a 60-second buffer. This inconsistency could lead to confusion in future maintenance.

Update the comment to match the implementation:

-	/// this one needs some thought - we should allow for a buffer of 40 seconds (or more) in the balance we show to the user
+	// We allow for a buffer of 60 seconds in the balance shown to the user

Line range hint 153-153: Remove debug console.log statement.

Debug logging should not be present in production code.

-	console.log('SuperTokenBalance', SuperTokenBalance);
src/components/views/donate/Recurring/RecurringDonationCard.tsx (2)

153-156: Document the scale factor calculation and extract the magic number

The scale factor calculation uses a magic number 10000n. This should be extracted as a named constant with documentation explaining its purpose and calculation.

+// The scale factor of 10000 is used to maintain precision when handling 6 decimal tokens
+const SCALE_FACTOR_6_DECIMALS = 10000n;
+
 const scaleFactor =
-  selectedRecurringToken?.token.decimals === 6 ? 10000n : 1n;
+  selectedRecurringToken?.token.decimals === 6 ? SCALE_FACTOR_6_DECIMALS : 1n;

783-785: Consider simplifying the token stream access

The token stream access can be simplified using optional chaining and nullish coalescing.

-tokenStreams[
-  selectedRecurringToken?.token.id.toLowerCase() || ''
-]
+tokenStreams[selectedRecurringToken?.token.id?.toLowerCase() ?? '']
src/wagmiConfigs.ts (1)

41-43: Consider creating a tracking issue for the TODO

The comment indicates this is a temporary hotfix. We should track this technical debt to ensure proper transport management for all chains is implemented.

Would you like me to create a GitHub issue to track this improvement task?

src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx (2)

129-143: Consider extracting token decimal conversion logic.

The token decimal conversion logic could be moved to a separate utility function for better reusability and maintainability. Also, consider adding validation for other decimal values.

+ // In src/lib/helpers/token.ts
+ export const normalizeTokenAmount = (amount: bigint, tokenDecimals: number): bigint => {
+   if (tokenDecimals === 6) {
+     const divisor = BigInt(10 ** tokenDecimals);
+     const currentAmount = Number(amount) / Number(divisor);
+     return ethers.utils.parseUnits(currentAmount.toString(), 18).toBigInt();
+   }
+   return amount;
+ }

- let newAmount = amount;
- if (token && token.decimals === 6) {
-   const divisor = BigInt(10 ** token.decimals);
-   const currentAmount = Number(amount) / Number(divisor);
-   newAmount = ethers.utils
-     .parseUnits(currentAmount.toString(), 18)
-     .toBigInt();
- }
+ const newAmount = token ? normalizeTokenAmount(amount, token.decimals) : amount;

144-145: Consider using structured logging.

Replace console.log with structured logging for better debugging capabilities.

- console.log('token', token);
- console.log('supertoken', superToken);
+ console.log('Upgrading token to superToken:', {
+   token,
+   superToken,
+   amount: newAmount.toString()
+ });
src/artifacts/usdtMainnetABI.json (1)

70-85: Review security implications of admin functions

The USDT ABI includes sensitive admin functions like addBlackList and destroyBlackFunds. While these are part of the official USDT contract, it's important to note their implications:

  • These functions can only be called by the contract owner
  • They represent centralized control capabilities of USDT

Consider adding comments in the code to document these administrative capabilities and their potential impact on transactions.

Also applies to: 538-553

src/lib/helpers.ts (1)

396-398: Ensure robust type handling for decimals

The conversion from bigint to number is correct but could be more explicit.

Consider adding a type guard:

-if (typeof decimals === 'bigint') {
+if (typeof decimals === 'bigint') {
+  if (decimals > BigInt(Number.MAX_SAFE_INTEGER)) {
+    throw new Error('Decimal value too large');
+  }
   decimals = Number(decimals.toString());
 }
src/config/production.tsx (1)

Line range hint 529-564: Consider the impact on existing streams and integrations

The changes to token IDs and addition of USDC.e could affect:

  1. Existing payment streams using these tokens
  2. Frontend components that reference these tokens
  3. Integration points with SuperFluid

Consider:

  • Adding a migration plan for existing streams
  • Updating frontend components to handle both old and new token IDs during transition
  • Testing SuperFluid integration with the new token configurations
🛑 Comments failed to post (5)
src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx (1)

190-190: ⚠️ Potential issue

Remove non-null assertion and add proper type safety.

The non-null assertion (!) on superToken could lead to runtime errors if the prop is undefined. Consider adding proper validation and error handling.

Here's a safer approach:

-token={superToken!}
+token={superToken ?? undefined}

Also, consider adding prop validation at the component level:

if (!superToken) {
  return (
    <Wrapper>
      <div>Error: SuperToken is required for withdrawal</div>
    </Wrapper>
  );
}
src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx (2)

197-208: 🛠️ Refactor suggestion

Add null checks for nested token properties

The deep nested access of token properties could lead to runtime errors if any intermediate value is undefined.

Add null checks or use optional chaining:

- balances[token.underlyingToken.symbol]
+ balances[token.underlyingToken?.symbol ?? '']
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

										balance={
											balances[
												token.underlyingToken?.symbol ?? ''
											]
										}
										disable={
											balances[
												token.underlyingToken?.symbol ?? ''
											] === undefined ||
											balances[
												token.underlyingToken?.symbol ?? ''
											] === 0n

193-222: ⚠️ Potential issue

Remove unnecessary Fragment and add key to mapped elements

The Fragment (<>) is unnecessary here and the key prop should be moved to the outer element of the map.

Apply this fix:

- underlyingTokens.map(token => (
-   <>
-     <TokenInfo
-       key={token.underlyingToken?.symbol}
-       token={token.underlyingToken}
-       ...
-     />
-   </>
- ))
+ underlyingTokens.map(token => (
+   <TokenInfo
+     key={token.underlyingToken?.symbol}
+     token={token.underlyingToken}
+     ...
+   />
+ ))

Committable suggestion skipped: line range outside the PR's diff.

src/components/Footer/Footer.tsx (1)

146-159: ⚠️ Potential issue

Add security attributes and accessibility improvements to external links

The new QACC links open in new tabs but are missing security attributes and accessibility improvements.

Apply these changes:

-						<a href={links.QACC} target='_blank'>
+						<a href={links.QACC} target='_blank' rel='noreferrer noopener' aria-label='QACC (opens in new tab)'>
 							<LinkItem color={textColor}>
 								{formatMessage({
 									id: 'component.title.qacc',
 								})}
 							</LinkItem>
 						</a>
-						<a href={links.QACC_NEWS} target='_blank'>
+						<a href={links.QACC_NEWS} target='_blank' rel='noreferrer noopener' aria-label='QACC News (opens in new tab)'>
 							<LinkItem color={textColor}>
 								{formatMessage({
 									id: 'component.title.qacc_news',
 								})}
 							</LinkItem>
 						</a>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

						<a href={links.QACC} target='_blank' rel='noreferrer noopener' aria-label='QACC (opens in new tab)'>
							<LinkItem color={textColor}>
								{formatMessage({
									id: 'component.title.qacc',
								})}
							</LinkItem>
						</a>
						<a href={links.QACC_NEWS} target='_blank' rel='noreferrer noopener' aria-label='QACC News (opens in new tab)'>
							<LinkItem color={textColor}>
								{formatMessage({
									id: 'component.title.qacc_news',
								})}
							</LinkItem>
						</a>
src/lib/helpers.ts (1)

379-385: 🛠️ Refactor suggestion

Consider network-agnostic USDT handling

The USDT contract address is hardcoded for mainnet. This might cause issues when dealing with other networks.

Consider making the USDT address configurable per network:

+const USDT_ADDRESSES = {
+  1: '0xdac17f958d2ee523a2206206994597c13d831ec7', // mainnet
+  10: '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58', // optimism
+  // Add other network addresses
+};

-contractAddress === '0xdac17f958d2ee523a2206206994597c13d831ec7'
+USDT_ADDRESSES[chainId] === contractAddress

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

@mohammadranjbarz mohammadranjbarz left a comment

Choose a reason for hiding this comment

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

Thanks @kkatusic LGTM

@kkatusic kkatusic merged commit d2fe5e6 into main Dec 5, 2024
3 checks passed
@kkatusic kkatusic deleted the add_comarketing branch December 5, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: QA
Development

Successfully merging this pull request may close these issues.

2 participants