Skip to content

Commit

Permalink
Merge PR cosmos#4772: Add New Events Attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Jul 24, 2019
1 parent bfb6445 commit 2b3d785
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/spec/bank/04_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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} |
Expand Down
1 change: 1 addition & 0 deletions types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ var (
AttributeKeyAction = "action"
AttributeKeyModule = "module"
AttributeKeySender = "sender"
AttributeKeyAmount = "amount"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion x/bank/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions x/distribution/keeper/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
),
)
Expand Down Expand Up @@ -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()),
),
)
Expand All @@ -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()),
),
)
Expand Down
4 changes: 2 additions & 2 deletions x/distribution/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
),
)
Expand Down Expand Up @@ -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()),
),
)

Expand Down
1 change: 0 additions & 1 deletion x/distribution/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var (
EventTypeProposerReward = "proposer_reward"

AttributeKeyWithdrawAddress = "withdraw_address"
AttributeKeyAmount = "amount"
AttributeKeyValidator = "validator"

AttributeValueCategory = ModuleName
Expand Down
2 changes: 1 addition & 1 deletion x/gov/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
)
Expand Down
1 change: 0 additions & 1 deletion x/gov/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const (
EventTypeActiveProposal = "active_proposal"

AttributeKeyProposalResult = "proposal_result"
AttributeKeyAmount = "amount"
AttributeKeyOption = "option"
AttributeKeyProposalID = "proposal_id"
AttributeKeyVotingPeriodStart = "voting_period_start"
Expand Down
2 changes: 1 addition & 1 deletion x/mint/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
),
)
}
1 change: 0 additions & 1 deletion x/mint/internal/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ const (
AttributeKeyBondedRatio = "bonded_ratio"
AttributeKeyInflation = "inflation"
AttributeKeyAnnualProvisions = "annual_provisions"
AttributeKeyAmount = "amount"
)
8 changes: 4 additions & 4 deletions x/staking/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion x/staking/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var (
AttributeKeySrcValidator = "source_validator"
AttributeKeyDstValidator = "destination_validator"
AttributeKeyDelegator = "delegator"
AttributeKeyAmount = "amount"
AttributeKeyCompletionTime = "completion_time"
AttributeValueCategory = ModuleName
)

0 comments on commit 2b3d785

Please sign in to comment.