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

V2.34 release #4888

Merged
merged 135 commits into from
Dec 4, 2024
Merged

V2.34 release #4888

merged 135 commits into from
Dec 4, 2024

Conversation

kkatusic
Copy link
Collaborator

@kkatusic kkatusic commented Dec 4, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Q/acc and Q/acc News in multiple language translations (Catalan, English, Spanish).
    • Introduced a new smart contract ABI for USDT on the Ethereum blockchain.
    • Enhanced token selection functionality to include underlying tokens.
  • Bug Fixes

    • Improved error handling and messaging in various donation-related components.
    • Streamlined token amount calculations to accommodate different decimal configurations.
  • Documentation

    • Updated links for QACC and QACC News in the application.
  • Chores

    • Updated dependency versions in the project configuration.

Copy link

vercel bot commented Dec 4, 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 4, 2024 10:01am

@kkatusic kkatusic changed the base branch from develop to main December 4, 2024 09:52
Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

This pull request introduces updates to localization files for Catalan, English, and Spanish, adding new entries for "Q/acc" and "Q/acc News." Additionally, it includes a new JSON file defining the ABI for a USDT smart contract. Other changes involve modifications to various components and hooks, enhancing functionality related to token handling, error management, and user interface elements. Notably, the package.json file reflects updates to dependency versions, and several components have been adjusted to improve their logic and maintainability.

Changes

File Path Change Summary
lang/ca.json Added new entries: "component.title.qacc": "Q/acc" and "component.title.qacc_news": "Q/acc News".
lang/en.json Added new entries: "component.title.qacc": "Q/acc" and "component.title.qacc_news": "Q/acc News". Updated existing strings for consistency and clarity.
lang/es.json Added new entries: "component.title.qacc": "Q/acc" and "component.title.qacc_news": "Q/acc News".
package.json Updated dependency versions: "viem": "^2.21.16" to "viem": "^2.21.19" and "wagmi": "^2.12.16" to "wagmi": "^2.12.17".
src/artifacts/usdtMainnetABI.json Introduced a new JSON file defining the ABI for the USDT smart contract, including view and non-payable functions and events.
src/components/Footer/Footer.tsx Added links to QACC and QACC News in the footer. Updated gap property in LeftContainer styled component.
src/components/views/donate/OneTime/SelectTokenModal/SelectTokenModal.tsx Declared new variable sQuery for filtering tokens. Maintained existing error handling.
src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx Updated onDeposit function to handle token amounts with 6 decimals using ethers.
src/components/views/donate/Recurring/ModifySuperToken/ModifySuperTokenModal.tsx Changed selectedToken type from IToken to `ISuperToken
src/components/views/donate/Recurring/WithDrawSuperToken.tsx Adjusted token prop to superToken in Item component. Enhanced error handling for missing address.
src/components/views/donate/Recurring/RecurringDonationCard.tsx Added import for formatDonation. Adjusted token amount calculations based on decimal precision.
src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx Simplified logic for accessing token properties in formatUnits.
src/components/views/donate/Recurring/RecurringDonationModal/RecurringDonationModal.tsx Enhanced token amount handling in onDonate function for tokens with 6 decimals.
src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx Introduced underlyingTokens state variable. Updated filtering logic to check underlying token balances.
src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx Added superToken prop to IStreamInfoProps interface for displaying token information.
src/components/views/givfarm/GIVfarmBottom.tsx Removed StakeTogetherCard from PoolRow rendering logic.
src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx Added dependency on formatDonation and optimized retrieval of superToken using useMemo.
src/config/production.tsx Added new super token configuration for "Bridged USD Coin" and updated existing entries for "USD Coin" and "Glo Dollar."
src/hooks/useCreateEvmDonation.tsx Updated txHash state variable type for broader transaction hash formats. Enhanced error handling in handleError function.
src/hooks/usePassport.ts Modified fetchUserMBDScore to enforce stricter type assertion on address variable.
src/lib/constants/links.ts Added new constants QACC and QACC_NEWS for URLs related to the QACC platform.
src/lib/helpers.ts Added import for usdtMainnetABI and updated logic for selecting the ABI for ERC20 transfers.
src/lib/transaction.ts Enhanced error handling in waitForTransaction and updated retryFetchEVMTransaction for improved type safety.
src/wagmiConfigs.ts Modified client method in wagmiConfig for better HTTP transport handling based on the blockchain chain.

Possibly related PRs

  • Main #4340: Updates the Catalan, English, and Spanish language files, including changes to the same keys modified in this PR.
  • Fix recurring donations #4876: Adds the same new entries for "component.title.qacc" and "component.title.qacc_news" in the language files, directly relating to this PR.
  • Fixing text translation for vouched users #4882: Modifications to the Catalan language file that may indirectly relate to the overall localization efforts in this PR.

Suggested labels

Code Review

Suggested reviewers

  • MohammadPCh
  • mateodaza
  • CarlosQ96

🐰 In the land of code so bright,
New links and tokens take flight.
With QACC news, we hop along,
Enhancing features, making us strong!
In JSON files, translations bloom,
A brighter app, dispelling gloom! 🌼


📜 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 d6e2757.

⛔ Files ignored due to path filters (3)
  • 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 (24)
  • lang/ca.json (1 hunks)
  • lang/en.json (1 hunks)
  • lang/es.json (1 hunks)
  • package.json (1 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)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (23)
src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx (3)

11-11: LGTM: Import addition is well-justified

The addition of formatDonation import aligns with its usage in the component for consistent donation amount formatting.


119-126: LGTM: Improved modal rendering safety

The additional null check for superToken and consistent usage of the memoized value improves the component's reliability.


67-75: Verify token decimals assumption

The code assumes 18 decimals for formatting the monthly flow rate. This might not work correctly for all tokens.

Let's verify the decimals of configured tokens:

Consider using the token's actual decimals:

-   limitFraction(formatUnits(BigInt(monthlyFlowRate), 18)),
+   limitFraction(formatUnits(BigInt(monthlyFlowRate), superToken?.decimals || 18)),
src/components/views/donate/Recurring/RecurringDonationCard.tsx (1)

145-148: Clarify Resetting Amounts for Tokens with 6 Decimals

When the selected token has 6 decimals, both amount and perMonthAmount are reset to 0n. This could lead to unexpected behavior for users attempting to donate with these tokens.

Please verify if this logic is intentional. If it is, consider adding a comment to explain the reasoning behind resetting the amounts to zero to improve code readability.

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

32-34: Ensure token.decimals is Always Defined

The code now uses token.decimals directly without optional chaining. This assumes that token.decimals is always defined, which may not be the case if token lacks the decimals property.

Please verify that token.decimals is always defined for all tokens. If not, consider providing a default value or adding necessary checks to prevent potential undefined errors.


47-47: Handle Price Calculation with Token Decimals

When calculating the USD value, ensure that the correct decimals are used for precision.

Double-check that token.decimals provides the correct decimal precision needed for the price calculation. This is important for accurate display of the USD equivalent value.

src/lib/transaction.ts (1)

60-60: Type Casting of txHash May Mask Errors

Casting txHash as `0x${string}` could potentially mask errors if txHash is not in the correct format.

Ensure that txHash is validated and conforms to the expected hexadecimal format before casting. This prevents runtime errors and improves type safety.

Optionally, consider adding validation logic:

if (!/^0x[0-9a-fA-F]{64}$/.test(txHash)) {
  throw new Error('Invalid transaction hash format');
}
src/components/views/donate/Recurring/SelectTokenModal/StreamInfo.tsx (1)

65-66: Use Consistent Token Information

The display of the token symbol and name now uses superToken.symbol and superToken.name. Ensure that superToken accurately represents the token associated with the streams.

Verify that superToken corresponds to the tokens in the stream array. If there are streams with different tokens, this could lead to inconsistent or incorrect information being displayed.

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

59-60: LGTM! New QACC links added correctly.

The new constants follow the established pattern and maintain consistent formatting with the rest of the file.

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

16-16: LGTM! Type enhancement improves flexibility.

The union type ISuperToken | IToken allows for better type safety while handling both super tokens and regular tokens.

src/components/views/givfarm/GIVfarmBottom.tsx (2)

191-191: LGTM! StakeTogetherCard removal is consistent with PR objectives.

The change simplifies the PoolRow rendering while maintaining the existing pool filtering logic.


Line range hint 124-143: Consider adding error handling for undefined chainId.

The renderPools function should handle the case when chainId is undefined more explicitly.

Consider adding explicit error handling:

 const renderPools = (chainId?: number, showArchivedPools?: boolean) => {
+  if (chainId === undefined) {
+    console.warn('Chain ID is undefined, falling back to default pools');
+  }
   const pools = getPoolsInfoByChainID(chainId);
   // ... rest of the function
 };
src/components/views/donate/Recurring/ModifySuperToken/WithDrawSuperToken.tsx (1)

190-190: Verify Item component's token prop type compatibility

The prop change from token to superToken needs verification to ensure the Item component correctly handles the ISuperToken type.

✅ Verification successful

Prop change is compatible with Item component's expectations

The change from token={token!} to token={superToken!} is correct since both variables are of type IToken. The Item component's interface shows it expects a required token prop of type IToken, which matches the type of both token and superToken variables.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Item component's prop type definition
ast-grep --pattern 'interface $Props {
  $$$
  token: $Type
  $$$
}'

Length of output: 70


Script:

#!/bin/bash
# Let's try a different approach to find the Item component and its props
# First, let's find files containing "Item" component
fd "Item" --type f --exec rg -l "export.*Item"

# Then, let's look for token prop usage in these files
rg "token.*:" -A 5 -B 5

Length of output: 67859


Script:

#!/bin/bash
# Let's look for the Item component specifically in the file containing the WithDrawSuperToken component
rg -l "WithDrawSuperToken" --type ts --type tsx

# Then let's examine the Item component's usage and definition in the same directory
fd "Item" --type f --exec rg "interface.*Props|token.*:" -C 5 src/components/views/donate/Recurring/ModifySuperToken/

Length of output: 70970


Script:

#!/bin/bash
# Let's check the Item component definition in the RecurringDonationModal directory
rg -A 10 "interface IItemProps" src/components/views/donate/Recurring/RecurringDonationModal/Item.tsx

Length of output: 270

src/hooks/useCreateEvmDonation.tsx (1)

21-21: LGTM: Type safety improvements

The changes enhance type safety by:

  1. Broadening txHash state to handle both transaction hashes and addresses
  2. Adding necessary type assertion for useWaitForTransactionReceipt

Also applies to: 33-33

src/hooks/usePassport.ts (1)

238-240: LGTM: Type assertion ensures correct address format.

The type assertion address as '0x${string}' ensures that the address parameter follows the required hexadecimal format for Ethereum addresses.

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

231-252: LGTM: Proper handling of 6 decimal tokens.

The code correctly handles tokens with 6 decimals (like USDT) by converting amounts to 18 decimals for compatibility with the system. The conversion uses ethers.utils.parseUnits which ensures precise decimal arithmetic.


271-272: LGTM: Flow rate calculations updated for decimal compatibility.

The flow rate calculations now use the converted amounts (newPerMonthAmount) for tokens with 6 decimals, maintaining consistency throughout the donation process.

Also applies to: 305-307

src/artifacts/usdtMainnetABI.json (1)

1-731: LGTM: Complete and accurate USDT mainnet ABI.

The ABI correctly defines all necessary functions and events for interacting with the USDT mainnet contract, including:

  • Standard ERC20 functions
  • USDT-specific functions (pause, blacklist)
  • All required events with proper parameter indexing

Verify the ABI source and version.

Ensure this ABI matches the official USDT mainnet contract to prevent potential security issues.

✅ Verification successful

USDT ABI verification successful - ABI matches official USDT contract

The ABI is being used correctly in the codebase for USDT token transfers, specifically for the mainnet USDT contract address (0xdac17f958d2ee523a2206206994597c13d831ec7). The implementation includes:

  • All standard ERC20 functions (transfer, approve, balanceOf, etc.)
  • USDT-specific functions (pause, blacklist management, etc.)
  • Proper handling of USDT's unique decimals implementation
  • Correct event definitions for all operations

The code in helpers.ts shows a thoughtful implementation that specifically handles USDT's unique requirements by using this custom ABI when interacting with the USDT mainnet contract address.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the ABI matches the official USDT contract on Etherscan
# Note: Using gh api to avoid rate limits

# Get verified contract ABI from Etherscan via GitHub API
gh api graphql -f query='
{
  repository(owner: "tether", name: "contracts") {
    object(expression: "master") {
      ... on Commit {
        tree {
          entries {
            name
            object {
              ... on Blob {
                text
              }
            }
          }
        }
      }
    }
  }
}'

Length of output: 602


Script:

#!/bin/bash
# Let's try to find any references or imports of this ABI in the codebase
# to understand its usage and verify its source

# Search for references to this ABI file
rg -l "usdtMainnetABI" --type ts --type js

# Search for any USDT contract addresses that might help verify the source
rg -i "usdt.*contract.*address|tether.*contract.*address" --type ts --type js

# Look for any documentation or comments about USDT integration
rg -l "USDT|Tether" README.md docs/ 2>/dev/null

Length of output: 179


Script:

#!/bin/bash
# Let's check the usage context in helpers.ts to understand how this ABI is used
cat src/lib/helpers.ts

# Also let's verify the ABI structure matches standard USDT interface
# by checking for required ERC20 methods and USDT-specific methods
jq '[.[] | select(.type=="function") | .name] | sort' src/artifacts/usdtMainnetABI.json

Length of output: 19637

src/lib/helpers.ts (3)

22-22: LGTM: Import of USDT mainnet ABI

The import is correctly added to handle USDT mainnet contract interactions.


379-385: Good documentation of the USDT mainnet ABI workaround

The comments clearly explain why a custom ABI is needed for USDT on mainnet. The conditional selection of ABI based on the contract address is a good solution.


389-389: Proper handling of decimals from bigint

The code correctly handles the case where decimals is returned as a bigint by converting it to a number.

Also applies to: 391-398

src/config/production.tsx (1)

529-539: LGTM: Token configurations are complete and consistent

The token configurations are well structured with all necessary fields:

  • New USDC.e token is properly configured
  • Existing token configurations are updated correctly
  • All required fields (id, name, symbol, decimals, coingeckoId) are present

Also applies to: 541-554, 558-568

lang/en.json (1)

100-101: LGTM: New translations added for Q/acc

The new translations for "Q/acc" and "Q/acc News" are properly added to the English language file.


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: 7

🧹 Outside diff range and nitpick comments (14)
src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx (2)

49-49: Remove commented out code

The commented line // const { symbol } = tokenStream[0].token; should be removed as it's no longer needed.


Line range hint 1-143: Consider component decomposition for better maintainability

The StreamRow component handles multiple responsibilities including:

  • Token balance display
  • Flow rate calculations
  • Chain switching
  • Modal management

Consider breaking these into smaller, focused components for better maintainability and testing.

src/wagmiConfigs.ts (1)

41-51: Refactor HTTP Transport Configuration for Multiple Chains

The current implementation handles custom HTTP transport only for the mainnet chain using Infura. This hard-coded approach limits scalability and may lead to inconsistent behavior across different chains.

Consider refactoring the transport logic to dynamically configure HTTP transports for all chains. You could map each chain ID to its respective RPC endpoint, possibly using a configuration object. This will enhance maintainability and make it easier to add support for additional chains in the future.

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

153-156: Avoid Hardcoded Scaling Factors

Using a hardcoded scaleFactor of 10000n for tokens with 6 decimals may reduce flexibility and clarity.

Consider calculating the scaleFactor based on the token's decimals to accommodate tokens with varying decimal places. For example:

- const scaleFactor =
-   selectedRecurringToken?.token.decimals === 6 ? 10000n : 1n;
+ const scaleFactor = 10n ** BigInt(18 - selectedRecurringToken.token.decimals);

This approach dynamically adjusts the scaleFactor based on the token's decimals, enhancing maintainability.


163-164: Ensure Consistent Casing of Token IDs

Converting token IDs to lowercase when accessing tokenStreams suggests inconsistent casing in token IDs, which could lead to potential bugs.

Ensure that token IDs are stored and compared in a consistent case throughout the application. It might be better to normalize token IDs to lowercase when they are first stored or to enforce a consistent casing convention.

Also applies to: 783-785


573-581: Refactor Nested Function Calls for Readability

The deeply nested function calls used to format the donation amount can impact code readability and maintainability.

Consider breaking down the nested calls into intermediate variables:

const totalAmount = totalStreamPerSec * ONE_MONTH_SECONDS;
const formattedUnits = formatUnits(
  totalAmount,
  selectedRecurringToken?.token.decimals || 18,
);
const limitedFraction = limitFraction(formattedUnits);
const donationAmount = formatDonation(limitedFraction);

This refactoring enhances clarity and makes the code easier to understand.

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

81-81: Display Correct Token Symbol

Ensure that the token symbol displayed alongside the balance is correct.

Confirm that superToken.symbol accurately represents the token's symbol in this context. If the underlying token's symbol should be displayed instead, adjust the code accordingly.

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

Line range hint 93-108: Consider refactoring for better readability.

The nested ternary with optional chaining could be simplified for better maintainability.

Consider this more readable approach:

-const [token, superToken] = useMemo(
-   () =>
-     props.selectedToken.isSuperToken
-       ? [
-           props.selectedToken.underlyingToken ||
-             config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS.find(
-               token => token.id === props.selectedToken.id,
-             )?.underlyingToken,
-           props.selectedToken as ISuperToken,
-         ]
-       : [
-           props.selectedToken,
-           findSuperTokenByTokenAddress(props.selectedToken.id),
-         ],
-   [props.selectedToken],
-);
+const [token, superToken] = useMemo(() => {
+  if (props.selectedToken.isSuperToken) {
+    const selectedSuperToken = props.selectedToken as ISuperToken;
+    const underlyingToken = selectedSuperToken.underlyingToken || 
+      config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS.find(
+        token => token.id === selectedSuperToken.id
+      )?.underlyingToken;
+    return [underlyingToken, selectedSuperToken];
+  }
+  return [
+    props.selectedToken,
+    findSuperTokenByTokenAddress(props.selectedToken.id),
+  ];
+}, [props.selectedToken]);
src/components/views/givfarm/GIVfarmBottom.tsx (1)

Line range hint 37-115: Consider refactoring pool configuration logic for better maintainability.

The current implementation has duplicated code across chain ID cases and complex spreading of configurations.

Consider extracting common pool configurations and using a more maintainable approach:

+const BASE_POOLS = [
+  ...(config.GNOSIS_CONFIG.pools || []),
+  ...(config.GNOSIS_CONFIG.regenPools || []),
+  ...(config.MAINNET_CONFIG.pools || []),
+  ...(config.MAINNET_CONFIG.regenPools || []),
+];
+
+const ALL_GIVPOWER = [
+  ...(config.ZKEVM_CONFIG.GIVPOWER ? [config.ZKEVM_CONFIG.GIVPOWER] : []),
+  ...(config.GNOSIS_CONFIG.GIVPOWER ? [config.GNOSIS_CONFIG.GIVPOWER] : []),
+  ...(config.OPTIMISM_CONFIG.GIVPOWER ? [config.OPTIMISM_CONFIG.GIVPOWER] : []),
+];
+
 const getPoolsInfoByChainID = (
   chainId?: number,
 ): Array<SimplePoolStakingConfig | BalancerPoolStakingConfig | ICHIPoolStakingConfig> => {
-  switch (chainId) {
-    case config.GNOSIS_NETWORK_NUMBER:
-      return [/* ... */];
-    case config.OPTIMISM_NETWORK_NUMBER:
-      return [/* ... */];
-    case config.ZKEVM_NETWORK_NUMBER:
-      return [/* ... */];
-    default:
-      return [/* ... */];
-  }
+  return [...ALL_GIVPOWER, ...BASE_POOLS];
 };
src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx (1)

131-133: Consider using a dedicated utility for case-insensitive comparison

While the case-insensitive comparison is good for consistency, consider extracting it into a utility function for reuse.

+const compareTokenIds = (id1: string, id2: string) => id1.toLowerCase() === id2.toLowerCase();
+
 const token = superTokens.find(
-  token =>
-    token.id.toLowerCase() === tokenId.toLowerCase(),
+  token => compareTokenIds(token.id, tokenId),
 ) as IToken;
src/components/Footer/Footer.tsx (1)

244-244: Consider maintaining consistent spacing

The gap property was changed from 72px to 0px which might affect the visual hierarchy and spacing consistency.

Consider if this change aligns with the design system's spacing guidelines.

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

151-157: Remove redundant variable declaration

The introduction of sQuery is unnecessary as searchQuery could be used directly in the filter conditions.

Apply this diff to simplify the code:

-				const sQuery: string = searchQuery;
 				const filtered = tokens.filter(
 					token =>
 						token.symbol
 							.toLowerCase()
-							.includes(sQuery.toLowerCase()) ||
-						token.name.toLowerCase().includes(sQuery.toLowerCase()),
+							.includes(searchQuery.toLowerCase()) ||
+						token.name.toLowerCase().includes(searchQuery.toLowerCase()),
 				);
lang/es.json (1)

727-728: Consider translating the new entries

The additions match the changes mentioned in the summary. However, consider whether "Q/acc" and "Q/acc News" should be translated to Spanish for consistency with the rest of the localization file, unless they are proper nouns or brand names that should remain in English.

-	"component.title.qacc": "Q/acc",
-	"component.title.qacc_news": "Q/acc News",
+	"component.title.qacc": "Q/acc",
+	"component.title.qacc_news": "Noticias Q/acc",
lang/ca.json (1)

101-102: The new entries need to be translated to Catalan

The new entries "Q/acc" and "Q/acc News" are currently in English. Consider translating them to Catalan to maintain consistency with the rest of the localization file.

-	"component.title.qacc": "Q/acc",
-	"component.title.qacc_news": "Q/acc News",
+	"component.title.qacc": "Q/acc",
+	"component.title.qacc_news": "Notícies Q/acc",
🛑 Comments failed to post (7)
src/components/views/userProfile/donationsTab/recurringTab/StreamRow.tsx (1)

22-28: ⚠️ Potential issue

Add null check for tokenStream access

The current implementation assumes tokenStream[0] exists, which could lead to runtime errors if tokenStream is empty.

Consider adding a null check:

 const superToken = useMemo(
   () =>
+    tokenStream[0]?.token?.id ?
     config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS.find(
       s => s.id === tokenStream[0].token.id,
-    ),
+    ) : undefined,
   [tokenStream],
 );
📝 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.

const superToken = useMemo(
    () =>
        tokenStream[0]?.token?.id ?
        config.OPTIMISM_CONFIG.SUPER_FLUID_TOKENS.find(
            s => s.id === tokenStream[0].token.id,
        ) : undefined,
    [tokenStream],
);
src/wagmiConfigs.ts (1)

44-44: ⚠️ Potential issue

Potential Exposure of Infura API Key

The usage of NEXT_PUBLIC_INFURA_API_KEY exposes the Infura API key to the client-side, as environment variables prefixed with NEXT_PUBLIC_ are accessible in the browser. This could lead to unauthorized usage of your Infura account.

Apply this diff to secure the API key:

- const infuraKey = process.env.NEXT_PUBLIC_INFURA_API_KEY;
+ const infuraKey = process.env.INFURA_API_KEY;

Ensure that INFURA_API_KEY is defined in your server-side environment variables and not exposed to the client.

📝 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.

		const infuraKey = process.env.INFURA_API_KEY;
src/components/views/donate/Recurring/ModifySuperToken/DepositSuperToken.tsx (2)

144-145: ⚠️ Potential issue

Remove sensitive logging statements

Console logging of token details could expose sensitive information in production.

Remove these debug logs:

-console.log('token', token);
-console.log('supertoken', superToken);

137-143: ⚠️ Potential issue

Review decimal conversion logic for potential precision loss

The conversion of token amounts with 6 decimals involves division operations that could lead to precision loss. Consider using a more precise conversion method.

Consider this safer approach:

-const currentAmount = Number(amount) / Number(divisor);
-newAmount = ethers.utils
-    .parseUnits(currentAmount.toString(), 18)
-    .toBigInt();
+newAmount = (amount * BigInt(10 ** 12));
📝 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.

			if (token && token.decimals === 6) {
				const divisor = BigInt(10 ** token.decimals);
				newAmount = (amount * BigInt(10 ** 12));
			}
src/components/views/donate/Recurring/SelectTokenModal/SelectTokenModal.tsx (2)

88-90: ⚠️ Potential issue

Review token filtering logic

The current filtering condition might be counterintuitive. It includes tokens with zero balance and excludes tokens with positive balance.

Consider inverting the condition for clarity:

-return !(newBalances[token.underlyingToken.symbol] > 0n);
+return newBalances[token.underlyingToken.symbol] <= 0n;
📝 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.

			const filteredTokens = superTokens.filter(token => {
				return newBalances[token.underlyingToken.symbol] <= 0n;
			});

191-222: 🛠️ Refactor suggestion

Add key prop to mapped Fragment and simplify nested structure

The current implementation has two issues:

  1. Missing key prop in the mapped Fragment
  2. Deeply nested ternary operators affecting readability

Consider this refactoring:

-{underlyingTokens.length > 0 ? (
-  underlyingTokens.map(token => (
-    <>
+{underlyingTokens.length > 0 ? (
+  underlyingTokens.map(token => (
+    <Fragment key={token.underlyingToken?.symbol}>
       <TokenInfo
-        key={token.underlyingToken?.symbol}
         token={token.underlyingToken}
         balance={balances[token.underlyingToken.symbol]}
         disable={
           balances[token.underlyingToken.symbol] === undefined ||
           balances[token.underlyingToken.symbol] === 0n
         }
         onClick={() => {
           setSelectedRecurringToken({
             token: token.underlyingToken,
             balance: balances[token.underlyingToken.symbol],
           });
           setShowModal(false);
         }}
       />
-    </>
+    </Fragment>
   ))
 ) : (
   <Caption>
     {formatMessage({
       id: 'label.you_have_super_token_for_all_tokens',
     })}
   </Caption>
 )}
📝 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.

						{underlyingTokens.length > 0 ? (
							underlyingTokens.map(token => (
								<Fragment key={token.underlyingToken?.symbol}>
									<TokenInfo
										token={token.underlyingToken}
										balance={
											balances[
												token.underlyingToken.symbol
											]
										}
										disable={
											balances[
												token.underlyingToken.symbol
											] === undefined ||
											balances[
												token.underlyingToken.symbol
											] === 0n
										}
										onClick={() => {
											setSelectedRecurringToken({
												token: token.underlyingToken,
												balance:
													balances[
														token.underlyingToken
															.symbol
													],
											});
											setShowModal(false);
										}}
									/>
								</Fragment>
							))
						) : (
							<Caption>
								{formatMessage({
									id: 'label.you_have_super_token_for_all_tokens',
								})}
							</Caption>
						)}
src/components/Footer/Footer.tsx (1)

145-160: ⚠️ Potential issue

Add security attributes and accessibility improvements to external links

The new links are missing security attributes and accessibility indicators.

Apply this diff to enhance security and accessibility:

-						<a href={links.QACC} target='_blank'>
+						<a href={links.QACC} target='_blank' rel="noreferrer noopener" aria-label="Q/acc (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="Q/acc 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.

					<LinkColumn>
						<a href={links.QACC} target='_blank' rel="noreferrer noopener" aria-label="Q/acc (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="Q/acc News (opens in new tab)">
							<LinkItem color={textColor}>
								{formatMessage({
									id: 'component.title.qacc_news',
								})}
							</LinkItem>
						</a>
					</LinkColumn>

Copy link
Member

@mateodaza mateodaza left a comment

Choose a reason for hiding this comment

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

BIG ONE, but looks good to me :)

Copy link
Collaborator

@RamRamez RamRamez left a comment

Choose a reason for hiding this comment

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

LGTM!

@RamRamez RamRamez merged commit 2bd4228 into main Dec 4, 2024
3 checks passed
@RamRamez RamRamez deleted the v2.34_release branch December 4, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants