@@ -10,8 +10,8 @@ import { ButtonPrimary } from '../Button'
1010import { AutoColumn , ColumnCenter } from '../Column'
1111import Circle from '../../assets/images/blue-loader.svg'
1212
13- import { useActiveWeb3React } from '../../hooks'
1413import { getEtherscanLink } from '../../utils'
14+ import { useActiveWeb3React } from '../../hooks'
1515
1616const Wrapper = styled . div `
1717 width: 100%;
@@ -42,64 +42,53 @@ interface ConfirmationModalProps {
4242 topContent : ( ) => React . ReactChild
4343 bottomContent : ( ) => React . ReactChild
4444 attemptingTxn : boolean
45- pendingConfirmation : boolean
4645 pendingText : string
4746 title ?: string
4847}
4948
5049export default function ConfirmationModal ( {
5150 isOpen,
5251 onDismiss,
53- hash,
5452 topContent,
5553 bottomContent,
5654 attemptingTxn,
57- pendingConfirmation ,
55+ hash ,
5856 pendingText,
5957 title = ''
6058} : ConfirmationModalProps ) {
6159 const { chainId } = useActiveWeb3React ( )
6260 const theme = useContext ( ThemeContext )
6361
64- return (
65- < Modal isOpen = { isOpen } onDismiss = { onDismiss } maxHeight = { 90 } >
66- { ! attemptingTxn ? (
67- < Wrapper >
68- < Section >
69- < RowBetween >
70- < Text fontWeight = { 500 } fontSize = { 20 } >
71- { title }
72- </ Text >
73- < CloseIcon onClick = { onDismiss } />
74- </ RowBetween >
75- { topContent ( ) }
76- </ Section >
77- < BottomSection gap = "12px" > { bottomContent ( ) } </ BottomSection >
78- </ Wrapper >
79- ) : (
62+ const transactionBroadcast = ! ! hash
63+
64+ // waiting for user to confirm/reject tx _or_ showing info on a tx that has been broadcast
65+ if ( attemptingTxn || transactionBroadcast ) {
66+ return (
67+ < Modal isOpen = { isOpen } onDismiss = { onDismiss } maxHeight = { 90 } >
8068 < Wrapper >
8169 < Section >
8270 < RowBetween >
8371 < div />
8472 < CloseIcon onClick = { onDismiss } />
8573 </ RowBetween >
8674 < ConfirmedIcon >
87- { pendingConfirmation ? (
88- < CustomLightSpinner src = { Circle } alt = "loader" size = { '90px' } />
89- ) : (
75+ { transactionBroadcast ? (
9076 < ArrowUpCircle strokeWidth = { 0.5 } size = { 90 } color = { theme . primary1 } />
77+ ) : (
78+ < CustomLightSpinner src = { Circle } alt = "loader" size = { '90px' } />
9179 ) }
9280 </ ConfirmedIcon >
9381 < AutoColumn gap = "12px" justify = { 'center' } >
9482 < Text fontWeight = { 500 } fontSize = { 20 } >
95- { ! pendingConfirmation ? 'Transaction Submitted' : 'Waiting For Confirmation' }
83+ { transactionBroadcast ? 'Transaction Submitted' : 'Waiting For Confirmation' }
9684 </ Text >
9785 < AutoColumn gap = "12px" justify = { 'center' } >
9886 < Text fontWeight = { 600 } fontSize = { 14 } color = "" textAlign = "center" >
9987 { pendingText }
10088 </ Text >
10189 </ AutoColumn >
102- { ! pendingConfirmation && (
90+
91+ { transactionBroadcast ? (
10392 < >
10493 < ExternalLink href = { getEtherscanLink ( chainId , hash , 'transaction' ) } >
10594 < Text fontWeight = { 500 } fontSize = { 14 } color = { theme . primary1 } >
@@ -112,17 +101,33 @@ export default function ConfirmationModal({
112101 </ Text >
113102 </ ButtonPrimary >
114103 </ >
115- ) }
116-
117- { pendingConfirmation && (
104+ ) : (
118105 < Text fontSize = { 12 } color = "#565A69" textAlign = "center" >
119106 Confirm this transaction in your wallet
120107 </ Text >
121108 ) }
122109 </ AutoColumn >
123110 </ Section >
124111 </ Wrapper >
125- ) }
112+ </ Modal >
113+ )
114+ }
115+
116+ // confirmation screen
117+ return (
118+ < Modal isOpen = { isOpen } onDismiss = { onDismiss } maxHeight = { 90 } >
119+ < Wrapper >
120+ < Section >
121+ < RowBetween >
122+ < Text fontWeight = { 500 } fontSize = { 20 } >
123+ { title }
124+ </ Text >
125+ < CloseIcon onClick = { onDismiss } />
126+ </ RowBetween >
127+ { topContent ( ) }
128+ </ Section >
129+ < BottomSection gap = "12px" > { bottomContent ( ) } </ BottomSection >
130+ </ Wrapper >
126131 </ Modal >
127132 )
128133}
0 commit comments