-
Notifications
You must be signed in to change notification settings - Fork 902
chore(evm): move wrappers utils to types pkg #2905
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
Conversation
WalkthroughThe changes in this pull request primarily involve the refactoring of function calls related to EVM coin denomination and balance adjustments. The Changes
Possibly related PRs
Suggested labels
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.
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
📒 Files selected for processing (4)
- x/evm/statedb/state_object.go (2 hunks)
- x/evm/types/scaling.go (4 hunks)
- x/evm/types/scaling_test.go (5 hunks)
- x/evm/wrappers/bank.go (4 hunks)
🔇 Additional comments (18)
x/evm/types/scaling.go (4)
30-31
: Changes in ConvertEvmCoinFrom18Decimals are consistent and correct.The modifications in this function align with the changes made in the previous function, maintaining consistency throughout the file. The error message has been appropriately updated to reflect the new method call.
Also applies to: 34-34
43-43
: Changes in ConvertCoinsFrom18Decimals are consistent and correct.The modifications in this function maintain consistency with the changes made in the previous functions. The overall logic of the function remains intact, ensuring that only the EVM coin's amount is converted while preserving other coins in the collection.
Also applies to: 48-48
17-18
: Function updates look good, verify new method accessibility.The changes to
MustConvertEvmCoinTo18Decimals
simplify the function calls by removing theevmtypes
package prefix. This aligns with the move to thetypes
package.To ensure the new methods are properly defined and accessible, run the following script:
#!/bin/bash # Description: Verify the existence and accessibility of GetEVMCoinDenom() and GetEVMCoinDecimals() methods. # Test 1: Check for the definition of GetEVMCoinDenom() echo "Checking for GetEVMCoinDenom() definition:" rg --type go 'func GetEVMCoinDenom\(\)' x/evm/types/ # Test 2: Check for the definition of GetEVMCoinDecimals() echo "Checking for GetEVMCoinDecimals() definition:" rg --type go 'func GetEVMCoinDecimals\(\)' x/evm/types/Also applies to: 21-21
4-4
: Package name change looks good.The package name change from
wrappers
totypes
aligns with the PR objective of moving wrapper utils to the types package.To ensure this change doesn't break existing imports, run the following script:
✅ Verification successful
Package name change verified.
No remaining imports of the
wrappers
package found, and no naming conflicts detected in thetypes
package.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining imports of the old package name and verify no naming conflicts in the types package. # Test 1: Search for any remaining imports of the old package name echo "Checking for remaining imports of 'wrappers' package:" rg --type go 'import.*".*evm/types/wrappers"' # Test 2: Check for potential naming conflicts in the types package echo "Checking for potential naming conflicts in the types package:" rg --type go '^type \w+ struct {' x/evm/types/Length of output: 692
Script:
#!/bin/bash # Description: Check for any remaining imports of the old package name and verify no naming conflicts in the types package. # Test 1: Search for any remaining imports of the old package name echo "Checking for remaining imports of 'wrappers' package:" rg --type go 'import.*".*evm/types/wrappers"' # Test 2: Check for potential naming conflicts in the types package echo "Checking for potential naming conflicts in the types package:" rg --type go '^type \w+ struct {' x/evm/types/Length of output: 452
Script:
#!/bin/bash # Description: Check for any remaining imports of the old package name and verify no naming conflicts in the types package. # Test 1: Search for any remaining imports of the old package name echo "Checking for remaining imports of 'wrappers' package:" rg --type go 'import.*".*evm/types/wrappers"' # Test 2: Check for potential naming conflicts in the types package echo "Checking for potential naming conflicts in the types package:" rg --type go '^type \w+ struct \{' x/evm/types/Length of output: 4246
x/evm/wrappers/bank.go (5)
44-44
: LGTM: Consistent use of types packageThe change to use
types.ConvertEvmCoinFrom18Decimals
is consistent with the PR objective and improves code clarity by explicitly showing where the function is defined.
62-62
: LGTM: Consistent modificationThe change to use
types.ConvertEvmCoinFrom18Decimals
is consistent with the PR objective and the previous modification, maintaining consistency throughout the file.
92-92
: LGTM: Consistent modificationThe change to use
types.ConvertCoinsFrom18Decimals
is consistent with the PR objective and previous modifications, maintaining consistency throughout the file.
101-101
: LGTM: Consistent modification and overall improvementThe change to use
types.ConvertCoinsFrom18Decimals
is consistent with the PR objective and previous modifications. This final change completes the set of modifications in this file, resulting in a consistent use of thetypes
package for all conversion functions.Overall, these changes improve code clarity and organization by explicitly showing where these functions are defined. The modifications align well with the PR objective of moving wrapper utils to the types package.
85-85
: LGTM with a suggestion: Verify error handlingThe change to use
types.MustConvertEvmCoinTo18Decimals
is consistent with the PR objective. However, the use of a "Must" function implies that this function will panic if an error occurs.Please verify that potential panics are properly handled in the calling code. Run the following script to check for proper error handling:
x/evm/statedb/state_object.go (3)
113-113
: LGTM. Consistent with the change in AddBalance.The change from
wrappers.AdjustExtraDecimalsBigInt
totypes.AdjustExtraDecimalsBigInt
in theSubBalance
method is consistent with the similar change made in theAddBalance
method. This consistency is good for maintaining a uniform codebase.
Line range hint
1-265
: Overall assessment: Changes are consistent and align with PR objectives.The modifications in this file are part of the larger effort to move wrapper utils to the types package. The functionality of the
stateObject
remains unchanged, which is good.To ensure consistency across the codebase:
- Check other files in the PR for similar changes from
wrappers
totypes
.- Update any relevant documentation or comments that might reference the old
wrappers
package.- Consider updating any tests that might be affected by this change.
Please run the following script to check for similar changes in other files:
#!/bin/bash # Description: Check for similar changes from wrappers to types in other files # Search for files with changes from wrappers to types echo "Files with changes from wrappers to types:" rg --type go -e 'wrappers\.(\w+)' -e 'types\.\1' --stats # List files that still use the wrappers package echo "Files still using the wrappers package:" rg --type go 'import\s+.*"github\.com/evmos/evmos/v\d+/x/evm/wrappers"' -l
103-103
: LGTM. Verify imports and usage across the codebase.The change from
wrappers.AdjustExtraDecimalsBigInt
totypes.AdjustExtraDecimalsBigInt
aligns with the PR objective of moving wrapper utils to the types package. The functionality remains the same, which is good.Please run the following script to ensure that all imports and usages have been updated correctly across the codebase:
✅ Verification successful
Import and usage migration verified successfully.
All instances of
AdjustExtraDecimalsBigInt
have been correctly migrated from thewrappers
package to thetypes
package. No remaining references towrappers.AdjustExtraDecimalsBigInt
were found, and existing usages are properly updated.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify imports and usages of AdjustExtraDecimalsBigInt # Check for any remaining imports of wrappers.AdjustExtraDecimalsBigInt echo "Checking for remaining imports of wrappers.AdjustExtraDecimalsBigInt:" rg --type go 'import\s+.*"github\.com/evmos/evmos/v\d+/x/evm/wrappers"' # Check for any remaining usages of wrappers.AdjustExtraDecimalsBigInt echo "Checking for remaining usages of wrappers.AdjustExtraDecimalsBigInt:" rg --type go 'wrappers\.AdjustExtraDecimalsBigInt' # Check for new imports of types.AdjustExtraDecimalsBigInt echo "Checking for new imports of types.AdjustExtraDecimalsBigInt:" rg --type go 'import\s+.*"github\.com/evmos/evmos/v\d+/x/evm/types"' # Check for new usages of types.AdjustExtraDecimalsBigInt echo "Checking for new usages of types.AdjustExtraDecimalsBigInt:" rg --type go 'types\.AdjustExtraDecimalsBigInt'Length of output: 630
Script:
#!/bin/bash # Description: Verify imports and usages of AdjustExtraDecimalsBigInt # Check for any remaining imports of wrappers.AdjustExtraDecimalsBigInt echo "Checking for remaining imports of wrappers.AdjustExtraDecimalsBigInt:" rg --type go 'import\s+.*"github\.com/evmos/evmos/v\d+/x/evm/wrappers"' # Check for any remaining usages of wrappers.AdjustExtraDecimalsBigInt echo "Checking for remaining usages of wrappers.AdjustExtraDecimalsBigInt:" rg --type go 'wrappers\.AdjustExtraDecimalsBigInt' # Check for new imports of types.AdjustExtraDecimalsBigInt echo "Checking for new imports of types.AdjustExtraDecimalsBigInt:" rg --type go 'import\s+.*"github\.com/evmos/evmos/v\d+/x/evm/types"' # Check for new usages of types.AdjustExtraDecimalsBigInt echo "Checking for new usages of types.AdjustExtraDecimalsBigInt:" rg --type go 'types\.AdjustExtraDecimalsBigInt'Length of output: 1045
x/evm/types/scaling_test.go (6)
4-4
: LGTM: Package name change is appropriate.The package name change from
wrappers_test
totypes_test
aligns with the PR objective of moving wrapper utils to the types package and is consistent with the file location.
83-83
: LGTM: Function call updated correctly.The change from
wrappers.MustConvertEvmCoinTo18Decimals
toevmtypes.MustConvertEvmCoinTo18Decimals
is consistent with the PR objective. The function signature remains the same, ensuring that the test logic is unaffected.
149-149
: LGTM: Function call updated appropriately.The change from
wrappers.ConvertEvmCoinFrom18Decimals
toevmtypes.ConvertEvmCoinFrom18Decimals
aligns with the PR objective. The function signature remains unchanged, preserving the test logic integrity.
209-209
: LGTM: Function call updated correctly.The modification from
wrappers.ConvertCoinsFrom18Decimals
toevmtypes.ConvertCoinsFrom18Decimals
is in line with the PR objective. The function signature remains intact, ensuring that the test logic is preserved.
262-262
: LGTM: Function call updated appropriately.The change from
wrappers.AdjustExtraDecimalsBigInt
toevmtypes.AdjustExtraDecimalsBigInt
is consistent with the PR objective. The function signature remains the same, ensuring that the test logic is unaffected.
Line range hint
1-269
: Overall assessment: Changes are consistent and well-implemented.The modifications in this file align perfectly with the PR objective of moving wrapper utils to the types package. All changes are limited to updating the package name from
wrappers
toevmtypes
, which is a good practice for maintaining code organization. The test logic remains unchanged, ensuring that the existing functionality is preserved. These changes contribute to a more organized and maintainable codebase.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
Reviewers Checklist
All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.
I have...
Unreleased
section inCHANGELOG.md
Summary by CodeRabbit
New Features
types
package across various methods in the BankWrapper struct.Refactor
Bug Fixes