-
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
feat: support vyper on contract details #1223
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
WalkthroughA new feature has been introduced to support Vyper on EVM contract details. The changelog now documents this addition. In the codebase, the editor components now derive the language from the selected file instead of a hardcoded value, and related types have been updated to include Vyper support. A new Optimizer component has been implemented to encapsulate and display optimization details in the EVM contract overview. Verification types and configurations have also been refactored and enhanced to streamline support for both Solidity and Vyper contract details. Changes
Sequence Diagram(s)sequenceDiagram
participant OV as OverviewVerifiedInfo
participant OP as Optimizer
participant LT as LabelText
OV->>OP: Pass evmVerifyInfo
OP->>OP: Determine type of optimizer info
alt Optimizer is a string
OP->>LT: Render LabelText with string value
else Optimizer is object or undefined
OP->>LT: Render LabelText with "Enabled/Disabled" status
end
sequenceDiagram
participant FE as FullEditor
participant E as Editor
FE->>E: Provide selectedFile (code & language)
E->>E: Render content using dynamic language prop
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (1)
✨ Finishing Touches
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: 0
🧹 Nitpick comments (3)
src/lib/pages/evm-contract-details/components/evm-contract-details-overview/Optimizer.tsx (2)
4-6
: Add documentation for optimizer configurations.Consider adding JSDoc comments to document the different optimizer configurations supported by the component.
+/** + * Props for the Optimizer component + * @property {EvmVerifyInfo} evmVerifyInfo - Contains optimizer configuration which can be: + * - A string value representing the optimization status + * - An object with enabled flag and runs count + */ interface OptimizerProps { evmVerifyInfo: EvmVerifyInfo; }
8-22
: Improve type safety with type predicates.Consider using type predicates to narrow down the optimizer types for better type safety.
+type StringOptimizer = string; +type ObjectOptimizer = { enabled: boolean; runs: number }; + +const isStringOptimizer = (optimizer: any): optimizer is StringOptimizer => + typeof optimizer === "string"; + +const isObjectOptimizer = (optimizer: any): optimizer is ObjectOptimizer => + optimizer && typeof optimizer === "object" && "enabled" in optimizer; + export const Optimizer = ({ evmVerifyInfo: { optimizer } }: OptimizerProps) => { - if (typeof optimizer === "string") { + if (isStringOptimizer(optimizer)) { return <LabelText label="Optimization">{optimizer}</LabelText>; } return ( <LabelText label="Optimization Enabled"> - {optimizer - ? optimizer.enabled + {isObjectOptimizer(optimizer) + ? optimizer.enabled ? `Yes with ${optimizer.runs} runs` : "No" : "N/A"} </LabelText> ); };src/lib/pages/evm-contract-details/components/evm-contract-details-contract-info/ContractCode.tsx (1)
65-65
: LGTM! Consider extracting language mapping.The implementation correctly sets the editor language based on file extension. However, consider extracting the language mapping logic for better maintainability.
+const getEditorLanguage = (filePath: string): "python" | "sol" => { + const LANGUAGE_MAP: Record<string, "python" | "sol"> = { + ".vy": "python", + ".sol": "sol", + }; + const ext = filePath.substring(filePath.lastIndexOf(".")); + return LANGUAGE_MAP[ext] || "sol"; +}; + - editorLanguage={contractPath.endsWith(".vy") ? "python" : "sol"} + editorLanguage={getEditorLanguage(contractPath)}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
CHANGELOG.md
(1 hunks)src/lib/components/editor/FullEditor.tsx
(2 hunks)src/lib/components/editor/types.ts
(1 hunks)src/lib/pages/evm-contract-details/components/evm-contract-details-contract-info/ContractCode.tsx
(1 hunks)src/lib/pages/evm-contract-details/components/evm-contract-details-overview/Optimizer.tsx
(1 hunks)src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewVerifiedInfo.tsx
(2 hunks)src/lib/services/types/verification/evm.ts
(8 hunks)src/lib/utils/evm.ts
(1 hunks)
🔇 Additional comments (8)
src/lib/components/editor/types.ts (1)
1-1
: LGTM! Extension added for Vyper support.The addition of the "vy" extension to
EXTENSION_LIB
aligns with the PR objective to support Vyper files.src/lib/pages/evm-contract-details/components/evm-contract-details-overview/OverviewVerifiedInfo.tsx (1)
34-34
: LGTM! Good component extraction.The optimization display logic has been cleanly extracted into a separate component, improving code organization while maintaining the existing layout.
src/lib/components/editor/FullEditor.tsx (1)
15-21
: LGTM! Well-implemented language support.The addition of the
editorLanguage
prop and its integration with the Editor component is clean and follows React best practices.Also applies to: 23-30
src/lib/utils/evm.ts (1)
139-139
: LGTM! Improved input validation.The change enhances the constructor arguments validation by checking both existence and non-emptiness of the inputs array, which is a good defensive programming practice.
src/lib/services/types/verification/evm.ts (3)
146-155
: LGTM! Well-structured verification config.The verification config schema is well-defined with proper type transformations and validation.
183-199
: LGTM! Robust optimizer parsing.The optimizer JSON parsing includes proper error handling and type validation using Zod.
201-204
: LGTM! Good Vyper support.The Vyper optimizer enum properly handles all possible optimization values with a default.
CHANGELOG.md (1)
42-42
: LGTM! Clear changelog entry.The changelog entry follows the project's conventions and clearly documents the Vyper support feature.
Summary by CodeRabbit
New Features
Refactor