From 42cd30fe380c4285022e7f0d37a0b32e6e7ff997 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 10:14:01 +0100 Subject: [PATCH 01/14] refactor: updated posts event names Signed-off-by: Riccardo Montagnin --- x/posts/abci.go | 2 +- x/posts/keeper/msg_server.go | 22 ++-- x/posts/keeper/msg_server_test.go | 30 ++--- x/posts/spec/05-events.md | 200 +++++++++++++++--------------- x/posts/types/events.go | 24 ++-- 5 files changed, 139 insertions(+), 139 deletions(-) diff --git a/x/posts/abci.go b/x/posts/abci.go index e8eb512083..de66919396 100644 --- a/x/posts/abci.go +++ b/x/posts/abci.go @@ -18,7 +18,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) { // Emit an event ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeTallyPoll, + types.EventTypeTalliedPoll, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", poll.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", poll.PostID)), sdk.NewAttribute(types.AttributeKeyPollID, fmt.Sprintf("%d", poll.ID)), diff --git a/x/posts/keeper/msg_server.go b/x/posts/keeper/msg_server.go index c0f0474c12..e5b820da2f 100644 --- a/x/posts/keeper/msg_server.go +++ b/x/posts/keeper/msg_server.go @@ -103,7 +103,7 @@ func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) ( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeCreatePost, + types.EventTypeCreatedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", post.ID)), @@ -157,7 +157,7 @@ func (k msgServer) EditPost(goCtx context.Context, msg *types.MsgEditPost) (*typ ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeEditPost, + types.EventTypeEditedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyLastEditTime, updateTime.Format(time.RFC3339)), @@ -196,7 +196,7 @@ func (k msgServer) DeletePost(goCtx context.Context, msg *types.MsgDeletePost) ( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDeletePost, + types.EventTypeDeletedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), ), @@ -296,7 +296,7 @@ func (k msgServer) AddPostAttachment(goCtx context.Context, msg *types.MsgAddPos ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeAddPostAttachment, + types.EventTypeAddedPostAttachment, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyAttachmentID, fmt.Sprintf("%d", attachmentID)), @@ -353,7 +353,7 @@ func (k msgServer) RemovePostAttachment(goCtx context.Context, msg *types.MsgRem ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRemovePostAttachment, + types.EventTypeRemovedPostAttachment, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyAttachmentID, fmt.Sprintf("%d", msg.AttachmentID)), @@ -432,7 +432,7 @@ func (k msgServer) AnswerPoll(goCtx context.Context, msg *types.MsgAnswerPoll) ( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeAnswerPoll, + types.EventTypeAnsweredPoll, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyPollID, fmt.Sprintf("%d", msg.PollID)), @@ -530,7 +530,7 @@ func (k msgServer) MovePost(goCtx context.Context, msg *types.MsgMovePost) (*typ ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeMovePost, + types.EventTypeMovedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyNewSubspaceID, fmt.Sprintf("%d", msg.TargetSubspaceID)), @@ -586,7 +586,7 @@ func (k msgServer) RequestPostOwnerTransfer(goCtx context.Context, msg *types.Ms ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRequestPostOwnerTransfer, + types.EventTypeRequestedPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver), @@ -617,7 +617,7 @@ func (k msgServer) CancelPostOwnerTransferRequest(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeCancelPostOwnerTransfer, + types.EventTypeCanceledPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeySender, msg.Sender), @@ -673,7 +673,7 @@ func (k msgServer) AcceptPostOwnerTransferRequest(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeAcceptPostOwnerTransfer, + types.EventTypeAcceptedPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver), @@ -703,7 +703,7 @@ func (k msgServer) RefusePostOwnerTransferRequest(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRefusePostOwnerTransfer, + types.EventTypeRefusedPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver), diff --git a/x/posts/keeper/msg_server_test.go b/x/posts/keeper/msg_server_test.go index 860163f21c..4baa7554b5 100644 --- a/x/posts/keeper/msg_server_test.go +++ b/x/posts/keeper/msg_server_test.go @@ -364,7 +364,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreatePost() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreatePost, + types.EventTypeCreatedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySectionID, "0"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), @@ -480,7 +480,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreatePost() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreatePost, + types.EventTypeCreatedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySectionID, "0"), sdk.NewAttribute(types.AttributeKeyPostID, "2"), @@ -767,7 +767,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditPost() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeEditPost, + types.EventTypeEditedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyLastEditTime, time.Date(2021, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -968,7 +968,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeletePost() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeletePost, + types.EventTypeDeletedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), ), @@ -1019,7 +1019,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeletePost() { msg: types.NewMsgDeletePost(1, 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeletePost, + types.EventTypeDeletedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), ), @@ -1260,7 +1260,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddPostAttachment() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAddPostAttachment, + types.EventTypeAddedPostAttachment, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAttachmentID, "1"), @@ -1584,7 +1584,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemovePostAttachment() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRemovePostAttachment, + types.EventTypeRemovedPostAttachment, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAttachmentID, "1"), @@ -1666,7 +1666,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemovePostAttachment() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRemovePostAttachment, + types.EventTypeRemovedPostAttachment, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAttachmentID, "1"), @@ -2188,7 +2188,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAnswerPoll, + types.EventTypeAnsweredPoll, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyPollID, "1"), @@ -2269,7 +2269,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAnswerPoll, + types.EventTypeAnsweredPoll, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyPollID, "1"), @@ -2766,7 +2766,7 @@ func (suite *KeeperTestSuite) TestMsgServer_MovePost() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeMovePost, + types.EventTypeMovedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyNewSubspaceID, "2"), @@ -3155,7 +3155,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RequestPostOwnerTransfer() { expResponse: &types.MsgRequestPostOwnerTransferResponse{}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRequestPostOwnerTransfer, + types.EventTypeRequestedPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReceiver, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), @@ -3264,7 +3264,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CancelPostOwnerTransfer() { expResponse: &types.MsgCancelPostOwnerTransferRequestResponse{}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCancelPostOwnerTransfer, + types.EventTypeCanceledPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeySender, "cosmos1eqpa6mv2jgevukaqtjmx5535vhc3mm3cf458zg"), @@ -3504,7 +3504,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AcceptPostOwnerTransfer() { expResponse: &types.MsgAcceptPostOwnerTransferRequestResponse{}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAcceptPostOwnerTransfer, + types.EventTypeAcceptedPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReceiver, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), @@ -3599,7 +3599,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RefusePostOwnerTransfer() { expResponse: &types.MsgRefusePostOwnerTransferRequestResponse{}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRefusePostOwnerTransfer, + types.EventTypeRefusedPostOwnerTransfer, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReceiver, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), diff --git a/x/posts/spec/05-events.md b/x/posts/spec/05-events.md index b2075a6213..e23b351299 100644 --- a/x/posts/spec/05-events.md +++ b/x/posts/spec/05-events.md @@ -13,72 +13,72 @@ The posts module emits the following events: ### MsgCreatePost -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------|:------------------|:------------------------------| -| create_post | subspace_id | {subspaceID} | -| create_post | section_id | {sectionID} | -| create_post | post_id | {postID} | -| create_post | author | {userAddress} | -| create_post | creation_time | {CreationTime} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgCreatePost | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------|:------------------|:------------------------------| +| created_post | subspace_id | {subspaceID} | +| created_post | section_id | {sectionID} | +| created_post | post_id | {postID} | +| created_post | author | {userAddress} | +| created_post | creation_time | {CreationTime} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgCreatePost | +| message | sender | {userAddress} | ### MsgEditPost -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------|:------------------|:----------------------------| -| edit_post | subspace_id | {subspaceID} | -| edit_post | post_id | {postID} | -| edit_post | last_edit_time | {LastEditTime} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgEditPost | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------|:------------------|:----------------------------| +| edited_post | subspace_id | {subspaceID} | +| edited_post | post_id | {postID} | +| edited_post | last_edit_time | {LastEditTime} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgEditPost | +| message | sender | {userAddress} | ### MsgDeletePost -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------|:------------------|:------------------------------| -| delete_post | subspace_id | {subspaceID} | -| delete_post | post_id | {postID} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgDeletePost | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------|:------------------|:------------------------------| +| deleted_post | subspace_id | {subspaceID} | +| deleted_post | post_id | {postID} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgDeletePost | +| message | sender | {userAddress} | ### MsgAddPostAttachment -| **Type** | **Attribute Key** | **Attribute Value** | -|:--------------------|:------------------|:-------------------------------------| -| add_post_attachment | subspace_id | {subspaceID} | -| add_post_attachment | post_id | {postID} | -| add_post_attachment | attachment_id | {attachmentID} | -| add_post_attachment | last_edit_time | {lastEditTime} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgAddPostAttachment | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------------|:------------------|:-------------------------------------| +| added_post_attachment | subspace_id | {subspaceID} | +| added_post_attachment | post_id | {postID} | +| added_post_attachment | attachment_id | {attachmentID} | +| added_post_attachment | last_edit_time | {lastEditTime} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgAddPostAttachment | +| message | sender | {userAddress} | ### MsgRemovePostAttachment -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------|:------------------|:----------------------------------------| -| remove_post_attachment | subspace_id | {subspaceID} | -| remove_post_attachment | post_id | {postID} | -| remove_post_attachment | attachment_id | {attachmentID} | -| remove_post_attachment | last_edit_time | {lastEditTime} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgRemovePostAttachment | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------------|:------------------|:----------------------------------------| +| removed_post_attachment | subspace_id | {subspaceID} | +| removed_post_attachment | post_id | {postID} | +| removed_post_attachment | attachment_id | {attachmentID} | +| removed_post_attachment | last_edit_time | {lastEditTime} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgRemovePostAttachment | +| message | sender | {userAddress} | ### MsgAnswerPoll -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------|:------------------|:------------------------------| -| answer_poll | subspace_id | {subspaceID} | -| answer_poll | post_id | {postID} | -| answer_poll | poll_id | {pollID} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgAnswerPoll | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------|:------------------|:------------------------------| +| answered_poll | subspace_id | {subspaceID} | +| answered_poll | post_id | {postID} | +| answered_poll | poll_id | {pollID} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgAnswerPoll | +| message | sender | {userAddress} | ### MsgUpdateParams @@ -90,67 +90,67 @@ The posts module emits the following events: ## MsgMovePost -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------|:------------------|:----------------------------| -| move_post | subspace_id | {subspaceID} | -| move_post | post_id | {postID} | -| move_post | new_subspace_id | {newSubspaceID} | -| move_post | new_post_id | {newPostID} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgMovePost | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------|:------------------|:----------------------------| +| moved_post | subspace_id | {subspaceID} | +| moved_post | post_id | {postID} | +| moved_post | new_subspace_id | {newSubspaceID} | +| moved_post | new_post_id | {newPostID} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgMovePost | +| message | sender | {userAddress} | ## MsgRequestPostOwnerTransfer -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------------------|:------------------|:--------------------------------------------| -| request_post_owner_transfer | subspace_id | {subspaceID} | -| request_post_owner_transfer | post_id | {postID} | -| request_post_owner_transfer | receiver | {receiverAddress} | -| request_post_owner_transfer | sender | {senderAddress} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgRequestPostOwnerTransfer | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------------------|:------------------|:--------------------------------------------| +| requested_post_owner_transfer | subspace_id | {subspaceID} | +| requested_post_owner_transfer | post_id | {postID} | +| requested_post_owner_transfer | receiver | {receiverAddress} | +| requested_post_owner_transfer | sender | {senderAddress} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgRequestPostOwnerTransfer | +| message | sender | {userAddress} | ## MsgCancelPostOwnerTransferRequest -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------------------|:------------------|:--------------------------------------------------| -| cancel_post_owner_transfer | subspace_id | {subspaceID} | -| cancel_post_owner_transfer | post_id | {postID} | -| cancel_post_owner_transfer | sender | {senderAddress} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgCancelPostOwnerTransferRequest | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------------------|:------------------|:--------------------------------------------------| +| canceled_post_owner_transfer | subspace_id | {subspaceID} | +| canceled_post_owner_transfer | post_id | {postID} | +| canceled_post_owner_transfer | sender | {senderAddress} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgCancelPostOwnerTransferRequest | +| message | sender | {userAddress} | ## MsgAcceptPostOwnerTransferRequest -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------------------|:------------------|:--------------------------------------------------| -| accept_post_owner_transfer | subspace_id | {subspaceID} | -| accept_post_owner_transfer | post_id | {postID} | -| accept_post_owner_transfer | new_subspace_id | {newSubspaceID} | -| accept_post_owner_transfer | new_post_id | {newPostID} | -| accept_post_owner_transfer | receiver | {receiverAddress} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgAcceptPostOwnerTransferRequest | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------------------|:------------------|:--------------------------------------------------| +| accepted_post_owner_transfer | subspace_id | {subspaceID} | +| accepted_post_owner_transfer | post_id | {postID} | +| accepted_post_owner_transfer | new_subspace_id | {newSubspaceID} | +| accepted_post_owner_transfer | new_post_id | {newPostID} | +| accepted_post_owner_transfer | receiver | {receiverAddress} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgAcceptPostOwnerTransferRequest | +| message | sender | {userAddress} | ## MsgRefusePostOwnerTransferRequest -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------------------|:------------------|:--------------------------------------------------| -| refuse_post_owner_transfer | subspace_id | {subspaceID} | -| refuse_post_owner_transfer | post_id | {postID} | -| refuse_post_owner_transfer | receiver | {receiverAddress} | -| message | module | posts | -| message | action | desmos.posts.v3.MsgRefusePostOwnerTransferRequest | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------------------|:------------------|:--------------------------------------------------| +| refused_post_owner_transfer | subspace_id | {subspaceID} | +| refused_post_owner_transfer | post_id | {postID} | +| refused_post_owner_transfer | receiver | {receiverAddress} | +| message | module | posts | +| message | action | desmos.posts.v3.MsgRefusePostOwnerTransferRequest | +| message | sender | {userAddress} | ## Keeper -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------|:------------------|:--------------------| -| tally_poll | subspace_id | {subspaceID} | -| tally_poll | post_id | {postID} | -| tally_poll | poll_id | {pollID} | \ No newline at end of file +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------|:------------------|:--------------------| +| tallied_poll | subspace_id | {subspaceID} | +| tallied_poll | post_id | {postID} | +| tallied_poll | poll_id | {pollID} | \ No newline at end of file diff --git a/x/posts/types/events.go b/x/posts/types/events.go index 9a97feec7e..c038377c50 100644 --- a/x/posts/types/events.go +++ b/x/posts/types/events.go @@ -2,18 +2,18 @@ package types // Posts module event types const ( - EventTypeCreatePost = "create_post" - EventTypeEditPost = "edit_post" - EventTypeDeletePost = "delete_post" - EventTypeAddPostAttachment = "add_post_attachment" - EventTypeRemovePostAttachment = "remove_post_attachment" - EventTypeAnswerPoll = "answer_poll" - EventTypeTallyPoll = "tally_poll" - EventTypeMovePost = "move_post" - EventTypeRequestPostOwnerTransfer = "request_post_owner_transfer" - EventTypeCancelPostOwnerTransfer = "cancel_post_owner_transfer" - EventTypeAcceptPostOwnerTransfer = "accept_post_owner_transfer" - EventTypeRefusePostOwnerTransfer = "refuse_post_owner_transfer" + EventTypeCreatedPost = "created_post" + EventTypeEditedPost = "edited_post" + EventTypeDeletedPost = "deleted_post" + EventTypeAddedPostAttachment = "added_post_attachment" + EventTypeRemovedPostAttachment = "removed_post_attachment" + EventTypeAnsweredPoll = "answered_poll" + EventTypeTalliedPoll = "tallied_poll" + EventTypeMovedPost = "moved_post" + EventTypeRequestedPostOwnerTransfer = "requested_post_owner_transfer" + EventTypeCanceledPostOwnerTransfer = "canceled_post_owner_transfer" + EventTypeAcceptedPostOwnerTransfer = "accepted_post_owner_transfer" + EventTypeRefusedPostOwnerTransfer = "refused_post_owner_transfer" AttributeKeySubspaceID = "subspace_id" AttributeKeySectionID = "section_id" From 7bab8155f16bf119967e5a17dda4c2f94a9edbbf Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 10:39:27 +0100 Subject: [PATCH 02/14] refactor: updated profiles event names and emissions Signed-off-by: Riccardo Montagnin --- x/profiles/abci_test.go | 2 +- x/profiles/ibc_module.go | 26 +-- x/profiles/keeper/keeper_app_links.go | 4 +- x/profiles/keeper/keeper_app_links_test.go | 10 +- x/profiles/keeper/keeper_chain_links.go | 9 + x/profiles/keeper/msg_server_app_link.go | 2 +- x/profiles/keeper/msg_server_app_link_test.go | 10 +- x/profiles/keeper/msg_server_chain_link.go | 4 +- .../keeper/msg_server_chain_link_test.go | 4 +- .../keeper/msg_server_dtag_transfers.go | 8 +- .../keeper/msg_server_dtag_transfers_test.go | 12 +- x/profiles/keeper/msgs_server_profile.go | 4 +- x/profiles/keeper/msgs_server_profile_test.go | 10 +- x/profiles/spec/05-events.md | 189 ++++++++++-------- x/profiles/types/events.go | 32 +-- 15 files changed, 184 insertions(+), 142 deletions(-) diff --git a/x/profiles/abci_test.go b/x/profiles/abci_test.go index bf1984cc1e..b470ecda01 100644 --- a/x/profiles/abci_test.go +++ b/x/profiles/abci_test.go @@ -86,7 +86,7 @@ func TestBeginBlocker(t *testing.T) { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), diff --git a/x/profiles/ibc_module.go b/x/profiles/ibc_module.go index 5871de9b19..3f61085c47 100644 --- a/x/profiles/ibc_module.go +++ b/x/profiles/ibc_module.go @@ -241,11 +241,11 @@ func handleLinkChainAccountPacketData( ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeLinkChainAccountPacket, + types.EventTypeReceivedLinkChainAccountPacket, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeKeyChainLinkOwner, packetData.DestinationAddress), sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, address.GetValue()), sdk.NewAttribute(types.AttributeKeyChainLinkChainName, packetData.SourceChainConfig.Name), - sdk.NewAttribute(types.AttributeKeyChainLinkOwner, packetData.DestinationAddress), sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", true)), ), ) @@ -253,30 +253,30 @@ func handleLinkChainAccountPacketData( return true, acknowledgement, nil } -// handleOracleRequestPacketData tries handling athe given packet by deserializing the inner data +// handleOracleRequestPacketData tries handling the given packet by deserializing the inner data // as an OracleResponsePacketData instance. func handleOracleRequestPacketData( am IBCModule, ctx sdk.Context, packet channeltypes.Packet, ) (handled bool, ack channeltypes.Acknowledgement, err error) { - var data oracletypes.OracleResponsePacketData - if err := am.cdc.UnmarshalJSON(packet.GetData(), &data); err != nil { + var packetData oracletypes.OracleResponsePacketData + if err := am.cdc.UnmarshalJSON(packet.GetData(), &packetData); err != nil { return false, channeltypes.Acknowledgement{}, nil } acknowledgement := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - err = am.keeper.OnRecvApplicationLinkPacketData(ctx, data) + err = am.keeper.OnRecvApplicationLinkPacketData(ctx, packetData) if err != nil { acknowledgement = channeltypes.NewErrorAcknowledgement(err) } ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypePacket, + types.EventTypeReceivedOracleResponsePacketData, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(types.AttributeKeyClientID, data.ClientID), - sdk.NewAttribute(types.AttributeKeyRequestID, fmt.Sprintf("%d", data.RequestID)), - sdk.NewAttribute(types.AttributeKeyResolveStatus, data.ResolveStatus.String()), + sdk.NewAttribute(types.AttributeKeyClientID, packetData.ClientID), + sdk.NewAttribute(types.AttributeKeyRequestID, fmt.Sprintf("%d", packetData.RequestID)), + sdk.NewAttribute(types.AttributeKeyResolveStatus, packetData.ResolveStatus.String()), sdk.NewAttribute(types.AttributeKeyAckSuccess, fmt.Sprintf("%t", true)), ), ) @@ -315,7 +315,7 @@ func (am IBCModule) OnAcknowledgementPacket( ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypePacket, + types.EventTypeReceivedOracleResponsePacketData, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(types.AttributeKeyClientID, data.ClientID), sdk.NewAttribute(types.AttributeKeyAck, fmt.Sprintf("%v", ack)), @@ -326,14 +326,14 @@ func (am IBCModule) OnAcknowledgementPacket( case *channeltypes.Acknowledgement_Result: ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypePacket, + types.EventTypeReceivedOracleResponsePacketData, sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), ), ) case *channeltypes.Acknowledgement_Error: ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypePacket, + types.EventTypeReceivedOracleResponsePacketData, sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), ), ) diff --git a/x/profiles/keeper/keeper_app_links.go b/x/profiles/keeper/keeper_app_links.go index 94be07c93a..706c65c503 100644 --- a/x/profiles/keeper/keeper_app_links.go +++ b/x/profiles/keeper/keeper_app_links.go @@ -33,7 +33,7 @@ func (k Keeper) SaveApplicationLink(ctx sdk.Context, link types.ApplicationLink) ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypesApplicationLinkSaved, + types.EventTypeSavedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, link.User), sdk.NewAttribute(types.AttributeKeyApplicationName, link.Data.Application), sdk.NewAttribute(types.AttributeKeyApplicationUsername, link.Data.Username), @@ -108,7 +108,7 @@ func (k Keeper) DeleteApplicationLink(ctx sdk.Context, appLink types.Application ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, appLink.User), sdk.NewAttribute(types.AttributeKeyApplicationName, appLink.Data.Application), sdk.NewAttribute(types.AttributeKeyApplicationUsername, appLink.Data.Username), diff --git a/x/profiles/keeper/keeper_app_links_test.go b/x/profiles/keeper/keeper_app_links_test.go index 05610c7488..bb8a12d70d 100644 --- a/x/profiles/keeper/keeper_app_links_test.go +++ b/x/profiles/keeper/keeper_app_links_test.go @@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) Test_SaveApplicationLink() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypesApplicationLinkSaved, + types.EventTypeSavedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), @@ -422,7 +422,7 @@ func (suite *KeeperTestSuite) Test_DeleteApplicationLink() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos1xvvggrlgjkhu4rva9j500rc52za2smxhluvftc"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), @@ -476,7 +476,7 @@ func (suite *KeeperTestSuite) Test_DeleteApplicationLink() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "github"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), @@ -530,7 +530,7 @@ func (suite *KeeperTestSuite) Test_DeleteApplicationLink() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "another-user"), @@ -584,7 +584,7 @@ func (suite *KeeperTestSuite) Test_DeleteApplicationLink() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), diff --git a/x/profiles/keeper/keeper_chain_links.go b/x/profiles/keeper/keeper_chain_links.go index c072a27127..112a6f012f 100644 --- a/x/profiles/keeper/keeper_chain_links.go +++ b/x/profiles/keeper/keeper_chain_links.go @@ -56,6 +56,15 @@ func (k Keeper) SaveChainLink(ctx sdk.Context, link types.ChainLink) error { k.SaveDefaultExternalAddress(ctx, link.User, link.ChainConfig.Name, srcAddrData.GetValue()) } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeSavedChainLink, + sdk.NewAttribute(types.AttributeKeyChainLinkOwner, link.User), + sdk.NewAttribute(types.AttributeKeyChainLinkChainName, link.ChainConfig.Name), + sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, link.GetAddressData().GetValue()), + ), + ) + k.AfterChainLinkSaved(ctx, link) return nil } diff --git a/x/profiles/keeper/msg_server_app_link.go b/x/profiles/keeper/msg_server_app_link.go index d4e3edb6a8..c79287ffe3 100644 --- a/x/profiles/keeper/msg_server_app_link.go +++ b/x/profiles/keeper/msg_server_app_link.go @@ -49,7 +49,7 @@ func (k Keeper) LinkApplication( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypesApplicationLinkCreated, + types.EventTypeCreatedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, msg.Sender), sdk.NewAttribute(types.AttributeKeyApplicationName, msg.LinkData.Application), sdk.NewAttribute(types.AttributeKeyApplicationUsername, msg.LinkData.Username), diff --git a/x/profiles/keeper/msg_server_app_link_test.go b/x/profiles/keeper/msg_server_app_link_test.go index 8500841ad3..c20076c310 100644 --- a/x/profiles/keeper/msg_server_app_link_test.go +++ b/x/profiles/keeper/msg_server_app_link_test.go @@ -231,13 +231,13 @@ func (suite *KeeperTestSuite) TestMsgServer_LinkApplication() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypesApplicationLinkSaved, + types.EventTypeSavedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), ), sdk.NewEvent( - types.EventTypesApplicationLinkCreated, + types.EventTypeCreatedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), @@ -337,13 +337,13 @@ func (suite *KeeperTestSuite) TestMsgServer_LinkApplication() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypesApplicationLinkSaved, + types.EventTypeSavedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), ), sdk.NewEvent( - types.EventTypesApplicationLinkCreated, + types.EventTypeCreatedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), @@ -510,7 +510,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UnlinkApplication() { msg: types.NewMsgUnlinkApplication("twitter", "twitteruser", "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeApplicationLinkDeleted, + types.EventTypeDeletedApplicationLink, sdk.NewAttribute(types.AttributeKeyUser, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyApplicationName, "twitter"), sdk.NewAttribute(types.AttributeKeyApplicationUsername, "twitteruser"), diff --git a/x/profiles/keeper/msg_server_chain_link.go b/x/profiles/keeper/msg_server_chain_link.go index 4e0f5a05bb..5f268346cd 100644 --- a/x/profiles/keeper/msg_server_chain_link.go +++ b/x/profiles/keeper/msg_server_chain_link.go @@ -29,7 +29,7 @@ func (k MsgServer) LinkChainAccount(goCtx context.Context, msg *types.MsgLinkCha ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeLinkChainAccount, + types.EventTypeCreatedChainLink, sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, srcAddrData.GetValue()), sdk.NewAttribute(types.AttributeKeyChainLinkChainName, msg.ChainConfig.Name), sdk.NewAttribute(types.AttributeKeyChainLinkOwner, msg.Signer), @@ -55,7 +55,7 @@ func (k MsgServer) UnlinkChainAccount(goCtx context.Context, msg *types.MsgUnlin ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeUnlinkChainAccount, + types.EventTypeDeletedChainLink, sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, msg.Target), sdk.NewAttribute(types.AttributeKeyChainLinkChainName, msg.ChainName), sdk.NewAttribute(types.AttributeKeyChainLinkOwner, msg.Owner), diff --git a/x/profiles/keeper/msg_server_chain_link_test.go b/x/profiles/keeper/msg_server_chain_link_test.go index 3de7b23cfa..5426a29ea0 100644 --- a/x/profiles/keeper/msg_server_chain_link_test.go +++ b/x/profiles/keeper/msg_server_chain_link_test.go @@ -108,7 +108,7 @@ func (suite *KeeperTestSuite) TestMsgServer_LinkChainAccount() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeLinkChainAccount, + types.EventTypeCreatedChainLink, sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, srcAddr), sdk.NewAttribute(types.AttributeKeyChainLinkChainName, "cosmos"), sdk.NewAttribute(types.AttributeKeyChainLinkOwner, destAddr), @@ -199,7 +199,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UnlinkChainAccount() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeUnlinkChainAccount, + types.EventTypeDeletedChainLink, sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), sdk.NewAttribute(types.AttributeKeyChainLinkChainName, "cosmos"), sdk.NewAttribute(types.AttributeKeyChainLinkOwner, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), diff --git a/x/profiles/keeper/msg_server_dtag_transfers.go b/x/profiles/keeper/msg_server_dtag_transfers.go index e9e73bc4bd..b1e494ef1d 100644 --- a/x/profiles/keeper/msg_server_dtag_transfers.go +++ b/x/profiles/keeper/msg_server_dtag_transfers.go @@ -45,7 +45,7 @@ func (k MsgServer) RequestDTagTransfer(goCtx context.Context, msg *types.MsgRequ ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferRequest, + types.EventTypeRequestedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyDTagToTrade, dTagToTrade), sdk.NewAttribute(types.AttributeKeyRequestSender, transferRequest.Sender), sdk.NewAttribute(types.AttributeKeyRequestReceiver, transferRequest.Receiver), @@ -69,7 +69,7 @@ func (k MsgServer) CancelDTagTransferRequest(goCtx context.Context, msg *types.M ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferCancel, + types.EventTypeCanceledDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyRequestSender, msg.Sender), sdk.NewAttribute(types.AttributeKeyRequestReceiver, msg.Receiver), ), @@ -166,7 +166,7 @@ func (k MsgServer) AcceptDTagTransferRequest(goCtx context.Context, msg *types.M ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferAccept, + types.EventTypeAcceptedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyDTagToTrade, dTagToTrade), sdk.NewAttribute(types.AttributeKeyNewDTag, msg.NewDTag), sdk.NewAttribute(types.AttributeKeyRequestSender, msg.Sender), @@ -191,7 +191,7 @@ func (k MsgServer) RefuseDTagTransferRequest(goCtx context.Context, msg *types.M ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferRefuse, + types.EventTypeRefusedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyRequestSender, msg.Sender), sdk.NewAttribute(types.AttributeKeyRequestReceiver, msg.Receiver), ), diff --git a/x/profiles/keeper/msg_server_dtag_transfers_test.go b/x/profiles/keeper/msg_server_dtag_transfers_test.go index e280245e3b..afa5aa9725 100644 --- a/x/profiles/keeper/msg_server_dtag_transfers_test.go +++ b/x/profiles/keeper/msg_server_dtag_transfers_test.go @@ -83,7 +83,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RequestDTagTransfer() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferRequest, + types.EventTypeRequestedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyDTagToTrade, fmt.Sprintf("%s-dtag", "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns")), sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyRequestReceiver, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), @@ -150,7 +150,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CancelDTagTransfer() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferCancel, + types.EventTypeCanceledDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyRequestReceiver, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), ), @@ -367,7 +367,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AcceptDTagTransfer() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferAccept, + types.EventTypeAcceptedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyDTagToTrade, "DTag"), sdk.NewAttribute(types.AttributeKeyNewDTag, "NewDtag"), sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), @@ -396,7 +396,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AcceptDTagTransfer() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferAccept, + types.EventTypeAcceptedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyDTagToTrade, "DTag"), sdk.NewAttribute(types.AttributeKeyNewDTag, "NewDtag"), sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), @@ -434,7 +434,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AcceptDTagTransfer() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferAccept, + types.EventTypeAcceptedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyDTagToTrade, "receiverDTag"), sdk.NewAttribute(types.AttributeKeyNewDTag, "senderDTag"), sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), @@ -511,7 +511,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RefuseDTagTransfer() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDTagTransferRefuse, + types.EventTypeRefusedDTagTransferRequest, sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyRequestReceiver, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), ), diff --git a/x/profiles/keeper/msgs_server_profile.go b/x/profiles/keeper/msgs_server_profile.go index 0e8b2fb267..3f7517288c 100644 --- a/x/profiles/keeper/msgs_server_profile.go +++ b/x/profiles/keeper/msgs_server_profile.go @@ -71,7 +71,7 @@ func (k MsgServer) SaveProfile(goCtx context.Context, msg *types.MsgSaveProfile) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeProfileSaved, + types.EventTypeSavedProfile, sdk.NewAttribute(types.AttributeKeyProfileDTag, updated.DTag), sdk.NewAttribute(types.AttributeKeyProfileCreator, updated.GetAddress().String()), sdk.NewAttribute(types.AttributeKeyProfileCreationTime, updated.CreationDate.Format(time.RFC3339Nano)), @@ -92,7 +92,7 @@ func (k MsgServer) DeleteProfile(goCtx context.Context, msg *types.MsgDeleteProf ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeProfileDeleted, + types.EventTypeDeletedProfile, sdk.NewAttribute(types.AttributeKeyProfileCreator, msg.Creator), ), }) diff --git a/x/profiles/keeper/msgs_server_profile_test.go b/x/profiles/keeper/msgs_server_profile_test.go index 84ba020b12..e7f3338963 100644 --- a/x/profiles/keeper/msgs_server_profile_test.go +++ b/x/profiles/keeper/msgs_server_profile_test.go @@ -51,7 +51,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SaveProfile() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeProfileSaved, + types.EventTypeSavedProfile, sdk.NewAttribute(types.AttributeKeyProfileDTag, "custom_dtag"), sdk.NewAttribute(types.AttributeKeyProfileCreator, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyProfileCreationTime, blockTime.Format(time.RFC3339)), @@ -85,7 +85,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SaveProfile() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeProfileSaved, + types.EventTypeSavedProfile, sdk.NewAttribute(types.AttributeKeyProfileDTag, "other_dtag"), sdk.NewAttribute(types.AttributeKeyProfileCreator, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyProfileCreationTime, blockTime.Format(time.RFC3339)), @@ -125,7 +125,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SaveProfile() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeProfileSaved, + types.EventTypeSavedProfile, sdk.NewAttribute(types.AttributeKeyProfileDTag, "Test"), sdk.NewAttribute(types.AttributeKeyProfileCreator, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), sdk.NewAttribute(types.AttributeKeyProfileCreationTime, blockTime.Format(time.RFC3339)), @@ -203,7 +203,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SaveProfile() { ), expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeProfileSaved, + types.EventTypeSavedProfile, sdk.NewAttribute(types.AttributeKeyProfileDTag, "tomtom"), sdk.NewAttribute(types.AttributeKeyProfileCreator, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), sdk.NewAttribute(types.AttributeKeyProfileCreationTime, blockTime.Format(time.RFC3339)), @@ -294,7 +294,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteProfile() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeProfileDeleted, + types.EventTypeDeletedProfile, sdk.NewAttribute(types.AttributeKeyProfileCreator, "cosmos10nsdxxdvy9qka3zv0lzw8z9cnu6kanld8jh773"), ), }, diff --git a/x/profiles/spec/05-events.md b/x/profiles/spec/05-events.md index 60fd41b867..0501a7c8c0 100644 --- a/x/profiles/spec/05-events.md +++ b/x/profiles/spec/05-events.md @@ -13,89 +13,89 @@ The profiles module emits the following events: ### MsgSaveProfile -| **Type** | **Attribute Key** | **Attribute Value** | -|:-------------|:----------------------|:----------------------------------| -| save_profile | profile_dtag | {profileDTag} | -| save_profile | profile_creator | {userAddress} | -| save_profile | profile_creation_time | {profileCreationTime} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgSaveProfile | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------|:----------------------|:----------------------------------| +| saved_profile | profile_dtag | {profileDTag} | +| saved_profile | profile_creator | {userAddress} | +| saved_profile | profile_creation_time | {profileCreationTime} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgSaveProfile | +| message | sender | {userAddress} | ## MsgDeleteProfile -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------|:------------------|:------------------------------------| -| delete_profile | profile_creator | {userAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgDeleteProfile | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------|:------------------|:------------------------------------| +| deleted_profile | profile_creator | {userAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgDeleteProfile | +| message | sender | {userAddress} | ## MsgRequestDTagTransfer -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------------|:------------------|:------------------------------------------| -| create_dtag_transfer_request | dtag_to_trade | {dTagToTrade} | -| create_dtag_transfer_request | request_sender | {requestSenderAddress} | -| create_dtag_transfer_request | request_receiver | {requestReceiverAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgRequestDTagTransfer | -| message | sender | {requestSenderAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------------------|:------------------|:------------------------------------------| +| created_dtag_transfer_request | dtag_to_trade | {dTagToTrade} | +| created_dtag_transfer_request | request_sender | {requestSenderAddress} | +| created_dtag_transfer_request | request_receiver | {requestReceiverAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgRequestDTagTransfer | +| message | sender | {requestSenderAddress} | ## MsgCancelDTagTransferRequest -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------------|:------------------|:------------------------------------------------| -| cancel_dtag_transfer_request | request_sender | {requestSenderAddress} | -| cancel_dtag_transfer_request | request_receiver | {requestReceiverAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgCancelDTagTransferRequest | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------------|:------------------|:------------------------------------------------| +| canceled_dtag_transfer_request | request_sender | {requestSenderAddress} | +| canceled_dtag_transfer_request | request_receiver | {requestReceiverAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgCancelDTagTransferRequest | +| message | sender | {userAddress} | ## MsgAcceptDTagTransferRequest -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------------|:------------------|:------------------------------------------------| -| accept_dtag_transfer_request | dtag_to_trade | {dTagToTrade} | -| accept_dtag_transfer_request | new_dtag | {newDTag} | -| accept_dtag_transfer_request | request_sender | {requestSenderAddress} | -| accept_dtag_transfer_request | request_receiver | {requestReceiverAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgAcceptDTagTransferRequest | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------------|:------------------|:------------------------------------------------| +| accepted_dtag_transfer_request | dtag_to_trade | {dTagToTrade} | +| accepted_dtag_transfer_request | new_dtag | {newDTag} | +| accepted_dtag_transfer_request | request_sender | {requestSenderAddress} | +| accepted_dtag_transfer_request | request_receiver | {requestReceiverAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgAcceptDTagTransferRequest | +| message | sender | {userAddress} | ## MsgRefuseDTagTransferRequest -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------------|:------------------|:------------------------------------------------| -| refuse_dtag_transfer_request | request_sender | {requestSenderAddress} | -| refuse_dtag_transfer_request | request_receiver | {requestReceiverAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgRefuseDTagTransferRequest | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------------------|:------------------|:------------------------------------------------| +| refused_dtag_transfer_request | request_sender | {requestSenderAddress} | +| refused_dtag_transfer_request | request_receiver | {requestReceiverAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgRefuseDTagTransferRequest | +| message | sender | {userAddress} | ## MsgLinkChainAccount | **Type** | **Attribute Key** | **Attribute Value** | |:-------------------|:-----------------------------|:---------------------------------------| -| link_chain_account | chain_link_account_target | {targetAddress} | -| link_chain_account | chain_link_source_chain_name | {chainName} | -| link_chain_account | chain_link_account_owner | {userAddress} | -| link_chain_account | chain_link_creation_time | {creationTime} | +| created_chain_link | chain_link_account_target | {targetAddress} | +| created_chain_link | chain_link_source_chain_name | {chainName} | +| created_chain_link | chain_link_account_owner | {userAddress} | +| created_chain_link | chain_link_creation_time | {creationTime} | | message | module | profiles | | message | action | desmos.profiles.v3.MsgLinkChainAccount | | message | sender | {userAddress} | ## MsgUnlinkChainAccount -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------------|:-----------------------------|:-----------------------------------------| -| unlink_chain_account | chain_link_account_target | {targetAddress} | -| unlink_chain_account | chain_link_source_chain_name | {chainName} | -| unlink_chain_account | chain_link_account_owner | {userAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgUnlinkChainAccount | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------|:-----------------------------|:-----------------------------------------| +| deleted_chain_link | chain_link_account_target | {targetAddress} | +| deleted_chain_link | chain_link_source_chain_name | {chainName} | +| deleted_chain_link | chain_link_account_owner | {userAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgUnlinkChainAccount | +| message | sender | {userAddress} | ## MsgSetDefaultExternalAddress @@ -110,32 +110,63 @@ The profiles module emits the following events: ## MsgLinkApplication -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------|:-------------------------------|:--------------------------------------| -| link_application | user | {userAddress} | -| link_application | application_name | {applicationName} | -| link_application | application_username | {applicationUsername} | -| link_application | application_link_creation_time | {creationTime} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgLinkApplication | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------|:-------------------------------|:--------------------------------------| +| created_application_link | user | {userAddress} | +| created_application_link | application_name | {applicationName} | +| created_application_link | application_username | {applicationUsername} | +| created_application_link | application_link_creation_time | {creationTime} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgLinkApplication | +| message | sender | {userAddress} | ## MsgUnlinkApplication -| **Type** | **Attribute Key** | **Attribute Value** | -|:-------------------|:---------------------|:----------------------------------------| -| unlink_application | user | {userAddress} | -| unlink_application | application_name | {applicationName} | -| unlink_application | application_username | {applicationUsername} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgUnlinkApplication | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------|:---------------------|:----------------------------------------| +| deleted_application_link | user | {userAddress} | +| deleted_application_link | application_name | {applicationName} | +| deleted_application_link | application_username | {applicationUsername} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgUnlinkApplication | +| message | sender | {userAddress} | ## Keeper +### Chain Link Saved + +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------|:----------------------------|:--------------------| +| saved_chain_link | chain_link_owner | {userAddress} | +| saved_chain_link | chain_link_chain_name | {chainName} | +| saved_chain_link | chain_link_external_address | {externalAddress} | + ### Application Link Saved -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------|:---------------------|:----------------------------------------| -| application_link_saved | user | {userAddress} | -| application_link_saved | application_name | {applicationName} | -| application_link_saved | application_username | {applicationUsername} | \ No newline at end of file + +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------------|:---------------------|:----------------------| +| saved_application_link | user | {userAddress} | +| saved_application_link | application_name | {applicationName} | +| saved_application_link | application_username | {applicationUsername} | + +## IBC + +### Received link chain account IBC packet + +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------------------------|:----------------------------|:--------------------| +| received_link_chain_account_packet | module | profiles | +| received_link_chain_account_packet | chain_link_owner | {userAddress} | +| received_link_chain_account_packet | chain_link_chain_name | {chainName} | +| received_link_chain_account_packet | chain_link_external_address | {externalAddress} | +| received_link_chain_account_packet | success | true | + +### Received oracle response IBC packet + +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------------------------|:------------------|:--------------------| +| received_oracle_response_packet | module | profiles | +| received_oracle_response_packet | client_id | {clientID} | +| received_oracle_response_packet | request_id | {requestID} | +| received_oracle_response_packet | resolve_status | {resolveStatus} | +| received_oracle_response_packet | success | true | diff --git a/x/profiles/types/events.go b/x/profiles/types/events.go index 03fbd539a0..0973023a3a 100644 --- a/x/profiles/types/events.go +++ b/x/profiles/types/events.go @@ -3,21 +3,23 @@ package types // DONTCOVER const ( - EventTypeProfileSaved = "save_profile" - EventTypeProfileDeleted = "delete_profile" - EventTypeDTagTransferRequest = "create_dtag_transfer_request" - EventTypeDTagTransferAccept = "accept_dtag_transfer_request" - EventTypeDTagTransferRefuse = "refuse_dtag_transfer_request" - EventTypeDTagTransferCancel = "cancel_dtag_transfer_request" - EventTypeLinkChainAccount = "link_chain_account" - EventTypeUnlinkChainAccount = "unlink_chain_account" - EventTypeSetDefaultExternalAddress = "set_default_external_address" - EventTypeLinkChainAccountPacket = "link_chain_account_packet" - EventTypePacket = "receive_profiles_verification_packet" - EventTypeTimeout = "timeout" - EventTypesApplicationLinkCreated = "link_application" - EventTypeApplicationLinkDeleted = "unlink_application" - EventTypesApplicationLinkSaved = "application_link_saved" + EventTypeSavedProfile = "saved_profile" + EventTypeDeletedProfile = "deleted_profile" + + EventTypeRequestedDTagTransferRequest = "created_dtag_transfer_request" + EventTypeAcceptedDTagTransferRequest = "accepted_dtag_transfer_request" + EventTypeRefusedDTagTransferRequest = "refused_dtag_transfer_request" + EventTypeCanceledDTagTransferRequest = "canceled_dtag_transfer_request" + EventTypeCreatedChainLink = "created_chain_link" + EventTypeDeletedChainLink = "deleted_chain_link" + EventTypeSavedChainLink = "saved_chain_link" + EventTypeSetDefaultExternalAddress = "set_default_external_address" + EventTypeCreatedApplicationLink = "created_application_link" + EventTypeDeletedApplicationLink = "deleted_application_link" + EventTypeSavedApplicationLink = "saved_application_link" + EventTypeReceivedLinkChainAccountPacket = "received_link_chain_account_packet" + EventTypeReceivedOracleResponsePacketData = "received_oracle_response_packet" + EventTypeTimeout = "timeout" AttributeKeyProfileDTag = "profile_dtag" AttributeKeyProfileCreator = "profile_creator" From 8403e692762f5376363898a676f0a000ccee91a2 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 10:41:26 +0100 Subject: [PATCH 03/14] refactor: updated reactions event names Signed-off-by: Riccardo Montagnin --- x/reactions/keeper/msg_server.go | 6 +-- x/reactions/keeper/msg_server_test.go | 10 ++-- x/reactions/spec/05-events.md | 76 +++++++++++++-------------- x/reactions/types/events.go | 10 ++-- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/x/reactions/keeper/msg_server.go b/x/reactions/keeper/msg_server.go index 22ca1eac69..becaa8b48a 100644 --- a/x/reactions/keeper/msg_server.go +++ b/x/reactions/keeper/msg_server.go @@ -90,7 +90,7 @@ func (k msgServer) AddReaction(goCtx context.Context, msg *types.MsgAddReaction) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeAddReaction, + types.EventTypeAddedReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReactionID, fmt.Sprintf("%d", reaction.ID)), @@ -139,7 +139,7 @@ func (k msgServer) RemoveReaction(goCtx context.Context, msg *types.MsgRemoveRea ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveReaction, + types.EventTypeRemovedReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReactionID, fmt.Sprintf("%d", msg.ReactionID)), @@ -265,7 +265,7 @@ func (k msgServer) RemoveRegisteredReaction(goCtx context.Context, msg *types.Ms ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveRegisteredReaction, + types.EventTypeRemovedRegisteredReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, fmt.Sprintf("%d", msg.RegisteredReactionID)), ), diff --git a/x/reactions/keeper/msg_server_test.go b/x/reactions/keeper/msg_server_test.go index 4be4145ff2..bb5bf75b09 100644 --- a/x/reactions/keeper/msg_server_test.go +++ b/x/reactions/keeper/msg_server_test.go @@ -416,7 +416,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddReaction() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAddReaction, + types.EventTypeAddedReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReactionID, "1"), @@ -502,7 +502,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddReaction() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAddReaction, + types.EventTypeAddedReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReactionID, "1"), @@ -780,7 +780,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveReaction() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveReaction, + types.EventTypeRemovedReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReactionID, "1"), @@ -947,7 +947,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddRegisteredReaction() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAddRegisteredReaction, + types.EventTypeAddedRegisteredReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, "1"), ), @@ -1281,7 +1281,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveRegisteredReaction() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveRegisteredReaction, + types.EventTypeRemovedRegisteredReaction, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, "1"), ), diff --git a/x/reactions/spec/05-events.md b/x/reactions/spec/05-events.md index 8fee51f810..7ea1fcfbeb 100644 --- a/x/reactions/spec/05-events.md +++ b/x/reactions/spec/05-events.md @@ -13,56 +13,56 @@ The reactions module emits the following events: ### MsgAddReaction -| **Type** | **Attribute Key** | **Attribute Value** | -|:-------------|:------------------|:-----------------------------------| -| add_reaction | subspace_id | {subspaceID} | -| add_reaction | post_id | {postID} | -| add_reaction | reaction_id | {reactionID} | -| add_reaction | user | {userAddress} | -| message | module | reactions | -| message | action | desmos.reactions.v1.MsgAddReaction | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:---------------|:------------------|:-----------------------------------| +| added_reaction | subspace_id | {subspaceID} | +| added_reaction | post_id | {postID} | +| added_reaction | reaction_id | {reactionID} | +| added_reaction | user | {userAddress} | +| message | module | reactions | +| message | action | desmos.reactions.v1.MsgAddReaction | +| message | sender | {userAddress} | ### MsgRemoveReaction -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------|:------------------|:--------------------------------------| -| remove_reaction | subspace_id | {subspaceID} | -| remove_reaction | post_id | {postID} | -| remove_reaction | reaction_id | {reaction_id} | -| message | module | reactions | -| message | action | desmos.reactions.v1.MsgRemoveReaction | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------|:------------------|:--------------------------------------| +| removed_reaction | subspace_id | {subspaceID} | +| removed_reaction | post_id | {postID} | +| removed_reaction | reaction_id | {reaction_id} | +| message | module | reactions | +| message | action | desmos.reactions.v1.MsgRemoveReaction | +| message | sender | {userAddress} | ### MsgAddRegisteredReaction -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------------------|:-----------------------|:---------------------------------------------| -| add_registered_reaction | subspace_id | {subspaceID} | -| add_registered_reaction | registered_reaction_id | {registeredReactionID} | -| message | module | reactions | -| message | action | desmos.reactions.v1.MsgAddRegisteredReaction | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------------------|:-----------------------|:---------------------------------------------| +| added_registered_reaction | subspace_id | {subspaceID} | +| added_registered_reaction | registered_reaction_id | {registeredReactionID} | +| message | module | reactions | +| message | action | desmos.reactions.v1.MsgAddRegisteredReaction | +| message | sender | {userAddress} | ### MsgEditRegisteredReaction -| **Type** | **Attribute Key** | **Attribute Value** | -|:-------------------------|:-----------------------|:----------------------------------------------| -| edit_registered_reaction | subspace_id | {subspaceID} | -| edit_registered_reaction | registered_reaction_id | {registeredReactionID} | -| message | module | reactions | -| message | action | desmos.reactions.v1.MsgEditRegisteredReaction | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:---------------------------|:-----------------------|:----------------------------------------------| +| edited_registered_reaction | subspace_id | {subspaceID} | +| edited_registered_reaction | registered_reaction_id | {registeredReactionID} | +| message | module | reactions | +| message | action | desmos.reactions.v1.MsgEditRegisteredReaction | +| message | sender | {userAddress} | ### MsgRemoveRegisteredReaction -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------------------|:-----------------------|:------------------------------------------------| -| remove_registered_reaction | subspace_id | {subspaceID} | -| remove_registered_reaction | registered_reaction_id | {registeredReactionID} | -| message | module | reactions | -| message | action | desmos.reactions.v1.MsgRemoveRegisteredReaction | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------------------|:-----------------------|:------------------------------------------------| +| removed_registered_reaction | subspace_id | {subspaceID} | +| removed_registered_reaction | registered_reaction_id | {registeredReactionID} | +| message | module | reactions | +| message | action | desmos.reactions.v1.MsgRemoveRegisteredReaction | +| message | sender | {userAddress} | ### MsgSetReactionsParams diff --git a/x/reactions/types/events.go b/x/reactions/types/events.go index e6a8c8bcf0..fd8692d29b 100644 --- a/x/reactions/types/events.go +++ b/x/reactions/types/events.go @@ -3,11 +3,11 @@ package types // DONTCOVER const ( - EventTypeAddReaction = "add_reaction" - EventTypeRemoveReaction = "remove_reaction" - EventTypeAddRegisteredReaction = "add_registered_reaction" - EventTypeRemoveRegisteredReaction = "removed_registered_reaction" - EventTypeSetReactionsParams = "set_reactions_params" + EventTypeAddedReaction = "added_reaction" + EventTypeRemovedReaction = "removed_reaction" + EventTypeAddedRegisteredReaction = "added_registered_reaction" + EventTypeRemovedRegisteredReaction = "removed_registered_reaction" + EventTypeSetReactionsParams = "set_reactions_params" AttributeKeySubspaceID = "subspace_id" AttributeKeyPostID = "post_id" From 59426f158c7eac20b9750dd45014ccfdbdaf6b59 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 10:43:56 +0100 Subject: [PATCH 04/14] refactor: updated relationships event names Signed-off-by: Riccardo Montagnin --- x/relationships/keeper/msg_server.go | 16 +++--- x/relationships/keeper/msg_server_test.go | 16 +++--- x/relationships/spec/05-events.md | 66 +++++++++++------------ x/relationships/types/events.go | 10 ++-- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/x/relationships/keeper/msg_server.go b/x/relationships/keeper/msg_server.go index 21d117c43b..82f9f6cc3e 100644 --- a/x/relationships/keeper/msg_server.go +++ b/x/relationships/keeper/msg_server.go @@ -48,10 +48,10 @@ func (k msgServer) CreateRelationship(goCtx context.Context, msg *types.MsgCreat ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRelationshipCreated, + types.EventTypeCreatedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, msg.Signer), sdk.NewAttribute(types.AttributeRelationshipCounterparty, msg.Counterparty), - sdk.NewAttribute(types.AttributeKeySubspace, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -77,10 +77,10 @@ func (k msgServer) DeleteRelationship(goCtx context.Context, msg *types.MsgDelet ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRelationshipDeleted, + types.EventTypeDeletedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, msg.Signer), sdk.NewAttribute(types.AttributeRelationshipCounterparty, msg.Counterparty), - sdk.NewAttribute(types.AttributeKeySubspace, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -106,10 +106,10 @@ func (k msgServer) BlockUser(goCtx context.Context, msg *types.MsgBlockUser) (*t ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeBlockUser, + types.EventTypeBlockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, msg.Blocker), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, msg.Blocked), - sdk.NewAttribute(types.AttributeKeySubspace, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -135,10 +135,10 @@ func (k msgServer) UnblockUser(goCtx context.Context, msg *types.MsgUnblockUser) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeUnblockUser, + types.EventTypeUnblockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, msg.Blocker), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, msg.Blocked), - sdk.NewAttribute(types.AttributeKeySubspace, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) diff --git a/x/relationships/keeper/msg_server_test.go b/x/relationships/keeper/msg_server_test.go index 064d2546ca..06b466983f 100644 --- a/x/relationships/keeper/msg_server_test.go +++ b/x/relationships/keeper/msg_server_test.go @@ -82,10 +82,10 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateRelationship() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRelationshipCreated, + types.EventTypeCreatedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeRelationshipCounterparty, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspace, "1"), + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { @@ -181,10 +181,10 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteRelationship() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRelationshipDeleted, + types.EventTypeDeletedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeRelationshipCounterparty, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspace, "1"), + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { @@ -283,10 +283,10 @@ func (suite *KeeperTestSuite) TestMsgServer_BlockUser() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeBlockUser, + types.EventTypeBlockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspace, "1"), + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { @@ -383,10 +383,10 @@ func (suite *KeeperTestSuite) TestMsgServer_UnblockUser() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeUnblockUser, + types.EventTypeUnblockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspace, "1"), + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { diff --git a/x/relationships/spec/05-events.md b/x/relationships/spec/05-events.md index ec95bd3560..9840365163 100644 --- a/x/relationships/spec/05-events.md +++ b/x/relationships/spec/05-events.md @@ -7,50 +7,50 @@ slug: events # Events -The relationships module emits the following events: +The relationships module emits the following events: ## Handlers ### MsgCreateRelationship -| Type | Attribute Key | Attribute Value | -|:--------------------|:--------------|:-----------------------------------------------| -| create_relationship | creator | {userAddress} | -| create_relationship | counterparty | {counterpartyAddress} | -| create_relationship | subspace | {subspaceID} | -| message | module | relationships | -| message | action | /desmos.relationships.v1.MsgCreateRelationship | -| message | sender | {userAddress} | +| Type | Attribute Key | Attribute Value | +|:---------------------|:--------------|:-----------------------------------------------| +| created_relationship | creator | {userAddress} | +| created_relationship | counterparty | {counterpartyAddress} | +| created_relationship | subspace_id | {subspaceID} | +| message | module | relationships | +| message | action | /desmos.relationships.v1.MsgCreateRelationship | +| message | sender | {userAddress} | ### MsgDeleteRelationship -| Type | Attribute Key | Attribute Value | -|:--------------------|:--------------|:-----------------------------------------------| -| delete_relationship | creator | {userAddress} | -| delete_relationship | counterparty | {counterpartyAddress} | -| delete_relationship | subspace | {subspaceID} | -| message | module | relationships | -| message | action | /desmos.relationships.v1.MsgDeleteRelationship | -| message | sender | {userAddress} | +| Type | Attribute Key | Attribute Value | +|:---------------------|:--------------|:-----------------------------------------------| +| deleted_relationship | creator | {userAddress} | +| deleted_relationship | counterparty | {counterpartyAddress} | +| deleted_relationship | subspace_id | {subspaceID} | +| message | module | relationships | +| message | action | /desmos.relationships.v1.MsgDeleteRelationship | +| message | sender | {userAddress} | ### MsgBlockUser -| Type | Attribute Key | Attribute Value | -|:-----------|:--------------|:--------------------------------------| -| block_user | blocker | {blockerAddress} | -| block_user | blocked | {blockedAddress} | -| block_user | subspace | {subspaceID} | -| message | module | relationships | -| message | action | /desmos.relationships.v1.MsgBlockUser | -| message | sender | {userAddress} | +| Type | Attribute Key | Attribute Value | +|:-------------|:--------------|:--------------------------------------| +| blocked_user | blocker | {blockerAddress} | +| blocked_user | blocked | {blockedAddress} | +| blocked_user | subspace_id | {subspaceID} | +| message | module | relationships | +| message | action | /desmos.relationships.v1.MsgBlockUser | +| message | sender | {userAddress} | ### MsgUnblockUser -| Type | Attribute Key | Attribute Value | -|:-------------|:--------------|:----------------------------------------| -| unblock_user | blocker | {blockerAddress} | -| unblock_user | blocked | {blockedAddress} | -| unblock_user | subspace | {subspaceID} | -| message | module | relationships | -| message | action | /desmos.relationships.v1.MsgUnblockUser | -| message | sender | {userAddress} | \ No newline at end of file +| Type | Attribute Key | Attribute Value | +|:---------------|:--------------|:----------------------------------------| +| unblocked_user | blocker | {blockerAddress} | +| unblocked_user | blocked | {blockedAddress} | +| unblocked_user | subspace_id | {subspaceID} | +| message | module | relationships | +| message | action | /desmos.relationships.v1.MsgUnblockUser | +| message | sender | {userAddress} | \ No newline at end of file diff --git a/x/relationships/types/events.go b/x/relationships/types/events.go index af067d44b4..16f5eb2afc 100644 --- a/x/relationships/types/events.go +++ b/x/relationships/types/events.go @@ -3,14 +3,14 @@ package types // DONTCOVER const ( - EventTypeRelationshipCreated = "create_relationship" - EventTypeRelationshipDeleted = "delete_relationship" - EventTypeBlockUser = "block_user" - EventTypeUnblockUser = "unblock_user" + EventTypeCreatedRelationship = "created_relationship" + EventTypeDeletedRelationship = "deleted_relationship" + EventTypeBlockedUser = "blocked_user" + EventTypeUnblockedUser = "unblocked_user" AttributeRelationshipCreator = "creator" AttributeRelationshipCounterparty = "counterparty" AttributeKeyUserBlockBlocker = "blocker" AttributeKeyUserBlockBlocked = "blocked" - AttributeKeySubspace = "subspace" + AttributeKeySubspaceID = "subspace_id" ) From 95f8c83030ece38d670b41d2f2a52e25619af514 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 10:52:57 +0100 Subject: [PATCH 05/14] refactor: updated reports event names Signed-off-by: Riccardo Montagnin --- x/reports/keeper/msg_server.go | 14 ++--- x/reports/keeper/msg_server_test.go | 18 +++--- x/reports/spec/05-events.md | 95 ++++++++++++++--------------- x/reports/types/events.go | 14 ++--- 4 files changed, 70 insertions(+), 71 deletions(-) diff --git a/x/reports/keeper/msg_server.go b/x/reports/keeper/msg_server.go index 0798419633..21cce26be8 100644 --- a/x/reports/keeper/msg_server.go +++ b/x/reports/keeper/msg_server.go @@ -93,14 +93,14 @@ func (k msgServer) CreateReport(goCtx context.Context, msg *types.MsgCreateRepor switch target := target.(type) { case *types.PostTarget: reportEvent = sdk.NewEvent( - types.EventTypeReportPost, + types.EventTypeReportedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", target.PostID)), sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), ) case *types.UserTarget: reportEvent = sdk.NewEvent( - types.EventTypeReportUser, + types.EventTypeReportedUser, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUser, target.User), sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), @@ -111,7 +111,7 @@ func (k msgServer) CreateReport(goCtx context.Context, msg *types.MsgCreateRepor ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeCreateReport, + types.EventTypeCreatedReport, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReportID, fmt.Sprintf("%d", report.ID)), sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), @@ -153,7 +153,7 @@ func (k msgServer) DeleteReport(goCtx context.Context, msg *types.MsgDeleteRepor ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteReport, + types.EventTypeDeletedReport, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReportID, fmt.Sprintf("%d", msg.ReportID)), ), @@ -203,7 +203,7 @@ func (k msgServer) SupportStandardReason(goCtx context.Context, msg *types.MsgSu ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeSupportStandardReason, + types.EventTypeSupportedStandardReason, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyStandardReasonID, fmt.Sprintf("%d", msg.StandardReasonID)), sdk.NewAttribute(types.AttributeKeyReasonID, fmt.Sprintf("%d", reason.ID)), @@ -250,7 +250,7 @@ func (k msgServer) AddReason(goCtx context.Context, msg *types.MsgAddReason) (*t ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeAddReason, + types.EventTypeAddedReportingReason, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReasonID, fmt.Sprintf("%d", reason.ID)), ), @@ -285,7 +285,7 @@ func (k msgServer) RemoveReason(goCtx context.Context, msg *types.MsgRemoveReaso ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveReason, + types.EventTypeRemovedReportingReason, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReasonID, fmt.Sprintf("%d", msg.ReasonID)), ), diff --git a/x/reports/keeper/msg_server_test.go b/x/reports/keeper/msg_server_test.go index df6c8d8d8a..5915ef6f2e 100644 --- a/x/reports/keeper/msg_server_test.go +++ b/x/reports/keeper/msg_server_test.go @@ -280,14 +280,14 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateReport() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateReport, + types.EventTypeCreatedReport, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), ), sdk.NewEvent( - types.EventTypeReportUser, + types.EventTypeReportedUser, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1ggzk8tnte9lmzgpvyzzdtmwmn6rjlct4spmjjd"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), @@ -376,14 +376,14 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateReport() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateReport, + types.EventTypeCreatedReport, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), ), sdk.NewEvent( - types.EventTypeReportPost, + types.EventTypeReportedPost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), @@ -591,7 +591,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteReport() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteReport, + types.EventTypeDeletedReport, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), ), @@ -633,7 +633,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteReport() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteReport, + types.EventTypeDeletedReport, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), ), @@ -798,7 +798,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SupportStandardReason() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeSupportStandardReason, + types.EventTypeSupportedStandardReason, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyStandardReasonID, "1"), sdk.NewAttribute(types.AttributeKeyReasonID, "1"), @@ -976,7 +976,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddReason() { }, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAddReason, + types.EventTypeAddedReportingReason, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReasonID, "1"), ), @@ -1115,7 +1115,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveReason() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveReason, + types.EventTypeRemovedReportingReason, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReasonID, "1"), ), diff --git a/x/reports/spec/05-events.md b/x/reports/spec/05-events.md index 217d55749d..6623ce4b61 100644 --- a/x/reports/spec/05-events.md +++ b/x/reports/spec/05-events.md @@ -13,71 +13,70 @@ The reports module emits the following events: ### MsgCreateReport -| **Type** | **Attribute Key** | **Attribute Value** | -|:--------------|:------------------|:----------------------------------| -| create_report | subspace_id | {subspaceID} | -| create_report | report_id | {reportID} | -| create_report | reporter | {userAddress} | -| create_report | creation_time | {creationTime} | -| message | module | reports | -| message | action | desmos.reports.v1.MsgCreateReport | -| message | reporter | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:---------------|:------------------|:----------------------------------| +| created_report | subspace_id | {subspaceID} | +| created_report | report_id | {reportID} | +| created_report | reporter | {userAddress} | +| created_report | creation_time | {creationTime} | +| message | module | reports | +| message | action | desmos.reports.v1.MsgCreateReport | +| message | reporter | {userAddress} | Other events attributes depending on the type of the report target are attached. #### `Post Target` -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------|:------------------|:--------------------| -| report_post | subspace_id | {subspaceID} | -| report_post | post_id | {reportID} | -| report_post | reporter | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------|:------------------|:--------------------| +| reported_post | subspace_id | {subspaceID} | +| reported_post | post_id | {reportID} | +| reported_post | reporter | {userAddress} | #### `User Target` -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------|:------------------|:--------------------| -| report_user | subspace_id | {subspaceID} | -| report_user | user | {userAddress} | -| report_user | reporter | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------|:------------------|:--------------------| +| reported_user | subspace_id | {subspaceID} | +| reported_user | user | {userAddress} | +| reported_user | reporter | {userAddress} | ### MsgDeleteReport -| **Type** | **Attribute Key** | **Attribute Value** | -|:--------------|:------------------|:----------------------------------| -| delete_report | subspace_id | {subspaceID} | -| delete_report | report_id | {reportID} | -| message | module | reports | -| message | action | desmos.reports.v1.MsgDeleteReport | -| message | signer | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:---------------|:------------------|:----------------------------------| +| deleted_report | subspace_id | {subspaceID} | +| deleted_report | report_id | {reportID} | +| message | module | reports | +| message | action | desmos.reports.v1.MsgDeleteReport | +| message | signer | {userAddress} | ### MsgSupportStandardReason -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------------------|:-------------------|:-------------------------------------------| -| support_standard_reason | subspace_id | {subspaceID} | -| support_standard_reason | standard_reason_id | {reasonID} | -| support_standard_reason | reason_id | {reasonID} | -| message | module | reports | -| message | action | desmos.reports.v1.MsgSupportStandardReason | -| message | signer | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------------------|:-------------------|:-------------------------------------------| +| supported_standard_reason | subspace_id | {subspaceID} | +| supported_standard_reason | standard_reason_id | {reasonID} | +| supported_standard_reason | reason_id | {reasonID} | +| message | module | reports | +| message | action | desmos.reports.v1.MsgSupportStandardReason | +| message | signer | {userAddress} | ### MsgAddReason -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------|:------------------|:-------------------------------| -| add_reason | subspace_id | {subspaceID} | -| add_reason | reason_id | {reasonID} | -| message | module | reports | -| message | action | desmos.reports.v1.MsgAddReason | -| message | signer | {userAddress} | - +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------------|:------------------|:-------------------------------| +| added_reporting_reason | subspace_id | {subspaceID} | +| added_reporting_reason | reason_id | {reasonID} | +| message | module | reports | +| message | action | desmos.reports.v1.MsgAddReason | +| message | signer | {userAddress} | ### MsgRemoveReason -| **Type** | **Attribute Key** | **Attribute Value** | -|:--------------|:------------------|:----------------------------------| -| remove_reason | subspace_id | {subspaceID} | -| remove_reason | reason_id | {reasonID} | -| message | module | reports | -| message | action | desmos.reports.v1.MsgRemoveReason | \ No newline at end of file +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------|:------------------|:----------------------------------| +| removed_reporting_reason | subspace_id | {subspaceID} | +| removed_reporting_reason | reason_id | {reasonID} | +| message | module | reports | +| message | action | desmos.reports.v1.MsgRemoveReason | \ No newline at end of file diff --git a/x/reports/types/events.go b/x/reports/types/events.go index 303243da1e..6be242723b 100644 --- a/x/reports/types/events.go +++ b/x/reports/types/events.go @@ -3,13 +3,13 @@ package types // DONTCOVER const ( - EventTypeCreateReport = "create_report" - EventTypeReportPost = "report_post" - EventTypeReportUser = "report_user" - EventTypeDeleteReport = "delete_report" - EventTypeSupportStandardReason = "support_standard_reason" - EventTypeAddReason = "add_reason" - EventTypeRemoveReason = "remove_reason" + EventTypeCreatedReport = "created_report" + EventTypeReportedPost = "reported_post" + EventTypeReportedUser = "reported_user" + EventTypeDeletedReport = "deleted_report" + EventTypeSupportedStandardReason = "supported_standard_reason" + EventTypeAddedReportingReason = "added_reason" + EventTypeRemovedReportingReason = "removed_reason" AttributeKeySubspaceID = "subspace_id" AttributeKeyReportID = "report_id" From 0960cd14227534c79326383565bcb9125db20862 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 11:11:22 +0100 Subject: [PATCH 06/14] refactor: updated subspaces event names Signed-off-by: Riccardo Montagnin --- x/subspaces/keeper/msg_server.go | 46 +++-- x/subspaces/keeper/msg_server_test.go | 46 ++--- x/subspaces/spec/05-events.md | 271 +++++++++++++------------- x/subspaces/types/events.go | 41 ++-- 4 files changed, 206 insertions(+), 198 deletions(-) diff --git a/x/subspaces/keeper/msg_server.go b/x/subspaces/keeper/msg_server.go index 60716922fd..244b27b6a6 100644 --- a/x/subspaces/keeper/msg_server.go +++ b/x/subspaces/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "strings" "time" "github.com/desmos-labs/desmos/v6/x/subspaces/types" @@ -51,7 +52,7 @@ func (k msgServer) CreateSubspace(goCtx context.Context, msg *types.MsgCreateSub ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeCreateSubspace, + types.EventTypeCreatedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", subspaceID)), sdk.NewAttribute(types.AttributeKeySubspaceName, subspace.Name), sdk.NewAttribute(types.AttributeKeySubspaceCreator, subspace.Creator), @@ -96,7 +97,7 @@ func (k msgServer) EditSubspace(goCtx context.Context, msg *types.MsgEditSubspac ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeEditSubspace, + types.EventTypeEditedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", updated.ID)), ), }) @@ -128,7 +129,7 @@ func (k msgServer) DeleteSubspace(goCtx context.Context, msg *types.MsgDeleteSub ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteSubspace, + types.EventTypeDeletedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -181,7 +182,7 @@ func (k msgServer) CreateSection(goCtx context.Context, msg *types.MsgCreateSect ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeCreateSection, + types.EventTypeCreatedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", section.SubspaceID)), sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", section.ID)), ), @@ -230,7 +231,7 @@ func (k msgServer) EditSection(goCtx context.Context, msg *types.MsgEditSection) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeEditSection, + types.EventTypeEditedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", section.SubspaceID)), sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", section.ID)), ), @@ -286,7 +287,7 @@ func (k msgServer) MoveSection(goCtx context.Context, msg *types.MsgMoveSection) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeMoveSection, + types.EventTypeMovedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), ), @@ -324,7 +325,7 @@ func (k msgServer) DeleteSection(goCtx context.Context, msg *types.MsgDeleteSect ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteSection, + types.EventTypeDeletedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), ), @@ -391,7 +392,7 @@ func (k msgServer) CreateUserGroup(goCtx context.Context, msg *types.MsgCreateUs // Add the events to the list of to emit userEvents = append(userEvents, sdk.NewEvent( - types.EventTypeAddUserToGroup, + types.EventTypeAddedUserToGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", group.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", group.ID)), sdk.NewAttribute(types.AttributeKeyUser, member), @@ -400,7 +401,7 @@ func (k msgServer) CreateUserGroup(goCtx context.Context, msg *types.MsgCreateUs ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeCreateUserGroup, + types.EventTypeCreatedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", group.ID)), ), @@ -446,7 +447,7 @@ func (k msgServer) EditUserGroup(goCtx context.Context, msg *types.MsgEditUserGr ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeEditUserGroup, + types.EventTypeEditedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), ), @@ -501,7 +502,7 @@ func (k msgServer) MoveUserGroup(goCtx context.Context, msg *types.MsgMoveUserGr ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EvenTypeMoveUserGroup, + types.EvenTypeMovedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), ), @@ -555,6 +556,7 @@ func (k msgServer) SetUserGroupPermissions(goCtx context.Context, msg *types.Msg types.EventTypeSetUserGroupPermissions, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), + sdk.NewAttribute(types.AttributeKeyPermissions, strings.Join(msg.Permissions, ",")), ), }) @@ -591,7 +593,7 @@ func (k msgServer) DeleteUserGroup(goCtx context.Context, msg *types.MsgDeleteUs ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteUserGroup, + types.EventTypeDeletedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), ), @@ -640,7 +642,7 @@ func (k msgServer) AddUserToUserGroup(goCtx context.Context, msg *types.MsgAddUs ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeAddUserToGroup, + types.EventTypeAddedUserToGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), sdk.NewAttribute(types.AttributeKeyUser, msg.User), @@ -685,7 +687,7 @@ func (k msgServer) RemoveUserFromUserGroup(goCtx context.Context, msg *types.Msg ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveUserFromGroup, + types.EventTypeRemovedUserFromGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), sdk.NewAttribute(types.AttributeKeyUser, msg.User), @@ -736,6 +738,8 @@ func (k msgServer) SetUserPermissions(goCtx context.Context, msg *types.MsgSetUs sdk.NewEvent( types.EventTypeSetUserPermissions, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), + sdk.NewAttribute(types.AttributeKeyPermissions, strings.Join(msg.Permissions, ",")), sdk.NewAttribute(types.AttributeKeyUser, msg.User), ), }) @@ -778,7 +782,7 @@ func (k msgServer) GrantTreasuryAuthorization(goCtx context.Context, msg *types. ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeGrantTreasuryAuthorization, + types.EventTypeGrantedTreasuryAuthorization, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyGranter, msg.Granter), sdk.NewAttribute(types.AttributeKeyGrantee, msg.Grantee), @@ -816,7 +820,7 @@ func (k msgServer) RevokeTreasuryAuthorization(goCtx context.Context, msg *types ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRevokeTreasuryAuthorization, + types.EventTypeRevokedTreasuryAuthorization, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyGranter, msg.Granter), sdk.NewAttribute(types.AttributeKeyGrantee, msg.Grantee), @@ -845,7 +849,7 @@ func (k msgServer) GrantAllowance(goCtx context.Context, msg *types.MsgGrantAllo return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "fee allowance already exists") } events = events.AppendEvent(sdk.NewEvent( - types.EventTypeGrantAllowance, + types.EventTypeGrantedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyGranter, msg.Granter), sdk.NewAttribute(types.AttributeKeyUserGrantee, grantee.User), @@ -859,7 +863,7 @@ func (k msgServer) GrantAllowance(goCtx context.Context, msg *types.MsgGrantAllo return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "fee allowance already exists") } events = events.AppendEvent(sdk.NewEvent( - types.EventTypeGrantAllowance, + types.EventTypeGrantedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyGranter, msg.Granter), sdk.NewAttribute(types.AttributeKeyGroupGrantee, fmt.Sprintf("%d", grantee.GroupID)), @@ -904,7 +908,7 @@ func (k msgServer) RevokeAllowance(goCtx context.Context, msg *types.MsgRevokeAl } k.DeleteUserGrant(ctx, msg.SubspaceID, grantee.User) events = events.AppendEvent(sdk.NewEvent( - types.EventTypeRevokeAllowance, + types.EventTypeRevokedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyGranter, msg.Granter), sdk.NewAttribute(types.AttributeKeyUserGrantee, grantee.User), @@ -916,7 +920,7 @@ func (k msgServer) RevokeAllowance(goCtx context.Context, msg *types.MsgRevokeAl } k.DeleteGroupGrant(ctx, msg.SubspaceID, grantee.GroupID) events = events.AppendEvent(sdk.NewEvent( - types.EventTypeRevokeAllowance, + types.EventTypeRevokedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyGranter, msg.Granter), sdk.NewAttribute(types.AttributeKeyGroupGrantee, fmt.Sprintf("%d", grantee.GroupID)), @@ -956,7 +960,7 @@ func (k msgServer) UpdateSubspaceFeeTokens(goCtx context.Context, msg *types.Msg ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeUpdateSubspaceFeeToken, + types.EventTypeUpdatedSubspaceFeeToken, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", updated.ID)), sdk.NewAttribute(types.AttributeKeyUser, msg.Authority), ), diff --git a/x/subspaces/keeper/msg_server_test.go b/x/subspaces/keeper/msg_server_test.go index 5e4cf1315f..76a7618a1e 100644 --- a/x/subspaces/keeper/msg_server_test.go +++ b/x/subspaces/keeper/msg_server_test.go @@ -63,7 +63,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateSubspace() { expResponse: &types.MsgCreateSubspaceResponse{SubspaceID: 1}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateSubspace, + types.EventTypeCreatedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySubspaceName, "Test subspace"), sdk.NewAttribute(types.AttributeKeySubspaceCreator, "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69"), @@ -112,7 +112,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateSubspace() { expResponse: &types.MsgCreateSubspaceResponse{SubspaceID: 1}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateSubspace, + types.EventTypeCreatedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySubspaceName, "Test subspace"), sdk.NewAttribute(types.AttributeKeySubspaceCreator, "cosmos18atyyv6zycryhvnhpr2mjxgusdcah6kdpkffq0"), @@ -166,7 +166,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateSubspace() { expResponse: &types.MsgCreateSubspaceResponse{SubspaceID: 2}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateSubspace, + types.EventTypeCreatedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, "2"), sdk.NewAttribute(types.AttributeKeySubspaceName, "Another subspace"), sdk.NewAttribute(types.AttributeKeySubspaceCreator, "cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll"), @@ -358,7 +358,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditSubspace() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeEditSubspace, + types.EventTypeEditedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), ), }, @@ -481,7 +481,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteSubspace() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteSubspace, + types.EventTypeDeletedSubspace, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), ), }, @@ -712,7 +712,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateSection() { expResponse: &types.MsgCreateSectionResponse{SectionID: 2}, expEvent: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateSection, + types.EventTypeCreatedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySectionID, "2"), ), @@ -912,7 +912,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditSection() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeEditSection, + types.EventTypeEditedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySectionID, "1"), ), @@ -1167,7 +1167,7 @@ func (suite *KeeperTestSuite) TestMsgServer_MoveSection() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeMoveSection, + types.EventTypeMovedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySectionID, "2"), ), @@ -1314,7 +1314,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteSection() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteSection, + types.EventTypeDeletedSection, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeySectionID, "1"), ), @@ -1540,12 +1540,12 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateUserGroup() { expResponse: &types.MsgCreateUserGroupResponse{GroupID: 2}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeCreateUserGroup, + types.EventTypeCreatedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "2"), ), sdk.NewEvent( - types.EventTypeAddUserToGroup, + types.EventTypeAddedUserToGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "2"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos16yhs7fgqnf6fjm4tftv66g2smtmee62wyg780l"), @@ -1737,7 +1737,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditUserGroup() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeEditUserGroup, + types.EventTypeEditedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), ), @@ -2044,7 +2044,7 @@ func (suite *KeeperTestSuite) TestMsgServer_MoveUserGroup() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EvenTypeMoveUserGroup, + types.EvenTypeMovedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), ), @@ -2459,7 +2459,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteUserGroup() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeDeleteUserGroup, + types.EventTypeDeletedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), ), @@ -2638,7 +2638,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddUserToGroup() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeAddUserToGroup, + types.EventTypeAddedUserToGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm"), @@ -2817,7 +2817,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveUserFromGroup() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRemoveUserFromGroup, + types.EventTypeRemovedUserFromGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm"), @@ -3112,7 +3112,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UpdateSubspaceFeeTokens() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeUpdateSubspaceFeeToken, + types.EventTypeUpdatedSubspaceFeeToken, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUser, authtypes.NewModuleAddress("gov").String()), ), @@ -3294,7 +3294,7 @@ func (suite *KeeperTestSuite) TestMsgServer_GrantTreasuryAuthorization() { expResponse: &types.MsgGrantTreasuryAuthorizationResponse{}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeGrantTreasuryAuthorization, + types.EventTypeGrantedTreasuryAuthorization, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyGranter, "cosmos1lv3e0l66rr68k5l74mnrv4j9kyny6cz27pvnez"), sdk.NewAttribute(types.AttributeKeyGrantee, "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69"), @@ -3518,7 +3518,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RevokeTreasuryAuthorization() { expResponse: &types.MsgRevokeTreasuryAuthorizationResponse{}, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRevokeTreasuryAuthorization, + types.EventTypeRevokedTreasuryAuthorization, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyGranter, "cosmos1lv3e0l66rr68k5l74mnrv4j9kyny6cz27pvnez"), sdk.NewAttribute(types.AttributeKeyGrantee, "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69"), @@ -3755,7 +3755,7 @@ func (suite *KeeperTestSuite) TestMsgServer_GrantAllowance() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeGrantAllowance, + types.EventTypeGrantedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyGranter, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), sdk.NewAttribute(types.AttributeKeyUserGrantee, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), @@ -3811,7 +3811,7 @@ func (suite *KeeperTestSuite) TestMsgServer_GrantAllowance() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeGrantAllowance, + types.EventTypeGrantedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyGranter, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), sdk.NewAttribute(types.AttributeKeyGroupGrantee, "1"), @@ -3977,7 +3977,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RevokeAllowance() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRevokeAllowance, + types.EventTypeRevokedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyGranter, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), sdk.NewAttribute(types.AttributeKeyUserGrantee, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), @@ -4022,7 +4022,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RevokeAllowance() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRevokeAllowance, + types.EventTypeRevokedAllowance, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyGranter, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), sdk.NewAttribute(types.AttributeKeyGroupGrantee, "1"), diff --git a/x/subspaces/spec/05-events.md b/x/subspaces/spec/05-events.md index 8cd85fe566..b91cc768d9 100644 --- a/x/subspaces/spec/05-events.md +++ b/x/subspaces/spec/05-events.md @@ -13,103 +13,103 @@ The subspaces module emits the following events: ### MsgCreateSubspace -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------|:------------------|:--------------------------------------| -| create_subspace | subspace_id | {subspaceID} | -| create_subspace | subspace_name | {subspaceName} | -| create_subspace | subspace_creator | {subspaceCreator} | -| create_subspace | creation_date | {subspaceCreationTime} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgCreateSubspace | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------|:------------------|:--------------------------------------| +| created_subspace | subspace_id | {subspaceID} | +| created_subspace | subspace_name | {subspaceName} | +| created_subspace | subspace_creator | {subspaceCreator} | +| created_subspace | creation_date | {subspaceCreationTime} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgCreateSubspace | +| message | sender | {userAddress} | ### MsgEditSubspace -| **Type** | **Attribute Key** | **Attribute Value** | -|:--------------|:------------------|:------------------------------------| -| edit_subspace | subspace_id | {subspaceID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgEditSubspace | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------|:------------------|:------------------------------------| +| edited_subspace | subspace_id | {subspaceID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgEditSubspace | +| message | sender | {userAddress} | ### MsgDeleteSubspace -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------|:------------------|:--------------------------------------| -| delete_subspace | subspace_id | {subspaceID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgDeleteSubspace | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------|:------------------|:--------------------------------------| +| deleted_subspace | subspace_id | {subspaceID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgDeleteSubspace | +| message | sender | {userAddress} | ### MsgCreateSection -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------|:------------------|:-------------------------------------| -| create_section | subspace_id | {subspaceID} | -| create_section | section_id | {sectionID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgCreateSection | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------|:------------------|:-------------------------------------| +| created_section | subspace_id | {subspaceID} | +| created_section | section_id | {sectionID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgCreateSection | +| message | sender | {userAddress} | ### MsgEditSection -| **Type** | **Attribute Key** | **Attribute Value** | -|:-------------|:------------------|:-----------------------------------| -| edit_section | subspace_id | {subspaceID} | -| edit_section | section_id | {sectionID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgEditSection | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:---------------|:------------------|:-----------------------------------| +| edited_section | subspace_id | {subspaceID} | +| edited_section | section_id | {sectionID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgEditSection | +| message | sender | {userAddress} | ### MsgMoveSection -| **Type** | **Attribute Key** | **Attribute Value** | -|:-------------|:------------------|:-----------------------------------| -| move_section | subspace_id | {subspaceID} | -| move_section | section_id | {sectionID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgMoveSection | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:--------------|:------------------|:-----------------------------------| +| moved_section | subspace_id | {subspaceID} | +| moved_section | section_id | {sectionID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgMoveSection | +| message | sender | {userAddress} | ### MsgDeleteSection -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------|:------------------|:-------------------------------------| -| delete_section | subspace_id | {subspaceID} | -| delete_section | section_id | {sectionID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgDeleteSection | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------|:------------------|:-------------------------------------| +| deleted_section | subspace_id | {subspaceID} | +| deleted_section | section_id | {sectionID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgDeleteSection | +| message | sender | {userAddress} | ### MsgCreateUserGroup -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------------|:------------------|:---------------------------------------| -| create_user_group | subspace_id | {subspaceID} | -| create_user_group | user_group_id | {userGroupID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgCreateUserGroup | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------|:------------------|:---------------------------------------| +| created_user_group | subspace_id | {subspaceID} | +| created_user_group | user_group_id | {userGroupID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgCreateUserGroup | +| message | sender | {userAddress} | ### MsgEditUserGroup -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------|:------------------|:-------------------------------------| -| edit_user_group | subspace_id | {subspaceID} | -| edit_user_group | user_group_id | {userGroupID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgEditUserGroup | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------|:------------------|:-------------------------------------| +| edited_user_group | subspace_id | {subspaceID} | +| edited_user_group | user_group_id | {userGroupID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgEditUserGroup | +| message | sender | {userAddress} | ### MsgMoveUserGroup -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------|:------------------|:-------------------------------------| -| move_user_group | subspace_id | {subspaceID} | -| move_user_group | user_group_id | {userGroupID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgMoveUserGroup | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-----------------|:------------------|:-------------------------------------| +| moved_user_group | subspace_id | {subspaceID} | +| moved_user_group | user_group_id | {userGroupID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgMoveUserGroup | +| message | sender | {userAddress} | ### MsgSetUserGroupPermissions @@ -117,47 +117,50 @@ The subspaces module emits the following events: |:---------------------------|:------------------|:-----------------------------------------------| | set_user_group_permissions | subspace_id | {subspaceID} | | set_user_group_permissions | user_group_id | {userGroupID} | +| set_user_group_permissions | permissions | {permissions} | | message | module | subspaces | | message | action | desmos.subspaces.v3.MsgSetUserGroupPermissions | | message | sender | {userAddress} | ### MsgDeleteUserGroup -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------------|:------------------|:---------------------------------------| -| delete_user_group | subspace_id | {subspaceID} | -| delete_user_group | user_group_id | {userGroupID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgDeleteUserGroup | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------|:------------------|:---------------------------------------| +| deleted_user_group | subspace_id | {subspaceID} | +| deleted_user_group | user_group_id | {userGroupID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgDeleteUserGroup | +| message | sender | {userAddress} | ### MsgAddUserToUserGroup -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------|:------------------|:------------------------------------------| -| add_group_member | subspace_id | {subspaceID} | -| add_group_member | user_group_id | {userGroupID} | -| add_group_member | user | {userAddress} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgAddUserToUserGroup | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------|:------------------|:------------------------------------------| +| added_group_member | subspace_id | {subspaceID} | +| added_group_member | user_group_id | {userGroupID} | +| added_group_member | user | {userAddress} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgAddUserToUserGroup | +| message | sender | {userAddress} | ### MsgRemoveUserFromUserGroup -| **Type** | **Attribute Key** | **Attribute Value** | -|:--------------------|:------------------|:-----------------------------------------------| -| remove_group_member | subspace_id | {subspaceID} | -| remove_group_member | user_group_id | {userGroupID} | -| remove_group_member | user | {userAddress} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgRemoveUserFromUserGroup | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:---------------------|:------------------|:-----------------------------------------------| +| removed_group_member | subspace_id | {subspaceID} | +| removed_group_member | user_group_id | {userGroupID} | +| removed_group_member | user | {userAddress} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgRemoveUserFromUserGroup | +| message | sender | {userAddress} | ### MsgSetUserPermissions | **Type** | **Attribute Key** | **Attribute Value** | |:---------------------|:------------------|:------------------------------------| | set_user_permissions | subspace_id | {subspaceID} | +| set_user_permissions | section_id | {sectionID} | +| set_user_permissions | permissions | {permissions} | | set_user_permissions | user | {userAddress} | | message | module | subspaces | | message | action | desmos.subspaces.v3.MsgEditSubspace | @@ -165,56 +168,56 @@ The subspaces module emits the following events: ## MsgGrantTreasuryAuthorization -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------------------|:------------------|:--------------------------------------------------| -| grant_treasury_authorization | subspace_id | {subspaceID} | -| grant_treasury_authorization | granter | {userAddress} | -| grant_treasury_authorization | grantee | {userAddress} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------------|:------------------|:--------------------------------------------------| +| granted_treasury_authorization | subspace_id | {subspaceID} | +| granted_treasury_authorization | granter | {userAddress} | +| granted_treasury_authorization | grantee | {userAddress} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | +| message | sender | {userAddress} | ## MsgRevokeTreasuryAuthorization -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------------------------|:------------------|:---------------------------------------------------| -| revoke_treasury_authorization | subspace_id | {subspaceID} | -| revoke_treasury_authorization | granter | {userAddress} | -| revoke_treasury_authorization | grantee | {userAddress} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgRevokeTreasuryAuthorization | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:-------------------------------|:------------------|:---------------------------------------------------| +| revoked_treasury_authorization | subspace_id | {subspaceID} | +| revoked_treasury_authorization | granter | {userAddress} | +| revoked_treasury_authorization | grantee | {userAddress} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgRevokeTreasuryAuthorization | +| message | sender | {userAddress} | ## MsgGrantAllowance -| **Type** | **Attribute Key** | **Attribute Value** | -|:----------------|:------------------|:--------------------------------------------------| -| grant_allowance | subspace_id | {subspaceID} | -| grant_allowance | granter | {userAddress} | -| grant_allowance | user_grantee | {userAddress} | -| grant_allowance | group_grantee | {groupID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------|:------------------|:--------------------------------------------------| +| granted_allowance | subspace_id | {subspaceID} | +| granted_allowance | granter | {userAddress} | +| granted_allowance | user_grantee | {userAddress} | +| granted_allowance | group_grantee | {groupID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | +| message | sender | {userAddress} | ## MsgRevokeAllowance -| **Type** | **Attribute Key** | **Attribute Value** | -|:-----------------|:------------------|:--------------------------------------------------| -| revoke_allowance | subspace_id | {subspaceID} | -| revoke_allowance | granter | {userAddress} | -| revoke_allowance | user_grantee | {userAddress} | -| revoke_allowance | group_grantee | {groupID} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | -| message | sender | {userAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------|:------------------|:--------------------------------------------------| +| revoked_allowance | subspace_id | {subspaceID} | +| revoked_allowance | granter | {userAddress} | +| revoked_allowance | user_grantee | {userAddress} | +| revoked_allowance | group_grantee | {groupID} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | +| message | sender | {userAddress} | ## MsgUpdateSubspaceFeeTokens -| **Type** | **Attribute Key** | **Attribute Value** | -|:---------------------------|:------------------|:--------------------------------------------------| -| update_subspace_fee_tokens | subspace_id | {subspaceID} | -| update_subspace_fee_tokens | user | {authorityAddress} | -| message | module | subspaces | -| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | -| message | sender | {userAddress} | \ No newline at end of file +| **Type** | **Attribute Key** | **Attribute Value** | +|:----------------------------|:------------------|:--------------------------------------------------| +| updated_subspace_fee_tokens | subspace_id | {subspaceID} | +| updated_subspace_fee_tokens | user | {authorityAddress} | +| message | module | subspaces | +| message | action | desmos.subspaces.v3.MsgGrantTreasuryAuthorization | +| message | sender | {userAddress} | \ No newline at end of file diff --git a/x/subspaces/types/events.go b/x/subspaces/types/events.go index 52cceb1be1..c9a7acfabc 100644 --- a/x/subspaces/types/events.go +++ b/x/subspaces/types/events.go @@ -2,26 +2,26 @@ package types // Subspaces module event types const ( - EventTypeCreateSubspace = "create_subspace" - EventTypeEditSubspace = "edit_subspace" - EventTypeDeleteSubspace = "delete_subspace" - EventTypeCreateSection = "create_section" - EventTypeEditSection = "edit_section" - EventTypeMoveSection = "move_section" - EventTypeDeleteSection = "delete_section" - EventTypeCreateUserGroup = "create_user_group" - EventTypeEditUserGroup = "edit_user_group" - EvenTypeMoveUserGroup = "move_user_group" - EventTypeSetUserGroupPermissions = "set_user_group_permissions" - EventTypeDeleteUserGroup = "delete_user_group" - EventTypeAddUserToGroup = "add_group_member" - EventTypeRemoveUserFromGroup = "remove_group_member" - EventTypeSetUserPermissions = "set_user_permissions" - EventTypeGrantTreasuryAuthorization = "grant_treasury_authorization" - EventTypeRevokeTreasuryAuthorization = "revoke_treasury_authorization" - EventTypeGrantAllowance = "grant_allowance" - EventTypeRevokeAllowance = "revoke_allowance" - EventTypeUpdateSubspaceFeeToken = "update_subspace_fee_token" + EventTypeCreatedSubspace = "create_subspace" + EventTypeEditedSubspace = "edit_subspace" + EventTypeDeletedSubspace = "delete_subspace" + EventTypeCreatedSection = "create_section" + EventTypeEditedSection = "edit_section" + EventTypeMovedSection = "move_section" + EventTypeDeletedSection = "delete_section" + EventTypeCreatedUserGroup = "create_user_group" + EventTypeEditedUserGroup = "edit_user_group" + EvenTypeMovedUserGroup = "move_user_group" + EventTypeSetUserGroupPermissions = "set_user_group_permissions" + EventTypeDeletedUserGroup = "delete_user_group" + EventTypeAddedUserToGroup = "add_group_member" + EventTypeRemovedUserFromGroup = "remove_group_member" + EventTypeSetUserPermissions = "set_user_permissions" + EventTypeGrantedTreasuryAuthorization = "grant_treasury_authorization" + EventTypeRevokedTreasuryAuthorization = "revoke_treasury_authorization" + EventTypeGrantedAllowance = "grant_allowance" + EventTypeRevokedAllowance = "revoke_allowance" + EventTypeUpdatedSubspaceFeeToken = "update_subspace_fee_token" AttributeKeySubspaceID = "subspace_id" AttributeKeySubspaceName = "subspace_name" @@ -29,6 +29,7 @@ const ( AttributeKeyCreationTime = "creation_date" AttributeKeySectionID = "section_id" AttributeKeyUserGroupID = "user_group_id" + AttributeKeyPermissions = "permissions" AttributeKeyUser = "user" AttributeKeyGranter = "granter" AttributeKeyGrantee = "grantee" From 557b68630ab77f717f6f2793d29f7d36ae511fb8 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 11:20:34 +0100 Subject: [PATCH 07/14] refactor: replaced custom defined event attributes with already existing ones Signed-off-by: Riccardo Montagnin --- x/posts/abci.go | 4 ++- x/posts/keeper/msg_server.go | 24 ++++++++-------- x/posts/keeper/msg_server_test.go | 34 +++++++++++------------ x/posts/types/events.go | 2 -- x/reactions/keeper/msg_server.go | 18 ++++++------ x/reactions/keeper/msg_server_test.go | 22 ++++++++------- x/reactions/types/events.go | 2 -- x/relationships/keeper/msg_server.go | 10 ++++--- x/relationships/keeper/msg_server_test.go | 10 ++++--- x/relationships/types/events.go | 1 - x/reports/keeper/msg_server.go | 18 ++++++------ x/reports/keeper/msg_server_test.go | 20 ++++++------- x/reports/types/events.go | 2 -- 13 files changed, 86 insertions(+), 81 deletions(-) diff --git a/x/posts/abci.go b/x/posts/abci.go index de66919396..3623f0084a 100644 --- a/x/posts/abci.go +++ b/x/posts/abci.go @@ -3,6 +3,8 @@ package posts import ( "fmt" + subspacestypes "github.com/desmos-labs/desmos/v6/x/subspaces/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/desmos-labs/desmos/v6/x/posts/keeper" @@ -19,7 +21,7 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) { ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeTalliedPoll, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", poll.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", poll.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", poll.PostID)), sdk.NewAttribute(types.AttributeKeyPollID, fmt.Sprintf("%d", poll.ID)), ), diff --git a/x/posts/keeper/msg_server.go b/x/posts/keeper/msg_server.go index e5b820da2f..3399bb8bbe 100644 --- a/x/posts/keeper/msg_server.go +++ b/x/posts/keeper/msg_server.go @@ -104,8 +104,8 @@ func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) ( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreatedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), - sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", post.ID)), sdk.NewAttribute(types.AttributeKeyAuthor, msg.Author), sdk.NewAttribute(types.AttributeKeyCreationTime, post.CreationDate.Format(time.RFC3339)), @@ -158,7 +158,7 @@ func (k msgServer) EditPost(goCtx context.Context, msg *types.MsgEditPost) (*typ ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeEditedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyLastEditTime, updateTime.Format(time.RFC3339)), ), @@ -197,7 +197,7 @@ func (k msgServer) DeletePost(goCtx context.Context, msg *types.MsgDeletePost) ( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeDeletedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), ), }) @@ -297,7 +297,7 @@ func (k msgServer) AddPostAttachment(goCtx context.Context, msg *types.MsgAddPos ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAddedPostAttachment, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyAttachmentID, fmt.Sprintf("%d", attachmentID)), sdk.NewAttribute(types.AttributeKeyLastEditTime, post.LastEditedDate.Format(time.RFC3339)), @@ -354,7 +354,7 @@ func (k msgServer) RemovePostAttachment(goCtx context.Context, msg *types.MsgRem ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRemovedPostAttachment, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyAttachmentID, fmt.Sprintf("%d", msg.AttachmentID)), sdk.NewAttribute(types.AttributeKeyLastEditTime, post.LastEditedDate.Format(time.RFC3339)), @@ -433,7 +433,7 @@ func (k msgServer) AnswerPoll(goCtx context.Context, msg *types.MsgAnswerPoll) ( ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAnsweredPoll, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyPollID, fmt.Sprintf("%d", msg.PollID)), ), @@ -531,7 +531,7 @@ func (k msgServer) MovePost(goCtx context.Context, msg *types.MsgMovePost) (*typ ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeMovedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyNewSubspaceID, fmt.Sprintf("%d", msg.TargetSubspaceID)), sdk.NewAttribute(types.AttributeKeyNewPostID, fmt.Sprintf("%d", updatedPost.ID)), @@ -587,7 +587,7 @@ func (k msgServer) RequestPostOwnerTransfer(goCtx context.Context, msg *types.Ms ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRequestedPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver), sdk.NewAttribute(types.AttributeKeySender, msg.Sender), @@ -618,7 +618,7 @@ func (k msgServer) CancelPostOwnerTransferRequest(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCanceledPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeySender, msg.Sender), ), @@ -674,7 +674,7 @@ func (k msgServer) AcceptPostOwnerTransferRequest(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAcceptedPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver), ), @@ -704,7 +704,7 @@ func (k msgServer) RefusePostOwnerTransferRequest(goCtx context.Context, msg *ty ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRefusedPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReceiver, msg.Receiver), ), diff --git a/x/posts/keeper/msg_server_test.go b/x/posts/keeper/msg_server_test.go index 4baa7554b5..d1af47b4cd 100644 --- a/x/posts/keeper/msg_server_test.go +++ b/x/posts/keeper/msg_server_test.go @@ -365,8 +365,8 @@ func (suite *KeeperTestSuite) TestMsgServer_CreatePost() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeCreatedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeySectionID, "0"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySectionID, "0"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAuthor, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -481,8 +481,8 @@ func (suite *KeeperTestSuite) TestMsgServer_CreatePost() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeCreatedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeySectionID, "0"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySectionID, "0"), sdk.NewAttribute(types.AttributeKeyPostID, "2"), sdk.NewAttribute(types.AttributeKeyAuthor, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -768,7 +768,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditPost() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeEditedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyLastEditTime, time.Date(2021, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), ), @@ -969,7 +969,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeletePost() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeDeletedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), ), }, @@ -1020,7 +1020,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeletePost() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeDeletedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), ), }, @@ -1261,7 +1261,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddPostAttachment() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAddedPostAttachment, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAttachmentID, "1"), sdk.NewAttribute(types.AttributeKeyLastEditTime, time.Date(2021, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -1585,7 +1585,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemovePostAttachment() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRemovedPostAttachment, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAttachmentID, "1"), sdk.NewAttribute(types.AttributeKeyLastEditTime, time.Date(2021, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -1667,7 +1667,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemovePostAttachment() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRemovedPostAttachment, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAttachmentID, "1"), sdk.NewAttribute(types.AttributeKeyLastEditTime, time.Date(2021, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -2189,7 +2189,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAnsweredPoll, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyPollID, "1"), ), @@ -2270,7 +2270,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAnsweredPoll, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyPollID, "1"), ), @@ -2767,7 +2767,7 @@ func (suite *KeeperTestSuite) TestMsgServer_MovePost() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeMovedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyNewSubspaceID, "2"), sdk.NewAttribute(types.AttributeKeyNewPostID, "2"), @@ -3156,7 +3156,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RequestPostOwnerTransfer() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRequestedPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReceiver, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), sdk.NewAttribute(types.AttributeKeySender, "cosmos1eqpa6mv2jgevukaqtjmx5535vhc3mm3cf458zg"), @@ -3265,7 +3265,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CancelPostOwnerTransfer() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeCanceledPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeySender, "cosmos1eqpa6mv2jgevukaqtjmx5535vhc3mm3cf458zg"), ), @@ -3505,7 +3505,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AcceptPostOwnerTransfer() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAcceptedPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReceiver, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), ), @@ -3600,7 +3600,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RefusePostOwnerTransfer() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRefusedPostOwnerTransfer, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReceiver, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), ), diff --git a/x/posts/types/events.go b/x/posts/types/events.go index c038377c50..8bb268a82a 100644 --- a/x/posts/types/events.go +++ b/x/posts/types/events.go @@ -15,8 +15,6 @@ const ( EventTypeAcceptedPostOwnerTransfer = "accepted_post_owner_transfer" EventTypeRefusedPostOwnerTransfer = "refused_post_owner_transfer" - AttributeKeySubspaceID = "subspace_id" - AttributeKeySectionID = "section_id" AttributeKeyPostID = "post_id" AttributeKeyAuthor = "author" AttributeKeyCreationTime = "creation_date" diff --git a/x/reactions/keeper/msg_server.go b/x/reactions/keeper/msg_server.go index becaa8b48a..dbafcb593d 100644 --- a/x/reactions/keeper/msg_server.go +++ b/x/reactions/keeper/msg_server.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + poststypes "github.com/desmos-labs/desmos/v6/x/posts/types" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -91,8 +93,8 @@ func (k msgServer) AddReaction(goCtx context.Context, msg *types.MsgAddReaction) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAddedReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), - sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(poststypes.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReactionID, fmt.Sprintf("%d", reaction.ID)), sdk.NewAttribute(types.AttributeKeyUser, msg.User), ), @@ -140,8 +142,8 @@ func (k msgServer) RemoveReaction(goCtx context.Context, msg *types.MsgRemoveRea ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRemovedReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), - sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(poststypes.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyReactionID, fmt.Sprintf("%d", msg.ReactionID)), ), }) @@ -190,7 +192,7 @@ func (k msgServer) AddRegisteredReaction(goCtx context.Context, msg *types.MsgAd ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.ActionAddRegisteredReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, fmt.Sprintf("%d", reaction.ID)), ), }) @@ -233,7 +235,7 @@ func (k msgServer) EditRegisteredReaction(goCtx context.Context, msg *types.MsgE ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.ActionEditRegisteredReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, fmt.Sprintf("%d", msg.RegisteredReactionID)), ), }) @@ -266,7 +268,7 @@ func (k msgServer) RemoveRegisteredReaction(goCtx context.Context, msg *types.Ms ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRemovedRegisteredReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, fmt.Sprintf("%d", msg.RegisteredReactionID)), ), }) @@ -301,7 +303,7 @@ func (k msgServer) SetReactionsParams(goCtx context.Context, msg *types.MsgSetRe ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSetReactionsParams, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) diff --git a/x/reactions/keeper/msg_server_test.go b/x/reactions/keeper/msg_server_test.go index bb5bf75b09..3204bb7603 100644 --- a/x/reactions/keeper/msg_server_test.go +++ b/x/reactions/keeper/msg_server_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + subspacestypes "github.com/desmos-labs/desmos/v6/x/subspaces/types" + "github.com/golang/mock/gomock" sdk "github.com/cosmos/cosmos-sdk/types" @@ -417,8 +419,8 @@ func (suite *KeeperTestSuite) TestMsgServer_AddReaction() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAddedReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeyPostID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(poststypes.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReactionID, "1"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1efa8l9h4p6hmkps6vk8lu7nxydr46npr8qtg5f"), ), @@ -503,8 +505,8 @@ func (suite *KeeperTestSuite) TestMsgServer_AddReaction() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAddedReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeyPostID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(poststypes.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReactionID, "1"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1efa8l9h4p6hmkps6vk8lu7nxydr46npr8qtg5f"), ), @@ -781,8 +783,8 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveReaction() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRemovedReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeyPostID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(poststypes.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReactionID, "1"), ), }, @@ -948,7 +950,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddRegisteredReaction() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAddedRegisteredReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, "1"), ), }, @@ -1138,7 +1140,7 @@ func (suite *KeeperTestSuite) TestMsgServer_EditRegisteredReaction() { expEvents: sdk.Events{ sdk.NewEvent( types.ActionEditRegisteredReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, "1"), ), }, @@ -1282,7 +1284,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveRegisteredReaction() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRemovedRegisteredReaction, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, "1"), ), }, @@ -1415,7 +1417,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SetReactionsParams() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeSetReactionsParams, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { diff --git a/x/reactions/types/events.go b/x/reactions/types/events.go index fd8692d29b..0738f07b1d 100644 --- a/x/reactions/types/events.go +++ b/x/reactions/types/events.go @@ -9,8 +9,6 @@ const ( EventTypeRemovedRegisteredReaction = "removed_registered_reaction" EventTypeSetReactionsParams = "set_reactions_params" - AttributeKeySubspaceID = "subspace_id" - AttributeKeyPostID = "post_id" AttributeKeyReactionID = "reaction_id" AttributeKeyRegisteredReactionID = "registered_reaction_id" AttributeKeyUser = "user" diff --git a/x/relationships/keeper/msg_server.go b/x/relationships/keeper/msg_server.go index 82f9f6cc3e..c2991d6428 100644 --- a/x/relationships/keeper/msg_server.go +++ b/x/relationships/keeper/msg_server.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + subspacestypes "github.com/desmos-labs/desmos/v6/x/subspaces/types" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -51,7 +53,7 @@ func (k msgServer) CreateRelationship(goCtx context.Context, msg *types.MsgCreat types.EventTypeCreatedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, msg.Signer), sdk.NewAttribute(types.AttributeRelationshipCounterparty, msg.Counterparty), - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -80,7 +82,7 @@ func (k msgServer) DeleteRelationship(goCtx context.Context, msg *types.MsgDelet types.EventTypeDeletedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, msg.Signer), sdk.NewAttribute(types.AttributeRelationshipCounterparty, msg.Counterparty), - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -109,7 +111,7 @@ func (k msgServer) BlockUser(goCtx context.Context, msg *types.MsgBlockUser) (*t types.EventTypeBlockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, msg.Blocker), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, msg.Blocked), - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) @@ -138,7 +140,7 @@ func (k msgServer) UnblockUser(goCtx context.Context, msg *types.MsgUnblockUser) types.EventTypeUnblockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, msg.Blocker), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, msg.Blocked), - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), ), }) diff --git a/x/relationships/keeper/msg_server_test.go b/x/relationships/keeper/msg_server_test.go index 06b466983f..4ef74bbcc2 100644 --- a/x/relationships/keeper/msg_server_test.go +++ b/x/relationships/keeper/msg_server_test.go @@ -4,6 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" + subspacestypes "github.com/desmos-labs/desmos/v6/x/subspaces/types" + "github.com/desmos-labs/desmos/v6/x/relationships/keeper" "github.com/desmos-labs/desmos/v6/x/relationships/types" ) @@ -85,7 +87,7 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateRelationship() { types.EventTypeCreatedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeRelationshipCounterparty, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { @@ -184,7 +186,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteRelationship() { types.EventTypeDeletedRelationship, sdk.NewAttribute(types.AttributeRelationshipCreator, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeRelationshipCounterparty, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { @@ -286,7 +288,7 @@ func (suite *KeeperTestSuite) TestMsgServer_BlockUser() { types.EventTypeBlockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { @@ -386,7 +388,7 @@ func (suite *KeeperTestSuite) TestMsgServer_UnblockUser() { types.EventTypeUnblockedUser, sdk.NewAttribute(types.AttributeKeyUserBlockBlocker, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyUserBlockBlocked, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), ), }, check: func(ctx sdk.Context) { diff --git a/x/relationships/types/events.go b/x/relationships/types/events.go index 16f5eb2afc..a7cf7d7762 100644 --- a/x/relationships/types/events.go +++ b/x/relationships/types/events.go @@ -12,5 +12,4 @@ const ( AttributeRelationshipCounterparty = "counterparty" AttributeKeyUserBlockBlocker = "blocker" AttributeKeyUserBlockBlocked = "blocked" - AttributeKeySubspaceID = "subspace_id" ) diff --git a/x/reports/keeper/msg_server.go b/x/reports/keeper/msg_server.go index 21cce26be8..cc07cc324b 100644 --- a/x/reports/keeper/msg_server.go +++ b/x/reports/keeper/msg_server.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + poststypes "github.com/desmos-labs/desmos/v6/x/posts/types" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -94,14 +96,14 @@ func (k msgServer) CreateReport(goCtx context.Context, msg *types.MsgCreateRepor case *types.PostTarget: reportEvent = sdk.NewEvent( types.EventTypeReportedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), - sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", target.PostID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(poststypes.AttributeKeyPostID, fmt.Sprintf("%d", target.PostID)), sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), ) case *types.UserTarget: reportEvent = sdk.NewEvent( types.EventTypeReportedUser, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUser, target.User), sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), ) @@ -112,7 +114,7 @@ func (k msgServer) CreateReport(goCtx context.Context, msg *types.MsgCreateRepor ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreatedReport, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReportID, fmt.Sprintf("%d", report.ID)), sdk.NewAttribute(types.AttributeKeyReporter, msg.Reporter), sdk.NewAttribute(types.AttributeKeyCreationTime, report.CreationDate.Format(time.RFC3339)), @@ -154,7 +156,7 @@ func (k msgServer) DeleteReport(goCtx context.Context, msg *types.MsgDeleteRepor ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeDeletedReport, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReportID, fmt.Sprintf("%d", msg.ReportID)), ), }) @@ -204,7 +206,7 @@ func (k msgServer) SupportStandardReason(goCtx context.Context, msg *types.MsgSu ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSupportedStandardReason, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyStandardReasonID, fmt.Sprintf("%d", msg.StandardReasonID)), sdk.NewAttribute(types.AttributeKeyReasonID, fmt.Sprintf("%d", reason.ID)), ), @@ -251,7 +253,7 @@ func (k msgServer) AddReason(goCtx context.Context, msg *types.MsgAddReason) (*t ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeAddedReportingReason, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReasonID, fmt.Sprintf("%d", reason.ID)), ), }) @@ -286,7 +288,7 @@ func (k msgServer) RemoveReason(goCtx context.Context, msg *types.MsgRemoveReaso ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRemovedReportingReason, - sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyReasonID, fmt.Sprintf("%d", msg.ReasonID)), ), }) diff --git a/x/reports/keeper/msg_server_test.go b/x/reports/keeper/msg_server_test.go index 5915ef6f2e..8df95e83f4 100644 --- a/x/reports/keeper/msg_server_test.go +++ b/x/reports/keeper/msg_server_test.go @@ -281,14 +281,14 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateReport() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeCreatedReport, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), ), sdk.NewEvent( types.EventTypeReportedUser, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1ggzk8tnte9lmzgpvyzzdtmwmn6rjlct4spmjjd"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), ), @@ -377,15 +377,15 @@ func (suite *KeeperTestSuite) TestMsgServer_CreateReport() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeCreatedReport, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), ), sdk.NewEvent( types.EventTypeReportedPost, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeyPostID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(poststypes.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyReporter, "cosmos1qycmg40ju50fx2mcc82qtkzuswjs3mj3mqekeh"), ), }, @@ -592,7 +592,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteReport() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeDeletedReport, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), ), }, @@ -634,7 +634,7 @@ func (suite *KeeperTestSuite) TestMsgServer_DeleteReport() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeDeletedReport, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReportID, "1"), ), }, @@ -799,7 +799,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SupportStandardReason() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeSupportedStandardReason, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyStandardReasonID, "1"), sdk.NewAttribute(types.AttributeKeyReasonID, "1"), ), @@ -977,7 +977,7 @@ func (suite *KeeperTestSuite) TestMsgServer_AddReason() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeAddedReportingReason, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReasonID, "1"), ), }, @@ -1116,7 +1116,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RemoveReason() { expEvents: sdk.Events{ sdk.NewEvent( types.EventTypeRemovedReportingReason, - sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyReasonID, "1"), ), }, diff --git a/x/reports/types/events.go b/x/reports/types/events.go index 6be242723b..a4a1758780 100644 --- a/x/reports/types/events.go +++ b/x/reports/types/events.go @@ -11,12 +11,10 @@ const ( EventTypeAddedReportingReason = "added_reason" EventTypeRemovedReportingReason = "removed_reason" - AttributeKeySubspaceID = "subspace_id" AttributeKeyReportID = "report_id" AttributeKeyReporter = "reporter" AttributeKeyCreationTime = "creation_time" AttributeKeyStandardReasonID = "standard_reason_id" AttributeKeyReasonID = "reason_id" - AttributeKeyPostID = "post_id" AttributeKeyUser = "user" ) From 2d31eb90b6ebdd66aeee96acd6c1babdc0a5cd20 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 11:31:10 +0100 Subject: [PATCH 08/14] feat: improve posts event attributes Signed-off-by: Riccardo Montagnin --- types/utils/slices.go | 9 +++++++++ x/posts/keeper/msg_server.go | 7 +++++++ x/posts/spec/05-events.md | 10 +++++----- x/posts/types/events.go | 22 ++++++++++++---------- x/posts/types/models.go | 8 ++++++++ 5 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 types/utils/slices.go diff --git a/types/utils/slices.go b/types/utils/slices.go new file mode 100644 index 0000000000..27ce7489fd --- /dev/null +++ b/types/utils/slices.go @@ -0,0 +1,9 @@ +package utils + +func Map[T, U any](ts []T, f func(T) U) []U { + us := make([]U, len(ts)) + for i := range ts { + us[i] = f(ts[i]) + } + return us +} diff --git a/x/posts/keeper/msg_server.go b/x/posts/keeper/msg_server.go index 3399bb8bbe..ffbb8deb17 100644 --- a/x/posts/keeper/msg_server.go +++ b/x/posts/keeper/msg_server.go @@ -4,8 +4,11 @@ import ( "context" "fmt" "sort" + "strings" "time" + "github.com/desmos-labs/desmos/v6/types/utils" + "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -436,6 +439,10 @@ func (k msgServer) AnswerPoll(goCtx context.Context, msg *types.MsgAnswerPoll) ( sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", msg.PostID)), sdk.NewAttribute(types.AttributeKeyPollID, fmt.Sprintf("%d", msg.PollID)), + sdk.NewAttribute(types.AttributeKeyAnswersIndexes, strings.Join(utils.Map(msg.AnswersIndexes, func(index uint32) string { + return fmt.Sprintf("%d", index) + }), ",")), + sdk.NewAttribute(types.AttributeKeyAnswerer, msg.Signer), ), }) diff --git a/x/posts/spec/05-events.md b/x/posts/spec/05-events.md index e23b351299..1924f9ab23 100644 --- a/x/posts/spec/05-events.md +++ b/x/posts/spec/05-events.md @@ -88,7 +88,7 @@ The posts module emits the following events: | message | action | desmos.posts.v3.MsgUpdateParams | | message | sender | {userAddress} | -## MsgMovePost +### MsgMovePost | **Type** | **Attribute Key** | **Attribute Value** | |:-----------|:------------------|:----------------------------| @@ -100,7 +100,7 @@ The posts module emits the following events: | message | action | desmos.posts.v3.MsgMovePost | | message | sender | {userAddress} | -## MsgRequestPostOwnerTransfer +### MsgRequestPostOwnerTransfer | **Type** | **Attribute Key** | **Attribute Value** | |:------------------------------|:------------------|:--------------------------------------------| @@ -112,7 +112,7 @@ The posts module emits the following events: | message | action | desmos.posts.v3.MsgRequestPostOwnerTransfer | | message | sender | {userAddress} | -## MsgCancelPostOwnerTransferRequest +### MsgCancelPostOwnerTransferRequest | **Type** | **Attribute Key** | **Attribute Value** | |:-----------------------------|:------------------|:--------------------------------------------------| @@ -123,7 +123,7 @@ The posts module emits the following events: | message | action | desmos.posts.v3.MsgCancelPostOwnerTransferRequest | | message | sender | {userAddress} | -## MsgAcceptPostOwnerTransferRequest +### MsgAcceptPostOwnerTransferRequest | **Type** | **Attribute Key** | **Attribute Value** | |:-----------------------------|:------------------|:--------------------------------------------------| @@ -136,7 +136,7 @@ The posts module emits the following events: | message | action | desmos.posts.v3.MsgAcceptPostOwnerTransferRequest | | message | sender | {userAddress} | -## MsgRefusePostOwnerTransferRequest +### MsgRefusePostOwnerTransferRequest | **Type** | **Attribute Key** | **Attribute Value** | |:----------------------------|:------------------|:--------------------------------------------------| diff --git a/x/posts/types/events.go b/x/posts/types/events.go index 8bb268a82a..2b1805eaf9 100644 --- a/x/posts/types/events.go +++ b/x/posts/types/events.go @@ -15,14 +15,16 @@ const ( EventTypeAcceptedPostOwnerTransfer = "accepted_post_owner_transfer" EventTypeRefusedPostOwnerTransfer = "refused_post_owner_transfer" - AttributeKeyPostID = "post_id" - AttributeKeyAuthor = "author" - AttributeKeyCreationTime = "creation_date" - AttributeKeyLastEditTime = "last_edit_date" - AttributeKeyAttachmentID = "attachment_id" - AttributeKeyPollID = "poll_id" - AttributeKeyNewSubspaceID = "new_subspace_id" - AttributeKeyNewPostID = "new_post_id" - AttributeKeySender = "sender" - AttributeKeyReceiver = "receiver" + AttributeKeyPostID = "post_id" + AttributeKeyAuthor = "author" + AttributeKeyCreationTime = "creation_date" + AttributeKeyLastEditTime = "last_edit_date" + AttributeKeyAttachmentID = "attachment_id" + AttributeKeyPollID = "poll_id" + AttributeKeyAnswersIndexes = "answers_indexes" + AttributeKeyAnswerer = "answerer" + AttributeKeyNewSubspaceID = "new_subspace_id" + AttributeKeyNewPostID = "new_post_id" + AttributeKeySender = "sender" + AttributeKeyReceiver = "receiver" ) diff --git a/x/posts/types/models.go b/x/posts/types/models.go index 520932fd95..8736180170 100644 --- a/x/posts/types/models.go +++ b/x/posts/types/models.go @@ -791,6 +791,14 @@ func (a *Poll_ProvidedAnswer) UnpackInterfaces(unpacker codectypes.AnyUnpacker) // -------------------------------------------------------------------------------------------------------------------- +func MapAnswersIndexesToStrings(answersIndexes []uint32) []string { + answers := make([]string, len(answersIndexes)) + for i, answer := range answersIndexes { + answers[i] = strconv.FormatUint(uint64(answer), 10) + } + return answers +} + // NewUserAnswer returns a new UserAnswer instance func NewUserAnswer(subspaceID uint64, postID uint64, pollID uint32, answersIndexes []uint32, user string) UserAnswer { return UserAnswer{ From fbc442ccaa595bbc7b81c51f6f74d9ca858f3e88 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 12:20:34 +0100 Subject: [PATCH 09/14] fix(tests): fixed tests Signed-off-by: Riccardo Montagnin --- x/posts/keeper/msg_server_test.go | 4 ++++ x/profiles/keeper/keeper_chain_links.go | 4 ++-- x/profiles/keeper/msg_server_chain_link_test.go | 6 ++++++ x/reactions/keeper/msg_server.go | 2 +- x/subspaces/keeper/msg_server_test.go | 4 ++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/x/posts/keeper/msg_server_test.go b/x/posts/keeper/msg_server_test.go index d1af47b4cd..54c6a19942 100644 --- a/x/posts/keeper/msg_server_test.go +++ b/x/posts/keeper/msg_server_test.go @@ -2192,6 +2192,8 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() { sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyPollID, "1"), + sdk.NewAttribute(types.AttributeKeyAnswersIndexes, "0"), + sdk.NewAttribute(types.AttributeKeyAnswerer, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), ), }, check: func(ctx sdk.Context) { @@ -2273,6 +2275,8 @@ func (suite *KeeperTestSuite) TestMsgServer_AnswerPoll() { sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyPollID, "1"), + sdk.NewAttribute(types.AttributeKeyAnswersIndexes, "0,1"), + sdk.NewAttribute(types.AttributeKeyAnswerer, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), ), }, check: func(ctx sdk.Context) { diff --git a/x/profiles/keeper/keeper_chain_links.go b/x/profiles/keeper/keeper_chain_links.go index 112a6f012f..3bb4cf9367 100644 --- a/x/profiles/keeper/keeper_chain_links.go +++ b/x/profiles/keeper/keeper_chain_links.go @@ -59,9 +59,9 @@ func (k Keeper) SaveChainLink(ctx sdk.Context, link types.ChainLink) error { ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSavedChainLink, - sdk.NewAttribute(types.AttributeKeyChainLinkOwner, link.User), - sdk.NewAttribute(types.AttributeKeyChainLinkChainName, link.ChainConfig.Name), sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, link.GetAddressData().GetValue()), + sdk.NewAttribute(types.AttributeKeyChainLinkChainName, link.ChainConfig.Name), + sdk.NewAttribute(types.AttributeKeyChainLinkOwner, link.User), ), ) diff --git a/x/profiles/keeper/msg_server_chain_link_test.go b/x/profiles/keeper/msg_server_chain_link_test.go index 5426a29ea0..330e71e589 100644 --- a/x/profiles/keeper/msg_server_chain_link_test.go +++ b/x/profiles/keeper/msg_server_chain_link_test.go @@ -107,6 +107,12 @@ func (suite *KeeperTestSuite) TestMsgServer_LinkChainAccount() { ), shouldErr: false, expEvents: sdk.Events{ + sdk.NewEvent( + types.EventTypeSavedChainLink, + sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, srcAddr), + sdk.NewAttribute(types.AttributeKeyChainLinkChainName, "cosmos"), + sdk.NewAttribute(types.AttributeKeyChainLinkOwner, destAddr), + ), sdk.NewEvent( types.EventTypeCreatedChainLink, sdk.NewAttribute(types.AttributeKeyChainLinkExternalAddress, srcAddr), diff --git a/x/reactions/keeper/msg_server.go b/x/reactions/keeper/msg_server.go index dbafcb593d..8fe46619f6 100644 --- a/x/reactions/keeper/msg_server.go +++ b/x/reactions/keeper/msg_server.go @@ -191,7 +191,7 @@ func (k msgServer) AddRegisteredReaction(goCtx context.Context, msg *types.MsgAd ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.ActionAddRegisteredReaction, + types.EventTypeAddedRegisteredReaction, sdk.NewAttribute(subspacestypes.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyRegisteredReactionID, fmt.Sprintf("%d", reaction.ID)), ), diff --git a/x/subspaces/keeper/msg_server_test.go b/x/subspaces/keeper/msg_server_test.go index 76a7618a1e..53bad055fa 100644 --- a/x/subspaces/keeper/msg_server_test.go +++ b/x/subspaces/keeper/msg_server_test.go @@ -2267,6 +2267,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SetUserGroupPermissions() { types.EventTypeSetUserGroupPermissions, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), + sdk.NewAttribute(types.AttributeKeyPermissions, "EVERYTHING"), ), }, check: func(ctx sdk.Context) { @@ -2317,6 +2318,7 @@ func (suite *KeeperTestSuite) TestMsgServer_SetUserGroupPermissions() { types.EventTypeSetUserGroupPermissions, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), + sdk.NewAttribute(types.AttributeKeyPermissions, "SET_PERMISSIONS"), ), }, check: func(ctx sdk.Context) { @@ -2985,6 +2987,8 @@ func (suite *KeeperTestSuite) TestMsgServer_SetUserPermissions() { sdk.NewEvent( types.EventTypeSetUserPermissions, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeySectionID, "0"), + sdk.NewAttribute(types.AttributeKeyPermissions, "EDIT_SUBSPACE"), sdk.NewAttribute(types.AttributeKeyUser, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), ), }, From 75fb5e6c99f4a4bfce0e28c2a54a9ac5cab3335b Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 12:58:01 +0100 Subject: [PATCH 10/14] chore: updated event names Signed-off-by: Riccardo Montagnin --- x/subspaces/types/events.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/x/subspaces/types/events.go b/x/subspaces/types/events.go index c9a7acfabc..10989debcb 100644 --- a/x/subspaces/types/events.go +++ b/x/subspaces/types/events.go @@ -2,26 +2,26 @@ package types // Subspaces module event types const ( - EventTypeCreatedSubspace = "create_subspace" - EventTypeEditedSubspace = "edit_subspace" - EventTypeDeletedSubspace = "delete_subspace" - EventTypeCreatedSection = "create_section" - EventTypeEditedSection = "edit_section" - EventTypeMovedSection = "move_section" - EventTypeDeletedSection = "delete_section" - EventTypeCreatedUserGroup = "create_user_group" - EventTypeEditedUserGroup = "edit_user_group" - EvenTypeMovedUserGroup = "move_user_group" + EventTypeCreatedSubspace = "created_subspace" + EventTypeEditedSubspace = "edited_subspace" + EventTypeDeletedSubspace = "deleted_subspace" + EventTypeCreatedSection = "created_section" + EventTypeEditedSection = "edited_section" + EventTypeMovedSection = "moved_section" + EventTypeDeletedSection = "deleted_section" + EventTypeCreatedUserGroup = "created_user_group" + EventTypeEditedUserGroup = "edited_user_group" + EvenTypeMovedUserGroup = "moved_user_group" EventTypeSetUserGroupPermissions = "set_user_group_permissions" - EventTypeDeletedUserGroup = "delete_user_group" - EventTypeAddedUserToGroup = "add_group_member" - EventTypeRemovedUserFromGroup = "remove_group_member" + EventTypeDeletedUserGroup = "deleted_user_group" + EventTypeAddedUserToGroup = "added_group_member" + EventTypeRemovedUserFromGroup = "removed_group_member" EventTypeSetUserPermissions = "set_user_permissions" - EventTypeGrantedTreasuryAuthorization = "grant_treasury_authorization" - EventTypeRevokedTreasuryAuthorization = "revoke_treasury_authorization" - EventTypeGrantedAllowance = "grant_allowance" - EventTypeRevokedAllowance = "revoke_allowance" - EventTypeUpdatedSubspaceFeeToken = "update_subspace_fee_token" + EventTypeGrantedTreasuryAuthorization = "granted_treasury_authorization" + EventTypeRevokedTreasuryAuthorization = "revoked_treasury_authorization" + EventTypeGrantedAllowance = "granted_allowance" + EventTypeRevokedAllowance = "revoked_allowance" + EventTypeUpdatedSubspaceFeeToken = "updated_subspace_fee_token" AttributeKeySubspaceID = "subspace_id" AttributeKeySubspaceName = "subspace_name" From ef1858de5da2d63a2c4d9dbb4e420edbc38ed4a9 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Thu, 1 Feb 2024 13:04:55 +0100 Subject: [PATCH 11/14] chore: fixed event name typo Signed-off-by: Riccardo Montagnin --- x/subspaces/keeper/msg_server.go | 2 +- x/subspaces/keeper/msg_server_test.go | 2 +- x/subspaces/types/events.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/subspaces/keeper/msg_server.go b/x/subspaces/keeper/msg_server.go index 244b27b6a6..7863556003 100644 --- a/x/subspaces/keeper/msg_server.go +++ b/x/subspaces/keeper/msg_server.go @@ -502,7 +502,7 @@ func (k msgServer) MoveUserGroup(goCtx context.Context, msg *types.MsgMoveUserGr ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EvenTypeMovedUserGroup, + types.EventTypeMovedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), ), diff --git a/x/subspaces/keeper/msg_server_test.go b/x/subspaces/keeper/msg_server_test.go index 53bad055fa..c084aa923e 100644 --- a/x/subspaces/keeper/msg_server_test.go +++ b/x/subspaces/keeper/msg_server_test.go @@ -2044,7 +2044,7 @@ func (suite *KeeperTestSuite) TestMsgServer_MoveUserGroup() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EvenTypeMovedUserGroup, + types.EventTypeMovedUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), ), diff --git a/x/subspaces/types/events.go b/x/subspaces/types/events.go index 10989debcb..d0c481c842 100644 --- a/x/subspaces/types/events.go +++ b/x/subspaces/types/events.go @@ -11,7 +11,7 @@ const ( EventTypeDeletedSection = "deleted_section" EventTypeCreatedUserGroup = "created_user_group" EventTypeEditedUserGroup = "edited_user_group" - EvenTypeMovedUserGroup = "moved_user_group" + EventTypeMovedUserGroup = "moved_user_group" EventTypeSetUserGroupPermissions = "set_user_group_permissions" EventTypeDeletedUserGroup = "deleted_user_group" EventTypeAddedUserToGroup = "added_group_member" From f937baf894dfe93d1ec37204497c63a95afc6fc1 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 7 Feb 2024 14:35:46 +0100 Subject: [PATCH 12/14] fix: inconsistent event names Signed-off-by: Riccardo Montagnin --- x/profiles/keeper/msg_server_dtag_transfers.go | 2 +- .../keeper/msg_server_dtag_transfers_test.go | 2 +- x/profiles/spec/05-events.md | 16 ++++++++-------- x/profiles/types/events.go | 2 +- x/reports/types/events.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x/profiles/keeper/msg_server_dtag_transfers.go b/x/profiles/keeper/msg_server_dtag_transfers.go index b1e494ef1d..4ba37a8b17 100644 --- a/x/profiles/keeper/msg_server_dtag_transfers.go +++ b/x/profiles/keeper/msg_server_dtag_transfers.go @@ -45,7 +45,7 @@ func (k MsgServer) RequestDTagTransfer(goCtx context.Context, msg *types.MsgRequ ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - types.EventTypeRequestedDTagTransferRequest, + types.EventTypeRequestedDTagTransfer, sdk.NewAttribute(types.AttributeKeyDTagToTrade, dTagToTrade), sdk.NewAttribute(types.AttributeKeyRequestSender, transferRequest.Sender), sdk.NewAttribute(types.AttributeKeyRequestReceiver, transferRequest.Receiver), diff --git a/x/profiles/keeper/msg_server_dtag_transfers_test.go b/x/profiles/keeper/msg_server_dtag_transfers_test.go index afa5aa9725..b117506d6e 100644 --- a/x/profiles/keeper/msg_server_dtag_transfers_test.go +++ b/x/profiles/keeper/msg_server_dtag_transfers_test.go @@ -83,7 +83,7 @@ func (suite *KeeperTestSuite) TestMsgServer_RequestDTagTransfer() { shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( - types.EventTypeRequestedDTagTransferRequest, + types.EventTypeRequestedDTagTransfer, sdk.NewAttribute(types.AttributeKeyDTagToTrade, fmt.Sprintf("%s-dtag", "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns")), sdk.NewAttribute(types.AttributeKeyRequestSender, "cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47"), sdk.NewAttribute(types.AttributeKeyRequestReceiver, "cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns"), diff --git a/x/profiles/spec/05-events.md b/x/profiles/spec/05-events.md index 0501a7c8c0..1f46f14ca7 100644 --- a/x/profiles/spec/05-events.md +++ b/x/profiles/spec/05-events.md @@ -33,14 +33,14 @@ The profiles module emits the following events: ## MsgRequestDTagTransfer -| **Type** | **Attribute Key** | **Attribute Value** | -|:------------------------------|:------------------|:------------------------------------------| -| created_dtag_transfer_request | dtag_to_trade | {dTagToTrade} | -| created_dtag_transfer_request | request_sender | {requestSenderAddress} | -| created_dtag_transfer_request | request_receiver | {requestReceiverAddress} | -| message | module | profiles | -| message | action | desmos.profiles.v3.MsgRequestDTagTransfer | -| message | sender | {requestSenderAddress} | +| **Type** | **Attribute Key** | **Attribute Value** | +|:------------------------|:------------------|:------------------------------------------| +| requested_dtag_transfer | dtag_to_trade | {dTagToTrade} | +| requested_dtag_transfer | request_sender | {requestSenderAddress} | +| requested_dtag_transfer | request_receiver | {requestReceiverAddress} | +| message | module | profiles | +| message | action | desmos.profiles.v3.MsgRequestDTagTransfer | +| message | sender | {requestSenderAddress} | ## MsgCancelDTagTransferRequest diff --git a/x/profiles/types/events.go b/x/profiles/types/events.go index 0973023a3a..c473abe540 100644 --- a/x/profiles/types/events.go +++ b/x/profiles/types/events.go @@ -6,7 +6,7 @@ const ( EventTypeSavedProfile = "saved_profile" EventTypeDeletedProfile = "deleted_profile" - EventTypeRequestedDTagTransferRequest = "created_dtag_transfer_request" + EventTypeRequestedDTagTransfer = "requested_dtag_transfer" EventTypeAcceptedDTagTransferRequest = "accepted_dtag_transfer_request" EventTypeRefusedDTagTransferRequest = "refused_dtag_transfer_request" EventTypeCanceledDTagTransferRequest = "canceled_dtag_transfer_request" diff --git a/x/reports/types/events.go b/x/reports/types/events.go index a4a1758780..ee693fd03e 100644 --- a/x/reports/types/events.go +++ b/x/reports/types/events.go @@ -8,8 +8,8 @@ const ( EventTypeReportedUser = "reported_user" EventTypeDeletedReport = "deleted_report" EventTypeSupportedStandardReason = "supported_standard_reason" - EventTypeAddedReportingReason = "added_reason" - EventTypeRemovedReportingReason = "removed_reason" + EventTypeAddedReportingReason = "added_reporting_reason" + EventTypeRemovedReportingReason = "removed_reporting_reason" AttributeKeyReportID = "report_id" AttributeKeyReporter = "reporter" From c29811435236af47be60999f524a2af189812f26 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 7 Feb 2024 14:36:00 +0100 Subject: [PATCH 13/14] chore: removed unused method Signed-off-by: Riccardo Montagnin --- x/posts/types/models.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/x/posts/types/models.go b/x/posts/types/models.go index 8736180170..520932fd95 100644 --- a/x/posts/types/models.go +++ b/x/posts/types/models.go @@ -791,14 +791,6 @@ func (a *Poll_ProvidedAnswer) UnpackInterfaces(unpacker codectypes.AnyUnpacker) // -------------------------------------------------------------------------------------------------------------------- -func MapAnswersIndexesToStrings(answersIndexes []uint32) []string { - answers := make([]string, len(answersIndexes)) - for i, answer := range answersIndexes { - answers[i] = strconv.FormatUint(uint64(answer), 10) - } - return answers -} - // NewUserAnswer returns a new UserAnswer instance func NewUserAnswer(subspaceID uint64, postID uint64, pollID uint32, answersIndexes []uint32, user string) UserAnswer { return UserAnswer{ From 019ffa10e4a0895fe2e4db5cc6f1a720fc2d3f37 Mon Sep 17 00:00:00 2001 From: Riccardo Montagnin Date: Wed, 7 Feb 2024 17:14:27 +0100 Subject: [PATCH 14/14] chore: added changeset entry Signed-off-by: Riccardo Montagnin --- ...6899301d06b3b3a7a6bb3a324e0d8575cd332a3558e4eb7e8f0.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/entries/22c2a6c7f91416899301d06b3b3a7a6bb3a324e0d8575cd332a3558e4eb7e8f0.yaml diff --git a/.changeset/entries/22c2a6c7f91416899301d06b3b3a7a6bb3a324e0d8575cd332a3558e4eb7e8f0.yaml b/.changeset/entries/22c2a6c7f91416899301d06b3b3a7a6bb3a324e0d8575cd332a3558e4eb7e8f0.yaml new file mode 100644 index 0000000000..c7b582a28a --- /dev/null +++ b/.changeset/entries/22c2a6c7f91416899301d06b3b3a7a6bb3a324e0d8575cd332a3558e4eb7e8f0.yaml @@ -0,0 +1,6 @@ +type: refactor +module: other +pull_request: 1295 +description: Updated the event andattributes names for better naming consistency +backward_compatible: false +date: 2024-02-07T16:14:12.727157086Z