// Auto-generated types for wallets module
import type { levels, wallets } from "@folo-services/drizzle"
import type { InferSelectModel } from "drizzle-orm"

import type { EmptyResponse, SerializedModel, SuccessResponse } from "../../types"

// Re-export database types
export type WalletModel = SerializedModel<InferSelectModel<typeof wallets>>
export type LevelModel = SerializedModel<InferSelectModel<typeof levels>>

// Wallet with level and daily power info
export interface WalletWithLevel extends WalletModel {
  level: Pick<
    LevelModel,
    "level" | "rank" | "prevActivityPoints" | "activityPoints"
  > | null
  todayDailyPower: string
}

// Wallets API request/response types
export type WalletsGetResponse = SuccessResponse<WalletWithLevel[]>

export type WalletsPostResponse = SuccessResponse<WalletModel>

export type WalletsRefreshResponse = EmptyResponse

export interface WalletRankingQuery {
  limit?: number
  offset?: number
}

export interface RankingItem {
  userId: string
  username?: string
  avatar?: string
  balance: string
  rank: number
}

export type WalletRankingResponse = SuccessResponse<RankingItem[]>

export interface PowerPriceData {
  price: number
  currency: string
  lastUpdated: string
}

export type PowerPriceResponse = SuccessResponse<PowerPriceData>

// Transaction types
export interface TransactionQuery {
  page?: number
  limit?: number
  type?: "tip" | "withdraw" | "claim" | "airdrop"
}

export interface TransactionItem {
  id: string
  type: "tip" | "withdraw" | "claim" | "airdrop"
  amount: string
  status: "pending" | "success" | "failed"
  hash?: string
  createdAt: string
  fromUserId?: string
  toUserId?: string
  entryId?: string
}

export type TransactionsGetResponse = SuccessResponse<TransactionItem[]>

export interface TipRequest {
  toUserId: string
  amount: string
  entryId?: string
}

export type TipResponse = SuccessResponse<{ txHash: string }>

// ClaimDaily has no request parameters

export type ClaimDailyResponse = SuccessResponse<{
  amount: string
  txHash?: string
}>

export interface WithdrawRequest {
  amount: string
  toAddress: string
}

export type WithdrawResponse = SuccessResponse<{ txHash: string }>

export interface ClaimCheckData {
  canClaim: boolean
  lastClaimTime?: string
  nextClaimTime?: string
  amount?: string
}

export type ClaimCheckResponse = SuccessResponse<ClaimCheckData>

// Airdrop types

export interface AirdropData {
  isEligible: boolean
  amount?: string
  claimedAt?: string
  requirements?: string[]
}

export type AirdropGetResponse = SuccessResponse<AirdropData>

// AirdropClaim has no request parameters

export type AirdropClaimResponse = SuccessResponse<{
  txHash: string
  amount: string
}>

// AirdropUpdate request parameters (to be determined based on actual route)

export type AirdropUpdateResponse = EmptyResponse
