package bond // module.go holds the bond module's AppModule + RegisterServices // (P6-02-01, REQ-038). // // The AppModule wraps the bond 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 StandKeeper expected-keeper shim is injected at construction // (nil-able for partial tests — a nil StandKeeper skips the StandExists // check on issuance). 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/bond/keeper" "github.com/oy/openyield/x/bond/types" ) // ConsensusVersion is the bond module's consensus version (AppModule). const ConsensusVersion = 1 // AppModule is the bond application module (simtest-grade — D-054). type AppModule struct { keeper keeper.Keeper } // NewAppModule constructs a new bond AppModule. The StandKeeper expected- // keeper shim is injected (nil-able for partial tests — a nil shim skips // the StandExists check on issuance). func NewAppModule(cdc codec.Codec, storeKey storetypes.StoreKey, sk types.StandKeeper) AppModule { k := keeper.NewKeeper(cdc, storeKey, sk) return AppModule{keeper: k} } // RegisterServices registers the bond 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 bond MsgServer for this module's keeper. func (am AppModule) MsgServer() types.MsgServer { return keeper.NewMsgServerImpl(am.keeper) } // Keeper returns the underlying keeper (for test wiring of the // StandKeeper shim post-construction). func (am AppModule) Keeper() keeper.Keeper { return 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 bond module (simtest- // grade no-op — the runtime stores are created at handler time; genesis // init of runtime-promoted stores is deferred to the live chain v0.6+). // Uses encoding/json directly (the bond GenesisState is the v0.2/v0.3 // JSON-shaped struct; it does not implement proto.Message, so the codec // JSONCodec is not used — matching types.ValidateGenesis which uses // encoding/json). func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { var gs types.GenesisState _ = json.Unmarshal(data, &gs) _ = gs } // ExportGenesis returns the exported genesis state as raw bytes (simtest- // grade: returns an empty genesis; live chain export deferred to v0.6+). func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs := types.DefaultGenesisState() bz, _ := json.Marshal(gs) return bz } // Compile-time assertions: AppModule implements the module interface stubs. var _ module.HasName = AppModule{} var _ module.HasConsensusVersion = AppModule{}