-
Notifications
You must be signed in to change notification settings - Fork 898
chore(bank-prec): Update bank precompile doc to specify decimals used #2924
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 pull request implements various cosmetic changes across multiple files in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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 and nitpick comments (1)
precompiles/bank/bank.go (1)
24-25
: Approved: Constant renamed for clarityThe renaming of
GasBalanceOf
toGasBalances
improves code clarity and better reflects its purpose. The gas cost value remains unchanged, maintaining the existing behavior.Consider updating any related documentation or comments that might reference the old constant name
GasBalanceOf
to ensure consistency throughout the codebase.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- precompiles/bank/IBank.sol (2 hunks)
- precompiles/bank/bank.go (4 hunks)
- precompiles/bank/integration_test.go (2 hunks)
- precompiles/bank/query.go (7 hunks)
- precompiles/bank/types.go (1 hunks)
✅ Files skipped from review due to trivial changes (2)
- precompiles/bank/IBank.sol
- precompiles/bank/types.go
🧰 Additional context used
🔇 Additional comments (12)
precompiles/bank/query.go (5)
7-7
: LGTM: Import of fmt packageThe addition of the "fmt" package import is appropriate for the improved error handling mentioned in the summary.
27-30
: LGTM: Improved documentation for Balances methodThe updated documentation provides clearer information about the method's behavior, specifically:
- It now mentions that balances are returned for all tokens registered in the x/bank module.
- It clarifies that the returned amounts maintain the original decimal precision.
These changes align well with the PR objectives and improve the overall clarity of the code.
40-40
: LGTM: Enhanced error handling in Balances methodThe error message has been improved to provide more context, specifying that the error occurred in the bank precompile. This enhancement will facilitate easier debugging and aligns with the overall goal of improving error handling mentioned in the summary.
71-73
: LGTM: Improved documentation and error handlingThe changes in the TotalSupply and SupplyOf methods are consistent with the improvements made throughout the file:
- The documentation for both methods has been enhanced to provide more clarity on their behavior and the precision of returned amounts.
- Error handling in the SupplyOf method has been improved, providing more context in the error message.
These changes align well with the PR objectives of enhancing documentation and improving error handling.
Also applies to: 110-114, 123-123
Line range hint
1-135
: Overall assessment: Improvements enhance code quality and documentationThe changes in this file consistently improve the code quality through:
- Enhanced documentation for all methods, providing clearer information about their behavior and the precision of returned amounts.
- Improved error handling, offering more context in error messages.
- Consistent naming updates (e.g., GasBalanceOf to GasBalances).
These improvements align well with the PR objectives and will contribute to better maintainability and usability of the code. The only pending item is the verification of the GasBalances constant definition and usage.
precompiles/bank/bank.go (4)
3-6
: Excellent documentation addition!The new comment block provides a clear and concise overview of the package's purpose. It accurately describes that the bank precompile is for querying the bank module and returns information in the original decimal representation. This addition aligns well with the PR objectives of enhancing the documentation and providing better clarity.
48-49
: Approved: Improved method documentationThe updated comment for the
NewPrecompile
function now clearly states that it implements thePrecompiledContract
interface. This change enhances the documentation's accuracy and provides better context for developers working with this code.
94-94
: Approved: Consistent gas cost reference updateThe gas cost reference has been correctly updated from
GasBalanceOf
toGasBalances
in theRequiredGas
method. This change maintains consistency with the earlier constant renaming and ensures that the correct gas cost is applied for theBalancesMethod
.
Line range hint
1-150
: Summary: Documentation and naming improvementsThe changes in this file focus on improving documentation and naming conventions without altering the underlying functionality of the bank precompile. Key improvements include:
- Addition of a clear package description comment.
- Renaming of the
GasBalanceOf
constant toGasBalances
for better clarity.- Updated method comment for
NewPrecompile
to specify interface implementation.- Consistent update of the gas cost reference in the
RequiredGas
method.These changes align well with the PR objectives of enhancing the bank precompile documentation and provide better clarity for developers working with this code.
precompiles/bank/integration_test.go (3)
222-222
: LGTM: Consistent naming for gas calculationThe renaming of
GasBalanceOf
toGasBalances
improves consistency in the naming convention for gas-related constants. The logic of the gas calculation remains unchanged.
365-365
: LGTM: Consistent renaming appliedThe renaming of
GasBalanceOf
toGasBalances
has been consistently applied here as well, maintaining uniformity throughout the file. The gas calculation logic remains intact.
Line range hint
1-437
: Summary: Consistent renaming of gas constantThe changes in this file are limited to renaming the constant
GasBalanceOf
toGasBalances
in two locations (lines 222 and 365). This modification improves naming consistency for gas-related constants without altering the underlying logic of the tests. The changes are straightforward and do not introduce any new issues or potential problems.
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.
LGTM! Thanks @0xstepit !!
The bank precompile allows only queries to the bank module and no state transitions. For this reason, no updates to the code are required. A clear description of the assumption to always return the original decimals representation stored in the bank module is added with this PR.
Summary by CodeRabbit
Balances
andSupplyOf
methods for better context.IBank
interface and related comments.