feat: add SingleRequestForwarder to request scan#74
Conversation
|
Warning Rate limit exceeded@aimensahnoun has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 16 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces several new files and modifications aimed at enhancing code quality and development workflow. A pre-commit hook is set up using Husky and lint-staged to enforce linting and formatting checks on staged files. Additionally, new React components and hooks are added for managing and displaying deployment data, along with GraphQL queries for fetching payment and deployment information. Configuration files for linting and formatting tools are also introduced, establishing a structured approach to code quality. 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.
Actionable comments posted: 11
🧹 Outside diff range and nitpick comments (13)
src/lib/types.ts (2)
38-51: Add JSDoc documentation for better code maintainabilityConsider adding documentation to describe the purpose of this interface and its properties, especially for fields that have specific requirements or constraints.
+/** + * Represents a Single Request Flow (SRF) proxy deployment + * @interface SingleRequestProxyDeployment + */ export interface SingleRequestProxyDeployment { + /** Unique identifier for the deployment */ id: string; + /** Address where fees are sent */ feeAddress: string; + /** Amount of fees in base units */ feeAmount: string; + /** Indicates if a fee proxy was used for this deployment */ feeProxyUsed: boolean; + /** Address of the payee */ payee: string; + /** Reference for the payment */ paymentReference: string; + /** Address of the deployed proxy */ proxyAddress: string; + /** Type of the proxy contract */ proxyType: string; + /** Unix timestamp of the deployment */ timestamp: number; + /** Address of the token contract */ tokenAddress: string; + /** Transaction hash of the deployment */ txHash: string; + /** Blockchain network identifier */ chain: string; }
38-51: Consider strengthening type safetyThe interface could benefit from more specific types for certain fields to improve type safety and prevent potential errors.
export interface SingleRequestProxyDeployment { id: string; - feeAddress: string; + feeAddress: `0x${string}`; // Ethereum address feeAmount: string; feeProxyUsed: boolean; - payee: string; + payee: `0x${string}`; // Ethereum address paymentReference: string; - proxyAddress: string; + proxyAddress: `0x${string}`; // Ethereum address - proxyType: string; + proxyType: 'ERC20' | 'NATIVE'; // Add specific proxy types timestamp: number; - tokenAddress: string; + tokenAddress: `0x${string}`; // Ethereum address - txHash: string; + txHash: `0x${string}`; // Transaction hash - chain: string; + chain: 'mainnet' | 'goerli' | 'sepolia'; // Add supported chains }src/lib/hooks/use-latest-srf-deployments.tsx (3)
9-14: Update interface naming conventionThe
Iprefix in interface names is an outdated TypeScript naming convention. Consider removing theIprefix for better alignment with modern TypeScript practices.-interface ILatestSRFDeployments { +interface LatestSRFDeployments { deployments: SingleRequestProxyDeployment[]; isLoading: boolean; status: string; isFetching: boolean; }
16-21: Enhance Props type with JSDoc documentationConsider adding JSDoc documentation to describe the purpose and constraints of each prop.
+/** + * Configuration options for SRF deployments query + * @property {number} [first=10] - Number of deployments to fetch + * @property {number} [skip=0] - Number of deployments to skip for pagination + * @property {number} [pollInterval=0] - Interval in milliseconds for polling updates + * @property {number} [page=0] - Current page number + */ type Props = { first?: number; skip?: number; pollInterval?: number; page?: number; };
29-34: Consider adding retry configuration for failed requestsThe query might benefit from custom retry logic for handling transient failures.
const { status, isLoading, data, isFetching } = useQuery({ queryKey: ["proxy-deployments", first, skip], queryFn: () => fetchProxyDeployments({ first, skip }), ...commonQueryOptions, refetchInterval: pollInterval === 0 ? false : pollInterval, + retry: (failureCount, error) => { + // Retry up to 3 times for network errors + return failureCount < 3 && error instanceof Error && error.message.includes('network'); + }, });src/lib/queries/utils.ts (1)
45-67: Consider improving type safety and robustness.While the function works correctly, there are several opportunities for improvement:
- The index signature
[x: string]could be replaced with a more specific type- The network name derivation assumes a "payment_" prefix
- Consider using immutable array operations
Consider this refactoring:
+ type NetworkData = { + [K in `payment_${string}`]: { + singleRequestProxyDeployments: SingleRequestProxyDeployment[]; + }; + }; - export const formatProxyDeploymentData = ( - data: { - [x: string]: { - singleRequestProxyDeployments: SingleRequestProxyDeployment[]; - }; - } | null - ) => { + export const formatProxyDeploymentData = (data: NetworkData | null) => { if (!data) return []; - const deployments: SingleRequestProxyDeployment[] = []; - Object.keys(data).forEach((key) => { - const networkName = key.replace("payment_", ""); - const networkDeployments = data[key].singleRequestProxyDeployments.map( - (deployment) => ({ - ...deployment, - chain: networkName, - }) - ); - deployments.push(...networkDeployments); - }); + return Object.entries(data) + .flatMap(([key, value]) => { + const networkName = key.replace(/^payment_/, ''); + return value.singleRequestProxyDeployments.map(deployment => ({ + ...deployment, + chain: networkName, + })); + }) + .sort((a, b) => b.timestamp - a.timestamp); - return deployments.sort((a, b) => b.timestamp - a.timestamp); };src/components/recent-srf-deployments-table.tsx (3)
28-30: Consider improving the polling configuration.The polling configuration could be enhanced for better maintainability and type safety:
- Extract the default polling interval (30000) to a named constant
- Add type checking for the environment variable
Consider applying this refactor:
+const DEFAULT_POLL_INTERVAL = 30000; +const getPollInterval = () => { + const interval = process.env.NEXT_PUBLIC_POLL_INTERVAL; + return interval ? Number(interval) : DEFAULT_POLL_INTERVAL; +}; export function RecentSRFDeploymentsTable() { const { deployments, isLoading } = useLatestSRFDeployments({ - pollInterval: Number(process.env.NEXT_PUBLIC_POLL_INTERVAL) || 30000, + pollInterval: getPollInterval(), });
32-38: Enhance empty state UX with more informative messaging.The current empty state message "No data" is too generic. Consider providing more context and guidance to users.
Consider this improvement:
if (!deployments) { - return <div>No data</div>; + return ( + <div className="text-center p-4"> + <p className="text-gray-500">No SRF deployments found.</p> + <p className="text-sm">New deployments will appear here automatically.</p> + </div> + ); }
104-111: Improve timestamp handling and accessibility.The timestamp display could be enhanced for better accessibility and consistency.
Consider these improvements:
<TimeAgo datetime={deployment.timestamp * 1000} locale="en_short" + title={formatTimestamp(deployment.timestamp)} /> <span className="hidden 2xl:inline-block"> - ({formatTimestamp(deployment.timestamp)}) + <time dateTime={new Date(deployment.timestamp * 1000).toISOString()}> + ({formatTimestamp(deployment.timestamp)}) + </time> </span>src/lib/utils.ts (2)
37-43: Consider adding type safety for timestamp parameterWhile the function works correctly, consider adding runtime validation for the timestamp parameter to prevent potential issues with invalid inputs.
-export const formatTimestamp = (timestamp: number) => +export const formatTimestamp = (timestamp: number) => { + if (timestamp < 0 || !Number.isInteger(timestamp)) { + throw new Error('Invalid timestamp value'); + } + return `${new Date(timestamp * 1000).toLocaleString("en-US", { year: "numeric", month: "short", day: "numeric", hour: "numeric", minute: "numeric", timeZone: "UTC", })} UTC`; +}
68-74: Improve error handling specificityThe current error handling is too generic. Consider adding more specific error handling to help with debugging.
try { return `0x${PaymentReferenceCalculator.calculate(requestId, salt, address)}`; } catch (error) { - console.error("Error calculating short payment reference", error); + if (error instanceof Error) { + console.error(`Failed to calculate payment reference: ${error.message}`, { + requestId, + salt, + address, + error, + }); + } return undefined; }src/lib/hooks/payments.ts (2)
12-12: Remove unnecessary comment symbol in the GraphQL queryThe
#character at line 12 is unnecessary and can be removed to clean up the query.Apply this diff to remove the unnecessary character:
query PaymentsQuery($first: Int, $skip: Int!) { - #
13-152: Refactor the GraphQL query to reduce repetitionThe
PAYMENTS_QUERYcontains repetitive code for each network, which can make maintenance challenging. Consider refactoring the query to dynamically handle multiple networks or using a more scalable approach to reduce duplication.One possible solution is to pass an array of network names and construct the query dynamically. Here's an example of how you might adjust the code:
const networkNames = [ 'payment_mainnet', 'payment_arbitrum_one', 'payment_avalanche', // ...add other network names here ]; const PAYMENTS_QUERY = gql` ${CORE_PAYMENT_FIELDS} query PaymentsQuery($first: Int, $skip: Int!, $networks: [String!]!) { ${networkNames.map( (network) => ` ${network}: ${network} { payments( first: $first skip: $skip orderBy: timestamp orderDirection: desc ) { ...PaymentFields } } ` ).join('\n')} } `;Adjust the variables and execution accordingly to handle dynamic network queries.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
.husky/pre-commit(1 hunks).lintstagedrc.js(1 hunks)biome.json(1 hunks)package.json(2 hunks)src/components/recent-area.tsx(1 hunks)src/components/recent-srf-deployments-table.tsx(1 hunks)src/lib/graphQlClient.ts(1 hunks)src/lib/hooks/payments.ts(1 hunks)src/lib/hooks/use-latest-srf-deployments.tsx(1 hunks)src/lib/queries/srf-deployments.ts(1 hunks)src/lib/queries/utils.ts(2 hunks)src/lib/types.ts(1 hunks)src/lib/utils.ts(6 hunks)
✅ Files skipped from review due to trivial changes (4)
- .husky/pre-commit
- .lintstagedrc.js
- biome.json
- src/lib/graphQlClient.ts
🔇 Additional comments (11)
src/components/recent-area.tsx (2)
3-5: LGTM! Clean and consistent import structure.
The new import follows the established pattern and is properly grouped with other table component imports.
12-14: LGTM! Good responsive layout implementation.
The full-width placement of the SRF deployments table using md:col-span-2 makes good use of the available space, especially on larger screens. The wrapper div with w-full ensures proper width behavior.
src/lib/types.ts (1)
50-50: Verify chain property consistency
The chain property appears in both Payment and SingleRequestProxyDeployment interfaces. Let's ensure consistent usage across the codebase.
✅ Verification successful
Chain property usage is consistent across the codebase
The verification shows consistent usage of the chain property:
- Both interfaces (
PaymentandSingleRequestProxyDeployment) define it asstring - Usage in code shows proper string values representing blockchain networks (mainnet, arbitrum, avalanche, etc.)
- The property is correctly mapped in utility functions and queries
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check usage of chain property across the codebase
# Expected: Consistent usage of chain values
# Search for chain property usage in type definitions
echo "Checking chain property in type definitions:"
ast-grep --pattern 'interface $_ { $$$ chain: $_; $$$ }'
# Search for actual chain values being used
echo -e "\nChecking chain values in code:"
rg -A 1 'chain:' --type ts
Length of output: 3384
src/lib/hooks/use-latest-srf-deployments.tsx (1)
5-5: Verify fetchProxyDeployments implementation
Let's verify the implementation of the imported function to ensure proper error handling and type safety.
✅ Verification successful
Implementation verified with proper type safety and error handling
The implementation of fetchProxyDeployments is well-structured with:
- Strong TypeScript typing through
SingleRequestProxyDeploymentinterface - GraphQL query with proper field fragments and type definitions
- Data transformation with null checks in
formatProxyDeploymentData - Error handling through GraphQLClient's built-in error handling
- Proper pagination support through
firstandskipparameters
The integration is safe to use.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for fetchProxyDeployments implementation and its error handling
ast-grep --pattern 'export const fetchProxyDeployments = async ($$$) => {
$$$
}'
# Check for proper error handling in the implementation
rg -A 10 "fetchProxyDeployments.*=.*async"
Length of output: 878
Script:
#!/bin/bash
# Let's check the error handling in graphQLClient and the type definitions
rg -A 5 "graphQLClient.*=.*"
# Check the formatProxyDeploymentData implementation
ast-grep --pattern 'const formatProxyDeploymentData = ($$$) => {
$$$
}'
# Check for type definitions
rg -A 5 "type SingleRequestProxyDeployment"
# Check the PROXY_DEPLOYMENTS_QUERY definition
rg "PROXY_DEPLOYMENTS_QUERY.*=.*" -A 10
Length of output: 4061
Script:
#!/bin/bash
# Let's check the CORE_PROXY_DEPLOYMENT_FIELDS and ProxyDeploymentFields fragment
rg "CORE_PROXY_DEPLOYMENT_FIELDS.*=.*" -A 10
# Check for SingleRequestProxyDeployment type definition which wasn't found in previous search
fd -e ts -e tsx -x rg -l "SingleRequestProxyDeployment" {} \; | xargs cat
# Check for any try-catch blocks around graphQLClient usage
rg -B 5 -A 5 "try.*{.*graphQLClient"
Length of output: 14610
src/lib/queries/utils.ts (2)
3-4: LGTM! Clean and well-organized imports.
The imports are properly structured, with type imports separated using the TypeScript type keyword.
29-43: Verify completeness of proxy deployment fields.
The GraphQL fragment includes essential fields for proxy deployment. Let's verify if all necessary fields are included and used consistently across the codebase.
✅ Verification successful
Let me gather more information about the type definition and usage to ensure field completeness.
Let me fix the command to properly search for the fragment usage.
Based on the results, I can now generate the final response since I have compared the GraphQL fragment fields with the TypeScript interface and its usage in queries.
GraphQL fragment fields are complete and consistent with type definition
The CORE_PROXY_DEPLOYMENT_FIELDS fragment includes all fields defined in the SingleRequestProxyDeployment interface except for the chain field. However, this appears intentional as the query in srf-deployments.ts is already scoped to payment_mainnet, making the chain field redundant in this context.
- Fragment is correctly used in
PROXY_DEPLOYMENTS_QUERYfor fetching proxy deployments - All essential fields for proxy deployment data are included
- Fields match the TypeScript interface definition ensuring type safety
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any other GraphQL queries or mutations using SingleRequestProxyDeployment
# to ensure field consistency and completeness
# Search for GraphQL operations using SingleRequestProxyDeployment
rg -t ts -t tsx "SingleRequestProxyDeployment" --type-add 'tsx:*.tsx'
# Search for other GraphQL fragments or operations that might need these fields
ast-grep --pattern 'gql`
$$$
SingleRequestProxyDeployment
$$$
`'
Length of output: 1257
Script:
#!/bin/bash
# Check the type definition and any GraphQL queries using this type
cat src/lib/types.ts | grep -A 15 "interface SingleRequestProxyDeployment"
# Find all GraphQL operations using this fragment
rg -t ts -t tsx "CORE_PROXY_DEPLOYMENT_FIELDS" -B 2 -A 10
Length of output: 492
Script:
#!/bin/bash
# Find all GraphQL operations using this fragment with proper file type handling
rg --type-add 'tsx:*.tsx' -t ts -t tsx "CORE_PROXY_DEPLOYMENT_FIELDS" -B 2 -A 10
# Find any GraphQL queries or mutations related to proxy deployments
rg --type-add 'tsx:*.tsx' -t ts -t tsx "query.*singleRequestProxyDeployments|mutation.*singleRequestProxyDeployments" -B 2 -A 10
Length of output: 1865
package.json (2)
43-43: LGTM! Consider version pinning strategy
The added development dependencies are up-to-date and commonly used together for pre-commit hooks. However, using caret ranges (^) could lead to unexpected behavior if minor versions introduce breaking changes.
Consider:
- Pinning exact versions for more predictable builds
- Adding an npm/yarn lock file to the PR if not already included
Let's verify the stability of these versions:
Also applies to: 50-51
✅ Verification successful
LGTM! Lock file is present and dependencies are properly resolved
The package-lock.json file is present and shows that all dependencies are properly resolved with exact versions:
- @biomejs/biome@1.9.4 with all its platform-specific binaries
- husky@9.1.7
- lint-staged@15.2.10
The lock file ensures deterministic installations across environments, addressing the version pinning concern from the original review.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for lock files
echo "Checking for lock files..."
for lockfile in package-lock.json yarn.lock pnpm-lock.yaml; do
if [ -f "$lockfile" ]; then
echo "Found lock file: $lockfile"
cat "$lockfile" | grep -A 5 -B 5 "biome\|husky\|lint-staged"
fi
done
Length of output: 7883
9-11: Consider potential linting tool conflicts and script naming clarity
You have both ESLint and Biome configured for linting/formatting. While ESLint is standard for Next.js projects, running both tools might lead to conflicting rules or confusion.
Consider either:
- Using only one tool for consistency
- Clearly defining the scope of each tool
- Renaming the format script to be more explicit (e.g.,
format:biome)
Let's check for potential rule conflicts:
src/lib/queries/srf-deployments.ts (1)
1-6: LGTM! Well-organized imports
The imports are logically structured and each dependency serves a clear purpose in the implementation.
src/components/recent-srf-deployments-table.tsx (1)
1-26: LGTM! Well-organized imports with clear client-side directive.
The imports are logically grouped and the "use client" directive is correctly placed for client-side rendering requirements.
src/lib/utils.ts (1)
3-19: LGTM: Import statements are well-organized
The import statements are properly structured with clear separation between external dependencies and internal types.
…-add-single-request-forwarder-deployments-to-request-scan
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
src/components/srf-info-section.tsx (1)
1-1: Use type-only import for better tree-shaking and performance.
SinceSingleRequestProxyDeploymentis only used as a type, consider importing it with theimport typesyntax to ensure the compiler drops unnecessary imports.- import { SingleRequestProxyDeployment } from "@/lib/types"; + import type { SingleRequestProxyDeployment } from "@/lib/types";🧰 Tools
🪛 Biome (1.9.4)
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
src/components/srf-deployments-table.tsx (1)
251-255: Relying solely on row count to disable the 'Next' button may be brittle.
Currently, the button is disabled iftable.getRowModel().rows?.length < 10. This may cause issues if the page size changes or if the last page has fewer than 10 results.- disabled={ - !table.getCanNextPage() || - isFetching || - table.getRowModel().rows?.length < 10 - } + disabled={ + !table.getCanNextPage() || + isFetching + }src/lib/hooks/use-latest-srf-deployments.tsx (2)
10-15: Follow TypeScript naming conventions.The "I" prefix for interfaces is not recommended in modern TypeScript. Consider removing the "I" prefix.
-interface ILatestSRFDeployments { +interface LatestSRFDeployments { deployments: SingleRequestProxyDeployment[]; isLoading: boolean; status: string; isFetching: boolean; }
50-62: Optimize useEffect implementation.
- Extract the async function for better readability.
- Consider memoizing dependencies to prevent unnecessary re-renders.
+const prefetchDeployments = async (first: number, page: number) => { + const deployments = await prefetch(first, page * first); + return deployments; +}; useEffect(() => { if (page === 0) { return; } const params = new URLSearchParams(searchParams); params.set("page", page.toString()); replace(`${pathname}?${params.toString()}`); - (async () => { - const deployments = await prefetch(first, page * first); - setPrefetchedData(deployments); - })(); + prefetchDeployments(first, page).then(setPrefetchedData); }, [page, first, pathname, replace, searchParams]);src/components/recent-srf-deployments-table.tsx (1)
28-30: Improve environment variable handling.The current implementation has a few issues:
- No type checking for the environment variable
- No fallback value validation
+const DEFAULT_POLL_INTERVAL = 30000; +const getPollInterval = () => { + const interval = Number(process.env.NEXT_PUBLIC_POLL_INTERVAL); + return !isNaN(interval) && interval > 0 ? interval : DEFAULT_POLL_INTERVAL; +}; const { deployments, isLoading } = useLatestSRFDeployments({ - pollInterval: Number(process.env.NEXT_PUBLIC_POLL_INTERVAL) || 30000, + pollInterval: getPollInterval(), });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (11)
package.json(2 hunks)src/app/request/[id]/page.tsx(4 hunks)src/app/requests/page.tsx(1 hunks)src/app/single-request-forwarders/page.tsx(1 hunks)src/components/recent-srf-deployments-table.tsx(1 hunks)src/components/srf-deployments-table.tsx(1 hunks)src/components/srf-info-section.tsx(1 hunks)src/lib/hooks/use-latest-srf-deployments.tsx(1 hunks)src/lib/queries/srf-deployments.ts(1 hunks)src/lib/types.ts(1 hunks)src/lib/utils.ts(6 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/app/requests/page.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
- src/lib/types.ts
- package.json
- src/lib/utils.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/srf-info-section.tsx
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Use import type.
(lint/style/useImportType)
🔇 Additional comments (11)
src/app/single-request-forwarders/page.tsx (1)
8-31: Great use of a dedicated hook for pagination and data fetching.
By centralizing pagination logic in theuseState<PaginationState>and passing it touseLatestSRFDeployments, you keep the pagination state predictable and easy to maintain. The code is clear and follows good React practices.src/components/srf-info-section.tsx (2)
12-15: Conditionally rendering the component is a good approach.
You skip rendering when no deployments are present, effectively reducing unnecessary DOM usage. This helps keep the UI clean and performant.
17-95: Structured and readable table layout.
The table displays each deployment's details in a straightforward manner. Good job in linking addresses to explorers and properly handling the scenario for native tokens.src/components/srf-deployments-table.tsx (3)
3-23: Good use of type-only imports.
You’re already importingSingleRequestProxyDeploymentandColumnDefas types, which helps reduce bundle size and clarifies their usage as types only. Nicely done!
30-122: Columns definition is well-structured.
By separating each column's logic, you keep the implementation clean and maintainable. The approach to partial string rendering (e.g., slicing addresses) is user-friendly.
132-264: Smart usage of@tanstack/react-tablefor pagination and data modeling.
The manual pagination pattern and table state management are consistent. The fallback states for loading and errors are also well-handled, enhancing user experience.src/app/request/[id]/page.tsx (4)
39-40: Imports for newly introduced SRF deployments feature are clear.
Bringing infetchProxyDeploymentsByReferenceandSRFInfoSectionextends this page’s functionality without clutter.
152-159: Enabling the fetch conditionally is a nice optimization.
By usingenabled: !!longPaymentReference, you avoid unnecessary queries when no payment reference is available, reducing wasted network calls.
160-160: Combined loading check for all queries is concise.
Guarding with a singleifstatement keeps the UI logic straightforward and prevents partially rendered content.
Line range hint
368-384: Good approach to conditionally render SRF information.
DisplayingSRFInfoSectiononly whensrfDeploymentsexist helps focus on relevant data and avoids empty sections.src/lib/hooks/use-latest-srf-deployments.tsx (1)
41-48: 🛠️ Refactor suggestionEnhance error handling and query key structure.
- Error handling is missing in the implementation.
- Query key structure could be improved for better cache management.
- const { status, isLoading, data, isFetching } = useQuery({ + const { status, isLoading, data, isFetching, error } = useQuery< + SingleRequestProxyDeployment[], + Error + >({ - queryKey: ["srf-deployments", first, skip], + queryKey: ["srf-deployments", { first, skip }], queryFn: () => fetchProxyDeployments({ first, skip }), refetchInterval: pollInterval === 0 ? false : pollInterval, placeholderData: commonQueryOptions.placeholderData, staleTime: commonQueryOptions.staleTime, initialData: prefetchedData, });Likely invalid or redundant comment.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (13)
src/lib/queries/utils.ts (1)
45-67: Consider adding error handling or null checks before processing.
While the function handles anullreturn early by providing an empty array, it assumesdata[key]is valid within the loop. In scenarios wheredata[key]might be undefined or missing, this could lead to runtime errors.Object.keys(data).forEach((key) => { + if (!data[key]?.singleRequestProxyDeployments) { + return; + } const networkName = key.replace("payment_", ""); ... });src/lib/hooks/payments.ts (1)
9-154: Potential duplication across multiple network queries.
You query payments for each network individually, which can become cumbersome to maintain if more networks are added.- payment_mainnet { - payments(...) - ... - } - payment_arbitrum_one { - ... - } + # Optionally consider grouping these into a single typed network query + # or reusing a unified fragment.src/components/srf-deployments-table.tsx (1)
132-264: Consider separating table logic from pagination.
While this component effectively manages data display and pagination, extracting pagination logic into a custom hook can simplify the component, improving readability and maintainability.src/app/request/[id]/page.tsx (1)
152-159: Optional: Provide fallback or error state for SRF deployments.
Currently, there's no error-specific check for the SRF request. IffetchProxyDeploymentsByReferencefails, only the combined loading skeleton is displayed. Consider handling SRF-specific errors for more granularity.src/lib/hooks/use-latest-srf-deployments.tsx (2)
28-33: Good default parameters, but consider removingpagefrom the hook if not needed.
Ifpageis used only for side effects (URL updating, prefetch), ensure it’s essential. If the logic grows, consider separating pagination from fetching to keep the hook lean.
64-75: Memoized return value reduces re-renders.
Casting the memoized result toILatestSRFDeploymentsis acceptable, though you could remove theascasting by aligning the return types with the interface’s shape.src/components/srf-info-section.tsx (1)
1-1: Useimport typeto optimize bundling for imports used solely as types.
Static analysis suggests these imports are only used as types. Replacing them withimport typecan reduce bundle size if compiled accordingly.-import { SingleRequestProxyDeployment } from "@/lib/types"; +import type { SingleRequestProxyDeployment } from "@/lib/types";🧰 Tools
🪛 Biome (1.9.4)
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
src/components/recent-srf-deployments-table.tsx (1)
40-120: Limiting results to 10.
There is a.slice(0, 10)usage that might limit visibility for the user. To expand functionality, consider adding a “Load more” or pagination for a more scalable approach.src/components/recent-area.tsx (1)
12-14: LGTM with accessibility enhancement suggestionThe grid layout and component integration look good. Consider adding an ARIA label or heading to improve accessibility for this new section.
- <div className="md:col-span-2 w-full"> + <div className="md:col-span-2 w-full" aria-label="Recent SRF Deployments"> + <h2 className="sr-only">Recent SRF Deployments</h2> <RecentSRFDeploymentsTable />src/app/requests/page.tsx (1)
4-7: LGTM with performance optimization suggestionThe type imports and client-side directive are correctly implemented. Consider memoizing the pagination state setter to prevent unnecessary re-renders.
- const [pagination, setPagination] = useState<PaginationState>({ + const [pagination, setPagination] = useState<PaginationState>(() => ({ pageIndex: 0, pageSize: 10, - }); + }));src/lib/types.ts (1)
39-52: Add JSDoc documentation for the interface and its fields.The interface looks well-structured, but adding documentation would improve maintainability and help other developers understand the purpose of each field.
Consider adding documentation like this:
+/** + * Represents a single request proxy deployment configuration + */ export interface SingleRequestProxyDeployment { + /** Unique identifier for the deployment */ id: string; + /** Address where fees are sent */ feeAddress: string; // ... (add docs for other fields) }package.json (2)
9-11: Consider adding combined and check-only scripts.The scripts look good, but consider adding:
- A combined script to run both lint and format
- A check-only format script that doesn't write changes
Add these scripts:
"scripts": { "lint": "next lint", "format": "biome check --write .", + "format:check": "biome check .", + "check": "npm run lint && npm run format:check", "prepare": "husky install" }
44-44: Consider version locking for consistent builds.The new dev dependencies use caret (
^) versioning which allows minor version updates. For development tools that affect the build process, consider using exact versions to ensure consistent behavior across all environments.- "@biomejs/biome": "^1.9.4", + "@biomejs/biome": "1.9.4", - "husky": "^9.1.7", + "husky": "9.1.7", - "lint-staged": "^15.2.10" + "lint-staged": "15.2.10"Also applies to: 51-52
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (18)
.husky/pre-commit(1 hunks).lintstagedrc.js(1 hunks)biome.json(1 hunks)package.json(2 hunks)src/app/request/[id]/page.tsx(4 hunks)src/app/requests/page.tsx(1 hunks)src/app/single-request-forwarders/page.tsx(1 hunks)src/components/recent-area.tsx(1 hunks)src/components/recent-srf-deployments-table.tsx(1 hunks)src/components/srf-deployments-table.tsx(1 hunks)src/components/srf-info-section.tsx(1 hunks)src/lib/graphQlClient.ts(1 hunks)src/lib/hooks/payments.ts(1 hunks)src/lib/hooks/use-latest-srf-deployments.tsx(1 hunks)src/lib/queries/srf-deployments.ts(1 hunks)src/lib/queries/utils.ts(2 hunks)src/lib/types.ts(1 hunks)src/lib/utils.ts(6 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/srf-info-section.tsx
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the compilers and avoids loading unnecessary modules.
Safe fix: Use import type.
(lint/style/useImportType)
🔇 Additional comments (39)
src/lib/queries/utils.ts (2)
3-4: Imports look good.
There are no concerns with these import statements.
29-43: GraphQL fragment naming is consistent and comprehensive.
The chosen fragment nameProxyDeploymentFieldsclearly reflects its purpose, and the selected fields cover the essential attributes of aSingleRequestProxyDeployment. No issues found.src/lib/hooks/payments.ts (1)
156-164: Add error handling infetchPaymentsfunction
This concern was raised in a previous review. Wrapping the GraphQL request in atry-catchblock prevents unhandled rejections and provides clearer error management.src/lib/queries/srf-deployments.ts (4)
7-121: Consider optimizing the GraphQL query structure
This recommendation was mentioned before, suggesting reusable fragments or a more compact approach.
9-9: Fix inconsistent parameter requirements
Previously noted:$firstis optional while$skipis mandatory. They typically work together for pagination and should be equally required.
123-134: Add error handling and input validation
This function lacks checks for invalid or out-of-range parameters and does not handle network request failures.
197-206: Enhance type safety and error handling
A try-catch pattern and stricter return types can improve robustness offetchProxyDeploymentsByReference.src/components/srf-deployments-table.tsx (1)
30-122: Validate numeric conversions forfeeAmount.
In lines 90-91, convertingfeeAmountto a BigInt may throw if the value is not a valid numeric string. Consider safe parsing or extra checks.const feeAmount = row.getValue("feeAmount") as string; +if (!/^\d+$/.test(feeAmount)) { + // handle invalid numeric string scenario or fallback +} return formatUnits(BigInt(feeAmount), 18);src/app/request/[id]/page.tsx (3)
39-40: Imports are appropriate.
AddingfetchProxyDeploymentsByReferenceandSRFInfoSectionaligns with the new SRF deployment feature.
160-160: Loading condition is seamlessly integrated.
IncludingisLoadingSRFin the overall loading check ensures consistent user experience.
Line range hint
368-384: Conditional SRF section is clear and unobtrusive.
The optional rendering ofSRFInfoSectionis a sensible approach, showing SRF data only when available.src/app/single-request-forwarders/page.tsx (4)
1-2: Use of"use client"is correct.
This ensures the component is properly compiled as a client component in Next.js’ App Router.
8-13: Initialization of pagination state is clear.
The usage ofuseState<PaginationState>()withpageIndexandpageSizeis a good approach for controlling pagination.
14-19: Query parameters align well with pagination state.
It’s good to see thatskipis computed aspageIndex * pageSize, ensuring correct offset for pagination. Also, verifying that the calls touseLatestSRFDeploymentsmatch the typed parameters is recommended.
20-31: Table integration is straightforward.
PassingpaginationandsetPaginationto<SRFDeploymentsTable>is a sound approach for controlling pagination externally. This approach fosters reusability of the table component.src/lib/hooks/use-latest-srf-deployments.tsx (4)
1-2: Client directive is appropriate for a hook using Next.js’ App Router.
No issues found.
24-26: Smooth prefetch method.
Exporting anasync function prefetchwhich directly callsfetchProxyDeploymentsis straightforward. This can be a valuable approach for SSR usage or anticipating queries.
34-40: Usage of router for side-effect is beneficial.
Updating URL params on page change is well-handled. Continue verifying that the new query param logic does not break direct links or push states if the user navigates back.
50-62: Replacing URL query parameters.
Ensure that the updated URL does not cause undesired re-renders or infinite loops. So far, your checks are sound (returning early ifpage === 0).src/components/srf-info-section.tsx (2)
8-15: Graceful handling of empty or null deployments.
Returningnullearly avoids rendering empty UI elements. This is good for cleanliness.
17-95: Comprehensive display of forwarder details.
Link usage, chain identification, token handling, and timestamps are implemented correctly. Including clickable addresses to block explorers and payees is a great user experience.src/components/recent-srf-deployments-table.tsx (3)
3-30: Clear separation of UI and data fetching throughuseLatestSRFDeployments.
It’s good that you retrieve the data within this component using the hook. The environment-based poll interval is well structured.
32-38: Skeleton usage.
Returning a skeleton placeholder while loading is a good UX choice, ensuring users see immediate feedback.
36-38: No data fallback.
Displaying “No data” for empty or undefined deployments simplifies the user experience and clarifies the absence of data.src/lib/utils.ts (9)
3-19: All good on the import statements.
No major concerns with the typed imports and references; the usage of type imports promotes clarity.
37-43: Function looks fine.
The date formatting logic is appropriate for displaying a UTC timestamp with clear date/time info.
48-55: Missing explicit handling for undefined currency details.
You have not incorporated the previous suggestion to add a warning or explicit handling for unusable currency data. The code still quietly falls back to default decimals & symbol.
69-80: Console error usage is acceptable.
The short/long payment references are calculated correctly. Logging the caught error is reasonable, though you may consider a more descriptive or user-facing message.
93-138: Consider transitioning to a typed approach for the chain keys.
Refactoring to a more type-safe approach (e.g., using a typed map or deriving the chain keys dynamically) helps avoid the risk of missing or misspelling a chain key and improves maintainability.
178-180: Great use of BigInt for summing amounts.
Storing and handling priced data with BigInt is a robust approach for financial calculations.
187-192: Address rendering logic is concise.
Joining and filtering truthy parts ensures a clean, human-readable address.
196-196: Utility functions are straightforward.
BothsafeTruncateEthAddressandcapitalizeare neatly implemented and easy to read.Also applies to: 198-199
201-229: Remove debug logging in production code.
Console logs can inadvertently expose sensitive data and clutter logs. Please remove or transform them into trace-level logs if needed for debugging..husky/pre-commit (1)
1-4: Pre-commit hook is well-configured.
Runninglint-stagedensures code quality checks are performed automatically before committing..lintstagedrc.js (1)
1-4: Configuration looks good.
Applyingbiome format --writeandbiome lintto staged files validates code style and correctness on each commit.src/lib/graphQlClient.ts (1)
3-15: No issues with updated string literal formatting.
Switching to double quotes and preserving environment variable usage is consistent with the linting rules.Also applies to: 17-17
biome.json (2)
23-31: Review disabled linting rulesThe following rules are disabled:
noExplicitAny: Could lead to type-safety issuesnoNonNullAssertion: May hide potential null/undefined errorsnoForEach: Performance consideration for large datasetsConsider if these rules align with the project's quality standards. If they must be disabled, document the reasoning in the configuration file.
3-7: Verify VCS configuration impactThe VCS configuration is disabled and ignores
.gitignore. This could lead to Biome processing files that should be ignored (e.g., build artifacts, node_modules).Consider enabling VCS integration:
- "enabled": false, + "enabled": true, - "useIgnoreFile": false + "useIgnoreFile": truesrc/lib/types.ts (1)
39-52: Verify type consistency with existing interfaces.The interface structure looks good, but let's verify the type consistency:
- Common fields like
id,txHash,chainmatch types in thePaymentinterface- Consider making some fields optional if they might not always be available
- Consider using more specific types for
proxyTypeinstead of stringLet's check the usage of these fields across the codebase:
✅ Verification successful
Let me gather more information about the type consistency.
Type consistency verified, but proxyType can be improved
Based on the verification results:
- Common fields like
id,txHash,chain,tokenAddress,feeAddress,feeAmount, andtimestampmatch the types in thePaymentinterface.- All fields appear to be required in practice as there are no optional field accesses (
?.) specifically forSingleRequestProxyDeploymentfields.- The
proxyTypefield is defined as string, but no concrete values were found in the codebase, suggesting this might be an area for improvement.Recommendations:
- Consider defining a union type for
proxyTypewhen the possible values are known- Keep all fields required as the current usage suggests they are always present
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usages of SingleRequestProxyDeployment fields # to verify type consistency and optional fields # Check proxyType values rg -A 1 "proxyType.*=.*" # Check if any fields are conditionally accessed rg -A 1 "deployment\?\.|\?\."Length of output: 13834
Script:
#!/bin/bash # Search for Payment interface definition and other related types ast-grep --pattern 'interface Payment { $$$ }' # Search for proxyType values being assigned rg "proxyType: ['\"].*['\"]" # Search for SingleRequestProxyDeployment usage rg "SingleRequestProxyDeployment" -A 2Length of output: 5135
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (8)
src/lib/hooks/payments.ts (3)
12-12: Remove empty comment.The empty comment
#serves no purpose and should be removed.
9-154: Consider reducing query duplication using variables.The current implementation repeats the same query structure for each network, leading to maintenance challenges. Consider refactoring to use GraphQL aliases and a more dynamic approach.
Here's a suggested approach:
const NETWORK_NAMES = [ 'mainnet', 'arbitrum_one', 'avalanche', 'base', 'bsc', 'celo', 'fantom', 'fuse', 'matic', 'moonbeam', 'optimism', 'sepolia', 'xdai', 'zksyncera' ] as const; export const PAYMENTS_QUERY = gql` ${CORE_PAYMENT_FIELDS} query PaymentsQuery($first: Int, $skip: Int!) { ${NETWORK_NAMES.map(network => ` payment_${network}: payment_${network} { payments( first: $first skip: $skip orderBy: timestamp orderDirection: desc ) { ...PaymentFields } } `).join('')} } `;
156-169: Consider enhancing error handling and adding retries.While the basic error handling is in place, consider these improvements:
- Add specific error types for better error handling
- Include more context in error logs
- Implement retry mechanism for transient failures
Here's a suggested implementation:
type FetchPaymentsError = { message: string; code: string; networks?: string[]; }; export const fetchPayments = async (variables: { first: number; skip: number; }): Promise<Payment[]> => { const maxRetries = 3; let attempt = 0; while (attempt < maxRetries) { try { const data: { [x: string]: { payments: Payment[] } } = await graphQLClient.request(PAYMENTS_QUERY, variables); return formatPaymentData(data); } catch (err) { attempt++; const error = err as FetchPaymentsError; console.error( `Error fetching payments (attempt ${attempt}/${maxRetries}):`, { message: error.message, code: error.code, networks: error.networks, variables } ); if (attempt === maxRetries) { return []; } // Exponential backoff await new Promise(resolve => setTimeout(resolve, Math.pow(2, attempt) * 1000) ); } } return []; };src/lib/hooks/use-latest-srf-deployments.tsx (4)
18-23: Remove unused page parameter from Props interfaceThe
pageparameter in the Props interface is defined but not used in the query function. Consider removing it if it's not essential for the component's functionality.type Props = { first?: number; skip?: number; pollInterval?: number; - page?: number; };
38-40: Simplify prefetchedData state typeThe type union with
nullis unnecessary as undefined is already included by the optional type.const [prefetchedData, setPrefetchedData] = useState< - SingleRequestProxyDeployment[] | null + SingleRequestProxyDeployment[] >();
51-63: Optimize useEffect dependenciesThe current implementation might cause unnecessary re-renders due to
searchParamsbeing included in the dependency array. Consider usingsearchParams.get('page')instead.useEffect(() => { if (page === 0) { return; } const params = new URLSearchParams(searchParams); params.set("page", page.toString()); replace(`${pathname}?${params.toString()}`); (async () => { const deployments = await prefetch(first, page * first); setPrefetchedData(deployments); })(); -}, [page, first, pathname, replace, searchParams]); +}, [page, first, pathname, replace]);
65-77: Remove type assertion for better type safetyThe type assertion can be avoided by properly typing the useMemo hook.
- const value = useMemo( + const value = useMemo<LatestSRFDeployments>( () => ({ deployments: data, isLoading, status, isFetching, error, }), [data, isLoading, status, isFetching, error] ); - return value as LatestSRFDeployments; + return value;src/lib/queries/srf-deployments.ts (1)
23-137: Optimize GraphQL query structure using fragmentsThe query is repetitive and could be simplified using a network-specific fragment.
+const NETWORK_DEPLOYMENTS_FRAGMENT = gql` + fragment NetworkDeployments on Network { + singleRequestProxyDeployments( + first: $first + skip: $skip + orderBy: timestamp + orderDirection: desc + ) { + ...ProxyDeploymentFields + } + } +`; export const PROXY_DEPLOYMENTS_QUERY = gql` ${CORE_PROXY_DEPLOYMENT_FIELDS} + ${NETWORK_DEPLOYMENTS_FRAGMENT} query ProxyDeploymentsQuery($first: Int!, $skip: Int!) { payment_mainnet { - singleRequestProxyDeployments( - first: $first - skip: $skip - orderBy: timestamp - orderDirection: desc - ) { - ...ProxyDeploymentFields - } + ...NetworkDeployments } payment_arbitrum_one { - singleRequestProxyDeployments( - first: $first - skip: $skip - orderBy: timestamp - orderDirection: desc - ) { - ...ProxyDeploymentFields - } + ...NetworkDeployments } # ... repeat for other networks } `;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/components/recent-srf-deployments-table.tsx(1 hunks)src/lib/hooks/payments.ts(1 hunks)src/lib/hooks/use-latest-srf-deployments.tsx(1 hunks)src/lib/queries/srf-deployments.ts(1 hunks)src/lib/utils.ts(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/components/recent-srf-deployments-table.tsx
- src/lib/utils.ts
🔇 Additional comments (3)
src/lib/hooks/payments.ts (2)
1-8: LGTM! Clean and well-organized imports.All necessary dependencies are properly imported, and types are correctly referenced.
10-10: Verify CORE_PAYMENT_FIELDS fragment definition.The query depends on the
CORE_PAYMENT_FIELDSfragment. Let's verify its definition and fields.✅ Verification successful
Let me gather more information to see the complete fragment definition and its usage.
Let me verify one more thing to ensure we have the complete picture of how this fragment is being used.
Let me try a different approach to see the usage context.
Let me try one final approach to see the complete context.
CORE_PAYMENT_FIELDS fragment is properly defined and used
The fragment is correctly defined in
src/lib/queries/utils.tsas:fragment PaymentFields on Payment { currency amount amountInCrypto block contractAddress feeAddress feeAmount feeAmountInCrypto from gasPrice }And it's properly:
- Imported from
../queries/utils- Used in the
PAYMENTS_QUERYto share common payment fields across multiple chain-specific queries- Referenced correctly in the fragment spread
...PaymentFields🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the CORE_PAYMENT_FIELDS fragment definition rg -l "CORE_PAYMENT_FIELDS.*=.*gql" rg "fragment PaymentFields on" -A 10Length of output: 560
Script:
#!/bin/bash # Get the complete CORE_PAYMENT_FIELDS definition and its usage rg "CORE_PAYMENT_FIELDS" -A 5 src/lib/queries/utils.tsLength of output: 185
Script:
#!/bin/bash # Check how CORE_PAYMENT_FIELDS is being used in the payments hook rg -B 2 -A 5 "\${CORE_PAYMENT_FIELDS}" src/lib/hooks/payments.tsLength of output: 172
Script:
#!/bin/bash # Escape the special characters in the pattern rg -B 2 -A 5 "\\\${CORE_PAYMENT_FIELDS}" src/lib/hooks/payments.tsLength of output: 175
Script:
#!/bin/bash # Just show the content of the payments.ts file cat src/lib/hooks/payments.tsLength of output: 3353
src/lib/queries/srf-deployments.ts (1)
139-155: 🛠️ Refactor suggestionImprove type safety in fetchProxyDeployments
The function uses a generic object type for the GraphQL response. Consider using a proper interface for better type safety.
+interface NetworkResponse { + singleRequestProxyDeployments: SingleRequestProxyDeployment[]; +} +interface ProxyDeploymentsResponse { + payment_mainnet?: NetworkResponse; + payment_arbitrum_one?: NetworkResponse; + payment_avalanche?: NetworkResponse; + // ... add other networks +} export const fetchProxyDeployments = async (variables: { first: number; skip: number; }): Promise<SingleRequestProxyDeployment[]> => { try { - const data: { - [x: string]: { - singleRequestProxyDeployments: SingleRequestProxyDeployment[]; - }; - } = await graphQLClient.request(PROXY_DEPLOYMENTS_QUERY, variables); + const data = await graphQLClient.request<ProxyDeploymentsResponse>( + PROXY_DEPLOYMENTS_QUERY, + variables + ); return formatProxyDeploymentData(data); } catch (error) { console.error("Error fetching proxy deployments:", error); throw error; } };Likely invalid or redundant comment.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/lib/queries/srf-deployments.ts (3)
123-139: Enhance type safety for network keysConsider using a union type for network keys instead of the generic string index type.
+type NetworkKey = + | "payment_mainnet" + | "payment_arbitrum_one" + | "payment_avalanche" + | "payment_base" + | "payment_bsc" + | "payment_celo" + | "payment_matic" + | "payment_optimism" + | "payment_sepolia" + | "payment_xdai" + | "payment_zksyncera"; const data: { - [x: string]: { + [K in NetworkKey]?: { singleRequestProxyDeployments: SingleRequestProxyDeployment[]; }; }
202-216: Apply consistent type safety improvementsFor consistency with the previous function, consider adding type annotation for the GraphQL response.
export const fetchProxyDeploymentsByReference = async (variables: { reference: string; }): Promise<SingleRequestProxyDeployment[]> => { try { - const data = await graphQLClient.request( + const data = await graphQLClient.request<{ + [K in NetworkKey]?: { + singleRequestProxyDeployments: SingleRequestProxyDeployment[]; + }; + }>( PROXY_DEPLOYMENTS_BY_REFERENCE_QUERY, variables );
1-216: Consider centralizing network list managementThe list of supported networks is duplicated across queries. Consider extracting network names into a shared constant to make maintenance easier.
export const SUPPORTED_NETWORKS = [ 'payment_mainnet', 'payment_arbitrum_one', // ... other networks ] as const; export type NetworkKey = typeof SUPPORTED_NETWORKS[number];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/lib/queries/srf-deployments.ts(1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/lib/queries/srf-deployments.ts (1)
Learnt from: aimensahnoun
PR: RequestNetwork/request-scan#74
File: src/lib/queries/srf-deployments.ts:218-232
Timestamp: 2025-01-02T11:51:08.073Z
Learning: The user aimensahnoun prefers returning an empty array instead of throwing errors in functions like fetchProxyDeploymentsByReference to avoid crashing the entire app.
🔇 Additional comments (3)
src/lib/queries/srf-deployments.ts (3)
1-6: LGTM! Clean and well-organized importsAll imports are necessary and properly organized.
7-121: Consider optimizing the GraphQL query structureThe query structure is repetitive across networks and could benefit from using a reusable fragment.
141-200: Query structure follows the same pattern as PROXY_DEPLOYMENTS_QUERY
Resolves #71
CleanShot.2025-01-02.at.12.29.59.mp4
Summary by CodeRabbit
Release Notes
New Features
Improvements
Bug Fixes