From bb43132f79d72e31b810d5304b5ee8799b485e65 Mon Sep 17 00:00:00 2001
From: Matt Witkowski <mwitkowski@provenance.io>
Date: Tue, 16 Apr 2024 15:44:35 -0400
Subject: [PATCH] Removes emitting of sdk.EventTypeMessage (#1933)

* Update changelog.

* Remove emitting of EventTypeMessage.
---
 CHANGELOG.md                                 |   1 +
 internal/handlers/msg_service_router_test.go |   4 -
 x/marker/keeper/msg_server.go                | 119 -------------------
 x/marker/keeper/msg_server_test.go           |  11 --
 x/metadata/keeper/msg_server.go              |   7 --
 x/oracle/keeper/msg_server.go                |  14 ---
 x/oracle/keeper/msg_server_test.go           |  13 +-
 7 files changed, 2 insertions(+), 167 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 629e08ecd8..4811907fb6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
 * Bump the SDK to `v0.50.5-pio-1` (from an earlier ephemeral version) [#1897](https://github.com/provenance-io/provenance/pull/1897).
 * Removed `rewards` module [#1905](https://github.com/provenance-io/provenance/pull/1905).
 * Remove unused navs [#1920](https://github.com/provenance-io/provenance/issues/1920).
+* Remove emitting of EventTypeMessage [#1760](https://github.com/provenance-io/provenance/issues/1760).
 * Update genutil for sdk 50 [#1760](https://github.com/provenance-io/provenance/issues/1760).
 * Migrate module params from param space to module store.
   *  Attribute module param migration [#1927](https://github.com/provenance-io/provenance/pull/1927)
diff --git a/internal/handlers/msg_service_router_test.go b/internal/handlers/msg_service_router_test.go
index 44d82c1fd0..71d5c4cdd8 100644
--- a/internal/handlers/msg_service_router_test.go
+++ b/internal/handlers/msg_service_router_test.go
@@ -1125,10 +1125,6 @@ func CreateSendCoinEvents(fromAddress, toAddress string, amt sdk.Coins) []abci.E
 		sdk.NewAttribute(banktypes.AttributeKeySender, fromAddress),
 		sdk.NewAttribute(sdk.AttributeKeyAmount, amt.String()),
 	))
-	events = events.AppendEvent(sdk.NewEvent(
-		sdk.EventTypeMessage,
-		sdk.NewAttribute(banktypes.AttributeKeySender, fromAddress),
-	))
 
 	return events.ToABCIEvents()
 }
diff --git a/x/marker/keeper/msg_server.go b/x/marker/keeper/msg_server.go
index 3f48852eb7..987f8516ac 100644
--- a/x/marker/keeper/msg_server.go
+++ b/x/marker/keeper/msg_server.go
@@ -126,13 +126,6 @@ func (k msgServer) AddMarker(goCtx context.Context, msg *types.MsgAddMarkerReque
 		}
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgAddMarkerResponse{}, nil
 }
 
@@ -153,13 +146,6 @@ func (k msgServer) AddAccess(goCtx context.Context, msg *types.MsgAddAccessReque
 		}
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgAddAccessResponse{}, nil
 }
 
@@ -198,13 +184,6 @@ func (k msgServer) Finalize(goCtx context.Context, msg *types.MsgFinalizeRequest
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgFinalizeResponse{}, nil
 }
 
@@ -221,13 +200,6 @@ func (k msgServer) Activate(goCtx context.Context, msg *types.MsgActivateRequest
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgActivateResponse{}, nil
 }
 
@@ -244,13 +216,6 @@ func (k msgServer) Cancel(goCtx context.Context, msg *types.MsgCancelRequest) (*
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgCancelResponse{}, nil
 }
 
@@ -267,13 +232,6 @@ func (k msgServer) Delete(goCtx context.Context, msg *types.MsgDeleteRequest) (*
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgDeleteResponse{}, nil
 }
 
@@ -290,13 +248,6 @@ func (k msgServer) Mint(goCtx context.Context, msg *types.MsgMintRequest) (*type
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	defer func() {
 		telemetry.IncrCounterWithLabels(
 			[]string{types.ModuleName, types.EventTelemetryKeyMint},
@@ -331,13 +282,6 @@ func (k msgServer) Burn(goCtx context.Context, msg *types.MsgBurnRequest) (*type
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	defer func() {
 		telemetry.IncrCounterWithLabels(
 			[]string{types.ModuleName, types.EventTelemetryKeyBurn},
@@ -378,13 +322,6 @@ func (k msgServer) Withdraw(goCtx context.Context, msg *types.MsgWithdrawRequest
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	defer func() {
 		telemetry.IncrCounterWithLabels(
 			[]string{types.ModuleName, types.EventTelemetryKeyWithdraw},
@@ -438,13 +375,6 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransferRequest
 		return nil, err
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	defer func() {
 		telemetry.IncrCounterWithLabels(
 			[]string{types.ModuleName, types.EventTelemetryKeyTransfer},
@@ -493,13 +423,6 @@ func (k msgServer) IbcTransfer(goCtx context.Context, msg *types.MsgIbcTransferR
 		return nil, err
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	defer func() {
 		telemetry.IncrCounterWithLabels(
 			[]string{types.ModuleName, types.EventTelemetryKeyIbcTransfer},
@@ -545,13 +468,6 @@ func (k msgServer) SetDenomMetadata(
 		return nil, err
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgSetDenomMetadataResponse{}, nil
 }
 
@@ -611,13 +527,6 @@ func (k msgServer) AddFinalizeActivateMarker(goCtx context.Context, msg *types.M
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgAddFinalizeActivateMarkerResponse{}, nil
 }
 
@@ -689,13 +598,6 @@ func (k msgServer) UpdateRequiredAttributes(goCtx context.Context, msg *types.Ms
 	m.SetRequiredAttributes(reqAttrs)
 	k.SetMarker(ctx, m)
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgUpdateRequiredAttributesResponse{}, nil
 }
 
@@ -726,13 +628,6 @@ func (k msgServer) UpdateForcedTransfer(goCtx context.Context, msg *types.MsgUpd
 	marker.SetAllowForcedTransfer(msg.AllowForcedTransfer)
 	k.SetMarker(ctx, marker)
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgUpdateForcedTransferResponse{}, nil
 }
 
@@ -807,13 +702,6 @@ func (k msgServer) UpdateSendDenyList(goCtx context.Context, msg *types.MsgUpdat
 		k.AddSendDeny(ctx, markerAddr, denyAddr)
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgUpdateSendDenyListResponse{}, nil
 }
 
@@ -840,12 +728,5 @@ func (k msgServer) AddNetAssetValues(goCtx context.Context, msg *types.MsgAddNet
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgAddNetAssetValuesResponse{}, nil
 }
diff --git a/x/marker/keeper/msg_server_test.go b/x/marker/keeper/msg_server_test.go
index 78dde04112..ce779ffe1a 100644
--- a/x/marker/keeper/msg_server_test.go
+++ b/x/marker/keeper/msg_server_test.go
@@ -509,17 +509,6 @@ func (s *MsgServerTestSuite) TestUpdateForcedTransfer() {
 					allowsForcedTransfer := markerNow.AllowsForcedTransfer()
 					s.Assert().Equal(tc.msg.AllowForcedTransfer, allowsForcedTransfer, "AllowsForcedTransfer after UpdateForcedTransfer")
 				}
-
-				expEvents := sdk.Events{
-					{
-						Type: sdk.EventTypeMessage,
-						Attributes: []abci.EventAttribute{
-							{Key: sdk.AttributeKeyModule, Value: types.ModuleName},
-						},
-					},
-				}
-				events := em.Events()
-				s.Assert().Equal(expEvents, events, "events emitted during UpdateForcedTransfer")
 			}
 		})
 	}
diff --git a/x/metadata/keeper/msg_server.go b/x/metadata/keeper/msg_server.go
index 7be1117cdd..d908bee7fc 100644
--- a/x/metadata/keeper/msg_server.go
+++ b/x/metadata/keeper/msg_server.go
@@ -761,12 +761,5 @@ func (k msgServer) AddNetAssetValues(goCtx context.Context, msg *types.MsgAddNet
 		return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error())
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgAddNetAssetValuesResponse{}, nil
 }
diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go
index 106dcc3333..e81969c60c 100644
--- a/x/oracle/keeper/msg_server.go
+++ b/x/oracle/keeper/msg_server.go
@@ -31,13 +31,6 @@ func (s msgServer) UpdateOracle(goCtx context.Context, msg *types.MsgUpdateOracl
 
 	s.Keeper.SetOracle(ctx, sdk.MustAccAddressFromBech32(msg.Address))
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgUpdateOracleResponse{}, nil
 }
 
@@ -50,13 +43,6 @@ func (s msgServer) SendQueryOracle(goCtx context.Context, msg *types.MsgSendQuer
 		return nil, err
 	}
 
-	ctx.EventManager().EmitEvent(
-		sdk.NewEvent(
-			sdk.EventTypeMessage,
-			sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-		),
-	)
-
 	return &types.MsgSendQueryOracleResponse{
 		Sequence: seq,
 	}, nil
diff --git a/x/oracle/keeper/msg_server_test.go b/x/oracle/keeper/msg_server_test.go
index 3397bac147..d050674bd7 100644
--- a/x/oracle/keeper/msg_server_test.go
+++ b/x/oracle/keeper/msg_server_test.go
@@ -10,10 +10,6 @@ import (
 
 func (s *KeeperTestSuite) TestUpdateOracle() {
 	authority := s.app.OracleKeeper.GetAuthority()
-	event := sdk.NewEvent(
-		sdk.EventTypeMessage,
-		sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-	)
 
 	tests := []struct {
 		name  string
@@ -37,8 +33,7 @@ func (s *KeeperTestSuite) TestUpdateOracle() {
 				Address:   "cosmos1w6t0l7z0yerj49ehnqwqaayxqpe3u7e23edgma",
 				Authority: authority,
 			},
-			res:   &types.MsgUpdateOracleResponse{},
-			event: &event,
+			res: &types.MsgUpdateOracleResponse{},
 		},
 	}
 
@@ -67,11 +62,6 @@ func (s *KeeperTestSuite) TestUpdateOracle() {
 }
 
 func (s *KeeperTestSuite) TestSendQueryOracle() {
-	event := sdk.NewEvent(
-		sdk.EventTypeMessage,
-		sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
-	)
-
 	s.app.OracleKeeper = s.app.OracleKeeper.WithMockICS4Wrapper(keeper.MockICS4Wrapper{})
 	s.app.OracleKeeper = s.app.OracleKeeper.WithMockScopedKeeper(keeper.MockScopedKeeper{})
 
@@ -103,7 +93,6 @@ func (s *KeeperTestSuite) TestSendQueryOracle() {
 			res: &types.MsgSendQueryOracleResponse{
 				Sequence: 1,
 			},
-			event:       &event,
 			mockChannel: true,
 		},
 	}