Skip to content

Commit e667615

Browse files
support proposed new FoT-capable methods (#866)
* support new FoT-capable methods short-circuit modal footer rendering if no trade improve clarity of tx modal flow * update router address + ABI
1 parent 4ab61fa commit e667615

File tree

12 files changed

+289
-235
lines changed

12 files changed

+289
-235
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@typescript-eslint/parser": "^2.31.0",
3434
"@uniswap/sdk": "^2.0.5",
3535
"@uniswap/v2-core": "1.0.0",
36-
"@uniswap/v2-periphery": "1.0.0-beta.0",
36+
"@uniswap/v2-periphery": "^1.1.0-beta.0",
3737
"@web3-react/core": "^6.0.9",
3838
"@web3-react/fortmatic-connector": "^6.0.9",
3939
"@web3-react/injected-connector": "^6.0.7",

src/components/ConfirmationModal/index.tsx

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { ButtonPrimary } from '../Button'
1010
import { AutoColumn, ColumnCenter } from '../Column'
1111
import Circle from '../../assets/images/blue-loader.svg'
1212

13-
import { useActiveWeb3React } from '../../hooks'
1413
import { getEtherscanLink } from '../../utils'
14+
import { useActiveWeb3React } from '../../hooks'
1515

1616
const 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

5049
export 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
}

src/components/swap/SwapModalFooter.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export default function SwapModalFooter({
3737
confirmText: string
3838
}) {
3939
const theme = useContext(ThemeContext)
40+
41+
if (!trade) {
42+
return null
43+
}
44+
4045
return (
4146
<>
4247
<AutoColumn gap="0px">

src/components/swap/SwapModalHeader.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,30 @@ import TokenLogo from '../TokenLogo'
1111
import { TruncatedText } from './styleds'
1212

1313
export default function SwapModalHeader({
14-
formattedAmounts,
1514
tokens,
15+
formattedAmounts,
1616
slippageAdjustedAmounts,
1717
priceImpactSeverity,
1818
independentField
1919
}: {
20-
formattedAmounts?: { [field in Field]?: string }
21-
tokens?: { [field in Field]?: Token }
22-
slippageAdjustedAmounts?: { [field in Field]?: TokenAmount }
20+
tokens: { [field in Field]?: Token }
21+
formattedAmounts: { [field in Field]?: string }
22+
slippageAdjustedAmounts: { [field in Field]?: TokenAmount }
2323
priceImpactSeverity: number
2424
independentField: Field
2525
}) {
2626
const theme = useContext(ThemeContext)
27+
2728
return (
2829
<AutoColumn gap={'md'} style={{ marginTop: '20px' }}>
2930
<RowBetween align="flex-end">
3031
<TruncatedText fontSize={24} fontWeight={500}>
31-
{!!formattedAmounts[Field.INPUT] && formattedAmounts[Field.INPUT]}
32+
{formattedAmounts[Field.INPUT]}
3233
</TruncatedText>
3334
<RowFixed gap="4px">
3435
<TokenLogo address={tokens[Field.INPUT]?.address} size={'24px'} />
3536
<Text fontSize={24} fontWeight={500} style={{ marginLeft: '10px' }}>
36-
{tokens[Field.INPUT]?.symbol || ''}
37+
{tokens[Field.INPUT]?.symbol}
3738
</Text>
3839
</RowFixed>
3940
</RowBetween>
@@ -42,12 +43,12 @@ export default function SwapModalHeader({
4243
</RowFixed>
4344
<RowBetween align="flex-end">
4445
<TruncatedText fontSize={24} fontWeight={500} color={priceImpactSeverity > 2 ? theme.red1 : ''}>
45-
{!!formattedAmounts[Field.OUTPUT] && formattedAmounts[Field.OUTPUT]}
46+
{formattedAmounts[Field.OUTPUT]}
4647
</TruncatedText>
4748
<RowFixed gap="4px">
4849
<TokenLogo address={tokens[Field.OUTPUT]?.address} size={'24px'} />
4950
<Text fontSize={24} fontWeight={500} style={{ marginLeft: '10px' }}>
50-
{tokens[Field.OUTPUT]?.symbol || ''}
51+
{tokens[Field.OUTPUT]?.symbol}
5152
</Text>
5253
</RowFixed>
5354
</RowBetween>
@@ -56,7 +57,7 @@ export default function SwapModalHeader({
5657
<TYPE.italic textAlign="left" style={{ width: '100%' }}>
5758
{`Output is estimated. You will receive at least `}
5859
<b>
59-
{slippageAdjustedAmounts[Field.OUTPUT]?.toSignificant(6)} {tokens[Field.OUTPUT]?.symbol}{' '}
60+
{slippageAdjustedAmounts[Field.OUTPUT]?.toSignificant(6)} {tokens[Field.OUTPUT]?.symbol}
6061
</b>
6162
{' or the transaction will revert.'}
6263
</TYPE.italic>

src/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ChainId, JSBI, Percent, Token, WETH, Pair, TokenAmount } from '@uniswap
22

33
import { fortmatic, injected, portis, walletconnect, walletlink } from '../connectors'
44

5-
export const ROUTER_ADDRESS = '0xf164fC0Ec4E93095b804a4795bBe1e041497b92a'
5+
export const ROUTER_ADDRESS = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
66

77
// used to construct intermediary pairs for trading
88
export const BASES_TO_CHECK_TRADES_AGAINST: { readonly [chainId in ChainId]: Token[] } = {

0 commit comments

Comments
 (0)