From 2b3d78599e005a2b27c0373fbd6959e0a9e1c049 Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Wed, 24 Jul 2019 15:50:34 -0700 Subject: [PATCH] Merge PR #4772: Add New Events Attributes --- docs/spec/bank/04_events.md | 1 + types/events.go | 1 + x/bank/internal/keeper/keeper.go | 2 +- x/distribution/keeper/allocation.go | 6 +++--- x/distribution/keeper/keeper.go | 4 ++-- x/distribution/types/events.go | 1 - x/gov/deposit.go | 2 +- x/gov/types/events.go | 1 - x/mint/abci.go | 2 +- x/mint/internal/types/events.go | 1 - x/staking/handler.go | 8 ++++---- x/staking/types/events.go | 1 - 12 files changed, 14 insertions(+), 16 deletions(-) diff --git a/docs/spec/bank/04_events.md b/docs/spec/bank/04_events.md index bacc531d3..a7fac1194 100644 --- a/docs/spec/bank/04_events.md +++ b/docs/spec/bank/04_events.md @@ -9,6 +9,7 @@ The bank module emits the following events: | Type | Attribute Key | Attribute Value | |----------|---------------|--------------------| | transfer | recipient | {recipientAddress} | +| transfer | amount | {amount} | | message | module | bank | | message | action | send | | message | sender | {senderAddress} | diff --git a/types/events.go b/types/events.go index a93dbf80d..bbe51819c 100644 --- a/types/events.go +++ b/types/events.go @@ -137,6 +137,7 @@ var ( AttributeKeyAction = "action" AttributeKeyModule = "module" AttributeKeySender = "sender" + AttributeKeyAmount = "amount" ) type ( diff --git a/x/bank/internal/keeper/keeper.go b/x/bank/internal/keeper/keeper.go index 0c58b2f5d..04844dcfc 100644 --- a/x/bank/internal/keeper/keeper.go +++ b/x/bank/internal/keeper/keeper.go @@ -210,7 +210,6 @@ func (keeper BaseSendKeeper) InputOutputCoins(ctx sdk.Context, inputs []types.In // SendCoins moves coins from one account to another func (keeper BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) sdk.Error { - _, err := keeper.SubtractCoins(ctx, fromAddr, amt) if err != nil { return err @@ -225,6 +224,7 @@ func (keeper BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, sdk.NewEvent( types.EventTypeTransfer, sdk.NewAttribute(types.AttributeKeyRecipient, toAddr.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, amt.String()), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index f902e79d7..43a659999 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -57,7 +57,7 @@ func (k Keeper) AllocateTokens( ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeProposerReward, - sdk.NewAttribute(types.AttributeKeyAmount, proposerReward.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, proposerReward.String()), sdk.NewAttribute(types.AttributeKeyValidator, proposerValidator.GetOperator().String()), ), ) @@ -109,7 +109,7 @@ func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.Validato ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeCommission, - sdk.NewAttribute(types.AttributeKeyAmount, commission.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, commission.String()), sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), ), ) @@ -126,7 +126,7 @@ func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.Validato ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeRewards, - sdk.NewAttribute(types.AttributeKeyAmount, tokens.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, tokens.String()), sdk.NewAttribute(types.AttributeKeyValidator, val.GetOperator().String()), ), ) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index db8d9a17b..b56c13caa 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -89,7 +89,7 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeWithdrawRewards, - sdk.NewAttribute(types.AttributeKeyAmount, rewards.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, rewards.String()), sdk.NewAttribute(types.AttributeKeyValidator, valAddr.String()), ), ) @@ -126,7 +126,7 @@ func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddr ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeWithdrawCommission, - sdk.NewAttribute(types.AttributeKeyAmount, commission.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, commission.String()), ), ) diff --git a/x/distribution/types/events.go b/x/distribution/types/events.go index c5fb7c826..d6db25784 100644 --- a/x/distribution/types/events.go +++ b/x/distribution/types/events.go @@ -10,7 +10,6 @@ var ( EventTypeProposerReward = "proposer_reward" AttributeKeyWithdrawAddress = "withdraw_address" - AttributeKeyAmount = "amount" AttributeKeyValidator = "validator" AttributeValueCategory = ModuleName diff --git a/x/gov/deposit.go b/x/gov/deposit.go index 0059d693d..03b1ab7d3 100644 --- a/x/gov/deposit.go +++ b/x/gov/deposit.go @@ -67,7 +67,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeProposalDeposit, - sdk.NewAttribute(types.AttributeKeyAmount, depositAmount.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, depositAmount.String()), sdk.NewAttribute(types.AttributeKeyProposalID, fmt.Sprintf("%d", proposalID)), ), ) diff --git a/x/gov/types/events.go b/x/gov/types/events.go index b823d4dac..383078459 100644 --- a/x/gov/types/events.go +++ b/x/gov/types/events.go @@ -9,7 +9,6 @@ const ( EventTypeActiveProposal = "active_proposal" AttributeKeyProposalResult = "proposal_result" - AttributeKeyAmount = "amount" AttributeKeyOption = "option" AttributeKeyProposalID = "proposal_id" AttributeKeyVotingPeriodStart = "voting_period_start" diff --git a/x/mint/abci.go b/x/mint/abci.go index 3c4bc5fc5..07d8d8462 100644 --- a/x/mint/abci.go +++ b/x/mint/abci.go @@ -39,7 +39,7 @@ func BeginBlocker(ctx sdk.Context, k Keeper) { sdk.NewAttribute(types.AttributeKeyBondedRatio, bondedRatio.String()), sdk.NewAttribute(types.AttributeKeyInflation, minter.Inflation.String()), sdk.NewAttribute(types.AttributeKeyAnnualProvisions, minter.AnnualProvisions.String()), - sdk.NewAttribute(types.AttributeKeyAmount, mintedCoin.Amount.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()), ), ) } diff --git a/x/mint/internal/types/events.go b/x/mint/internal/types/events.go index 678def7bf..dce85bdb7 100644 --- a/x/mint/internal/types/events.go +++ b/x/mint/internal/types/events.go @@ -7,5 +7,4 @@ const ( AttributeKeyBondedRatio = "bonded_ratio" AttributeKeyInflation = "inflation" AttributeKeyAnnualProvisions = "annual_provisions" - AttributeKeyAmount = "amount" ) diff --git a/x/staking/handler.go b/x/staking/handler.go index bafa1d325..ad39070d1 100644 --- a/x/staking/handler.go +++ b/x/staking/handler.go @@ -156,7 +156,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k sdk.NewEvent( types.EventTypeCreateValidator, sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress.String()), - sdk.NewAttribute(types.AttributeKeyAmount, msg.Value.Amount.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Value.Amount.String()), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -243,7 +243,7 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper) sdk.NewEvent( types.EventTypeDelegate, sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress.String()), - sdk.NewAttribute(types.AttributeKeyAmount, msg.Amount.Amount.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -277,7 +277,7 @@ func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keep sdk.NewEvent( types.EventTypeUnbond, sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress.String()), - sdk.NewAttribute(types.AttributeKeyAmount, msg.Amount.Amount.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), ), sdk.NewEvent( @@ -315,7 +315,7 @@ func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k k types.EventTypeRedelegate, sdk.NewAttribute(types.AttributeKeySrcValidator, msg.ValidatorSrcAddress.String()), sdk.NewAttribute(types.AttributeKeyDstValidator, msg.ValidatorDstAddress.String()), - sdk.NewAttribute(types.AttributeKeyAmount, msg.Amount.Amount.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.Amount.String()), sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)), ), sdk.NewEvent( diff --git a/x/staking/types/events.go b/x/staking/types/events.go index f0155fda1..f4eb81d2e 100644 --- a/x/staking/types/events.go +++ b/x/staking/types/events.go @@ -16,7 +16,6 @@ var ( AttributeKeySrcValidator = "source_validator" AttributeKeyDstValidator = "destination_validator" AttributeKeyDelegator = "delegator" - AttributeKeyAmount = "amount" AttributeKeyCompletionTime = "completion_time" AttributeValueCategory = ModuleName )