-
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: evm create null to #1243
fix: evm create null to #1243
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
WalkthroughThis pull request updates multiple EVM transaction components and utilities. A new bug fix entry is added to the changelog for an EVM Create null check issue (PR #1243). Several components now pass an additional property Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Frontend Component
participant Chip as EvmMethodChip
participant Data as EvmInputData / TxMsgDetails
participant Utils as Utility Functions (getEvmMethod, extractErc20TransferInput)
UI->>Chip: Pass txInput, txTo
Chip->>Utils: Call getEvmMethod(txInput, txTo)
Utils-->>Chip: Return method details
Chip->>UI: Render UI based on method
UI->>Data: Provide txInput and txTo for transaction details
Data->>Utils: Get EVM method and, if ERC20, extract transfer input
Utils-->>Data: Return processed data for rendering
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/pages/evm-tx-details/data.tsOops! 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. src/lib/pages/tx-details/components/evm-related-tx-section/index.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. src/lib/components/EvmToCell.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.
✨ 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: 1
🧹 Nitpick comments (5)
src/lib/utils/evm.ts (1)
17-18
: Consider handling creation transactions withtxInput === "0x"
.
IftxTo
is null andtxInput
equals"0x"
, it may still represent a contract creation with no code. Clarify if that scenario should be handled or distinguished.src/lib/components/EvmToCell.tsx (1)
20-61
: Refactor duplicate code for created contract rendering.The JSX structure for both
Create
andCallErc20Factory
methods is identical. Consider extracting this into a reusable component.+const CreatedContractCell = ({ address }: { address: string }) => ( + <Flex direction="column"> + <Text variant="body3" color="text.disabled"> + Created Contract + </Text> + <Flex gap={1} align="center"> + <CustomIcon + name="contract-address" + boxSize={3} + color="primary.main" + /> + <ExplorerLink + value={address} + type="evm_contract_address" + showCopyOnHover + /> + </Flex> + </Flex> +); + export const EvmToCell = ({ toAddress }: EvmToCellProps) => { if (!toAddress) return ( <Text variant="body2" color="text.dark"> - </Text> ); if (toAddress.Method === EvmMethodName.Create || toAddress.Method === EvmMethodName.CallErc20Factory) - return ( - <Flex direction="column"> - <Text variant="body3" color="text.disabled"> - Created Contract - </Text> - <Flex gap={1} align="center"> - <CustomIcon - name="contract-address" - boxSize={3} - color="primary.main" - /> - <ExplorerLink - value={toAddress.address} - type="evm_contract_address" - showCopyOnHover - /> - </Flex> - </Flex> - ); + return <CreatedContractCell address={toAddress.address} />;src/lib/pages/evm-tx-details/components/EvmInputData.tsx (1)
43-48
: Remove redundant case clause.The
Raw
case is redundant as it performs the same action as the default clause.case EvmDataFormatTabs.UTF8: return Buffer.from(txInput.slice(2), "hex").toString("binary"); - case EvmDataFormatTabs.Raw: default: return txInput;
🧰 Tools
🪛 Biome (1.9.4)
[error] 45-45: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
src/lib/types/evm.ts (1)
22-35
: Consider removing the redundant address property.The TODO comment suggests that the
address
property should be removed. Since each variant of the union type includes this property, it appears to be redundant or no longer needed.Additionally, consider adding JSDoc comments to document the purpose of each variant in the union type, especially to explain when each variant is used.
src/lib/services/tx/index.ts (1)
665-668
: Simplify the enabled condition.The enabled condition is redundant as it checks
!!cosmosTxHash
twice:
- Once in the
enabled
property.- Again in the query function where it throws an error if
!cosmosTxHash
.- enabled: evm.enabled && !!evm.jsonRpc && !!cosmosTxHash, + enabled: evm.enabled && !!evm.jsonRpc,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
CHANGELOG.md
(1 hunks)src/lib/components/EvmMethodChip.tsx
(1 hunks)src/lib/components/EvmToCell.tsx
(3 hunks)src/lib/components/table/evm-transactions/EvmTransactionsTableMobileCard.tsx
(1 hunks)src/lib/components/table/evm-transactions/EvmTransactionsTableRow.tsx
(1 hunks)src/lib/pages/evm-tx-details/components/EvmInputData.tsx
(3 hunks)src/lib/pages/evm-tx-details/components/EvmTxMsgDetails.tsx
(1 hunks)src/lib/pages/evm-tx-details/components/EvmTxMsgDetailsBody.tsx
(1 hunks)src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.tsx
(1 hunks)src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxTransfer.tsx
(1 hunks)src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxTransferErc20.tsx
(5 hunks)src/lib/pages/tx-details/components/evm-related-tx-section/index.tsx
(1 hunks)src/lib/services/tx/index.ts
(2 hunks)src/lib/services/tx/jsonRpc.ts
(1 hunks)src/lib/types/evm.ts
(2 hunks)src/lib/utils/evm.ts
(5 hunks)
✅ Files skipped from review due to trivial changes (3)
- src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxCreateContract.tsx
- src/lib/services/tx/jsonRpc.ts
- CHANGELOG.md
🧰 Additional context used
🪛 Biome (1.9.4)
src/lib/pages/evm-tx-details/components/EvmInputData.tsx
[error] 45-45: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (20)
src/lib/utils/evm.ts (8)
2-8
: Imports look consistent with usage.
No concerns at this time.
35-39
: EnsureevmTxData
is always defined upstream.
getEvmToAddress
no longer acceptsOption<TxDataJsonRpc>
. Verify that calling code never passes an undefined or null transaction.
45-47
: AddedMethod
andevmTxHash
fields for Create method.
Looks good.
56-59
: Return structure forCallErc20Factory
appears consistent.
No issues noted.
61-64
: Confirm settingMethod
to null is intentional.
Ifmethod === EvmMethodName.TransferErc20
, returningMethod: null
might be confusing. Verify that consumers of this output can handle anull
method.
70-70
: ReturningMethod: null
for standard calls.
This is a valid choice as long as downstream logic expects a null for non-special transactions.
82-82
: Updated usage ofgetEvmMethod
.
Your method call matches the new signature.
86-86
: Add checks for ERC20 input validity.
Similar to earlier feedback, verify thatinput
is large enough before slicing for the amount.src/lib/components/EvmMethodChip.tsx (2)
3-9
: Extending props withtxTo
.
ProvidingtxTo
in the props aligns with the updated function signature. No immediate issues.
15-19
: Integration oftxTo
intogetEvmMethod
.
Properly passingtxTo
togetEvmMethod
ensures the method is accurately determined.src/lib/pages/evm-tx-details/components/EvmTxMsgDetails.tsx (1)
37-37
: Passing bothtxInput
andtxTo
toEvmInputData
.
This change enhances clarity and supports the expanded signature in the utility functions.src/lib/pages/evm-tx-details/components/EvmTxMsgDetailsBody.tsx (1)
24-24
: LGTM! Enhanced method determination withto
address.The addition of
evmTxData.tx.to
as a second argument togetEvmMethod
aligns with the PR objective to fix EVM Create null to handling.src/lib/components/EvmToCell.tsx (1)
13-18
: LGTM! Improved null check handling.The explicit check for
!toAddress
followed by a clear fallback UI improves the code's robustness.src/lib/pages/evm-tx-details/components/EvmInputData.tsx (1)
11-14
: LGTM! Improved prop naming and addedtxTo
parameter.The renaming of
inputData
totxInput
improves clarity, and the addition oftxTo
aligns with the PR objective.src/lib/pages/tx-details/components/evm-related-tx-section/index.tsx (1)
44-44
: LGTM! AddedtxTo
prop to EvmMethodChip.The addition of
txTo
prop is consistent with other components and aligns with the PR objective.src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxTransfer.tsx (1)
48-48
: LGTM! Consistent prop addition.The addition of
txTo={to}
prop is consistent with the PR's objective and properly handles the transaction's destination address.src/lib/pages/evm-tx-details/components/evm-tx-method/EvmTxTransferErc20.tsx (1)
31-32
: LGTM! Improved code organization.The refactoring improves code organization by:
- Using a dedicated utility function for ERC20 transfer data extraction
- Centralizing the address and amount extraction logic
- Maintaining consistent usage of extracted values
Also applies to: 33-37
src/lib/components/table/evm-transactions/EvmTransactionsTableRow.tsx (1)
75-79
:❓ Verification inconclusive
Verify address consistency.
The component uses both
evmTransaction.tx.to
(forEvmMethodChip
) andgetEvmToAddress(evmTransaction)
(for display). Ensure these values are used appropriately and consistently.
🏁 Script executed:
#!/bin/bash # Search for all usages of getEvmToAddress to understand its purpose rg "getEvmToAddress" -A 3Length of output: 2699
Verify address handling consistency.
In this file (
src/lib/components/table/evm-transactions/EvmTransactionsTableRow.tsx
), the rawevmTransaction.tx.to
is directly passed to<EvmMethodChip>
, while elsewhere (e.g., inEvmTransactionsTableMobileCard.tsx
and other parts of the codebase) the address is computed usinggetEvmToAddress(evmTransaction)
. Please verify that this discrepancy is intentional. If the computed address fromgetEvmToAddress
provides necessary formatting or validation, consider passing that value to<EvmMethodChip>
for consistency.src/lib/components/table/evm-transactions/EvmTransactionsTableMobileCard.tsx (1)
69-72
: Similar address consistency concern as in EvmTransactionsTableRow.This component has the same pattern of using both
evmTransaction.tx.to
andgetEvmToAddress(evmTransaction)
.src/lib/services/tx/index.ts (1)
744-747
: LGTM!The changes look good:
- Setting
staleTime: Infinity
prevents unnecessary refetching of data that rarely changes.- The
enabled
condition is correctly simplified.
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/lib/components/EvmToCell.tsx
(3 hunks)src/lib/types/evm.ts
(2 hunks)src/lib/utils/evm.ts
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/lib/components/EvmToCell.tsx
- src/lib/utils/evm.ts
🔇 Additional comments (3)
src/lib/types/evm.ts (3)
5-5
: LGTM!The new imports are correctly added and follow the project's import style.
Also applies to: 8-8
24-37
: LGTM! Well-designed type definition.The new
EvmToAddress
type is well-structured:
- Uses discriminated unions for type safety
- Properly handles nullable fields
- Clear separation of concerns between different address types
13-13
:✅ Verification successful
Verify the impact of renaming
Create
toBasicCreate
.The rename in
EvmMethodId
might affect other parts of the codebase that reference this enum value.Run the following script to find potential references:
🏁 Script executed:
#!/bin/bash # Description: Find references to EvmMethodId.Create or EvmMethodId.BasicCreate # Search for potential references to the old name echo "Searching for potential references to the old name 'EvmMethodId.Create':" rg "EvmMethodId\.Create" -A 2 # Search for references to the new name echo -e "\nSearching for references to the new name 'EvmMethodId.BasicCreate':" rg "EvmMethodId\.BasicCreate" -A 2Length of output: 579
Renaming Verified:
EvmMethodId.BasicCreate
is correctly propagatedThe search confirms that references to the old name
EvmMethodId.Create
no longer exist while the new name is appropriately used (e.g., insrc/lib/utils/evm.ts
withtxInput.startsWith(EvmMethodId.BasicCreate)
). No further impacts are apparent.
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 (2)
src/lib/types/evm.ts (2)
13-16
: Improve comment format for better readability.Consider restructuring the comments to better document the contract creation patterns:
- // Note: Create multiple contracts - // 2 -> 0x60A06040 - // 3 -> 0x60C06040 + // Contract creation patterns: + // - Single contract: 0x60806040 (current) + // - Two contracts: 0x60A06040 + // - Three contracts: 0x60C06040 SingleCreate = "0x60806040",
27-40
: Add JSDoc comments to document theEvmToAddress
type.Consider adding documentation to explain the purpose and usage of this type:
+/** + * Represents the destination address of an EVM transaction with its type. + * - For contract creation transactions, includes the contract address and transaction hash + * - For factory calls, includes the created token address + * - For regular transactions, includes just the recipient address + */ export type EvmToAddress = | { toType: EvmMethodName.Create; address: HexAddr20; evmTxHash: Nullable<string>; } | { toType: EvmMethodName.CallErc20Factory; address: HexAddr20; } | { toType: null; address: HexAddr20; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/lib/types/evm.ts
(2 hunks)src/lib/utils/evm.ts
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/utils/evm.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
src/lib/types/evm.ts (1)
20-25
: Maintain consistency betweenEvmMethodId
andEvmMethodName
enums.The method is named
SingleCreate
inEvmMethodId
butCreate
inEvmMethodName
. This inconsistency could lead to confusion.export enum EvmMethodName { Transfer = "Transfer", TransferErc20 = "Transfer ERC20", - Create = "Create", + Create = "Single Create", CallErc20Factory = "Call ERC20 Factory", }
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 (2)
src/lib/components/EvmToCell.tsx (2)
23-23
: Address the TODO comment about contract addresses.The TODO comment suggests there might be an issue with contract addresses that needs to be fixed.
Would you like me to help investigate and fix the contract addresses issue? Please provide more context about the problem.
13-18
: Remove unused propevmTxHash
.The
evmTxHash
prop is defined in the component's props interface but is not used within the component.const EvmToCellCreate = ({ address, }: { address: HexAddr20; - evmTxHash?: string; }) => (
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
src/lib/components/EvmToCell.tsx
(2 hunks)src/lib/pages/evm-contract-details/data.ts
(2 hunks)src/lib/pages/evm-tx-details/data.ts
(2 hunks)src/lib/pages/tx-details/components/evm-related-tx-section/index.tsx
(3 hunks)src/lib/services/searchService.ts
(2 hunks)src/lib/services/tx/index.ts
(5 hunks)src/lib/types/evm.ts
(2 hunks)src/lib/utils/evm.ts
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- src/lib/types/evm.ts
- src/lib/utils/evm.ts
- src/lib/pages/tx-details/components/evm-related-tx-section/index.tsx
- src/lib/services/tx/index.ts
🔇 Additional comments (6)
src/lib/pages/evm-contract-details/data.ts (1)
5-5
: LGTM! Clean refactoring to EVM-specific hook.The change consistently updates the import and usage to the new EVM-specific data fetching hook while maintaining the existing functionality.
Also applies to: 41-41
src/lib/pages/evm-tx-details/data.ts (1)
9-9
: LGTM! Clean refactoring to EVM-specific hook.The change consistently updates the import and usage to the new EVM-specific data fetching hook while maintaining the existing functionality.
Also applies to: 44-44
src/lib/services/searchService.ts (1)
34-34
: LGTM! Clean refactoring to EVM-specific hook.The change consistently updates the import and usage to the new EVM-specific data fetching hook while maintaining the existing validation logic for EVM transaction hashes.
Also applies to: 222-222
src/lib/components/EvmToCell.tsx (3)
3-4
: LGTM!The imports and types are well-defined and properly used.
Also applies to: 9-11
36-41
: LGTM!The null check is well-implemented with an appropriate fallback UI.
43-60
: LGTM!The conditional rendering logic is well-structured and handles all cases appropriately.
Summary by CodeRabbit
Bug Fixes
New Features
Refactor