-
Notifications
You must be signed in to change notification settings - Fork 14
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
refactor: standardize checkpoint address format #852
Conversation
WalkthroughThe changes introduce a new address conversion function Changes
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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: 2
🧹 Nitpick comments (1)
x/crosschain/types/types.go (1)
530-539
: Consider defining constants for bridge identifiersThe gravityId values are hardcoded strings. Consider defining them as package-level constants for better maintainability.
+const ( + TronBridgeID = "fx-tron-bridge" + TronBridgeTestnetID = "fx-tron-bridge-testnet" +) func toHexAddr(gravityId, addr string) gethcommon.Address { - if gravityId == "fx-tron-bridge" || gravityId == "fx-tron-bridge-testnet" { + if gravityId == TronBridgeID || gravityId == TronBridgeTestnetID {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
x/crosschain/types/types.go
(7 hunks)
🔇 Additional comments (2)
x/crosschain/types/types.go (2)
15-15
: LGTM: Import for Tron address handling
The addition of the gotron-sdk package is appropriate for handling Tron address conversions.
530-539
: Verify address conversion usage across the codebase
Let's verify if there are other locations in the codebase that might need similar address conversion logic.
✅ Verification successful
Address conversion logic is correctly implemented and isolated
Based on the search results, the address conversion logic is appropriately placed and doesn't require changes in other locations. Here's why:
-
The Base58 address conversion is only used in two specific modules:
x/tron/types/address.go
: Contains Tron-specific address handlingx/crosschain/types/types.go
: The file under review, which handles cross-chain conversions
-
The
gravityId
check for "fx-tron-bridge" and "fx-tron-bridge-testnet" is unique to the cross-chain module and correctly determines when to use Base58 conversion for Tron addresses. -
All other address conversions in the codebase use
HexToAddress
directly, which is the correct behavior for Ethereum-style addresses.
The implementation maintains a clear separation of concerns where Tron-specific address handling is properly isolated to the relevant modules, and the conditional logic in toHexAddr
correctly routes the conversion based on the bridge type.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for potential address conversion patterns
echo "Searching for HexToAddress usage..."
rg "HexToAddress\(" --type go
echo -e "\nSearching for Base58 address patterns..."
rg "Base58.*ddress" --type go
echo -e "\nSearching for gravityId references..."
rg "gravityId.*=|gravityID.*=" --type go
Length of output: 7244
Summary by CodeRabbit