Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add category tags #4049

Merged
merged 7 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pending/breaking/gaiarest/4049-update-tag
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#4049 update tag MsgWithdrawValidatorCommission to match type
1 change: 1 addition & 0 deletions .pending/improvements/sdk/3774-add-category-tag
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3774 add category tag to transactions for ease of filtering
19 changes: 15 additions & 4 deletions docs/spec/bank/04_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ The bank module emits the following events/tags:

### MsgSend

| Key | Value |
|-----------|---------------------------|
| sender | {senderAccountAddress} |
| recipient | {recipientAccountAddress} |
| Key | Value |
|-------------|---------------------------|
| `action` | `send` |
| `category` | `bank` |
| `sender` | {senderAccountAddress} |
| `recipient` | {recipientAccountAddress} |

### MsgMultiSend

| Key | Value |
|-------------|---------------------------|
| `action` | `multisend` |
| `category` | `bank` |
| `sender` | {senderAccountAddress} |
| `recipient` | {recipientAccountAddress} |
11 changes: 6 additions & 5 deletions docs/spec/crisis/03_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ The crisis module emits the following events/tags:

### MsgVerifyInvariance

| Key | Value |
|-----------|---------------------|
| action | verify_invariant |
| sender | {message-sender} |
| invariant | {invariant-route} |
| Key | Value |
|-------------|--------------------|
| `action` | `verify_invariant` |
| `category` | `crisis` |
| `sender` | {message-sender} |
| `invariant` | {invariant-route} |
34 changes: 17 additions & 17 deletions docs/spec/distribution/06_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ The distribution module emits the following events/tags:

### MsgSetWithdrawAddress

| Key | Value |
|-----------|---------------------------|
| delegator | {delegatorAccountAddress} |

### MsgWithdrawDelegatorRewardsAll

| Key | Value |
|-----------|---------------------------|
| delegator | {delegatorAccountAddress} |
| Key | Value |
|-------------|---------------------------|
| `action` | `set_withdraw_address` |
| `category` | `distribution` |
| `delegator` | {delegatorAccountAddress} |

### MsgWithdrawDelegatorReward

| Key | Value |
|------------------|---------------------------|
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| Key | Value |
|--------------------|-----------------------------|
| `action` | `withdraw_delegator_reward` |
| `category` | `distribution` |
| `delegator` | {delegatorAccountAddress} |
| `source-validator` | {srcOperatorAddress} |

### MsgWithdrawValidatorRewardsAll
### MsgWithdrawValidatorCommission

| Key | Value |
|------------------|----------------------|
| source-validator | {srcOperatorAddress} |
| Key | Value |
|--------------------|---------------------------------|
| `action` | `withdraw_validator_commission` |
| `category` | `distribution` |
| `source-validator` | {srcOperatorAddress} |
41 changes: 22 additions & 19 deletions docs/spec/governance/04_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,38 @@ The governance module emits the following events/tags:

## EndBlocker

| Key | Value |
|-----------------|------------------------------------------------------|
| proposal-result | proposal-passed\|proposal-rejected\|proposal-dropped |
| Key | Value |
|-------------------|------------------------------------------------------------|
| `proposal-result` | `proposal-passed`\|`proposal-rejected`\|`proposal-dropped` |

## Handlers

### MsgSubmitProposal

| Key | Value |
|-------------------------|--------------------------|
| action | proposal-vote |
| proposer | {proposerAccountAddress} |
| proposal-id | {proposalID} |
| voting-period-start [0] | {proposalID} |
| Key | Value |
|---------------------------|--------------------------|
| `action` | `submit_proposal` |
| `category` | `governance` |
| `proposer` | {proposerAccountAddress} |
| `proposal-id` | {proposalID} |
| `voting-period-start` [0] | {proposalID} |

* [0] Tag only emitted if the voting period starts during the submission.

### MsgVote

| Key | Value |
|-------------|-----------------------|
| action | proposal-vote |
| voter | {voterAccountAddress} |
| proposal-id | {proposalID} |
| Key | Value |
|---------------|-----------------------|
| `action` | `vote` |
| `category` | `governance` |
| `voter` | {voterAccountAddress} |
| `proposal-id` | {proposalID} |

### MsgDeposit

| Key | Value |
|-------------|---------------------------|
| action | proposal-vote |
| depositor | {depositorAccountAddress} |
| proposal-id | {proposalID} |
| Key | Value |
|---------------|---------------------------|
| `action` | `deposit` |
| `category` | `governance` |
| `depositor` | {depositorAccountAddress} |
| `proposal-id` | {proposalID} |
9 changes: 5 additions & 4 deletions docs/spec/slashing/06_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ The slashing module emits the following events/tags:

### MsgUnjail

| Key | Value |
|-----------|----------------------------|
| action | validator-unjailed |
| validator | {validatorOperatorAddress} |
| Key | Value |
|-------------|----------------------------|
| `action` | `unjail` |
| `category` | `slashing` |
| `validator` | {validatorOperatorAddress} |
69 changes: 38 additions & 31 deletions docs/spec/staking/06_tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,62 @@ The staking module emits the following events/tags:

## EndBlocker

| Key | Value |
|-----------------------|-------------------------------------------|
| action | complete-unbonding\|complete-redelegation |
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| destination-validator | {dstOperatorAddress} |
| Key | Value |
|-------------------------|-----------------------------------------------|
| `action` | `complete-unbonding`\|`complete-redelegation` |
| `category` | `staking` |
| `delegator` | {delegatorAccountAddress} |
| `source-validator` | {srcOperatorAddress} |
| `destination-validator` | {dstOperatorAddress} |

## Handlers

### MsgCreateValidator

| Key | Value |
|-----------------------|----------------------|
| destination-validator | {dstOperatorAddress} |
| moniker | {validatorMoniker} |
| identity | {validatorIdentity} |
| Key | Value |
|-------------------------|----------------------|
| `action` | `create_validator` |
| `category` | `staking` |
| `destination-validator` | {dstOperatorAddress} |

### MsgEditValidator

| Key | Value |
|-----------------------|----------------------|
| destination-validator | {dstOperatorAddress} |
| moniker | {validatorMoniker} |
| identity | {validatorIdentity} |
| Key | Value |
|-------------------------|----------------------|
| `action` | `edit_validator` |
| `category` | `staking` |
| `destination-validator` | {dstOperatorAddress} |

### MsgDelegate

| Key | Value |
|-----------------------|-------------------------------------------|
| delegator | {delegatorAccountAddress} |
| destination-validator | {dstOperatorAddress} |
| Key | Value |
|-------------------------|---------------------------|
| `action` | `delegate` |
| `category` | `staking` |
| `delegator` | {delegatorAccountAddress} |
| `destination-validator` | {dstOperatorAddress} |

### MsgBeginRedelegate

| Key | Value |
|-----------------------|-------------------------------------------|
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| destination-validator | {dstOperatorAddress} |
| end-time [0] | {delegationFinishTime} |
| Key | Value |
|-------------------------|---------------------------|
| `action` | `begin_redelegate` |
| `category` | `staking` |
| `delegator` | {delegatorAccountAddress} |
| `source-validator` | {srcOperatorAddress} |
| `destination-validator` | {dstOperatorAddress} |
| `end-time` [0] | {delegationFinishTime} |

* [0] Time is formatted in the RFC3339 standard

### MsgUndelegate

| Key | Value |
|------------------|---------------------------|
| delegator | {delegatorAccountAddress} |
| source-validator | {srcOperatorAddress} |
| end-time [0] | {delegationFinishTime} |
| Key | Value |
|--------------------|---------------------------|
| `action` | `begin_unbonding` |
| `category` | `staking` |
| `delegator` | {delegatorAccountAddress} |
| `source-validator` | {srcOperatorAddress} |
| `end-time` [0] | {delegationFinishTime} |

* [0] Time is formatted in the RFC3339 standard
1 change: 1 addition & 0 deletions types/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func MakeTag(k string, v string) Tag {
// common tags
var (
TagAction = "action"
TagCategory = "category"
TagSrcValidator = "source-validator"
TagDstValidator = "destination-validator"
TagDelegator = "delegator"
Expand Down
16 changes: 12 additions & 4 deletions x/bank/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bank

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/tags"
)

// NewHandler returns a handler for "bank" type messages.
Expand All @@ -24,13 +25,19 @@ func handleMsgSend(ctx sdk.Context, k Keeper, msg MsgSend) sdk.Result {
if !k.GetSendEnabled(ctx) {
return ErrSendDisabled(k.Codespace()).Result()
}
tags, err := k.SendCoins(ctx, msg.FromAddress, msg.ToAddress, msg.Amount)
err := k.SendCoins(ctx, msg.FromAddress, msg.ToAddress, msg.Amount)
if err != nil {
return err.Result()
}

resTags := sdk.NewTags(
tags.Category, tags.TxCategory,
tags.Sender, msg.FromAddress.String(),
tags.Recipient, msg.ToAddress.String(),
)

return sdk.Result{
Tags: tags,
Tags: resTags,
}
}

Expand All @@ -40,12 +47,13 @@ func handleMsgMultiSend(ctx sdk.Context, k Keeper, msg MsgMultiSend) sdk.Result
if !k.GetSendEnabled(ctx) {
return ErrSendDisabled(k.Codespace()).Result()
}
tags, err := k.InputOutputCoins(ctx, msg.Inputs, msg.Outputs)
resTags, err := k.InputOutputCoins(ctx, msg.Inputs, msg.Outputs)
if err != nil {
return err.Result()
}

resTags = resTags.AppendTag(tags.Category, tags.TxCategory)
return sdk.Result{
Tags: tags,
Tags: resTags,
}
}
Loading