@@ -20,7 +20,7 @@ import styled from 'styled-components';
20
20
import { copyToClipboard , truncateAddress } from '@/common-util' ;
21
21
import { COLOR , COW_SWAP_GNOSIS_XDAI_OLAS_URL } from '@/constants' ;
22
22
import { UNICODE_SYMBOLS } from '@/constants/unicode' ;
23
- import { useBalance } from '@/hooks' ;
23
+ import { useWallet } from '@/hooks/useWallet ' ;
24
24
import { Address } from '@/types' ;
25
25
26
26
import { CardSection } from '../styled/CardSection' ;
@@ -34,22 +34,24 @@ const CustomizedCardSection = styled(CardSection)<{ border?: boolean }>`
34
34
` ;
35
35
36
36
export const MainAddFunds = ( ) => {
37
- const { wallets } = useBalance ( ) ;
37
+ const { masterSafeAddress , masterEoaAddress } = useWallet ( ) ;
38
38
const [ isAddFundsVisible , setIsAddFundsVisible ] = useState ( false ) ;
39
39
40
- const walletAddress = useMemo ( ( ) => wallets [ 0 ] ?. address , [ wallets ] ) ;
40
+ const fundingAddress : Address | undefined =
41
+ masterSafeAddress ?? masterEoaAddress ;
41
42
42
- const truncatedWalletAddress = useMemo (
43
- ( ) => truncateAddress ( walletAddress ) ,
44
- [ walletAddress ] ,
43
+ const truncatedFundingAddress : string | undefined = useMemo (
44
+ ( ) => fundingAddress && truncateAddress ( fundingAddress ) ,
45
+ [ fundingAddress ] ,
45
46
) ;
46
47
47
- const handleCopyWalletAddress = useCallback (
48
+ const handleCopyAddress = useCallback (
48
49
( ) =>
49
- copyToClipboard ( walletAddress ) . then ( ( ) =>
50
+ fundingAddress &&
51
+ copyToClipboard ( fundingAddress ) . then ( ( ) =>
50
52
message . success ( 'Copied successfully!' ) ,
51
53
) ,
52
- [ walletAddress ] ,
54
+ [ fundingAddress ] ,
53
55
) ;
54
56
55
57
return (
@@ -78,9 +80,9 @@ export const MainAddFunds = () => {
78
80
< >
79
81
< AddFundsWarningAlertSection />
80
82
< AddFundsAddressSection
81
- truncatedWalletAddress = { truncatedWalletAddress }
82
- walletAddress = { walletAddress }
83
- handleCopy = { handleCopyWalletAddress }
83
+ truncatedFundingAddress = { truncatedFundingAddress }
84
+ fundingAddress = { masterSafeAddress }
85
+ handleCopy = { handleCopyAddress }
84
86
/>
85
87
< AddFundsGetTokensSection />
86
88
</ >
@@ -111,19 +113,23 @@ const AddFundsWarningAlertSection = () => (
111
113
) ;
112
114
113
115
const AddFundsAddressSection = ( {
114
- walletAddress ,
115
- truncatedWalletAddress ,
116
+ fundingAddress ,
117
+ truncatedFundingAddress ,
116
118
handleCopy,
117
119
} : {
118
- walletAddress : Address ;
119
- truncatedWalletAddress : string ;
120
+ fundingAddress ?: string ;
121
+ truncatedFundingAddress ? : string ;
120
122
handleCopy : ( ) => void ;
121
123
} ) => (
122
124
< CardSection gap = { 10 } justify = "center" align = "center" >
123
125
< Tooltip
124
- title = { < span className = "can-select-text flex" > { walletAddress } </ span > }
126
+ title = {
127
+ < span className = "can-select-text flex" >
128
+ { fundingAddress ?? 'Error loading address' }
129
+ </ span >
130
+ }
125
131
>
126
- < Text title = { walletAddress } > GNO: { truncatedWalletAddress } </ Text >
132
+ < Text title = { fundingAddress } > GNO: { truncatedFundingAddress ?? '--' } </ Text >
127
133
</ Tooltip >
128
134
< Button onClick = { handleCopy } >
129
135
< CopyOutlined />
@@ -133,7 +139,7 @@ const AddFundsAddressSection = ({
133
139
content = {
134
140
< QRCode
135
141
size = { 250 }
136
- value = { `https://metamask.app.link/send/${ walletAddress } @${ 100 } ` }
142
+ value = { `https://metamask.app.link/send/${ fundingAddress } @${ 100 } ` }
137
143
/>
138
144
}
139
145
>
0 commit comments