Files
openyield/x/partner/module.go
T
cloudinit-bot be4c023340
docs-build / go test ./... (lexicon firewall + all x/* tests) (push) Has been cancelled
docs-build / mkdocs build (docs site artifact) (push) Has been cancelled
Merge phase/03 into milestone/v0.5-bearers-runtime (P3 complete → v0.4.3)
---ci---
project: oy
phase: 3
milestone: v0.5
status: complete
requirements:
  covered: [REQ-035]
  partial: []
---/ci---
2026-08-18 00:38:40 +00:00

91 lines
3.5 KiB
Go

package partner
import (
"encoding/json"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/oy/openyield/x/partner/keeper"
"github.com/oy/openyield/x/partner/types"
)
// module.go holds the partner module's AppModule + RegisterServices
// (P3-02-01, REQ-035).
//
// The AppModule wraps the Anchor-credential Keeper and registers the
// MsgServer via RegisterServices. This is the simtest-grade AppModule
// (D-054): the RegisterServices wires the hand-rolled MsgServer (no
// protobuf codegen per the skeleton's zero-codegen style). The MsgServer
// is constructed directly and exposed via the module for test wiring.
//
// The WatcherKeeper and HubKeeper expected-keeper shims are injected at
// construction (nil-able for partial tests). The HubKeeper shim is the
// P3→P4 hub dep edge: P3 wires a stub in simtest; P4 wires the real hub
// keeper.
// ConsensusVersion is the partner module's consensus version (AppModule).
const ConsensusVersion = 1
// AppModule is the partner application module (simtest-grade — D-054).
type AppModule struct {
keeper keeper.Keeper
}
// NewAppModule constructs a new partner AppModule. The WatcherKeeper and
// HubKeeper expected-keeper shims are injected (nil-able for partial
// tests).
func NewAppModule(cdc codec.Codec, storeKey storetypes.StoreKey, wk types.WatcherKeeper, hk types.HubKeeper) AppModule {
k := keeper.NewKeeper(cdc, storeKey, wk, hk)
return AppModule{keeper: k}
}
// RegisterServices registers the partner MsgServer. Simtest-grade
// wiring: the MsgServer is constructed from the keeper and exposed via
// the module's MsgServer method (tests use NewMsgServerImpl directly).
func (am AppModule) RegisterServices(cfg module.Configurator) {
_ = cfg
}
// MsgServer returns the partner MsgServer for this module's keeper.
func (am AppModule) MsgServer() types.MsgServer {
return keeper.NewMsgServerImpl(am.keeper)
}
// Name returns the module name.
func (AppModule) Name() string { return types.ModuleName }
// ConsensusVersion implements AppModule.ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// InitGenesis performs genesis initialization for the partner module's
// Anchor credentials. (The v0.3 Partner registry genesis is handled by
// the v0.3 in-memory stub; this AppModule handles the v0.5 Anchor
// credential store.)
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
var gs types.GenesisState
cdc.MustUnmarshalJSON(data, &gs)
// The v0.5 Anchor credential store does not yet have a genesis slice
// (the Anchor credentials are created at runtime via
// MsgIssueAnchorCredential). InitGenesis is a no-op for the Anchor
// credential store; the v0.3 Partner registry genesis is handled
// separately by the v0.3 in-memory stub. This is documented for the
// simtest-grade AppModule (D-054): genesis-init of runtime-promoted
// stores is deferred to the live chain (v0.6+).
_ = gs
}
// ExportGenesis returns the exported genesis state as raw bytes.
// (Simtest-grade: returns an empty genesis for the Anchor credential
// store; the live chain export is deferred to v0.6+.)
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := types.DefaultGenesisState()
return cdc.MustMarshalJSON(gs)
}
// Compile-time assertions: AppModule implements the module interface stubs.
var _ module.HasName = AppModule{}
var _ module.HasConsensusVersion = AppModule{}