-
Notifications
You must be signed in to change notification settings - Fork 20
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
Fix(pages): check verified contract and minor EVM contract details #1239
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
WalkthroughThis pull request refactors several React components and helper functions. The changes include simplifying the URL construction logic in the UserDocsLink component by removing the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant VerifyComponent as EvmContractVerifyBody
participant Validator
User->>VerifyComponent: Enter contract address
VerifyComponent->>Validator: Perform base verification
Validator-->>VerifyComponent: Return verification status
alt Contract is already verified
VerifyComponent->>User: Display error "Contract is already verified"
VerifyComponent->>User: Disable submission
else Verification passes
VerifyComponent->>User: Display any other errors (if present)
VerifyComponent->>User: Enable form submission
end
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
src/lib/components/upload/UploadCard.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.json". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (1)
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: 1
🔭 Outside diff range comments (1)
src/lib/pages/evm-contract-verify/index.tsx (1)
129-188
: 🛠️ Refactor suggestionRefactor isFormDisabled for better maintainability.
The function is complex and handles multiple validation scenarios. Consider breaking it down into smaller, focused functions:
const isBaseValidationSuccess = (formData: EvmContractVerifyForm) => { return ( zEvmContractVerifyBase.safeParse({ contractAddress: formData.contractAddress, licenseType: formData.licenseType, language: formData.language, compilerVersion: formData.compilerVersion, option: formData.option, }).success && formData.language !== undefined && formData.option !== undefined ); }; const isOptionValidationSuccess = ( option: EvmVerifyOptions | undefined, formData: EvmContractVerifyForm ) => { if (!option) return false; if (isVerifyByExternals(option)) return true; const baseSuccess = formData.licenseType !== undefined && formData.compilerVersion !== ""; if (!baseSuccess) return false; const optionValidators = { [EvmVerifyOptions.SolidityUploadFiles]: () => zEvmContractVerifySolidityOptionUploadFilesForm.safeParse( formData.verifyForm.solidityUploadFiles ).success, // Add other validators... }; return optionValidators[option]?.() ?? false; }; const isFormDisabled = () => { return ( !isBaseValidationSuccess(watch()) || !isOptionValidationSuccess(option, watch()) || !!evmVerifyInfo?.isVerified ); };
🧹 Nitpick comments (3)
src/lib/components/UserDocsLink.tsx (1)
27-28
: LGTM! Component structure has been simplified.The removal of the
handleLink
function and inline URL construction makes the code more straightforward and easier to understand.Consider extracting the duplicated URL construction logic.
The URL construction logic is duplicated in both the
href
andtrackWebsite
calls.export const UserDocsLink = ({ title, cta, href, isButton = false, isInline = false, isDevTool = false, mt = 8, -}: UserDocsLinkProps) => +}: UserDocsLinkProps) => { + const constructedUrl = `${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`; + return ( isButton ? ( <Link - href={`${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`} + href={constructedUrl} onClick={(e) => { - trackWebsite( - `${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}` - ); + trackWebsite(constructedUrl); e.stopPropagation(); }}Also applies to: 30-31, 32-34
src/lib/types/evm.ts (1)
190-194
: Consider moving array reversal to the UI layer.While the transformation works, reversing arrays in the type definition couples presentation logic with data structure. Consider:
- Moving the reversal to the UI components where the versions are displayed.
- Adding a separate function in a helper file to handle version sorting/ordering.
This separation would:
- Keep the type definition focused on data structure
- Allow more flexibility in how versions are ordered in different UI contexts
- Make it easier to modify the sorting logic if requirements change
- solidity_evm_versions: z - .array(z.string()) - .transform((val) => val.reverse()), + solidity_evm_versions: z.array(z.string()), - vyper_evm_versions: z.array(z.string()).transform((val) => val.reverse()), + vyper_evm_versions: z.array(z.string()),Add a helper function:
// src/lib/helpers/version.ts export const getSortedVersions = (versions: string[]) => [...versions].reverse();src/lib/pages/evm-contract-verify/index.tsx (1)
228-228
: Consider using theme tokens for spacing.The hardcoded padding values could be replaced with theme tokens for consistency.
- <PageContainer px={12} pt={9} pb={40} p={0}> + <PageContainer px="spacing.12" pt="spacing.9" pb="spacing.40" p={0}>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
src/lib/components/UserDocsLink.tsx
(2 hunks)src/lib/components/upload/UploadCard.tsx
(2 hunks)src/lib/components/upload/hooks/useCardTheme.ts
(0 hunks)src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewInfo.tsx
(2 hunks)src/lib/pages/evm-contract-verify/components/ContractLicenseInfoAccordion.tsx
(1 hunks)src/lib/pages/evm-contract-verify/helpers.ts
(1 hunks)src/lib/pages/evm-contract-verify/index.tsx
(3 hunks)src/lib/types/evm.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- src/lib/components/upload/hooks/useCardTheme.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
src/lib/pages/evm-contract-verify/components/ContractLicenseInfoAccordion.tsx (1)
47-48
: LGTM!The changes align with the updated
UserDocsLink
component interface, using the relative path andisDevTool
prop for better documentation management.src/lib/components/upload/UploadCard.tsx (1)
54-70
: LGTM! UI improvements enhance user experience.The changes improve the UI by:
- Using a more compact
IconButton
for the delete action- Adding clear hover states for better user feedback
- Maintaining accessibility with an appropriate aria-label
src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewInfo.tsx (1)
32-33
: LGTM! Layout improvements enhance responsiveness.The changes to the grid template columns and column gap values improve the component's flexibility and responsiveness:
- Using
repeat(4, max-content)
allows columns to adapt to their content.- Responsive column gaps (
base: 14, 2xl: 36
) provide better spacing across different screen sizes.Also applies to: 37-40
src/lib/pages/evm-contract-verify/index.tsx (1)
260-264
: LGTM! Improved error handling for verified contracts.The conditional error message provides better feedback by explicitly indicating when a contract is already verified.
Summary by CodeRabbit
Refactor
Style
Bug Fixes