Skip to content

Commit

Permalink
Merge branch 'main' into feat/orange-pill
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisling-dev committed Sep 17, 2024
2 parents e06fd03 + c96384a commit d9f186f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions apps/portal/src/domains/staking/subtensor/atoms/taostats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export const taostatsAtom = atom(async () => {
const stats = await (await fetch(TAOSTATS_DATA_URL)).json()
return Array.isArray(stats) ? (stats as Taostats) : []
} catch (cause) {
throw new Error('Failed to fetch TAO stats', { cause })
console.error('Failed to fetch TAO stats', { cause })
return []
}
})

Expand All @@ -42,7 +43,7 @@ export const taostatsByChainAtomFamily = atomFamily((genesisHash: string | undef
const networkName = TaostatsNetworkByGenesisHash.get(genesisHash)
if (!networkName) return atom(() => Promise.resolve(undefined))

return atom(async get => (await get(taostatsAtom)).find(stats => stats.network === networkName))
return atom(async get => (await get(taostatsAtom))?.find(stats => stats.network === networkName))
})

export const stakingAprByChainAtomFamily = atomFamily((genesisHash: string | undefined) =>
Expand Down
4 changes: 3 additions & 1 deletion apps/portal/src/domains/staking/subtensor/hooks/useApr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export const useApr = (genesisHash: string | undefined) => {
}

export const useAprFormatted = (genesisHash: string | undefined) => {
return useApr(genesisHash).toLocaleString(undefined, { style: 'percent', maximumFractionDigits: 2 })
const apr = useApr(genesisHash)

return apr ? apr.toLocaleString(undefined, { style: 'percent', maximumFractionDigits: 2 }) : '--'
}

0 comments on commit d9f186f

Please sign in to comment.