# frozen_string_literal: true

module SynorGovernance
  # Proposal status
  module ProposalStatus
    PENDING = "pending"
    ACTIVE = "active"
    PASSED = "passed"
    REJECTED = "rejected"
    EXECUTED = "executed"
    CANCELLED = "cancelled"
  end

  # Vote choice
  module VoteChoice
    FOR = "for"
    AGAINST = "against"
    ABSTAIN = "abstain"
  end

  # DAO type
  module DaoType
    TOKEN = "token"
    MULTISIG = "multisig"
    HYBRID = "hybrid"
  end

  # Vesting status
  module VestingStatus
    ACTIVE = "active"
    COMPLETED = "completed"
    REVOKED = "revoked"
  end

  # Configuration
  Config = Struct.new(:api_key, :endpoint, :timeout, :retries, :debug, keyword_init: true) do
    def initialize(api_key:, endpoint: "https://governance.synor.io/v1", timeout: 30, retries: 3, debug: false)
      super
    end
  end

  # Data types
  ProposalAction = Struct.new(:target, :method, :data, :value, keyword_init: true)

  ProposalDraft = Struct.new(:title, :description, :discussion_url, :voting_start_time, :voting_end_time, :dao_id, :actions, keyword_init: true)

  VoteTally = Struct.new(:for_votes, :against_votes, :abstain_votes, :quorum, :quorum_required, :total_voters, keyword_init: true)

  Proposal = Struct.new(:id, :title, :description, :discussion_url, :proposer, :status, :created_at, :voting_start_time, :voting_end_time, :execution_time, :vote_tally, :actions, :dao_id, keyword_init: true)

  ProposalFilter = Struct.new(:status, :proposer, :dao_id, :limit, :offset, keyword_init: true)

  Vote = Struct.new(:choice, :reason, keyword_init: true)

  VoteReceipt = Struct.new(:id, :proposal_id, :voter, :choice, :weight, :reason, :voted_at, :tx_hash, keyword_init: true)

  VotingPower = Struct.new(:address, :delegated_power, :own_power, :total_power, :delegators, keyword_init: true)

  DelegationReceipt = Struct.new(:id, :from, :to, :amount, :delegated_at, :tx_hash, keyword_init: true)

  DaoConfig = Struct.new(:name, :description, :type, :voting_period_days, :timelock_days, :token_address, :quorum_percent, :proposal_threshold, :multisig_members, :multisig_threshold, keyword_init: true)

  Dao = Struct.new(:id, :name, :description, :type, :token_address, :voting_period_days, :timelock_days, :quorum_percent, :proposal_threshold, :total_proposals, :active_proposals, :treasury_value, :member_count, :created_at, keyword_init: true)

  TreasuryToken = Struct.new(:address, :balance, :name, :symbol, keyword_init: true)

  DaoTreasury = Struct.new(:dao_id, :total_value, :tokens, :last_updated, keyword_init: true)

  VestingSchedule = Struct.new(:beneficiary, :total_amount, :start_time, :cliff_duration, :vesting_duration, :revocable, keyword_init: true)

  VestingContract = Struct.new(:id, :beneficiary, :grantor, :total_amount, :released_amount, :releasable_amount, :start_time, :cliff_time, :end_time, :status, :revocable, :created_at, keyword_init: true)

  ClaimReceipt = Struct.new(:id, :contract_id, :amount, :tx_hash, :claimed_at, keyword_init: true)
end
