package types

import sdk "github.com/cosmos/cosmos-sdk/types"

type TokenFactoryMsg struct {
	Token *TokenMsg `json:"token,omitempty"`
}

type TokenMsg struct {
	/// Contracts can create denoms, namespaced under the contract's address.
	/// A contract may create any number of independent sub-denoms.
	CreateDenom *CreateDenom `json:"create_denom,omitempty"`
	/// Contracts can change the admin of a denom that they are the admin of.
	ChangeAdmin *ChangeAdmin `json:"change_admin,omitempty"`
	/// Contracts can mint native tokens for an existing factory denom
	/// that they are the admin of.
	MintTokens *MintTokens `json:"mint_tokens,omitempty"`
	/// Contracts can burn native tokens for an existing factory denom
	/// that they are the admin of.
	/// Currently, the burn from address must be the admin contract.
	BurnTokens *BurnTokens `json:"burn_tokens,omitempty"`
	/// Sets the metadata on a denom which the contract controls
	SetMetadata *SetMetadata `json:"set_metadata,omitempty"`
	/// Forces a transfer of tokens from one address to another.
	ForceTransfer *ForceTransfer `json:"force_transfer,omitempty"`
}

// CreateDenom creates a new factory denom, of denomination:
// factory/{creating contract address}/{Subdenom}
// Subdenom can be of length at most 44 characters, in [0-9a-zA-Z./]
// The (creating contract address, subdenom) pair must be unique.
// The created denom's admin is the creating contract address,
// but this admin can be changed using the ChangeAdmin binding.
type CreateDenom struct {
	Subdenom string    `json:"subdenom"`
	Metadata *Metadata `json:"metadata,omitempty"`
}

// ChangeAdmin changes the admin for a factory denom.
// If the NewAdminAddress is empty, the denom has no admin.
type ChangeAdmin struct {
	Denom           string `json:"denom"`
	NewAdminAddress string `json:"new_admin_address"`
}

type MintTokens struct {
	Denom         string  `json:"denom"`
	Amount        sdk.Int `json:"amount"`
	MintToAddress string  `json:"mint_to_address"`
}

type BurnTokens struct {
	Denom           string  `json:"denom"`
	Amount          sdk.Int `json:"amount"`
	BurnFromAddress string  `json:"burn_from_address"`
}

type SetMetadata struct {
	Denom    string   `json:"denom"`
	Metadata Metadata `json:"metadata"`
}

type ForceTransfer struct {
	Denom       string  `json:"denom"`
	Amount      sdk.Int `json:"amount"`
	FromAddress string  `json:"from_address"`
	ToAddress   string  `json:"to_address"`
}
