Skip to content

Commit

Permalink
Move a hook to the API wrapper layer
Browse files Browse the repository at this point in the history
So that it's more easily available for general usage
  • Loading branch information
csillag committed Jun 28, 2024
1 parent ed691bb commit 3091d78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
17 changes: 1 addition & 16 deletions src/app/pages/ProposalDetailsPage/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Validator,
ExtendedValidatorList,
List,
useGetConsensusProposalsProposalIdVotes,
useGetConsensusValidators,
} from '../../../oasis-nexus/api'
import { List, useGetConsensusProposalsProposalIdVotes, useValidatorMap } from '../../../oasis-nexus/api'
import { Network } from '../../../types/network'
import { ExtendedVote, ProposalVoteValue, VoteType } from '../../../types/vote'
import { getFilterForVoterNameFragment, getFilterForVoteType, getRandomVote } from '../../utils/vote'
Expand Down Expand Up @@ -32,15 +26,6 @@ const getRandomVoteFor = (address: string) => {
return newVote
}

const useValidatorMap = (network: Network) => {
const { data, isLoading, isError } = useGetConsensusValidators(network)
return {
isLoading,
isError,
map: (data?.data as ExtendedValidatorList)?.map ?? new Map<string, Validator>(),
}
}

export const useAllVotes = (network: Network, proposalId: number): AllVotesData => {
const query = useGetConsensusProposalsProposalIdVotes(network, proposalId)
const {
Expand Down
9 changes: 9 additions & 0 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,15 @@ export const useGetConsensusValidators: typeof generated.useGetConsensusValidato
})
}

export const useValidatorMap = (network: Network) => {
const { data, isLoading, isError } = useGetConsensusValidators(network)
return {
isLoading,
isError,
map: (data?.data as ExtendedValidatorList)?.map ?? new Map<string, generated.Validator>(),
}
}

export const useGetConsensusAccounts: typeof generated.useGetConsensusAccounts = (
network,
params?,
Expand Down

0 comments on commit 3091d78

Please sign in to comment.