@@ -10,13 +10,14 @@ import { Card } from "ui/card/Card";
10
10
import { Button } from "ui/button/Button" ;
11
11
import { useLarskristoHellheadsContext } from "context/evm/larskristo-hellheads/useLarskristoHellheadsContext" ;
12
12
import { Icon } from "ui/icon/Icon" ;
13
+ import evm from "providers/evm" ;
13
14
14
15
import { DetailsModalProps } from "./DetailsModal.types" ;
15
16
import styles from "./DetailsModal.module.scss" ;
16
17
17
18
export const DetailsModal : React . FC < DetailsModalProps > = ( { onClose, className, item } ) => {
18
- const larskristohellheads = useLarskristoHellheadsContext ( ) ;
19
- const { data : ensName } = useEnsName ( { address : larskristohellheads . owner } ) ;
19
+ const ERC721 = useLarskristoHellheadsContext ( ) ;
20
+ const { data : ensName } = useEnsName ( { address : ERC721 . owner } ) ;
20
21
const { open } = useWeb3Modal ( ) ;
21
22
const { isConnected } = useAccount ( ) ;
22
23
@@ -29,23 +30,23 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
29
30
} ;
30
31
31
32
const handleOnBuyNowClick = ( ) => {
32
- larskristohellheads . buyToken ( item . id ! ) ;
33
+ ERC721 . buyToken ( item . id ! ) ;
33
34
} ;
34
35
35
36
useEffect ( ( ) => {
36
37
( async ( ) => {
37
- await larskristohellheads . ownerOf ( item . id ! ) ;
38
- await larskristohellheads . getTokenPrice ( item . id ! ) ;
38
+ await ERC721 . ownerOf ( item . id ! ) ;
39
+ await ERC721 . getTokenPrice ( item . id ! ) ;
39
40
} ) ( ) ;
40
41
} , [ item . id ] ) ;
41
42
42
43
useEffect ( ( ) => {
43
- if ( ! larskristohellheads . tokenPrice ?. rawValue ) return ;
44
+ if ( ! ERC721 . tokenPrice ?. rawValue ) return ;
44
45
45
46
( async ( ) => {
46
- await larskristohellheads . royaltyInfo ( item . id ! ) ;
47
+ await ERC721 . royaltyInfo ( item . id ! ) ;
47
48
} ) ( ) ;
48
- } , [ larskristohellheads . tokenPrice ?. rawValue ] ) ;
49
+ } , [ ERC721 . tokenPrice ?. rawValue ] ) ;
49
50
50
51
return (
51
52
< Modal
@@ -68,7 +69,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
68
69
</ div >
69
70
</ div >
70
71
< Typography . TextLead flat >
71
- { larskristohellheads . contractValues ?. name } , { larskristohellheads . contractValues ?. symbol }
72
+ { ERC721 . contractValues ?. name } , { ERC721 . contractValues ?. symbol }
72
73
</ Typography . TextLead >
73
74
</ Modal . Header >
74
75
< Modal . Content >
@@ -88,14 +89,13 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
88
89
< div >
89
90
< Typography . Headline5 flat > Price</ Typography . Headline5 >
90
91
< Typography . Headline4 className = { styles [ "details-modal__price-block--price" ] } >
91
- { larskristohellheads . tokenPrice ?. formattedValue } { " " }
92
- < span > ETH | { larskristohellheads . tokenPrice ?. exchangeRateFormatted } </ span >
92
+ { ERC721 . tokenPrice ?. formattedValue } { " " }
93
+ < span > ETH | { ERC721 . tokenPrice ?. exchangeRateFormatted } </ span >
93
94
</ Typography . Headline4 >
94
95
</ div >
95
96
< div >
96
97
< Typography . Text flat truncate className = { styles [ "details-modal__price-block--owner-pill" ] } >
97
- < span > Owned by:</ span > { " " }
98
- < Typography . Anchor > { ensName || larskristohellheads . owner } </ Typography . Anchor >
98
+ < span > Owned by:</ span > < Typography . Anchor > { ensName || ERC721 . owner } </ Typography . Anchor >
99
99
</ Typography . Text >
100
100
</ div >
101
101
</ div >
@@ -107,10 +107,29 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
107
107
</ div >
108
108
) }
109
109
< div className = { styles [ "details-modal__price-block--buy-now" ] } >
110
- < Button fullWidth disabled = { ! isConnected } onClick = { handleOnBuyNowClick } >
111
- Buy for: { larskristohellheads . tokenPrice ?. formattedValue } ETH
110
+ < Button
111
+ fullWidth
112
+ disabled = { ! isConnected || ERC721 . actions . buyToken . isPending }
113
+ onClick = { handleOnBuyNowClick }
114
+ isLoading = { ERC721 . actions . buyToken . isPending }
115
+ >
116
+ Buy for: { ERC721 . tokenPrice ?. formattedValue } ETH
112
117
</ Button >
113
118
</ div >
119
+ { ERC721 . actions . buyToken . isConfirmed && (
120
+ < div className = { styles [ "details-modal__price-block--success" ] } >
121
+ { ERC721 . actions . buyToken . isConfirmed && (
122
+ < Typography . Text flat >
123
+ Purchase confirmed! Check your transaction{ " " }
124
+ < Typography . Anchor
125
+ href = { `${ evm . getBlockExplorerUrl ( ) } /tx/${ ERC721 . actions . buyToken . transactionHash } ` }
126
+ >
127
+ here < Icon name = "icon-exit-up2" />
128
+ </ Typography . Anchor >
129
+ </ Typography . Text >
130
+ ) }
131
+ </ div >
132
+ ) }
114
133
</ Card . Content >
115
134
</ Card >
116
135
< Card className = { styles [ "details-modal__author-card" ] } >
@@ -145,7 +164,7 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
145
164
< Typography . Headline5 > Details</ Typography . Headline5 >
146
165
< div className = { styles [ "details-modal__details-card--row" ] } >
147
166
< Typography . Text flat > Contract Address</ Typography . Text >
148
- < Typography . Anchor truncate > { larskristohellheads . contractAddress } </ Typography . Anchor >
167
+ < Typography . Anchor truncate > { ERC721 . contractAddress } </ Typography . Anchor >
149
168
</ div >
150
169
< div className = { styles [ "details-modal__details-card--row" ] } >
151
170
< Typography . Text flat > Token ID</ Typography . Text >
@@ -157,11 +176,11 @@ export const DetailsModal: React.FC<DetailsModalProps> = ({ onClose, className,
157
176
</ div >
158
177
< div className = { styles [ "details-modal__details-card--row" ] } >
159
178
< Typography . Text flat > Owner</ Typography . Text >
160
- < Typography . Anchor truncate > { ensName || larskristohellheads . owner } </ Typography . Anchor >
179
+ < Typography . Anchor truncate > { ensName || ERC721 . owner } </ Typography . Anchor >
161
180
</ div >
162
181
< div className = { styles [ "details-modal__details-card--row" ] } >
163
182
< Typography . Text flat > Royalty</ Typography . Text >
164
- < Typography . Anchor > { larskristohellheads . royalty ?. percentageFormatted } </ Typography . Anchor >
183
+ < Typography . Anchor > { ERC721 . royalty ?. percentageFormatted } </ Typography . Anchor >
165
184
</ div >
166
185
< div className = { styles [ "details-modal__details-card--row" ] } >
167
186
< Typography . Text flat > Chain</ Typography . Text >
0 commit comments