package simulation

import (
	"math/rand"

	sdk "git.cw.tr/mukan-network/mukan-sdk/types"
	"git.cw.tr/mukan-network/mukan-sdk/types/address"
	simtypes "git.cw.tr/mukan-network/mukan-sdk/types/simulation"
	"git.cw.tr/mukan-network/mukan-sdk/x/bank/types"
	"git.cw.tr/mukan-network/mukan-sdk/x/simulation"
)

// Simulation operation weights constants
// will be removed in the future
const (
	DefaultWeightMsgUpdateParams int = 100
	OpWeightMsgUpdateParams          = "op_weight_msg_update_params"
)

// ProposalMsgs defines the module weighted proposals' contents
// migrate to the msg factories instead, this method will be removed in the future
func ProposalMsgs() []simtypes.WeightedProposalMsg {
	return []simtypes.WeightedProposalMsg{
		simulation.NewWeightedProposalMsg(
			OpWeightMsgUpdateParams,
			DefaultWeightMsgUpdateParams,
			SimulateMsgUpdateParams,
		),
	}
}

// SimulateMsgUpdateParams returns a random MsgUpdateParams
// will be removed in the future
func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
	// use the default gov module account address as authority
	var authority sdk.AccAddress = address.Module("gov")

	params := types.DefaultParams()
	params.DefaultSendEnabled = r.Intn(2) == 0

	return &types.MsgUpdateParams{
		Authority: authority.String(),
		Params:    params,
	}
}
