Skip to content

Commit

Permalink
fix: add MsgCancelUnbondingDelegation handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dadamu committed May 24, 2024
1 parent c1d8aae commit aa46dcc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions modules/top_accounts/handle_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func (m *Module) HandleMsg(index int, msg sdk.Msg, tx *juno.Tx) error {
case *stakingtypes.MsgUndelegate:
return m.handleMsgUndelegate(cosmosMsg.DelegatorAddress, tx.Height)

case *stakingtypes.MsgCancelUnbondingDelegation:
return m.handleMsgCancelUnbondingDelegation(cosmosMsg.DelegatorAddress, tx.Height)

// Handle x/distribution delegator rewards
case *distritypes.MsgWithdrawDelegatorReward:
return m.handleMsgWithdrawDelegatorReward(cosmosMsg.DelegatorAddress, tx.Height)
Expand Down Expand Up @@ -81,6 +84,31 @@ func (m *Module) handleMsgUndelegate(delAddr string, height int64) error {
return nil
}

// handleMsgCancelUnbondingDelegation handles a MsgCancelUnbondingDelegation storing the data inside the database
func (m *Module) handleMsgCancelUnbondingDelegation(delAddr string, height int64) error {
err := m.stakingModule.RefreshDelegations(delAddr, height)
if err != nil {
return fmt.Errorf("error while refreshing delegations of account %s, error: %s", delAddr, err)
}

err = m.stakingModule.RefreshUnbondings(delAddr, height)
if err != nil {
return fmt.Errorf("error while refreshing unbonding delegations of account %s, error: %s", delAddr, err)
}

err = m.bankModule.UpdateBalances([]string{delAddr}, height)
if err != nil {
return fmt.Errorf("error while refreshing balance of account %s, error: %s", delAddr, err)
}

err = m.refreshTopAccountsSum([]string{delAddr}, height)
if err != nil {
return fmt.Errorf("error while refreshing top accounts sum %s, error: %s", delAddr, err)
}

return nil
}

func (m *Module) handleMsgWithdrawDelegatorReward(delAddr string, height int64) error {
err := m.distrModule.RefreshDelegatorRewards([]string{delAddr}, height)
if err != nil {
Expand Down

0 comments on commit aa46dcc

Please sign in to comment.