1
1
import { useWallet } from '@txnlab/use-wallet'
2
2
import { useAtomValue } from 'jotai'
3
3
import { useState } from 'react'
4
- import { isSellingAtom } from '../atoms'
4
+ import { algorandClientAtom , isSellingAtom } from '../atoms'
5
5
import { ellipseAddress } from '../utils/ellipseAddress'
6
6
import ConnectWallet from './ConnectWallet'
7
7
import MintNft from './MintNft'
@@ -11,16 +11,27 @@ import Withdraw from './Withdraw'
11
11
export function Header ( ) {
12
12
const { activeAddress } = useWallet ( )
13
13
const isSelling = useAtomValue ( isSellingAtom )
14
+ const algorandClient = useAtomValue ( algorandClientAtom )
14
15
15
16
const [ openWalletModal , setOpenWalletModal ] = useState ( false )
16
17
const [ openSellModal , setOpenSellModal ] = useState ( false )
17
18
const [ openWithdrawModal , setOpenWithdrawModal ] = useState ( false )
18
19
const [ openMintModal , setOpenMintModal ] = useState ( false )
20
+ const [ assetHolding , setAssetHolding ] = useState < bigint [ ] > ( [ ] )
19
21
20
22
const toggleWalletModal = ( ) => {
21
23
setOpenWalletModal ( ( prev ) => ! prev )
22
24
}
23
25
const toggleSellModal = ( ) => {
26
+ if ( activeAddress && algorandClient ) {
27
+ algorandClient ! . account . getInformation ( activeAddress ! ) . then ( ( info ) => {
28
+ const listOfAssetsHolding = [ ]
29
+ for ( const asset of info . assets ! ) {
30
+ listOfAssetsHolding . push ( BigInt ( asset . assetId ) )
31
+ }
32
+ setAssetHolding ( listOfAssetsHolding )
33
+ } )
34
+ }
24
35
setOpenSellModal ( ( prev ) => ! prev )
25
36
}
26
37
const toggleWithdrawModal = ( ) => {
@@ -51,7 +62,7 @@ export function Header() {
51
62
</ button >
52
63
</ div >
53
64
< ConnectWallet openModal = { openWalletModal } closeModal = { toggleWalletModal } />
54
- < Sell openModal = { openSellModal } setModalState = { setOpenSellModal } />
65
+ < Sell assetHolding = { assetHolding } openModal = { openSellModal } setModalState = { setOpenSellModal } />
55
66
< Withdraw openModal = { openWithdrawModal } setModalState = { setOpenWithdrawModal } />
56
67
< MintNft openModal = { openMintModal } setModalState = { setOpenMintModal } />
57
68
</ div >
0 commit comments