Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/marketmap): events #281

Merged
merged 15 commits into from
Apr 4, 2024
Merged
20 changes: 18 additions & 2 deletions x/mm2/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"
"fmt"
"strconv"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions x/mm2/types/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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"
)
Loading