From 3e17443bc90219db734afab4792db98796275f52 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Mon, 25 Mar 2024 19:16:36 -0400 Subject: [PATCH 1/2] types --- x/mm2/types/events.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 x/mm2/types/events.go diff --git a/x/mm2/types/events.go b/x/mm2/types/events.go new file mode 100644 index 000000000..5ef42df29 --- /dev/null +++ b/x/mm2/types/events.go @@ -0,0 +1,15 @@ +package types + +// market map module event types + +const ( + EventTypeCreateMarket = "create_market" + EventTypeUpdateMarket = "update_market" + + AttributeKeyCurrencyPair = "currency_pair" + AttributeKeyDecimals = "decimals" + AttributeKeyMinProviderCount = "min_provider_count" + AttributeKeyMetadata = "metadata" + AttributeKeyProviders = "providers" + AttributeKeyPaths = "paths" +) From cd9c85551c6f895a8fa68d2dc18df9ed0e2e3e6e Mon Sep 17 00:00:00 2001 From: aljo242 Date: Mon, 25 Mar 2024 19:19:04 -0400 Subject: [PATCH 2/2] events --- x/mm2/keeper/msg_server.go | 20 ++++++++++++++++++-- x/mm2/types/events.go | 2 -- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/x/mm2/keeper/msg_server.go b/x/mm2/keeper/msg_server.go index 45282737e..985eb8fef 100644 --- a/x/mm2/keeper/msg_server.go +++ b/x/mm2/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "strconv" sdk "github.com/cosmos/cosmos-sdk/types" @@ -52,7 +53,14 @@ func (ms msgServer) CreateMarkets(goCtx context.Context, msg *types.MsgCreateMar return nil, fmt.Errorf("unable to run create market hook: %w", err) } - // TODO events + event := sdk.NewEvent( + types.EventTypeCreateMarket, + sdk.NewAttribute(types.AttributeKeyCurrencyPair, market.Ticker.String()), + sdk.NewAttribute(types.AttributeKeyDecimals, strconv.FormatUint(market.Ticker.Decimals, 10)), + sdk.NewAttribute(types.AttributeKeyMinProviderCount, strconv.FormatUint(market.Ticker.MinProviderCount, 10)), + sdk.NewAttribute(types.AttributeKeyMetadata, market.Ticker.Metadata_JSON), + ) + ctx.EventManager().EmitEvent(event) } // validate that the new state of the marketmap is valid @@ -94,7 +102,15 @@ func (ms msgServer) UpdateMarkets(goCtx context.Context, msg *types.MsgUpdateMar return nil, fmt.Errorf("unable to run update market hook: %w", err) } - // TODO events + event := sdk.NewEvent( + types.EventTypeUpdateMarket, + sdk.NewAttribute(types.AttributeKeyCurrencyPair, market.Ticker.String()), + sdk.NewAttribute(types.AttributeKeyDecimals, strconv.FormatUint(market.Ticker.Decimals, 10)), + sdk.NewAttribute(types.AttributeKeyMinProviderCount, strconv.FormatUint(market.Ticker.MinProviderCount, 10)), + sdk.NewAttribute(types.AttributeKeyMetadata, market.Ticker.Metadata_JSON), + ) + ctx.EventManager().EmitEvent(event) + } // validate that the new state of the marketmap is valid diff --git a/x/mm2/types/events.go b/x/mm2/types/events.go index 5ef42df29..74e0ee560 100644 --- a/x/mm2/types/events.go +++ b/x/mm2/types/events.go @@ -10,6 +10,4 @@ const ( AttributeKeyDecimals = "decimals" AttributeKeyMinProviderCount = "min_provider_count" AttributeKeyMetadata = "metadata" - AttributeKeyProviders = "providers" - AttributeKeyPaths = "paths" )