diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 60cabab88dd1..3ca0fb0a2a7a 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -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-alpha.2](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv1.0.0-alpha.2) diff --git a/core/README.md b/core/README.md index 6ab95a67a6f1..f54197bd7be5 100644 --- a/core/README.md +++ b/core/README.md @@ -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. diff --git a/core/event/event.go b/core/event/event.go index 4304e6e2b4af..de8fe739b379 100644 --- a/core/event/event.go +++ b/core/event/event.go @@ -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 }} } diff --git a/core/go.mod b/core/go.mod index 8f691cc75063..a3024b46e990 100644 --- a/core/go.mod +++ b/core/go.mod @@ -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 diff --git a/core/go.sum b/core/go.sum index e69de29bb2d1..447523b65a47 100644 --- a/core/go.sum +++ b/core/go.sum @@ -0,0 +1,2 @@ +cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk= +cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=