-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add withdrawal tx info #440
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
base: main
Are you sure you want to change the base?
Conversation
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 adds withdrawal transaction information to the delegation data structures, enabling the API to expose withdrawal transaction details when available.
Key Changes:
- Added
WithdrawalTxstruct to the database model layer with transaction details and timestamp - Added corresponding
WithdrawalInfostruct to the service layer with ISO-formatted timestamp - Implemented conditional mapping logic to include withdrawal info in API responses when present
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/indexer/db/model/delegation.go | Defines WithdrawalTx struct with BSON tags and adds it as an optional field to IndexerDelegationDetails |
| internal/v2/service/delegation.go | Defines WithdrawalInfo struct with JSON tags, adds it to DelegationPublic, and implements mapping logic in FromDelegationDocument |
The implementation is clean and follows established patterns in the codebase. The changes properly handle optional withdrawal data by checking for non-empty transaction hash before mapping, consistent with how unbonding transactions are handled elsewhere. The use of appropriate struct tags (bson for database, json for API) and omitempty flags ensures proper serialization at each layer.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b5d2b8 to
4b05d7d
Compare
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.
what about existing delegations? should we run a migration?
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.
i think it's fine.... until someone ask for it.
| } | ||
|
|
||
| type WithdrawalTx struct { | ||
| TxHash string `bson:"tx_hash"` |
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.
optional
No description provided.