-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use the graph for augmented data (#317)
* fix: use the graph for augmented data * rework how we query graphs to be more specific Signed-off-by: david <[email protected]> * improve hadling v2 queries * require vote subgraph, and remove kv dep * fix compile issues, comparison types --------- Signed-off-by: david <[email protected]>
- Loading branch information
Showing
11 changed files
with
724 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
import assert from "assert"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { augmentedVoteDataKey } from "constant"; | ||
import { getAugmentedVoteData } from "web3"; | ||
import { useActiveVotes } from "./useActiveVotes"; | ||
import { usePastVotes } from "./usePastVotes"; | ||
import { useUpcomingVotes } from "./useUpcomingVotes"; | ||
|
||
export function useAugmentedVoteData() { | ||
const { data: activeVotes } = useActiveVotes(); | ||
const { data: upcomingVotes } = useUpcomingVotes(); | ||
const { data: pastVotes } = usePastVotes(); | ||
|
||
const allVotes = { ...activeVotes, ...upcomingVotes, ...pastVotes }; | ||
|
||
const queryResult = useQuery({ | ||
export function useAugmentedVoteData( | ||
params: Partial<{ | ||
ancillaryData: string; | ||
time: number; | ||
identifier: string; | ||
}> | ||
) { | ||
return useQuery({ | ||
queryKey: [ | ||
augmentedVoteDataKey, | ||
activeVotes, | ||
upcomingVotes, | ||
pastVotes, | ||
allVotes, | ||
params.identifier ?? "", | ||
(params.time ?? 0).toString(), | ||
params.ancillaryData ?? "", | ||
], | ||
queryFn: () => getAugmentedVoteData(allVotes), | ||
queryFn: () => { | ||
assert(params.identifier, "identifier missing"); | ||
assert(params.time, "time missing"); | ||
assert(params.ancillaryData, "ancillaryData missing"); | ||
return getAugmentedVoteData({ | ||
identifier: params.identifier, | ||
time: params.time, | ||
ancillaryData: params.ancillaryData, | ||
}); | ||
}, | ||
enabled: !!params.identifier && !!params.time && !!params.identifier, | ||
}); | ||
|
||
return queryResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.