package crisis

import (
	"encoding/json"

	"github.com/cosmos/cosmos-sdk/codec"
	"github.com/cosmos/cosmos-sdk/types/module"
	"github.com/cosmos/cosmos-sdk/x/crisis"
	"github.com/cosmos/cosmos-sdk/x/crisis/types"

	customtypes "github.com/classic-terra/core/v3/custom/crisis/types"
	core "github.com/classic-terra/core/v3/types"
)

var _ module.AppModuleBasic = AppModuleBasic{}

// AppModuleBasic defines the basic application module used by the distribution module.
type AppModuleBasic struct {
	crisis.AppModuleBasic
}

// RegisterLegacyAminoCodec registers the crisis module's types for the given codec.
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
	customtypes.RegisterLegacyAminoCodec(cdc)
	*types.ModuleCdc = *customtypes.ModuleCdc
}

// DefaultGenesis returns default genesis state as raw bytes for the gov
// module.
func (am AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
	// customize to set default genesis state deposit denom to uluna
	defaultGenesisState := types.DefaultGenesisState()
	defaultGenesisState.ConstantFee.Denom = core.MicroLunaDenom

	return cdc.MustMarshalJSON(defaultGenesisState)
}
