-
Notifications
You must be signed in to change notification settings - Fork 44
Remove case insensitivity from asset code #967
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
|
stellar-disbursement-platform-backend-preview is available here: |
9767f36 to
6c07f85
Compare
|
stellar-disbursement-platform-backend-preview is available here: |
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.
Pull request overview
This PR removes case-insensitive comparisons for asset codes throughout the codebase, making them case-sensitive to align with Stellar's asset code standards. The changes replace strings.ToUpper() and strings.EqualFold() calls with direct equality checks, and introduce a new constant XLMAssetCodeAlias for the "NATIVE" alias. Only uppercase "XLM" and "NATIVE" are now recognized as native asset codes.
Key changes:
- Removed case-insensitive string operations (
ToUpper(),EqualFold()) from asset code comparisons - Added
XLMAssetCodeAliasconstant with value "NATIVE" alongside existingXLMAssetCode("XLM") - Updated all native asset checks to explicitly compare against both "XLM" and "NATIVE" constants
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/services/assets/assets_pubnet.go | Added XLMAssetCodeAlias constant for "NATIVE" |
| internal/data/assets.go | Replaced case-insensitive comparisons with case-sensitive equality checks for asset codes |
| internal/data/assets_test.go | Updated test cases to verify case-sensitive behavior |
| internal/data/fixtures.go | Updated fixture creation to check for both "XLM" and "NATIVE" explicitly |
| internal/transactionsubmission/transaction_worker.go | Replaced case-insensitive XLM check with explicit constant comparisons |
| internal/transactionsubmission/transaction_worker_test.go | Updated test to use asset constants instead of case-insensitive comparison |
| internal/transactionsubmission/services/horizon.go | Removed uppercasing from asset ID formatting |
| internal/services/payment_to_submitter_service.go | Updated payment validation to use case-sensitive asset code checks |
| internal/services/send_receiver_wallets_invite_service.go | Updated native asset detection to use exact constant matches |
| internal/services/send_receiver_wallets_invite_service_test.go | Added test cases for case-sensitive asset code behavior |
| internal/serve/httphandler/assets_handler.go | Removed uppercasing from asset creation and updated native asset checks |
| internal/serve/validators/wallet_validator.go | Updated asset type inference to use case-sensitive comparisons |
| internal/serve/validators/wallet_validator_test.go | Updated tests to verify case-sensitive asset code handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
stellar-disbursement-platform-backend-preview is available here: |
|
stellar-disbursement-platform-backend-preview is available here: |
marwen-abid
left a comment
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! Thank you for being thorough with the fix.
What
This PR makes the asset codes case sensitive everywhere in the codebase. Since assets that are enabled by default, and assets added through the asset API are uppercased before being persisted, disbursements with these assets should not break from upgrading. However, if assets with lowercase asset codes were added to the database, existing disbursements will break. This is considered an edge case, and we should note that the user should audit their assets table and fix any assets before upgrading.
Detect problematic assets:
Fix problematic assets:
Why
Stellar asset codes are case sensitive, so we shouldn't be uppercasing asset codes.
Known limitations
N/A
Checklist
SDP-1234: Add new featureorChore: Refactor package xyzformat. The Jira ticket code was included if available.CHANGELOG.mdis updated (if applicable)