feat(core/event): make core/event as a type alias of schema/appdata (#21719)
This commit is contained in:
parent
a9f057bf70
commit
7856d22603
@ -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)
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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 }}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
|
||||
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
|
||||
Loading…
Reference in New Issue
Block a user