package genex

import (
	"math/big"
	"time"

	"github.com/ethereum/go-ethereum/common"
)

// CouponDetail 券详情
type CouponDetail struct {
	TokenID        *big.Int       `json:"tokenId"`
	FaceValue      *big.Int       `json:"faceValue"`
	CouponType     uint8          `json:"couponType"` // 0=utility, 1=security
	ExpiryDate     time.Time      `json:"expiryDate"`
	ResaleCount    uint64         `json:"resaleCount"`
	MaxResaleCount uint64         `json:"maxResaleCount"`
	Transferable   bool           `json:"transferable"`
	Issuer         common.Address `json:"issuer"`
	Redeemed       bool           `json:"redeemed"`
}

// CouponHolding 券持有
type CouponHolding struct {
	TokenID *big.Int      `json:"tokenId"`
	BatchID *big.Int      `json:"batchId"`
	Detail  *CouponDetail `json:"detail"`
}

// BlockInfo 区块信息
type BlockInfo struct {
	Height    int64     `json:"height"`
	Hash      string    `json:"hash"`
	Timestamp time.Time `json:"timestamp"`
	TxCount   int       `json:"txCount"`
	Proposer  string    `json:"proposer"`
}

// TransactionInfo 交易信息
type TransactionInfo struct {
	Hash        string    `json:"hash"`
	BlockHeight int64     `json:"blockHeight"`
	From        string    `json:"from"`
	To          string    `json:"to"`
	Value       *big.Int  `json:"value"`
	GasUsed     uint64    `json:"gasUsed"`
	Status      string    `json:"status"` // "success" | "failed"
	Timestamp   time.Time `json:"timestamp"`
}

// ChainStats 链统计
type ChainStats struct {
	BlockHeight     int64    `json:"blockHeight"`
	TPS             float64  `json:"tps"`
	ActiveAddresses int64    `json:"activeAddresses"`
	TotalCoupons    int64    `json:"totalCoupons"`
	TotalVolume     *big.Int `json:"totalVolume"`
}

// ChainEvent 链事件
type ChainEvent struct {
	Type        string                 `json:"type"`
	BlockHeight int64                  `json:"blockHeight"`
	TxHash      string                 `json:"txHash"`
	Data        map[string]interface{} `json:"data"`
}

// EventFilter 事件过滤器
type EventFilter struct {
	ContractAddress *common.Address `json:"contractAddress,omitempty"`
	EventName       string          `json:"eventName,omitempty"`
	FromBlock       *big.Int        `json:"fromBlock,omitempty"`
	ToBlock         *big.Int        `json:"toBlock,omitempty"`
}

// SwapParams 交换参数
type SwapParams struct {
	TokenID    *big.Int       `json:"tokenId"`
	Buyer      common.Address `json:"buyer"`
	Seller     common.Address `json:"seller"`
	Price      *big.Int       `json:"price"`
	Stablecoin common.Address `json:"stablecoin"`
}

// Signer 签名接口
type Signer interface {
	SignTransaction(tx interface{}) ([]byte, error)
	GetAddress() common.Address
}
