cosmos-sdk/core/appmodule/v2/genesis.go
Julien Robert 6fc677faec
docs(core): add core documentation and principles (#21511)
Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
2024-09-03 22:20:05 +00:00

38 lines
1.2 KiB
Go

package appmodulev2
import (
"context"
"encoding/json"
)
// HasGenesis defines a custom genesis handling API implementation.
// WARNING: this API is meant as a short-term solution to allow for the
// migration of existing modules to the new app module API.
// It is intended to be replaced by an automatic genesis with collections/orm.
type HasGenesis interface {
AppModule
DefaultGenesis() json.RawMessage
ValidateGenesis(data json.RawMessage) error
InitGenesis(ctx context.Context, data json.RawMessage) error
ExportGenesis(ctx context.Context) (json.RawMessage, error)
}
// HasABCIGenesis defines a custom genesis handling API implementation for ABCI.
// (stateful genesis methods which returns validator updates)
// Most modules should not implement this interface.
type HasABCIGenesis interface {
AppModule
DefaultGenesis() json.RawMessage
ValidateGenesis(data json.RawMessage) error
InitGenesis(ctx context.Context, data json.RawMessage) ([]ValidatorUpdate, error)
ExportGenesis(ctx context.Context) (json.RawMessage, error)
}
// GenesisDecoder is an alternative to the InitGenesis method.
// It is implemented by the genutil module to decode genTxs.
type GenesisDecoder interface {
DecodeGenesisJSON(data json.RawMessage) ([]json.RawMessage, error)
}