useFetchProposals QUERY

Fetches a list of TokenVoting proposals.

import { useFetchProposals } from '@daobox/use-aragon'

Usage

import { useFetchProposals } from '@daobox/use-aragon'

function App() {
  const { data, isLoading, isError } = useFetchProposals({
    // required
    daoAddressOrEns: 'box.dao.eth',
    // optional
    skip: 0,
    limit: 10,
    direction: SortDirection.ASC, //  otherwise DESC ("descending")
    sortBy: ProposalSortBy.CREATED_AT, //  otherwise NAME, VOTES (POPULARITY coming soon)
    status: ProposalStatus.ACTIVE, //  otherwise PENDING, SUCCEEDED, EXECUTED, DEFEATED
  })

  if (isLoading) return <div>Loading...</div>
  if (isError) return <div>Error!!!</div>

  return (
    <>
      {data.map((vote) => (
        <div key={vote.id}>
          <h1>{vote.metadata.title}</h1>
          <p>{vote.metadata.summary}</p>
        </div>
      ))}
    </>
  )
}

Required Parameters

  • Name
    daoAddressOrEns
    Type
    string
    Description

    The address of the DAO

Optional Parameters

  • Name
    sortBy
    Type
    ProposalSortBy
    Description

    The type of sort function to use. defaults to CREATED_AT, otherwise NAME, VOTES (POPULARITY coming soon)

  • Name
    direction
    Type
    SortDirection
    Description

    The direction of the sort, either ASC or DESC

  • Name
    status
    Type
    ProposalStatus
    Description

    The status of the proposal. defaults to ACTIVE otherwise PENDING, SUCCEEDED, EXECUTED, DEFEATED

  • Name
    skip
    Type
    number
    Description

    The number of items to skip.

  • Name
    limit
    Type
    number
    Description

    The number of items to get

Return Data

data: TokenVotingProposalListItem[] | null

Return Data example

{ TokenVotingProposalListItem[]:
  [
    {
      id: "0x12345...",
      dao: {
        address: "0x1234567890123456789012345678901234567890",
        name: "Cool DAO"
      },
      creatorAddress: "0x1234567890123456789012345678901234567890",
      metadata: {
        title: "Test Proposal",
        summary: "Test Proposal Summary"
      },
      startDate: <Date>,
      endDate: <Date>,
      status: "Executed",
      token: {
        address: "0x1234567890123456789012345678901234567890,
        name: "The Token",
        symbol: "TOK",
        decimals: 18
      },
      results {
        yes: 100000n,
        no: 77777n,
        abstain: 0n
      }
    },
    {
      id: "0x12345...",
      dao: {
        address: "0x1234567890123456789012345678901234567890",
        name: "Cool DAO"
      },
      creatorAddress: "0x1234567890123456789012345678901234567890",
      metadata: {
        title: "Test Proposal 2",
        summary: "Test Proposal Summary 2"
      },
      startDate: <Date>,
      endDate: <Date>,
      status: "Pending",
      token: {
        address: "0x1234567890123456789012345678901234567890,
        name: "The Token",
        symbol: "TOK",
        decimals: 18
      },
      results {
        yes: 100000n,
        no: 77777n,
        abstain: 0n
      }
    }
  ]
}

Return Values

{
  data: TokenVotingProposalListItem[] | null,
  error: Error | null,
  isSuccess: boolean,
  isError: boolean,
  isLoading: boolean,
  isRefetching: boolean,
}