/**
 * Synor Governance SDK Types
 * Proposals, voting, DAOs, and vesting.
 */

// Proposal status
export type ProposalStatus =
  | 'draft'
  | 'active'
  | 'passed'
  | 'rejected'
  | 'executed'
  | 'cancelled'
  | 'expired';

// Vote choice
export type VoteChoice = 'for' | 'against' | 'abstain';

// Proposal type
export type ProposalType =
  | 'parameter_change'
  | 'treasury_spend'
  | 'upgrade'
  | 'text'
  | 'custom';

// DAO type
export type DaoType = 'token' | 'multisig' | 'hybrid';

// Vesting status
export type VestingStatus = 'active' | 'paused' | 'completed' | 'cancelled';

// Proposal draft
export interface ProposalDraft {
  title: string;
  description: string;
  type: ProposalType;
  actions?: ProposalAction[];
  startTime?: number;
  endTime?: number;
  quorum?: string;
  threshold?: string;
}

// Proposal action
export interface ProposalAction {
  target: string;
  value: string;
  calldata: string;
  description?: string;
}

// Proposal
export interface Proposal {
  id: string;
  title: string;
  description: string;
  type: ProposalType;
  status: ProposalStatus;
  proposer: string;
  actions: ProposalAction[];
  startTime: number;
  endTime: number;
  quorum: string;
  threshold: string;
  forVotes: string;
  againstVotes: string;
  abstainVotes: string;
  totalVotes: string;
  createdAt: number;
  executedAt?: number;
  executionTxHash?: string;
}

// Proposal filter
export interface ProposalFilter {
  status?: ProposalStatus;
  type?: ProposalType;
  proposer?: string;
  limit?: number;
  offset?: number;
}

// Vote
export interface Vote {
  choice: VoteChoice;
  reason?: string;
}

// Vote receipt
export interface VoteReceipt {
  proposalId: string;
  voter: string;
  choice: VoteChoice;
  weight: string;
  reason?: string;
  timestamp: number;
  txHash: string;
}

// Delegation receipt
export interface DelegationReceipt {
  delegator: string;
  delegatee: string;
  amount: string;
  timestamp: number;
  txHash: string;
}

// Voting power
export interface VotingPower {
  address: string;
  ownPower: string;
  delegatedPower: string;
  totalPower: string;
  delegatedFrom: DelegationInfo[];
  delegatedTo?: DelegationInfo;
}

// Delegation info
export interface DelegationInfo {
  address: string;
  amount: string;
  timestamp: number;
}

// DAO config
export interface DaoConfig {
  name: string;
  type: DaoType;
  tokenAddress?: string;
  signers?: string[];
  threshold?: number;
  votingPeriod: number;
  quorum: string;
  proposalThreshold: string;
  timelockDelay?: number;
}

// DAO
export interface Dao {
  id: string;
  name: string;
  type: DaoType;
  tokenAddress?: string;
  signers?: string[];
  threshold?: number;
  votingPeriod: number;
  quorum: string;
  proposalThreshold: string;
  timelockDelay?: number;
  treasury: string;
  totalProposals: number;
  activeProposals: number;
  totalMembers: number;
  createdAt: number;
}

// Vesting schedule
export interface VestingSchedule {
  beneficiary: string;
  totalAmount: string;
  startTime: number;
  cliffDuration: number;
  vestingDuration: number;
  revocable?: boolean;
}

// Vesting contract
export interface VestingContract {
  id: string;
  beneficiary: string;
  totalAmount: string;
  releasedAmount: string;
  vestedAmount: string;
  startTime: number;
  cliffTime: number;
  endTime: number;
  revocable: boolean;
  status: VestingStatus;
  createdAt: number;
  txHash: string;
}

// Claim result
export interface ClaimResult {
  vestingId: string;
  amount: string;
  recipient: string;
  timestamp: number;
  txHash: string;
}

// Transaction result
export interface GovernanceTransaction {
  txHash: string;
  timestamp: number;
  blockNumber: number;
  status: 'pending' | 'confirmed' | 'failed';
}

// Governance config
export interface GovernanceConfig {
  apiKey: string;
  endpoint?: string;
  timeout?: number;
  retries?: number;
  debug?: boolean;
}

// Internal response types
export interface ProposalsResponse {
  proposals: Proposal[];
}

export interface DaosResponse {
  daos: Dao[];
}

export interface VestingContractsResponse {
  contracts: VestingContract[];
}
