From afa818a58fb076a2b139f61a046c4358fc934a17 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 29 Apr 2021 08:57:46 +0200 Subject: [PATCH] Added a "new_shares" attribute inside the delegate event type (#9214) * Added a "new_shares" attribute inside the delegate event type * ADded CHANGELOG entry --- CHANGELOG.md | 1 + x/staking/keeper/msg_server.go | 3 ++- x/staking/types/events.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cff1105a4ed..35013902ab2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 022d7d746ddd..37e5edb042dd 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -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 } @@ -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, diff --git a/x/staking/types/events.go b/x/staking/types/events.go index ef0f01aa5c0e..99a0be1ad626 100644 --- a/x/staking/types/events.go +++ b/x/staking/types/events.go @@ -17,5 +17,6 @@ const ( AttributeKeyDstValidator = "destination_validator" AttributeKeyDelegator = "delegator" AttributeKeyCompletionTime = "completion_time" + AttributeKeyNewShares = "new_shares" AttributeValueCategory = ModuleName )