1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 20:02:58 +01:00

Allow specific origin to direct to second page of token allowance flow (#18395)

* Allow specific origin to direct to second page of token allowance flow

* Remove accidentally committed git diff text

---------

Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
This commit is contained in:
Dan J Miller 2023-03-31 07:04:55 -07:00 committed by PeterYinusa
parent 9dc8a0238f
commit e38f5ecb68

View File

@ -63,6 +63,8 @@ import { useSimulationFailureWarning } from '../../hooks/useSimulationFailureWar
import SimulationErrorMessage from '../../components/ui/simulation-error-message';
import { Icon, ICON_NAMES } from '../../components/component-library';
const ALLOWED_HOSTS = ['portfolio.metamask.io'];
export default function TokenAllowance({
origin,
siteImage,
@ -92,10 +94,13 @@ export default function TokenAllowance({
const history = useHistory();
const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
const { hostname } = new URL(origin);
const thisOriginIsAllowedToSkipFirstPage = ALLOWED_HOSTS.includes(hostname);
const [showContractDetails, setShowContractDetails] = useState(false);
const [showFullTxDetails, setShowFullTxDetails] = useState(false);
const [isFirstPage, setIsFirstPage] = useState(
dappProposedTokenAmount !== '0',
dappProposedTokenAmount !== '0' && !thisOriginIsAllowedToSkipFirstPage,
);
const [errorText, setErrorText] = useState('');
const [userAcknowledgedGasMissing, setUserAcknowledgedGasMissing] =
@ -107,10 +112,13 @@ export default function TokenAllowance({
const currentAccount = useSelector(getCurrentAccountWithSendEtherInfo);
const networkIdentifier = useSelector(getNetworkIdentifier);
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
const customTokenAmount = useSelector(getCustomTokenAmount);
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
const unapprovedTxs = useSelector(getUnapprovedTransactions);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
let customTokenAmount = useSelector(getCustomTokenAmount);
if (thisOriginIsAllowedToSkipFirstPage && dappProposedTokenAmount) {
customTokenAmount = dappProposedTokenAmount;
}
const replaceCommaToDot = (inputValue) => {
return inputValue.replace(/,/gu, '.');