Skip to content

Commit

Permalink
use EmitTypedEvent instead of EmitEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
liorzilp committed Sep 12, 2022
1 parent e98673a commit f830bf5
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 61 deletions.
40 changes: 0 additions & 40 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20280,16 +20280,6 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/dymensionxyz/dymension/rollapp/block_height_to_finalization_queue/{finalizationHeight}':
Expand Down Expand Up @@ -20516,16 +20506,6 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/dymensionxyz/dymension/rollapp/latest_state_info_index/{rollappId}':
Expand Down Expand Up @@ -20818,16 +20798,6 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/dymensionxyz/dymension/rollapp/rollapp/{rollappId}':
Expand Down Expand Up @@ -21148,16 +21118,6 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/dymensionxyz/dymension/rollapp/state_info/{rollappId}/{index}':
Expand Down
20 changes: 20 additions & 0 deletions proto/rollapp/event.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package dymensionxyz.dymension.rollapp;

option go_package = "github.com/dymensionxyz/dymension/x/rollapp/types";

// EventGrant is emitted on Msg/Grant
message EventStateUpdate {
// rollappId is the rollapp that was updated
// The rollappId follows the same standard as cosmos chain_id
string rollappId = 1;
// latestStateInfoIndex is a sequential increasing number, updating on each
// state update used for indexing to a specific state info
uint64 index = 2;
// startHeight is the block height of the first block in the batch
uint64 startHeight = 3;
// numBlocks is the number of blocks included in this batch update
uint64 numBlocks = 4;
// DAPath is the description of the location on the DA layer
string DAPath = 5;
}
18 changes: 8 additions & 10 deletions x/rollapp/keeper/msg_server_update_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"strconv"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -132,15 +131,14 @@ func (k msgServer) UpdateState(goCtx context.Context, msg *types.MsgUpdateState)
FinalizationQueue: newFinalizationQueue,
})

ctx.EventManager().EmitEvent(
sdk.NewEvent(types.EventTypeStateUpdate,
sdk.NewAttribute(types.AttributeKeyRollappId, msg.RollappId),
sdk.NewAttribute(types.AttributeKeyStateInfoIndex, strconv.FormatUint(stateInfoIndex.Index, 10)),
sdk.NewAttribute(types.AttributeKeyStartHeight, strconv.FormatUint(msg.StartHeight, 10)),
sdk.NewAttribute(types.AttributeKeyNumBlocks, strconv.FormatUint(msg.NumBlocks, 10)),
sdk.NewAttribute(types.AttributeKeyDAPath, msg.DAPath),
),
)
// nolint: errcheck, gosec
ctx.EventManager().EmitTypedEvent(&types.EventStateUpdate{
RollappId: msg.RollappId,
Index: newIndex,
StartHeight: msg.StartHeight,
NumBlocks: msg.NumBlocks,
DAPath: msg.DAPath,
})

return &types.MsgUpdateStateResponse{}, nil
}
Loading

0 comments on commit f830bf5

Please sign in to comment.