-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swaps: Create a new swap #11124
Swaps: Create a new swap #11124
Changes from 4 commits
78f740b
b10c44f
0fd8574
94b9927
d02b12f
9e81dba
ce3e5c5
f3f56a5
66b4c5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import { | |
prepareToLeaveSwaps, | ||
} from '../../../ducks/swaps/swaps'; | ||
import Mascot from '../../../components/ui/mascot'; | ||
import Box from '../../../components/ui/box'; | ||
import { | ||
QUOTES_EXPIRED_ERROR, | ||
SWAP_FAILED_ERROR, | ||
|
@@ -38,10 +39,9 @@ import { | |
SWAPS_CHAINID_DEFAULT_BLOCK_EXPLORER_URL_MAP, | ||
} from '../../../../shared/constants/swaps'; | ||
import { CHAIN_ID_TO_TYPE_MAP as VALID_INFURA_CHAIN_IDS } from '../../../../shared/constants/network'; | ||
import { isSwapsDefaultTokenSymbol } from '../../../../shared/modules/swaps.utils'; | ||
import PulseLoader from '../../../components/ui/pulse-loader'; | ||
|
||
import { ASSET_ROUTE, DEFAULT_ROUTE } from '../../../helpers/constants/routes'; | ||
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'; | ||
|
||
import { getRenderableNetworkFeesForQuote } from '../swaps.util'; | ||
import SwapsFooter from '../swaps-footer'; | ||
|
@@ -100,19 +100,25 @@ export default function AwaitingSwap({ | |
|
||
const hardwareWalletUsed = useSelector(isHardwareWallet); | ||
const hardwareWalletType = useSelector(getHardwareWalletType); | ||
const sensitiveProperties = { | ||
token_from: sourceTokenInfo?.symbol, | ||
token_from_amount: fetchParams?.value, | ||
token_to: destinationTokenInfo?.symbol, | ||
request_type: fetchParams?.balanceError ? 'Quote' : 'Order', | ||
slippage: fetchParams?.slippage, | ||
custom_slippage: fetchParams?.slippage === 2, | ||
gas_fees: feeinUnformattedFiat, | ||
is_hardware_wallet: hardwareWalletUsed, | ||
hardware_wallet_type: hardwareWalletType, | ||
}; | ||
const quotesExpiredEvent = useNewMetricEvent({ | ||
event: 'Quotes Timed Out', | ||
sensitiveProperties: { | ||
token_from: sourceTokenInfo?.symbol, | ||
token_from_amount: fetchParams?.value, | ||
token_to: destinationTokenInfo?.symbol, | ||
request_type: fetchParams?.balanceError ? 'Quote' : 'Order', | ||
slippage: fetchParams?.slippage, | ||
custom_slippage: fetchParams?.slippage === 2, | ||
gas_fees: feeinUnformattedFiat, | ||
is_hardware_wallet: hardwareWalletUsed, | ||
hardware_wallet_type: hardwareWalletType, | ||
}, | ||
sensitiveProperties, | ||
category: 'swaps', | ||
}); | ||
const makeAnotherSwapEvent = useNewMetricEvent({ | ||
event: 'Make Another Swap', | ||
sensitiveProperties, | ||
category: 'swaps', | ||
}); | ||
|
||
|
@@ -212,7 +218,7 @@ export default function AwaitingSwap({ | |
} else if (!errorKey && swapComplete) { | ||
headerText = t('swapTransactionComplete'); | ||
statusImage = <SwapSuccessIcon />; | ||
submitText = t('swapViewToken', [destinationTokenInfo.symbol]); | ||
submitText = t('close'); | ||
descriptionText = t('swapTokenAvailable', [ | ||
<span | ||
key="swapTokenAvailable-2" | ||
|
@@ -230,6 +236,22 @@ export default function AwaitingSwap({ | |
); | ||
} | ||
|
||
const MakeAnotherSwap = () => { | ||
return ( | ||
<Box marginBottom={3}> | ||
<a | ||
href="#" | ||
onClick={() => { | ||
makeAnotherSwapEvent(); | ||
dispatch(navigateBackToBuildQuote(history)); | ||
}} | ||
> | ||
{t('makeAnotherSwap')} | ||
</a> | ||
</Box> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className="awaiting-swap"> | ||
<div className="awaiting-swap__content"> | ||
|
@@ -245,6 +267,7 @@ export default function AwaitingSwap({ | |
<div className="awaiting-swap__main-descrption">{descriptionText}</div> | ||
{content} | ||
</div> | ||
{!errorKey && swapComplete && <MakeAnotherSwap />} | ||
<SwapsFooter | ||
onSubmit={async () => { | ||
if (errorKey === OFFLINE_FOR_MAINTENANCE) { | ||
|
@@ -262,12 +285,8 @@ export default function AwaitingSwap({ | |
); | ||
} else if (errorKey) { | ||
await dispatch(navigateBackToBuildQuote(history)); | ||
} else if ( | ||
isSwapsDefaultTokenSymbol(destinationTokenInfo?.symbol, chainId) | ||
) { | ||
history.push(DEFAULT_ROUTE); | ||
} else { | ||
history.push(`${ASSET_ROUTE}/${destinationTokenInfo?.address}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this line deleted? I believe the purpose of this was to redirect the user to the screen for the specific token that they are swapping to. Do we not want to do that any more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question! We synced up yesterday and here is a summary: the requirement is to show the Which redirects to the Activity tab, where a user can see progress of their transaction. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
history.push(DEFAULT_ROUTE); | ||
} | ||
}} | ||
onCancel={async () => await dispatch(navigateBackToBuildQuote(history))} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to use a
<button>
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! We had a quick chat about when to use a button or a link and since we do page redirection on click here, a link seems fine.