Skip to content

Commit

Permalink
feat(hooks): expose earnPositions on the useWallet hook (#76)
Browse files Browse the repository at this point in the history
### Description

Exposing earnPositions following the pattern proposed in the initial
useWallet PR
#25 (comment)

### Test plan

Copy/Pasted into node_modules of personal app and verified that it
works.
  • Loading branch information
jh2oman authored Feb 12, 2025
1 parent 00fca76 commit 096599c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/@divvi/mobile/src/public/hooks/useWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import { useMemo } from 'react'
import type { EarnPosition } from 'src/positions/types'
import type { UseSelector } from '../../redux/hooks'
import type { SortedTokensWithBalanceOrShowZeroBalanceSelector } from '../../tokens/selectors'
import type { TokenBalance } from '../../tokens/slice'
Expand Down Expand Up @@ -40,15 +41,24 @@ function useTokens() {
return tokens
}

function useEarnPositions() {
const useSelector = require('../../redux/hooks').useSelector as UseSelector
const earnPositionsSelector = require('../../positions/selectors').earnPositionsSelector
const positions = useSelector(earnPositionsSelector)
return positions
}

export function useWallet() {
const useSelector = require('../../redux/hooks').useSelector as UseSelector
const walletAddressSelector = require('../../web3/selectors')
.walletAddressSelector as WalletAddressSelector
const address = useSelector(walletAddressSelector) as string | null
const tokens = useTokens() as TokenBalance[]

const earnPositions = useEarnPositions() as EarnPosition[]
return {
address,
tokens,
earnPositions,
}
}

0 comments on commit 096599c

Please sign in to comment.