Skip to content

Commit

Permalink
Added a "new_shares" attribute inside the delegate event type (#9214)
Browse files Browse the repository at this point in the history
* Added a "new_shares" attribute inside the delegate event type

* ADded CHANGELOG entry
  • Loading branch information
RiccardoM authored Apr 29, 2021
1 parent 6ad84c5 commit afa818a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#8754](https://github.com/cosmos/cosmos-sdk/pull/8875) Added support for reverse iteration to pagination.
* [#9088](https://github.com/cosmos/cosmos-sdk/pull/9088) Added implementation to ADR-28 Derived Addresses.
* [\#9133](https://github.com/cosmos/cosmos-sdk/pull/9133) Added hooks for governance actions.
* (x/staking) [\#9214](https://github.com/cosmos/cosmos-sdk/pull/9214) Added `new_shares` attribute inside `EventTypeDelegate` event.

### Client Breaking Changes
* [\#8363](https://github.com/cosmos/cosmos-sdk/pull/8363) Addresses no longer have a fixed 20-byte length. From the SDK modules' point of view, any 1-255 bytes-long byte array is a valid address.
Expand Down
3 changes: 2 additions & 1 deletion x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ
}

// NOTE: source funds are always unbonded
_, err = k.Keeper.Delegate(ctx, delegatorAddress, msg.Amount.Amount, types.Unbonded, validator, true)
newShares, err := k.Keeper.Delegate(ctx, delegatorAddress, msg.Amount.Amount, types.Unbonded, validator, true)
if err != nil {
return nil, err
}
Expand All @@ -225,6 +225,7 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ
types.EventTypeDelegate,
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()),
sdk.NewAttribute(types.AttributeKeyNewShares, newShares.String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,
Expand Down
1 change: 1 addition & 0 deletions x/staking/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ const (
AttributeKeyDstValidator = "destination_validator"
AttributeKeyDelegator = "delegator"
AttributeKeyCompletionTime = "completion_time"
AttributeKeyNewShares = "new_shares"
AttributeValueCategory = ModuleName
)

0 comments on commit afa818a

Please sign in to comment.