Hooks
useVote

useVote

Hook to facilitate voting actions given a proposal

import { useVote } from '@public-assembly/builder-utils'

Usage

import { useVote } from '@public-assembly/builder-utils'
 
function App() {
  const { canVeto, canCancel, canVote } = useVote({
    proposalId: '0xaf97d910e87200254e6e9af15e5f22b9ed51a191440218073b86f9954ed0366b',
    support: 1,
    reason: "Create what's missing"
  })
 
  return (
    <>
      <button onClick={() => castVote?.()}>Cast vote</button>
      <p>Vote loading?: {castVoteLoading}</p>
      <p>Vote successful?: {castVoteSuccess}</p>
    </>
  )
}

Returns

{
  castVote: (() => void) | undefined
  castVoteLoading: boolean
  castVoteSuccess: boolean
  castVoteWithReason: (() => void) | undefined
  castVoteWithReasonLoading: boolean
  castVoteWithReasonSuccess: boolean
}