Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/indexer/db/model/delegation.go
Copy link
Contributor

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?

Copy link
Collaborator

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.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ type SlashingTx struct {
SpendingHeight uint32 `bson:"spending_height"`
}

type WithdrawalTx struct {
TxHash string `bson:"tx_hash"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional

}

type IndexerDelegationDetails struct {
StakingTxHashHex string `bson:"_id"` // Primary key
StakingTxHex string `bson:"staking_tx_hex"`
Expand All @@ -48,6 +52,7 @@ type IndexerDelegationDetails struct {
CovenantSignatures []CovenantSignature `bson:"covenant_unbonding_signatures"`
BTCDelegationCreatedBbnBlock BTCDelegationCreatedBbnBlock `bson:"btc_delegation_created_bbn_block"`
SlashingTx SlashingTx `bson:"slashing_tx"`
WithdrawalTx WithdrawalTx `bson:"withdrawal_tx,omitempty"`
PreviousStakingTxHashHex string `bson:"previous_staking_tx_hash_hex"`
}

Expand Down
12 changes: 12 additions & 0 deletions internal/v2/service/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ type UnbondingSlashing struct {
SpendingHeight uint32 `json:"spending_height"`
}

type WithdrawalInfo struct {
TxHash string `json:"tx_hash"`
}

type CovenantSignature struct {
CovenantBtcPkHex string `json:"covenant_btc_pk_hex"`
SignatureHex string `json:"signature_hex"`
Expand All @@ -59,6 +63,7 @@ type DelegationPublic struct {
DelegationStaking DelegationStaking `json:"delegation_staking"`
DelegationUnbonding DelegationUnbonding `json:"delegation_unbonding"`
State v2types.DelegationState `json:"state"`
WithdrawalInfo *WithdrawalInfo `json:"withdrawal_info,omitempty"`
PreviousStakingTxHashHex string `json:"previous_staking_tx_hash_hex,omitempty"`
}

Expand Down Expand Up @@ -108,6 +113,13 @@ func FromDelegationDocument(delegation indexerdbmodel.IndexerDelegationDetails)
PreviousStakingTxHashHex: delegation.PreviousStakingTxHashHex,
}

// Add withdrawal info if available
if delegation.WithdrawalTx.TxHash != "" {
delegationPublic.WithdrawalInfo = &WithdrawalInfo{
TxHash: delegation.WithdrawalTx.TxHash,
}
}

return delegationPublic, nil
}

Expand Down
Loading