-
-
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
merge main to develop #4856
base: develop
Are you sure you want to change the base?
merge main to develop #4856
Conversation
Fix/usdt donation on mainnet
HOTFIX: Updating wagmi and viem
HOTFIX: Update SelectTokenModal type issue
HOTFIX Moving from public to private RPC for mainnet viem client
removed stake together
added footer links to qacc
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Disable USDC on recurring donation
WalkthroughThis pull request introduces new localization entries for the Q/acc feature across multiple language files ( Changes
Possibly related PRs
Suggested reviewers
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: 3
🧹 Outside diff range and nitpick comments (20)
src/wagmiConfigs.ts (1)
41-43
: Address TODO: Implement proper transport managementThe comment indicates this is a temporary solution. Consider implementing a more robust transport management system that:
- Handles all chains consistently
- Provides fallback mechanisms
- Implements proper error handling
Would you like assistance in designing a more comprehensive transport management solution?
src/lib/transaction.ts (1)
60-60
: Type assertion looks good, consider adding runtime validationThe explicit type assertion to
0x${string}
improves type safety for thegetTransaction
call. However, since type assertions bypass TypeScript's type checking at runtime, consider adding a validation helper.Consider adding a validation helper to ensure the hash format at runtime:
const isValidEthereumHash = (hash: string): hash is `0x${string}` => { return /^0x[0-9a-fA-F]{64}$/.test(hash); }; // Usage in the function: if (!isValidEthereumHash(txHash)) { throw new Error('Invalid Ethereum transaction hash format'); } hash: txHash, // No type assertion needed if validation passessrc/lib/constants/links.ts (1)
59-60
: Consider environment-based URL configuration.While the current implementation works, consider moving service URLs to environment configuration for better flexibility across different environments (staging, development, etc.).
This would allow:
- Easier environment management
- Consistent URL handling across services
- Simplified deployment to different environments
Example approach:
const BASE_QACC_URL = process.env.NEXT_PUBLIC_QACC_URL || 'https://qacc.giveth.io/'; const links = { // ... QACC: BASE_QACC_URL, QACC_NEWS: `${BASE_QACC_URL}news`, // ... };src/hooks/useCreateEvmDonation.tsx (5)
Line range hint
33-57
: Complete the migration of onError handlerThe commented out
onError
handler contains important logic for handling multi-sig transactions. This could lead to missing error handling for Safe transactions.Would you like me to help implement the migrated version of the
onError
handler? This would ensure proper handling of multi-sig transaction errors.
Line range hint
59-143
: Improve error handling in handleSaveDonation
- The catch block uses
any
type which masks specific error types.- The backup API call uses potentially undefined variables (
transaction?.hash
,transaction?.nonce
,transaction?.from
).Consider these improvements:
-} catch (e: any) { +} catch (e: unknown) { + const error = e as Error; await postRequest('/api/donation-backup', true, { chainId: chainId || token.networkId, - txHash: transaction?.hash, + txHash: transaction?.hash ?? txHash, amount: amount, token, projectId, anonymous, - nonce: transaction?.nonce, + nonce: transaction?.nonce ?? undefined, chainvineReferred, - walletAddress: transaction?.from, + walletAddress: transaction?.from ?? undefined, symbol: token.symbol, - error: e.message, + error: error.message, useDonationBox, relevantDonationTxHash, });
Line range hint
145-167
: Enhance error handling structureThe current error handling could be more robust with better error discrimination and structured error reporting.
Consider enhancing the error handling:
const handleError = ( - error: any, + error: Error & { + replacement?: { hash: string }; + transactionHash?: string; + }, donationId: number, setFailedModalType: (type: EDonationFailedType) => void, ) => { console.error('name', error.name); const localTxHash = error.replacement?.hash || error.transactionHash; setTxHash(localTxHash); + const errorDetails = { + name: error.name, + message: error.message, + txHash: localTxHash, + donationId, + }; if (error.name === 'TransactionExecutionError') { setFailedModalType(EDonationFailedType.FAILED); } else { console.error('Rejected1', error); setFailedModalType(EDonationFailedType.REJECTED); } setDonationSaved(false); updateDonation(donationId, EDonationStatus.FAILED); - captureException(error, { tags: { section: 'confirmDonation' } }); + captureException(error, { + tags: { section: 'confirmDonation' }, + extra: errorDetails, + }); };
Line range hint
169-249
: Fix potential memory leak and improve error handling
- The Promise resolution logic could lead to memory leaks if the component unmounts before resolution
- Using donationId as 0 in error handling might be incorrect for failed transactions
Consider these improvements:
+ const [promiseResolver, setPromiseResolver] = useState<(() => void) | null>(null); + useEffect(() => { + return () => { + if (promiseResolver) { + promiseResolver(); + setPromiseResolver(null); + } + }; + }, [promiseResolver]); await new Promise(resolve => { if (status === 'success') { - setResolveState(null); + resolve(); } else { - setResolveState(() => resolve); + setPromiseResolver(() => resolve); } }); - handleError(error, 0, setFailedModalType); + handleError(error, draftDonationData?.createDraftDonation ?? 0, setFailedModalType);
Line range hint
251-270
: Fix missing effect dependenciesThe effect hook is missing dependencies that it uses within its callback.
Add missing dependencies:
useEffect(() => { if (status === 'success') { updateDonation(donationId, EDonationStatus.VERIFIED); setDonationMinted(true); if (resolveState) { resolveState(); setResolveState(null); } } const comingFromSafe = isSafeEnv && txHash; if (status === 'error' && !comingFromSafe) { updateDonation(donationId, EDonationStatus.FAILED); setDonationSaved(false); createDonationProps?.setFailedModalType(EDonationFailedType.FAILED); } - }, [status, donationId]); + }, [status, donationId, resolveState, isSafeEnv, txHash, createDonationProps]);src/components/views/donate/OneTime/SelectTokenModal/SelectTokenModal.tsx (5)
151-157
: Simplify token filtering logic by removing unnecessary variable.The introduction of
sQuery
adds unnecessary complexity. ThesearchQuery
variable can be used directly in the filtering logic.Consider this simpler implementation:
- 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()), );
Line range hint
183-191
: Improve error handling for balance fetching.The error from
fetchBalances
is only logged to console. Users should be notified when balance fetching fails, similar to how token data fetching errors are handled.Consider adding error notification:
} catch (error) { console.error('error on fetchTokenBalances', { error }); + setBalanceIsLoading(false); + showToastError('Failed to fetch token balances'); }
Line range hint
164-191
: Optimize balance fetching performance.The balance fetching logic currently runs on every filter change due to
filteredTokens
dependency. Consider caching the balances and only updating the filtered view.Consider this approach:
- Fetch balances only for
tokens
(notfilteredTokens
)- Store full balance map
- Filter the displayed tokens using the cached balances
// Add these state variables const [tokenBalanceMap, setTokenBalanceMap] = useState<Record<string, bigint>>({}); const [isInitialBalanceFetch, setIsInitialBalanceFetch] = useState(true); // Modify the fetch logic useEffect(() => { const fetchBalances = async () => { if (!isConnected || !tokens || !isInitialBalanceFetch) return; try { setBalanceIsLoading(true); const balances = isOnEVM ? await fetchEVMTokenBalances(tokens, walletAddress) : await Promise.all(/* ... */); const balanceMap = balances.reduce((acc, {token, balance}) => ({ ...acc, [token.address]: balance }), {}); setTokenBalanceMap(balanceMap); setIsInitialBalanceFetch(false); setBalanceIsLoading(false); } catch (error) { console.error('error on fetchTokenBalances', { error }); setBalanceIsLoading(false); showToastError('Failed to fetch token balances'); } }; fetchBalances(); }, [tokens, isConnected, isOnEVM, walletAddress, isInitialBalanceFetch]); // Use the balance map when displaying tokens const sortedTokens = filteredTokens.map(token => ({ token, balance: tokenBalanceMap[token.address] })).sort(/* ... */);
Line range hint
62-108
: Add warning for custom token support.When users input custom token addresses, they should be warned about potential risks of interacting with unknown tokens.
Consider adding a warning message when a custom token is detected:
if (existingToken) { setCustomToken(undefined); setFilteredTokens([existingToken]); } else if (isOnEVM && acceptCustomToken) { + // Show warning for custom tokens + showToastError( + 'Warning: Custom tokens may be unsafe. Please verify the token contract carefully.', + { type: 'warning', duration: 6000 } + ); const initialToken = { address: searchQuery, decimals: 18, name: shortenAddress(searchQuery), symbol: shortenAddress(searchQuery),
Line range hint
256-267
: Enhance input field accessibility.The search input field lacks proper accessibility attributes which are essential for screen readers and keyboard navigation.
Add ARIA attributes and labels:
const Input = styled.input` + /* existing styles */ padding: 8px 16px; padding-right: 48px; width: 100%; border: none; outline: none; font-size: 16px; background: transparent; line-height: 24px; `; + +// Usage in JSX: +<Input + placeholder='Search name or paste an address' + value={searchQuery} + onChange={e => setSearchQuery(e.target.value)} + aria-label="Search tokens" + role="searchbox" +/>src/hooks/usePassport.ts (3)
238-240
: LGTM! Consider adding type validationThe type assertion for the Ethereum address improves type safety. However, consider adding runtime validation to ensure the address format is correct before the assertion.
Consider adding validation before the assertion:
+ if (!address.match(/^0x[a-fA-F0-9]{40}$/)) { + throw new Error('Invalid Ethereum address format'); + } const userAddressScore = await scoreUserAddress( address as `0x${string}`, );
Line range hint
391-391
: Remove debugging console.log statementsThere are multiple console.log statements that appear to be debugging code. These should be removed as they:
- Expose sensitive user data and addresses
- Add noise to the browser console
- May impact performance in production
Remove all console.log statements or replace them with proper logging if needed:
- console.log('******0', address, isUserFullFilled, user); - console.log('******1', address, isUserFullFilled, user); - console.log('******2', address, isUserFullFilled, user); - console.log('******3', address, isUserFullFilled, user); - console.log('******4', address, isUserFullFilled, user); - console.log('******5', address, isUserFullFilled, user); - console.log('******6', address, isUserFullFilled, user); - console.log('******7', address, isUserFullFilled, user);Also applies to: 393-393, 396-396, 398-398, 400-400, 402-402, 404-404, 406-406, 408-408
Line range hint
242-245
: Enhance error handling with more contextThe current error handling could be improved to provide more context about what went wrong during the score fetching process.
Consider enhancing the error handling:
} catch (error) { - console.error('Failed to fetch user address score:', error); + const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + console.error(`Failed to fetch MBD score for address ${address}:`, { + error: errorMessage, + context: { address, activeQFRound: activeQFRound?.id } + }); updateState(user!); }src/lib/helpers.ts (3)
379-381
: Improve the comment about the viem package issueThe current comment about the viem package issue is not very clear. Consider adding more context or a reference to the issue.
-// 'viem' ABI contract for USDT donation fails on mainnet -// so we use the USDT mainnet ABI instead and put inside usdtMainnetABI.json file -// update for 'viem' package to fix this issue doesn't work +// Using custom USDT mainnet ABI due to incompatibility with viem's default ERC20 ABI +// See: [Add link to the viem issue here] +// TODO: Remove this workaround once the viem package issue is resolved
391-400
: Improve type safety for decimals handlingThe current implementation could be improved to handle decimals more safely:
- Add type assertion for the readContract result
- Add validation for the decimals value
-let decimals = await readContract(wagmiConfig, { +const decimalsResult = await readContract(wagmiConfig, { ...baseProps, functionName: 'decimals', -}); +}) as bigint | number; -if (typeof decimals === 'bigint') { - decimals = Number(decimals.toString()); +const decimals = typeof decimalsResult === 'bigint' + ? Number(decimalsResult.toString()) + : decimalsResult; + +if (decimals < 0 || decimals > 18) { + throw new Error('Invalid decimals value'); } const value = parseUnits(params.value, decimals);
379-400
: Add specific error handling for common ERC20 transfer failuresThe function should handle common ERC20 transfer failures more specifically to provide better error messages to users.
async function handleErc20Transfer( params: TransactionParams, contractAddress: Address, ): Promise<Address> { + try { const ABItoUse = contractAddress === '0xdac17f958d2ee523a2206206994597c13d831ec7' ? usdtMainnetABI : erc20Abi; const baseProps = { address: contractAddress, abi: ABItoUse, }; // ... rest of the function ... + } catch (error: any) { + // Handle specific ERC20 errors + if (error.message?.includes('insufficient allowance')) { + throw new Error('Insufficient token allowance'); + } + if (error.message?.includes('insufficient balance')) { + throw new Error('Insufficient token balance'); + } + // Re-throw other errors + throw error; + } }lang/ca.json (1)
101-102
: The new entries should be translated to CatalanThe new entries "Q/acc" and "Q/acc News" are in English, while this is a Catalan localization file. Consider translating these entries to maintain consistency with the rest of the translations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (15)
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/givfarm/GIVfarmBottom.tsx
(1 hunks)src/config/production.tsx
(1 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 (3)
- package.json
- src/artifacts/usdtMainnetABI.json
- src/config/production.tsx
🔇 Additional comments (11)
src/wagmiConfigs.ts (2)
5-5
: LGTM: Clean import addition
The import of mainnet
from viem/chains is appropriate for the chain identification logic.
46-49
: Verify the impact of using public transport for non-mainnet chains
The current implementation falls back to public transport for non-mainnet chains, which could lead to rate limiting or reliability issues in production.
Let's check for other chain configurations in the codebase:
✅ Verification successful
Based on the search results, I can now provide a definitive response about the impact of using public transport for non-mainnet chains:
Using public transport for non-mainnet chains is an intentional and safe design choice
The implementation in wagmiConfigs.ts
is actually following best practices because:
-
The code specifically checks for mainnet to use Infura, while other networks use their own dedicated RPC endpoints configured in their respective network configs (as seen in the search results showing RPC configurations for various chains).
-
The "public transport" for non-mainnet chains refers to the chain's own RPC endpoints (e.g., for Optimism, Gnosis, etc.) which are properly configured in the network configs and are production-ready.
-
The codebase shows careful handling of different networks with proper RPC configurations, including fallback providers and network-specific endpoints.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for chain configurations and RPC endpoints
echo "Searching for chain configurations..."
rg -l "chains.*=.*\[" --type ts
echo "Searching for RPC URL configurations..."
rg -l "rpc.*url" --type ts --type json
echo "Searching for Infura usage..."
rg -l "infura" --type ts --type json --type env
Length of output: 475
Script:
#!/bin/bash
# Let's search for chain configurations and HTTP transport setup more thoroughly
echo "Searching for chain and transport configurations..."
rg -A 5 "chain.*=|transport.*=|http\(.*\)" --type ts
echo "Searching for files containing mainnet or network configurations..."
rg -A 5 "mainnet|chain\.id" --type ts
echo "Searching for RPC related configurations..."
rg -A 5 "rpc|provider" --type ts
Length of output: 211090
src/lib/constants/links.ts (2)
59-60
: LGTM! New QACC constants follow existing patterns.
The new QACC-related constants are well-structured and follow the established naming conventions.
59-60
: Verify Footer component integration.
Let's verify that these new links are properly integrated into the Footer component with correct localization.
✅ Verification successful
Links are properly integrated with localization support
The QACC links are correctly integrated in the Footer component with:
- Proper usage of
links.QACC
andlinks.QACC_NEWS
constants - Translation keys
component.title.qacc
andcomponent.title.qacc_news
implemented in multiple language files (en, es, ca) - Correct implementation of
formatMessage
for localization
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify Footer component integration and localization
# Check Footer component for QACC links usage
echo "Checking Footer component for QACC links..."
rg -A 2 "QACC|QACC_NEWS" "src/components/Footer"
# Verify localization keys exist
echo "Verifying localization entries..."
rg -A 1 "qacc" "lang/*.json"
Length of output: 719
Script:
#!/bin/bash
# Let's check for localization files in the correct directory structure
echo "Finding localization files..."
fd -e json -d 3 "en|es|de"
# Once we find the location, let's check for QACC related translations
echo "Checking translations in public directory..."
rg -A 1 "qacc" "public/locales/"
# Let's also verify the import and usage pattern in Footer
echo "Checking Footer component structure..."
cat "src/components/Footer/Footer.tsx"
Length of output: 8185
Script:
#!/bin/bash
# Let's check for QACC related translations in the lang directory
echo "Checking translations in lang directory..."
rg -A 1 "qacc" "lang/"
# Let's also check the translation IDs used in Footer for QACC
echo "Checking specific translation keys used..."
rg "id: 'component.title.qacc" "src/components/Footer/Footer.tsx"
Length of output: 862
src/components/views/givfarm/GIVfarmBottom.tsx (2)
191-191
: LGTM: Simplified pool rendering structure
The removal of the extra Col
wrapper simplifies the component structure. The grid layout is still maintained through the renderPool
function which wraps each pool with appropriate Col
components.
191-191
: Verify StakeTogetherCard removal impact
The removal of StakeTogetherCard
from this component might affect staking functionality. Please ensure this feature is properly relocated or intentionally removed.
✅ Verification successful
Let me gather more information about the component's usage and potential relocation.
Let me check where this component is being used and how it's being rendered in the application.
Based on the git history and code changes, I can now provide a definitive response about the StakeTogetherCard removal.
StakeTogetherCard removal is intentional and safe
The removal of StakeTogetherCard from GIVfarmBottom was an intentional change (commit 9f67e61) that aligns with the codebase's evolution. The component was:
- First added on April 10, 2024 (commit 59c04ab)
- Actively maintained with features like conditional links and translations
- Deliberately removed on October 23, 2024 (commit 9f67e61)
The removal is safe because:
- The component still exists in the codebase at its original location (
src/components/cards/StakingCards/BaseStakingCard/StakeTogetherCard.tsx
) - The removal was a targeted change to only remove it from the GIVfarm view
- No other components were depending on its presence in GIVfarmBottom
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for StakeTogetherCard usage in the codebase
echo "Checking if StakeTogetherCard is used elsewhere:"
rg "StakeTogetherCard" -l
# Search for any new staking-related components that might replace it
echo -e "\nChecking for potential replacement components:"
rg -i "stake.*card" -l
Length of output: 719
Script:
#!/bin/bash
# Check the git history for StakeTogetherCard changes
echo "Checking recent changes to StakeTogetherCard:"
git log -p -- src/components/cards/StakingCards/BaseStakingCard/StakeTogetherCard.tsx
# Check for imports of StakeTogetherCard
echo -e "\nChecking for StakeTogetherCard imports:"
rg "import.*StakeTogetherCard" -A 1
# Check the content of StakeTogetherCard component
echo -e "\nChecking StakeTogetherCard component content:"
cat src/components/cards/StakingCards/BaseStakingCard/StakeTogetherCard.tsx
Length of output: 9063
Script:
#!/bin/bash
# Check for StakeTogetherCard imports and usage
echo "Checking for StakeTogetherCard imports and usage:"
rg "StakeTogetherCard" -B 2 -A 2
# Check the GIVfarmBottom component's history
echo -e "\nChecking GIVfarmBottom recent changes:"
git log -p -- src/components/views/givfarm/GIVfarmBottom.tsx
Length of output: 76058
src/components/Footer/Footer.tsx (1)
244-244
: Verify the layout impact of gap change
The gap property change from what appears to be 72px
to 0px
in the laptopL media query might affect the spacing between link columns in the footer.
Please verify that this change:
- Doesn't cause overlapping of link columns
- Maintains consistent spacing with other footer elements
- Looks correct across different screen sizes
Consider providing screenshots of the footer layout before and after this change to confirm the visual impact.
src/hooks/useCreateEvmDonation.tsx (1)
21-21
:
Potential type safety issue with txHash assertion
The broadened type of txHash
to include Address
combined with the forced type assertion to 0x${string}
in useWaitForTransactionReceipt
could lead to runtime errors if txHash
is actually an Address
.
Consider adding a type guard:
-hash: txHash as `0x${string}`,
+hash: txHash?.startsWith('0x') ? txHash as `0x${string}` : undefined,
Also applies to: 33-33
src/lib/helpers.ts (1)
22-22
: Verify the USDT mainnet ABI file
Let's ensure the imported ABI file exists and contains the correct USDT contract interface.
✅ Verification successful
USDT Mainnet ABI file verified successfully
The ABI file exists at the expected location and contains all the required ERC20 functions (transfer, balanceOf, decimals) needed for USDT token operations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify USDT mainnet ABI file existence and content
# Check if the ABI file exists
if [ -f "src/artifacts/usdtMainnetABI.json" ]; then
echo "File exists. Checking content..."
# Verify it's a valid JSON and contains essential USDT functions
jq -e '
. as $abi |
["transfer", "balanceOf", "decimals"] as $required |
$required - [($abi[] | select(.type == "function") | .name)] | length == 0
' src/artifacts/usdtMainnetABI.json
else
echo "ABI file not found at expected location"
# Search for the file in case it's in a different location
fd -t f "usdtMainnetABI.json"
fi
Length of output: 340
lang/en.json (1)
100-101
: LGTM! The new Q/acc localization entries are properly formatted.
The new entries follow the established naming conventions and are correctly placed in alphabetical order with other component titles.
lang/es.json (1)
709-710
: LGTM! The new Q/acc related translations are properly added.
The new entries follow the established patterns for component titles and appropriately preserve the branded terms without translation.
// TODO: we must manage this for all chains in a better way | ||
// basically to stop using viem's public transport | ||
// leaving this as a hotfix to keep it quick | ||
const infuraKey = process.env.NEXT_PUBLIC_INFURA_API_KEY; |
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.
Add environment variable validation and optimize transport creation
Several improvements are needed for production readiness:
- The Infura key should be validated at startup
- The HTTP transport instance could be memoized
Consider this implementation:
- const infuraKey = process.env.NEXT_PUBLIC_INFURA_API_KEY;
+ const infuraKey = process.env.NEXT_PUBLIC_INFURA_API_KEY;
+ if (!infuraKey) {
+ console.warn('Infura API key not found, falling back to public transport');
+ }
+
+ // Memoize transports
+ const mainnetTransport = infuraKey ? http(`https://mainnet.infura.io/v3/${infuraKey}`) : http();
+ const defaultTransport = http();
+
const customHttp =
chain.id === mainnet.id && infuraKey
- ? http(`https://mainnet.infura.io/v3/${infuraKey}`)
- : http();
+ ? mainnetTransport
+ : defaultTransport;
Also applies to: 46-51
<a href={links.QACC} target='_blank'> | ||
<LinkItem color={textColor}> | ||
{formatMessage({ | ||
id: 'component.title.qacc', | ||
})} | ||
</LinkItem> | ||
</a> |
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.
Add security attributes to external links
The new external links should include rel="noreferrer noopener"
attributes to prevent potential security vulnerabilities when using target="_blank"
.
Apply this diff:
- <a href={links.QACC} target='_blank'>
+ <a href={links.QACC} target='_blank' rel='noreferrer noopener'>
- <a href={links.QACC_NEWS} target='_blank'>
+ <a href={links.QACC_NEWS} target='_blank' rel='noreferrer noopener'>
Also applies to: 153-159
// 'viem' ABI contract for USDT donation fails on mainnet | ||
// so we use the USDT mainnet ABI instead and put inside usdtMainnetABI.json file | ||
// update for 'viem' package to fix this issue doesn't work | ||
const ABItoUse = | ||
contractAddress === '0xdac17f958d2ee523a2206206994597c13d831ec7' | ||
? usdtMainnetABI | ||
: erc20Abi; |
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.
🛠️ Refactor suggestion
Move the USDT contract address to constants
The hardcoded USDT contract address should be moved to a constants file for better maintainability and reusability.
+// In constants.ts
+export const USDT_MAINNET_ADDRESS = '0xdac17f958d2ee523a2206206994597c13d831ec7' as const;
-const ABItoUse =
- contractAddress === '0xdac17f958d2ee523a2206206994597c13d831ec7'
+const ABItoUse =
+ contractAddress === USDT_MAINNET_ADDRESS
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Improvements
Chores
package.json
for improved stability.