mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +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:
parent
fbd68d4a3f
commit
41210084dd
@ -65,6 +65,8 @@ import SimulationErrorMessage from '../../components/ui/simulation-error-message
|
||||
import { Icon, ICON_NAMES } from '../../components/component-library';
|
||||
import LedgerInstructionField from '../../components/app/ledger-instruction-field/ledger-instruction-field';
|
||||
|
||||
const ALLOWED_HOSTS = ['portfolio.metamask.io'];
|
||||
|
||||
export default function TokenAllowance({
|
||||
origin,
|
||||
siteImage,
|
||||
@ -94,10 +96,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] =
|
||||
@ -109,11 +114,14 @@ 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);
|
||||
const isHardwareWalletConnected = useSelector(isHardwareWallet);
|
||||
let customTokenAmount = useSelector(getCustomTokenAmount);
|
||||
if (thisOriginIsAllowedToSkipFirstPage && dappProposedTokenAmount) {
|
||||
customTokenAmount = dappProposedTokenAmount;
|
||||
}
|
||||
|
||||
const replaceCommaToDot = (inputValue) => {
|
||||
return inputValue.replace(/,/gu, '.');
|
||||
|
Loading…
Reference in New Issue
Block a user