-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update monetary to latest 0.7.3 * fix: use maximum stakable amount fetched from rpc * delete stray comment --------- Co-authored-by: Thomas Jeatt <[email protected]>
- Loading branch information
1 parent
67ba4b3
commit a896259
Showing
2 changed files
with
44 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { CurrencyExt, newMonetaryAmount } from '@interlay/interbtc-api'; | ||
import { MonetaryAmount } from '@interlay/monetary-js'; | ||
import { AccountId } from '@polkadot/types/interfaces'; | ||
import { useErrorHandler } from 'react-error-boundary'; | ||
import { useQuery } from 'react-query'; | ||
|
||
import { GOVERNANCE_TOKEN } from '@/config/relay-chains'; | ||
import useAccountId from '@/hooks/use-account-id'; | ||
import { BLOCKTIME_REFETCH_INTERVAL } from '@/utils/constants/api'; | ||
|
||
interface GetAccountStakableLimitResult { | ||
data: MonetaryAmount<CurrencyExt> | undefined; | ||
refetch: () => void; | ||
} | ||
|
||
const getAccountStakableLimit = async (account: AccountId) => { | ||
const { amount } = await window.bridge.api.rpc.escrow.totalSupply(account); | ||
return newMonetaryAmount(amount, GOVERNANCE_TOKEN); | ||
}; | ||
|
||
const useGetAccountStakableLimit = (): GetAccountStakableLimitResult => { | ||
const account = useAccountId(); | ||
|
||
const queryKey = ['staking', account]; | ||
|
||
const { data, error, refetch } = useQuery({ | ||
queryKey, | ||
queryFn: () => account && getAccountStakableLimit(account), | ||
refetchInterval: BLOCKTIME_REFETCH_INTERVAL, | ||
enabled: !!account | ||
}); | ||
|
||
useErrorHandler(error); | ||
|
||
return { data, refetch }; | ||
}; | ||
|
||
export { useGetAccountStakableLimit }; |
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
a896259
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interbtc-ui-kintsugi-testnet – ./
interbtc-ui.vercel.app
interbtc-ui-kintsugi-testnet-interlay.vercel.app
kintnet.interlay.io
interbtc-ui-kintsugi-testnet-git-master-interlay.vercel.app
a896259
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interbtc-ui-interlay-testnet – ./
interbtc-ui-interlay-testnet.vercel.app
interbtc-ui-interlay-testnet-git-master-interlay.vercel.app
interbtc-ui-interlay-testnet-interlay.vercel.app
testnet.interlay.io