mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-28 05:12:18 +01:00
e157d2b51f
* Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * This is a combination of 52 commits. normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Updates transaction user settings. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> 1. updateSwapApprovalTransaction should have id as first parameter 2. updateSwapApprovalTransaction should not show loading indicator Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> update swap transaction. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics code. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix swapApprovalTransaction update to use same return method as swap update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Draft methods to brak updateTransaction into smaller more targeted methods. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> normalize and validate tx params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Method to normalize tx and check if it's unapproved. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Move the methods to controllers/transactions/index.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Flesh out the methods to update transaction with custom notes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Test update gas fees Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> use lodash to remove undefined properties update swap transaction tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add Update Transaction Metrics Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update transaction gas fees actions.js Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update EIP 1559 Params. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint Fixes. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Documentations. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics from this PR Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes: Removed unused variables Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Update swap approval transaction Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> 1. updateSwapApprovalTransaction should have id as first parameter 2. updateSwapApprovalTransaction should not show loading indicator Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> update swap transaction. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove metrics code. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Add updateTransactionParams to actions.js updateXXX and return txData at the end of updateXXX method Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Fix swapApprovalTransaction update to use same return method as swap update Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove duplicate tests Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove comments. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Do not hideLoading, since we're not showing it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> ...approveTxMeta no longer needed here. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Remove estimated base fee from swap approval txs. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> remove txTradeMeta from params make sure rebase didn't mess up any code - first pass Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
70 lines
2.2 KiB
JavaScript
70 lines
2.2 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
import Modal from '../../modal';
|
|
import Typography from '../../../ui/typography';
|
|
import { TYPOGRAPHY } from '../../../../helpers/constants/design-system';
|
|
import withModalProps from '../../../../helpers/higher-order-components/with-modal-props';
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
|
import {
|
|
ADD_COLLECTIBLE_ROUTE,
|
|
ASSET_ROUTE,
|
|
} from '../../../../helpers/constants/routes';
|
|
import { getCollectibles } from '../../../../ducks/metamask/metamask';
|
|
import { removeToken } from '../../../../store/actions';
|
|
import { isEqualCaseInsensitive } from '../../../../../shared/modules/string-utils';
|
|
|
|
const ConvertTokenToNFTModal = ({ hideModal, tokenAddress }) => {
|
|
const history = useHistory();
|
|
const t = useI18nContext();
|
|
const dispatch = useDispatch();
|
|
const allCollectibles = useSelector(getCollectibles);
|
|
const tokenAddedAsNFT = allCollectibles.find(({ address }) =>
|
|
isEqualCaseInsensitive(address, tokenAddress),
|
|
);
|
|
|
|
return (
|
|
<Modal
|
|
onSubmit={async () => {
|
|
if (tokenAddedAsNFT) {
|
|
await dispatch(removeToken(tokenAddress));
|
|
const { tokenId } = tokenAddedAsNFT;
|
|
history.push({
|
|
pathname: `${ASSET_ROUTE}/${tokenAddress}/${tokenId}`,
|
|
});
|
|
} else {
|
|
history.push({
|
|
pathname: ADD_COLLECTIBLE_ROUTE,
|
|
state: { tokenAddress },
|
|
});
|
|
}
|
|
hideModal();
|
|
}}
|
|
submitText={t('yes')}
|
|
onCancel={() => hideModal()}
|
|
cancelText={t('cancel')}
|
|
>
|
|
<div className="convert-token-to-nft-modal">
|
|
<Typography
|
|
variant={TYPOGRAPHY.H6}
|
|
boxProps={{
|
|
marginTop: 2,
|
|
}}
|
|
>
|
|
{tokenAddedAsNFT
|
|
? t('convertTokenToNFTExistDescription')
|
|
: t('convertTokenToNFTDescription')}
|
|
</Typography>
|
|
</div>
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
ConvertTokenToNFTModal.propTypes = {
|
|
hideModal: PropTypes.func.isRequired,
|
|
tokenAddress: PropTypes.string,
|
|
};
|
|
|
|
export default withModalProps(ConvertTokenToNFTModal);
|