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(core/event): make core/event as a type alias of schema/appdata #21719

Merged
merged 11 commits into from
Sep 16, 2024
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* [#21719](https://github.com/cosmos/cosmos-sdk/pull/21719) Make `core/event` as a type alias of `schema/appdata`.

<!-- ## [v1.0.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv1.0.0) -->
## [v1.0.0-alpha.2](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv1.0.0-alpha.2)

Expand Down
17 changes: 6 additions & 11 deletions core/event/event.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
package event

import "cosmossdk.io/schema/appdata"

// Attribute is a kv-pair event attribute.
type Attribute struct {
Key, Value string
}
type Attribute = appdata.EventAttribute

func NewAttribute(key, value string) Attribute {
return Attribute{Key: key, Value: value}
}

// Events represents a list of events.
type Events struct {
Events []Event
}
type Events = appdata.EventData

func NewEvents(events ...Event) Events {
return Events{Events: events}
}

// Event defines how an event will emitted
type Event struct {
Type string
Attributes []Attribute
}
type Event = appdata.Event

func NewEvent(ty string, attrs ...Attribute) Event {
return Event{Type: ty, Attributes: attrs}
return Event{Type: ty, Attributes: func() ([]Attribute, error) { return attrs, nil }}
}
2 changes: 2 additions & 0 deletions core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ go 1.23

// Version tagged too early and incompatible with v0.50 (latest at the time of tagging)
retract v0.12.0

require cosmossdk.io/schema v0.2.0
2 changes: 2 additions & 0 deletions core/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
Loading