-
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.
Peter/refactor fetch oracle status from chain (#1359)
* chore: update monetary to latest 0.7.3 * refactor: fetch oracle status from chain * chore: remove commented-out code
- Loading branch information
1 parent
6d32c91
commit 9f967f5
Showing
3 changed files
with
43 additions
and
85 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useQuery } from 'react-query'; | ||
|
||
import { REFETCH_INTERVAL } from '@/utils/constants/api'; | ||
|
||
interface UseGetOracleStatusResult { | ||
data: OracleStatus | undefined; | ||
isLoading: boolean; | ||
} | ||
|
||
enum OracleStatus { | ||
ONLINE = 'ONLINE', | ||
OFFLINE = 'OFFLINE' | ||
} | ||
|
||
const getOracleStatus = async (): Promise<OracleStatus> => { | ||
const isOracleOnline = await window.bridge.oracle.isOnline(); | ||
return isOracleOnline ? OracleStatus.ONLINE : OracleStatus.OFFLINE; | ||
}; | ||
|
||
const useGetOracleStatus = (): UseGetOracleStatusResult => { | ||
const { data, isLoading } = useQuery({ | ||
queryKey: 'oracle-status', | ||
queryFn: getOracleStatus, | ||
enabled: window.bridge !== undefined, | ||
refetchInterval: REFETCH_INTERVAL.MINUTE | ||
}); | ||
|
||
return { data, isLoading }; | ||
}; | ||
|
||
export { OracleStatus, useGetOracleStatus }; |
9f967f5
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-kintsugi-testnet-interlay.vercel.app
interbtc-ui.vercel.app
interbtc-ui-kintsugi-testnet-git-master-interlay.vercel.app
kintnet.interlay.io
9f967f5
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
testnet.interlay.io
interbtc-ui-interlay-testnet-interlay.vercel.app