-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Manank Patni <manank321@gmail.com>
- Loading branch information
Showing
10 changed files
with
297 additions
and
30 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
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useQuery } from "react-query" | ||
import { getTokenDelegation } from "services/bakingBad/delegations" | ||
import { getDAOBalances } from "services/bakingBad/tokenBalances" | ||
import { useTezos } from "services/beacon/hooks/useTezos" | ||
|
||
export const useDelegationStatus = (tokenAddress: string | undefined) => { | ||
const { network, tezos, account, connect } = useTezos() | ||
|
||
const { data, ...rest } = useQuery<string | null, Error>( | ||
["tokenDelegations", tokenAddress], | ||
async () => { | ||
if (!tokenAddress) { | ||
return null | ||
} else { | ||
return await getTokenDelegation(tokenAddress, account, network) | ||
} | ||
}, | ||
{ | ||
enabled: !!tokenAddress | ||
} | ||
) | ||
|
||
return { | ||
data, | ||
...rest | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/services/contracts/token/hooks/useDelegationVoteWeight.ts
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useQuery } from "react-query" | ||
import { getTokenDelegationVoteWeight } from "services/bakingBad/delegations" | ||
import { UserDelegateBalance } from "services/bakingBad/delegations/types" | ||
import { useTezos } from "services/beacon/hooks/useTezos" | ||
|
||
export const useDelegationVoteWeight = (tokenAddress: string | undefined) => { | ||
const { network, account } = useTezos() | ||
|
||
const { data, ...rest } = useQuery<UserDelegateBalance[] | undefined, Error>( | ||
["delegationVoteWeight", tokenAddress], | ||
async () => { | ||
if (tokenAddress) { | ||
return await getTokenDelegationVoteWeight(tokenAddress, account, network) | ||
} | ||
}, | ||
{ | ||
enabled: !!tokenAddress | ||
} | ||
) | ||
|
||
return { | ||
data, | ||
...rest | ||
} | ||
} |
Oops, something went wrong.