Skip to content

Commit

Permalink
feat(core/event): make core/event as a type alias of `schema/appdat…
Browse files Browse the repository at this point in the history
…a` (#21719)
  • Loading branch information
cool-develope authored Sep 16, 2024
1 parent a9f057b commit 7856d22
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
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
2 changes: 1 addition & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Key features and principles:
4. Modules depend solely on core APIs for maximum compatibility.
5. New API additions undergo thorough consideration to maintain stability.
6. Adheres to a no-breaking-changes policy for reliable dependency management.
7. Aimed to have zero dependencies, ensuring a lightweight and self-contained foundation.
7. Aimed to only depend on `schema`, ensuring a lightweight and self-contained foundation.

The core module offers the [appmodule](https://pkg.go.dev/cosmossdk.io/core/appmodule) and [appmodule/v2](https://pkg.go.dev/cosmossdk.io/core/appmodule/v2) packages that include APIs to describe how modules can be written.
Additionally, it contains all core services APIs that can be used in modules to interact with the SDK, majoritarily via the `appmodule.Environment` struct.
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=

0 comments on commit 7856d22

Please sign in to comment.