Skip to content

Commit

Permalink
Better handling for cloudflare outages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ncookiez committed Oct 30, 2023
1 parent d87575b commit ab50f2f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/app/src/components/Account/AccountDepositsHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useUserTotalBalance } from '@generationsoftware/hyperstructure-react-hooks'
import { CurrencyValue } from '@shared/react-components'
import { Spinner } from '@shared/ui'
import { NETWORK, shorten } from '@shared/utilities'
Expand All @@ -7,6 +6,7 @@ import { useTranslations } from 'next-intl'
import { useMemo } from 'react'
import { Address } from 'viem'
import { useAccount, useEnsName } from 'wagmi'
import { useUserTotalBalance } from '@hooks/useUserTotalBalance'

interface AccountDepositsHeaderProps {
address?: Address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {
useAllUserVaultBalances,
useAllVaultSharePrices,
useSelectedVaults
} from '@generationsoftware/hyperstructure-react-hooks'
import { useMemo } from 'react'
import { Address, formatUnits } from 'viem'
import { useAllUserVaultBalances, useAllVaultSharePrices, useSelectedVaults } from '..'

/**
* Returns a user's total balance in ETH
Expand All @@ -24,7 +28,8 @@ export const useUserTotalBalance = (userAddress: Address) => {
isFetchedVaultBalances &&
!!allVaultShareTokens &&
!!vaultBalances &&
!!vaults.underlyingTokenAddresses
!!vaults.underlyingTokenAddresses &&
Object.values(allVaultShareTokens).some((token) => token.price !== undefined)

const data = useMemo(() => {
if (isFetched) {
Expand Down
3 changes: 2 additions & 1 deletion apps/app/src/hooks/useUserTotalDelegations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const useUserTotalDelegations = (userAddress: Address) => {
!!allVaultSharePrices &&
!!shareBalances &&
!!delegationBalances &&
!!vaults.underlyingTokenAddresses
!!vaults.underlyingTokenAddresses &&
Object.values(allVaultSharePrices).some((token) => token.price !== undefined)

const data = useMemo(() => {
if (isFetched) {
Expand Down
9 changes: 8 additions & 1 deletion apps/app/src/hooks/useUserTotalWinnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { useSupportedPrizePools } from './useSupportedPrizePools'

/**
* Returns a user's total prize winnings in ETH
* @param userAddress user address to get total winnings for
* @param options optional settings
* @returns
*/
export const useUserTotalWinnings = (
Expand Down Expand Up @@ -54,7 +56,12 @@ export const useUserTotalWinnings = (

return useMemo(() => {
const isFetched =
isFetchedWins && isFetchedPrizeToken && !!wins && !!prizeToken && !!totalTokensWonByChain
isFetchedWins &&
isFetchedPrizeToken &&
!!wins &&
!!prizeToken &&
prizeToken.price !== undefined &&
!!totalTokensWonByChain

let totalWinnings = 0

Expand Down
1 change: 0 additions & 1 deletion packages/hyperstructure-react-hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ yarn add @generationsoftware/hyperstructure-react-hooks
- `useAllVaultTokenPrices`
- `useAllVaultTotalSupplyTwabs`
- `useSortedVaults`
- `useUserTotalBalance`
- `useUserVaultDelegate`
- `useUserVaultDelegationBalance`
- `useUserVaultShareBalance`
Expand Down
2 changes: 1 addition & 1 deletion packages/hyperstructure-react-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@generationsoftware/hyperstructure-react-hooks",
"version": "1.7.9",
"version": "1.7.10",
"license": "MIT",
"main": "./dist/index.mjs",
"types": "./dist/index.d.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/hyperstructure-react-hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export * from './vaults/useAllVaultTokenData'
export * from './vaults/useAllVaultTokenPrices'
export * from './vaults/useAllVaultTotalSupplyTwabs'
export * from './vaults/useSortedVaults'
export * from './vaults/useUserTotalBalance'
export * from './vaults/useUserVaultDelegate'
export * from './vaults/useUserVaultDelegationBalance'
export * from './vaults/useUserVaultShareBalance'
Expand Down

0 comments on commit ab50f2f

Please sign in to comment.