-
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
Feature/evm contract verfied abi #1206
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
WalkthroughThis pull request introduces EVM contract details ABI functionality, enhancing the contract verification and details display process. The changes include adding a new query key for EVM verification information, creating a Changes
Sequence DiagramsequenceDiagram
participant User
participant EvmContractDetailsPage
participant VerificationService
participant API
User->>EvmContractDetailsPage: View Contract Details
EvmContractDetailsPage->>VerificationService: Fetch Verify Info
VerificationService->>API: getEvmVerifyInfo(chainId, contractAddress)
API-->>VerificationService: Return Verification Data
VerificationService-->>EvmContractDetailsPage: Provide ABI
EvmContractDetailsPage->>User: Display Contract ABI
Possibly related PRs
Suggested reviewers
Poem
✨ 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 (
|
…vm-contract-verfied-abi
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: 4
🧹 Nitpick comments (3)
src/lib/pages/evm-contract-verify/helpers.ts (1)
3-7
: Consider consolidating imports for better maintainability.The imports from
lib/services/types
could be more concise.-import { - EvmProgrammingLanguage, - EvmVerifyConfig, - EVMVerifyLicenseType, -} from "lib/services/types"; +import type { EvmProgrammingLanguage, EvmVerifyConfig, EVMVerifyLicenseType } from "lib/services/types";src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractAbi.tsx (1)
5-7
: Consider strengthening the type safety of the ABI propThe
abi
prop is typed as a string, but contract ABIs have a specific structure. Consider using a stricter type definition to catch potential issues at compile time.interface ContractAbiProps { - abi: string; + abi: Array<{ + type: string; + name?: string; + inputs?: Array<{ + name: string; + type: string; + components?: Array<{ + name: string; + type: string; + }>; + }>; + outputs?: Array<{ + name: string; + type: string; + }>; + stateMutability?: string; + }>; }src/lib/services/verification/evm/index.ts (1)
17-28
: Review query configuration settingsThe current configuration has some potential concerns:
staleTime: Infinity
prevents refetching even when data might have changed- Limited retry attempts might not be sufficient for transient failures
- Missing error handling callback
export const useEvmVerifyInfo = (contractAddress: HexAddr20) => { const { chainId } = useCurrentChain(); return useQuery({ queryKey: [CELATONE_QUERY_KEYS.EVM_VERIFY_INFO, chainId, contractAddress], queryFn: () => getEvmVerifyInfo(chainId, contractAddress), refetchOnWindowFocus: false, - retry: 1, + retry: 3, - staleTime: Infinity, + staleTime: 5 * 60 * 1000, // 5 minutes retryOnMount: false, + onError: (error) => { + console.error('Failed to fetch verification info:', error); + }, }); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
CHANGELOG.md
(1 hunks)src/lib/app-provider/env.ts
(1 hunks)src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/ContractAbi.tsx
(1 hunks)src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx
(3 hunks)src/lib/pages/evm-contract-verify/components/EvmContractVerifyOptions.tsx
(1 hunks)src/lib/pages/evm-contract-verify/components/EvmVersionToTarget.tsx
(1 hunks)src/lib/pages/evm-contract-verify/helpers.ts
(1 hunks)src/lib/pages/evm-contract-verify/index.tsx
(1 hunks)src/lib/pages/evm-contract-verify/types.ts
(1 hunks)src/lib/services/types/verification/evm.ts
(2 hunks)src/lib/services/verification/evm/api.ts
(1 hunks)src/lib/services/verification/evm/index.ts
(2 hunks)
🔇 Additional comments (11)
src/lib/pages/evm-contract-verify/components/EvmVersionToTarget.tsx (1)
3-3
: LGTM! Import consolidation looks good.The consolidation of imports from
lib/services/types
aligns with the centralization of type definitions.src/lib/services/types/verification/evm.ts (3)
5-8
: LGTM! Clear and well-defined enum.The
EvmProgrammingLanguage
enum effectively centralizes the supported programming languages for EVM contracts.
38-46
: LGTM! Well-structured source file schema.The
zEvmVerifyInfoSourceFile
schema properly validates source file information with appropriate transformations.
48-69
: Address the TODO comment for libraries field.The schema looks comprehensive, but there's an unimplemented TODO comment for libraries that needs attention.
Would you like me to help implement the libraries array schema? I can propose an implementation based on common EVM contract library structures.
Also, let's verify the completeness of the schema:
✅ Verification successful
Libraries field should be an array of library objects with name and address
The libraries field should be implemented as:
libraries: z.array( z.object({ name: z.string().min(1), address: zHexAddr20 }) )This matches the UI implementation in ContractLibraries.tsx and follows EVM contract library linking conventions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any library-related fields in contract verification rg -g '*.{ts,tsx}' 'librar(y|ies)' --type-add 'tsx:*.tsx'Length of output: 751
Script:
#!/bin/bash # Check ContractLibraries component implementation and related types cat src/lib/pages/evm-contract-verify/components/ContractLibraries.tsx # Search for any library-related types or interfaces ast-grep --pattern 'interface $_ { $$$ librar$_ $$$ }' # Search for any library-related type definitions ast-grep --pattern 'type $_ = { $$$ librar$_ $$$ }'Length of output: 3585
src/lib/pages/evm-contract-verify/components/EvmContractVerifyOptions.tsx (1)
3-4
: LGTM! Clean import organization.The separation of imports improves code organization while maintaining functionality.
src/lib/pages/evm-contract-verify/types.ts (1)
1-1
: LGTM! Proper type centralization.The removal of the local enum in favor of the centralized import improves maintainability and consistency.
src/lib/pages/evm-contract-verify/index.tsx (1)
45-45
: LGTM! Import consolidation improves type consistency.The addition of
EvmProgrammingLanguage
import fromlib/services/types
aligns with the centralization of type definitions, making the codebase more maintainable.src/lib/pages/evm-contract-verify/helpers.ts (1)
2-7
: Verify type consistency across the codebase.Let's ensure the centralized types are consistently used across all EVM-related components.
✅ Verification successful
Types are consistently defined and imported across the codebase
The
EvmProgrammingLanguage
type is properly centralized insrc/lib/services/types/verification/evm.ts
and consistently imported and used across all EVM contract verification components.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any remaining local definitions or inconsistent imports of EvmProgrammingLanguage # Check for local enum/type definitions rg -t typescript "enum\s+EvmProgrammingLanguage|type\s+EvmProgrammingLanguage" # Check for inconsistent imports rg -t typescript "import.*EvmProgrammingLanguage.*from\s+(?!.*lib/services/types)"Length of output: 506
Script:
#!/bin/bash # Search for type definitions using ast-grep ast-grep --pattern 'enum EvmProgrammingLanguage { $$$ }' ast-grep --pattern 'type EvmProgrammingLanguage = $$$' # Search for imports using simpler patterns rg "import.*EvmProgrammingLanguage" --type ts # Also check for actual usage rg "EvmProgrammingLanguage\." --type ts rg ":\s*EvmProgrammingLanguage" --type tsLength of output: 1958
src/lib/pages/evm-contract-details/components/EvmContractDetailsContarct/index.tsx (1)
Line range hint
32-33
: Remove or update TODO commentThere's a TODO comment about supporting all status. Either implement the missing status support or create an issue to track this work item.
src/lib/app-provider/env.ts (1)
175-175
: LGTM!The new query key
EVM_VERIFY_INFO
follows the established naming convention and pattern. This addition is well-integrated with the existing enum structure.CHANGELOG.md (1)
42-42
: LGTM!The changelog entry follows the Keep a Changelog format and provides clear information about the new feature with proper PR reference.
Summary by CodeRabbit
New Features
Improvements
Technical Updates