|
1 |
| -import { TransactionMeta } from '@metamask/transaction-controller'; |
| 1 | +import { |
| 2 | + TransactionMeta, |
| 3 | + TransactionType, |
| 4 | +} from '@metamask/transaction-controller'; |
2 | 5 | import React, { useCallback } from 'react';
|
3 | 6 | import { useDispatch } from 'react-redux';
|
4 | 7 | import { useHistory } from 'react-router-dom';
|
@@ -38,7 +41,26 @@ export const WalletInitiatedHeader = () => {
|
38 | 41 | const handleBackButtonClick = useCallback(async () => {
|
39 | 42 | const { id } = currentConfirmation;
|
40 | 43 |
|
41 |
| - await dispatch(editExistingTransaction(AssetType.token, id.toString())); |
| 44 | + const isNativeSend = |
| 45 | + currentConfirmation.type === TransactionType.simpleSend; |
| 46 | + const isERC20TokenSend = |
| 47 | + currentConfirmation.type === TransactionType.tokenMethodTransfer; |
| 48 | + const isNFTTokenSend = |
| 49 | + currentConfirmation.type === TransactionType.tokenMethodTransferFrom || |
| 50 | + currentConfirmation.type === TransactionType.tokenMethodSafeTransferFrom; |
| 51 | + |
| 52 | + let assetType: AssetType; |
| 53 | + if (isNativeSend) { |
| 54 | + assetType = AssetType.native; |
| 55 | + } else if (isERC20TokenSend) { |
| 56 | + assetType = AssetType.token; |
| 57 | + } else if (isNFTTokenSend) { |
| 58 | + assetType = AssetType.NFT; |
| 59 | + } else { |
| 60 | + assetType = AssetType.unknown; |
| 61 | + } |
| 62 | + |
| 63 | + await dispatch(editExistingTransaction(assetType, id.toString())); |
42 | 64 | dispatch(clearConfirmTransaction());
|
43 | 65 | dispatch(showSendTokenPage());
|
44 | 66 |
|
|
0 commit comments