refactor: automate EventTypeMessage inclusion in every message execution (#13532)
This commit is contained in:
parent
d9f3eb027d
commit
3c9b244f62
15
UPGRADING.md
15
UPGRADING.md
|
@ -67,6 +67,21 @@ the correct code.
|
|||
|
||||
### Modules
|
||||
|
||||
#### `**all**`
|
||||
|
||||
`EventTypeMessage` events, with `sdk.AttributeKeyModule` and `sdk.AttributeKeySender` are now emitted directly at message excecution (in `baseapp`).
|
||||
This means that you can remove the following boilerplate from all your custom modules:
|
||||
|
||||
```go
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, `signer/sender`),
|
||||
),
|
||||
)
|
||||
```
|
||||
|
||||
#### `x/gov`
|
||||
|
||||
##### Minimum Proposal Deposit At Time of Submission
|
||||
|
|
|
@ -669,7 +669,6 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
|
|||
// and we're in DeliverTx. Note, runMsgs will never return a reference to a
|
||||
// Result if any single message fails or does not have a registered Handler.
|
||||
result, err = app.runMsgs(runMsgCtx, msgs, mode)
|
||||
|
||||
if err == nil {
|
||||
|
||||
// Run optional postHandlers.
|
||||
|
@ -717,28 +716,19 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
|
|||
break
|
||||
}
|
||||
|
||||
var (
|
||||
msgResult *sdk.Result
|
||||
eventMsgName string // name to use as value in event `message.action`
|
||||
err error
|
||||
)
|
||||
|
||||
if handler := app.msgServiceRouter.Handler(msg); handler != nil {
|
||||
// ADR 031 request type routing
|
||||
msgResult, err = handler(ctx, msg)
|
||||
eventMsgName = sdk.MsgTypeURL(msg)
|
||||
} else {
|
||||
handler := app.msgServiceRouter.Handler(msg)
|
||||
if handler == nil {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg)
|
||||
}
|
||||
|
||||
// ADR 031 request type routing
|
||||
msgResult, err := handler(ctx, msg)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrapf(err, "failed to execute message; message index: %d", i)
|
||||
}
|
||||
|
||||
msgEvents := sdk.Events{
|
||||
sdk.NewEvent(sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyAction, eventMsgName)),
|
||||
}
|
||||
msgEvents = msgEvents.AppendEvents(msgResult.GetEvents())
|
||||
// create message events
|
||||
msgEvents := createEvents(msg).AppendEvents(msgResult.GetEvents())
|
||||
|
||||
// append message events, data and logs
|
||||
//
|
||||
|
@ -779,3 +769,22 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
|
|||
func makeABCIData(msgResponses []*codectypes.Any) ([]byte, error) {
|
||||
return proto.Marshal(&sdk.TxMsgData{MsgResponses: msgResponses})
|
||||
}
|
||||
|
||||
func createEvents(msg sdk.Msg) sdk.Events {
|
||||
eventMsgName := sdk.MsgTypeURL(msg)
|
||||
msgEvent := sdk.NewEvent(sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyAction, eventMsgName))
|
||||
|
||||
// we set the signer attribute as the sender
|
||||
if len(msg.GetSigners()) > 0 && !msg.GetSigners()[0].Empty() {
|
||||
msgEvent = msgEvent.AppendAttributes(sdk.NewAttribute(sdk.AttributeKeySender, msg.GetSigners()[0].String()))
|
||||
}
|
||||
|
||||
// here we assume that routes module name is the second element of the route
|
||||
// e.g. "cosmos.bank.v1beta1.MsgSend" => "bank"
|
||||
moduleName := strings.Split(eventMsgName, ".")
|
||||
if len(moduleName) > 1 {
|
||||
msgEvent = msgEvent.AppendAttributes(sdk.NewAttribute(sdk.AttributeKeyModule, moduleName[1]))
|
||||
}
|
||||
|
||||
return sdk.Events{msgEvent}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@ func (msg *MsgCounter2) ValidateBasic() error {
|
|||
var _ sdk.Msg = &MsgKeyValue{}
|
||||
|
||||
func (msg *MsgKeyValue) GetSigners() []sdk.AccAddress {
|
||||
if len(msg.Signer) == 0 {
|
||||
return []sdk.AccAddress{}
|
||||
}
|
||||
|
||||
return []sdk.AccAddress{sdk.MustAccAddressFromBech32(msg.Signer)}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,13 +41,6 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/types/context.go#L17-L42
|
|||
`Events` by defining various `Types` and `Attributes` or use the common definitions found in `types/`. Clients can subscribe or query for these `Events`. These `Events` are collected throughout `DeliverTx`, `BeginBlock`, and `EndBlock` and are returned to Tendermint for indexing. For example:
|
||||
* **Priority:** The transaction priority, only relevant in `CheckTx`.
|
||||
|
||||
```go
|
||||
ctx.EventManager().EmitEvent(sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory)),
|
||||
)
|
||||
```
|
||||
|
||||
## Go Context Package
|
||||
|
||||
A basic `Context` is defined in the [Golang Context Package](https://pkg.go.dev/context). A `Context`
|
||||
|
|
|
@ -16,7 +16,7 @@ sidebar_position: 1
|
|||
|
||||
:::
|
||||
|
||||
## Typed Events
|
||||
## Events
|
||||
|
||||
Events are implemented in the Cosmos SDK as an alias of the ABCI `Event` type and
|
||||
take the form of: `{eventType}.{attributeKey}={attributeValue}`.
|
||||
|
@ -35,11 +35,12 @@ To parse the attribute values as strings, make sure to add `'` (single quotes) a
|
|||
:::
|
||||
|
||||
_Typed Events_ are Protobuf-defined [messages](../architecture/adr-032-typed-events.md) used by the Cosmos SDK
|
||||
for emitting and querying Events. They are defined in a `event.proto` file, on a **per-module basis**.
|
||||
for emitting and querying Events. They are defined in a `event.proto` file, on a **per-module basis** and are read as `proto.Message`.
|
||||
_Legacy Events_ are defined on a **per-module basis** in the module's `/types/events.go` file.
|
||||
They are triggered from the module's Protobuf [`Msg` service](../building-modules/03-msg-services.md)
|
||||
by using the [`EventManager`](#eventmanager), where they are read as `proto.Message`.
|
||||
by using the [`EventManager`](#eventmanager).
|
||||
|
||||
In addition, each module documents its Events under `spec/xx_events.md`.
|
||||
In addition, each module documents its events under in the `Events` sections of its specs (x/{moduleName}/`README.md`).
|
||||
|
||||
Lastly, Events are returned to the underlying consensus engine in the response of the following ABCI messages:
|
||||
|
||||
|
@ -71,21 +72,32 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/types/events.go#L17-L25
|
|||
```
|
||||
|
||||
The `EventManager` comes with a set of useful methods to manage Events. The method
|
||||
that is used most by module and application developers is `EmitTypedEvent` that tracks
|
||||
that is used most by module and application developers is `EmitTypedEvent` or `EmitEvent` that tracks
|
||||
an Event in the `EventManager`.
|
||||
|
||||
```go reference
|
||||
https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/types/events.go#L50-L59
|
||||
```
|
||||
|
||||
Module developers should handle Event emission via the `EventManager#EmitTypedEvent` in each message
|
||||
Module developers should handle Event emission via the `EventManager#EmitTypedEvent` or `EventManager#EmitEvent` in each message
|
||||
`Handler` and in each `BeginBlock`/`EndBlock` handler. The `EventManager` is accessed via
|
||||
the [`Context`](./02-context.md), where Event should be already registered, and emitted like this:
|
||||
|
||||
|
||||
**Typed events:**
|
||||
|
||||
```go reference
|
||||
https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/group/keeper/msg_server.go#L89-L92
|
||||
```
|
||||
|
||||
**Legacy events:**
|
||||
|
||||
```go
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(eventType, sdk.NewAttribute(attributeKey, attributeValue)),
|
||||
)
|
||||
```
|
||||
|
||||
Module's `handler` function should also set a new `EventManager` to the `context` to isolate emitted Events per `message`:
|
||||
|
||||
```go
|
||||
|
@ -139,10 +151,12 @@ Subscribing to this Event would be done like so:
|
|||
|
||||
where `ownerAddress` is an address following the [`AccAddress`](../basics/03-accounts.md#addresses) format.
|
||||
|
||||
## Events
|
||||
The same way can be used to subscribe to [legacy events](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/bank/types/events.go).
|
||||
|
||||
Previously, the Cosmos SDK supported emitting Events that were defined in `types/events.go`. It is the responsibility of the module developer to define Event types and Event attributes. Except in the `spec/XX_events.md` file, these Event types and attributes are unfortunately not easily discoverable,
|
||||
## Default Events
|
||||
|
||||
This is why this methods as been deprecated, and replaced by [Typed Events](#typed-events).
|
||||
There are a few events that are automatically emitted for all messages, directly from `baseapp`.
|
||||
|
||||
To learn more about the previous way of defining events, please refer to the [previous SDK documentation](https://docs.cosmos.network/v0.45/core/events.html#events-2).
|
||||
* `message.action`: The name of the message type.
|
||||
* `message.sender`: The address of the message signer.
|
||||
* `message.module`: The name of the module that emitted the message.
|
||||
|
|
|
@ -221,13 +221,13 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() {
|
|||
s.Require().NoError(err)
|
||||
// Check the result and gas used are correct.
|
||||
//
|
||||
// The 13 events are:
|
||||
// The 12 events are:
|
||||
// - Sending Fee to the pool: coin_spent, coin_received, transfer and message.sender=<val1>
|
||||
// - tx.* events: tx.fee, tx.acc_seq, tx.signature
|
||||
// - Sending Amount to recipient: coin_spent, coin_received, transfer and message.sender=<val1>
|
||||
// - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend
|
||||
s.Require().Equal(len(res.GetResult().GetEvents()), 13) // 1 coin recv 1 coin spent, 1 transfer, 3 messages.
|
||||
s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty.
|
||||
// - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend (in one message)
|
||||
s.Require().Equal(12, len(res.GetResult().GetEvents()))
|
||||
s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty.
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -268,8 +268,8 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() {
|
|||
s.Require().NoError(err)
|
||||
// Check the result and gas used are correct.
|
||||
s.Require().Len(result.GetResult().MsgResponses, 1)
|
||||
s.Require().Equal(len(result.GetResult().GetEvents()), 13) // See TestSimulateTx_GRPC for the 13 events.
|
||||
s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, jus
|
||||
s.Require().Equal(12, len(result.GetResult().GetEvents())) // See TestSimulateTx_GRPC for the 12 events.
|
||||
s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty.
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -84,13 +84,6 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgCreateVestingAccountResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -145,13 +138,6 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *type
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgCreatePermanentLockedAccountResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -205,11 +191,5 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
return &types.MsgCreatePeriodicVestingAccountResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -4,9 +4,6 @@ const (
|
|||
// ModuleName defines the module's name.
|
||||
ModuleName = "vesting"
|
||||
|
||||
// AttributeValueCategory is an alias for the message event value.
|
||||
AttributeValueCategory = ModuleName
|
||||
|
||||
// RouterKey defines the module's message routing key
|
||||
RouterKey = ModuleName
|
||||
)
|
||||
|
|
|
@ -61,13 +61,6 @@ func (k msgServer) Send(goCtx context.Context, msg *types.MsgSend) (*types.MsgSe
|
|||
}
|
||||
}()
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgSendResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -94,13 +87,6 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgMultiSendResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -114,14 +100,6 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, req.Authority),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgUpdateParamsResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -138,13 +116,5 @@ func (k msgServer) SetSendEnabled(goCtx context.Context, msg *types.MsgSetSendEn
|
|||
k.DeleteSendEnabled(ctx, msg.UseDefaultFor...)
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Authority),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgSetSendEnabledResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ const (
|
|||
AttributeKeyRecipient = "recipient"
|
||||
AttributeKeySender = sdk.AttributeKeySender
|
||||
|
||||
AttributeValueCategory = ModuleName
|
||||
|
||||
// supply and balance tracking events name and attributes
|
||||
EventTypeCoinSpent = "coin_spent"
|
||||
EventTypeCoinReceived = "coin_received"
|
||||
|
|
|
@ -37,13 +37,5 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
|
|||
|
||||
k.Set(ctx, &consensusParams)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, req.Authority),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgUpdateParamsResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ var (
|
|||
|
||||
// Events
|
||||
const (
|
||||
AttributeValueCategory = ModuleName
|
||||
|
||||
EventTypeUpdateParam = "update_param"
|
||||
|
||||
AttributeKeyParamUpdater = "param_updater"
|
||||
|
|
|
@ -57,11 +57,6 @@ func (k *Keeper) VerifyInvariant(goCtx context.Context, msg *types.MsgVerifyInva
|
|||
types.EventTypeInvariant,
|
||||
sdk.NewAttribute(types.AttributeKeyRoute, msg.InvariantRoute),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCrisis),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgVerifyInvariantResponse{}, nil
|
||||
|
|
|
@ -4,6 +4,5 @@ package types
|
|||
const (
|
||||
EventTypeInvariant = "invariant"
|
||||
|
||||
AttributeValueCrisis = ModuleName
|
||||
AttributeKeyRoute = "route"
|
||||
AttributeKeyRoute = "route"
|
||||
)
|
||||
|
|
|
@ -40,14 +40,6 @@ func (k msgServer) SetWithdrawAddress(goCtx context.Context, msg *types.MsgSetWi
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgSetWithdrawAddressResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -79,13 +71,6 @@ func (k msgServer) WithdrawDelegatorReward(goCtx context.Context, msg *types.Msg
|
|||
}
|
||||
}()
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
|
||||
),
|
||||
)
|
||||
return &types.MsgWithdrawDelegatorRewardResponse{Amount: amount}, nil
|
||||
}
|
||||
|
||||
|
@ -113,14 +98,6 @@ func (k msgServer) WithdrawValidatorCommission(goCtx context.Context, msg *types
|
|||
}
|
||||
}()
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgWithdrawValidatorCommissionResponse{Amount: amount}, nil
|
||||
}
|
||||
|
||||
|
@ -135,14 +112,6 @@ func (k msgServer) FundCommunityPool(goCtx context.Context, msg *types.MsgFundCo
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgFundCommunityPoolResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -156,14 +125,6 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, req.Authority),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgUpdateParamsResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -190,13 +151,5 @@ func (k msgServer) CommunityPoolSpend(goCtx context.Context, req *types.MsgCommu
|
|||
logger := k.Logger(ctx)
|
||||
logger.Info("transferred from the community pool to recipient", "amount", req.Amount.String(), "recipient", req.Recipient)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, req.Authority),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgCommunityPoolSpendResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -11,6 +11,4 @@ const (
|
|||
|
||||
AttributeKeyWithdrawAddress = "withdraw_address"
|
||||
AttributeKeyValidator = "validator"
|
||||
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
||||
|
|
|
@ -28,14 +28,6 @@ func (ms msgServer) SubmitEvidence(goCtx context.Context, msg *types.MsgSubmitEv
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetSubmitter().String()),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgSubmitEvidenceResponse{
|
||||
Hash: evidence.Hash(),
|
||||
}, nil
|
||||
|
|
|
@ -4,6 +4,5 @@ package types
|
|||
const (
|
||||
EventTypeSubmitEvidence = "submit_evidence"
|
||||
|
||||
AttributeValueCategory = "evidence"
|
||||
AttributeKeyEvidenceHash = "evidence_hash"
|
||||
)
|
||||
|
|
|
@ -9,6 +9,4 @@ const (
|
|||
|
||||
AttributeKeyGranter = "granter"
|
||||
AttributeKeyGrantee = "grantee"
|
||||
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
||||
|
|
|
@ -65,20 +65,12 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer()),
|
||||
),
|
||||
)
|
||||
|
||||
if votingStarted {
|
||||
submitEvent := sdk.NewEvent(govtypes.EventTypeSubmitProposal,
|
||||
sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)),
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(govtypes.EventTypeSubmitProposal,
|
||||
sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)),
|
||||
),
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(submitEvent)
|
||||
}
|
||||
|
||||
return &v1.MsgSubmitProposalResponse{
|
||||
|
@ -131,14 +123,6 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp
|
|||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter),
|
||||
),
|
||||
)
|
||||
|
||||
return &v1.MsgVoteResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -161,14 +145,6 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted)
|
|||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter),
|
||||
),
|
||||
)
|
||||
|
||||
return &v1.MsgVoteWeightedResponse{}, nil
|
||||
}
|
||||
|
||||
|
@ -191,14 +167,6 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe
|
|||
},
|
||||
)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor),
|
||||
),
|
||||
)
|
||||
|
||||
if votingStarted {
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
|
|
|
@ -14,7 +14,6 @@ const (
|
|||
AttributeKeyProposalID = "proposal_id"
|
||||
AttributeKeyProposalMessages = "proposal_messages" // Msg type_urls in the proposal
|
||||
AttributeKeyVotingPeriodStart = "voting_period_start"
|
||||
AttributeValueCategory = "governance"
|
||||
AttributeValueProposalDropped = "proposal_dropped" // didn't meet min deposit
|
||||
AttributeValueProposalPassed = "proposal_passed" // met vote quorum
|
||||
AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum
|
||||
|
|
|
@ -48,13 +48,5 @@ func (k msgServer) Unjail(goCtx context.Context, msg *types.MsgUnjail) (*types.M
|
|||
return nil, err
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddr),
|
||||
),
|
||||
)
|
||||
|
||||
return &types.MsgUnjailResponse{}, nil
|
||||
}
|
||||
|
|
|
@ -15,5 +15,4 @@ const (
|
|||
|
||||
AttributeValueDoubleSign = "double_sign"
|
||||
AttributeValueMissingSignature = "missing_signature"
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
||||
|
|
|
@ -132,11 +132,6 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa
|
|||
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
|
||||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Value.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgCreateValidatorResponse{}, nil
|
||||
|
@ -197,11 +192,6 @@ func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValida
|
|||
sdk.NewAttribute(types.AttributeKeyCommissionRate, validator.Commission.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyMinSelfDelegation, validator.MinSelfDelegation.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgEditValidatorResponse{}, nil
|
||||
|
@ -256,11 +246,6 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ
|
|||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyNewShares, newShares.String()),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgDelegateResponse{}, nil
|
||||
|
@ -322,11 +307,6 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed
|
|||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgBeginRedelegateResponse{
|
||||
|
@ -383,11 +363,6 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (
|
|||
sdk.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
|
||||
sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)),
|
||||
),
|
||||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress),
|
||||
),
|
||||
})
|
||||
|
||||
return &types.MsgUndelegateResponse{
|
||||
|
|
|
@ -20,5 +20,4 @@ const (
|
|||
AttributeKeyCreationHeight = "creation_height"
|
||||
AttributeKeyCompletionTime = "completion_time"
|
||||
AttributeKeyNewShares = "new_shares"
|
||||
AttributeValueCategory = ModuleName
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue