1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Show user the general contract interaction screen for token approvals, when the asset standard is undefined (#16765)

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
This commit is contained in:
Dan J Miller 2022-12-19 13:38:28 -03:30 committed by seaona
parent 281f8e16b9
commit cb2f25f767
2 changed files with 18 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import {
getNativeCurrency,
isAddressLedger,
} from '../../ducks/metamask/metamask';
import ConfirmContractInteraction from '../confirm-contract-interaction';
import {
getCurrentCurrency,
getSubjectMetadata,
@ -166,6 +167,9 @@ export default function ConfirmApprove({
if (tokenSymbol === undefined && assetName === undefined) {
return <Loading />;
}
if (assetStandard === undefined) {
return <ConfirmContractInteraction />;
}
if (improvedTokenAllowanceEnabled && assetStandard === ERC20) {
return (
<GasFeeContextProvider transaction={transaction}>

View File

@ -1165,8 +1165,21 @@ export default class ConfirmTransactionBase extends Component {
requestsWaitingText,
} = this.getNavigateTxData();
// This `isTokenApproval` case is added to handle possible rendering of this component from
// confirm-approve.js when `assetStandard` is `undefined`. That will happen if the request to
// get the asset standard fails. In that scenario, confirm-approve.js returns the `<ConfirmContractInteraction />`
// component, which in turn returns this `<ConfirmTransactionBase />` component. We meed to prevent
// the user from editing the transaction in those cases.
const isTokenApproval =
txData.type === TRANSACTION_TYPES.TOKEN_METHOD_SET_APPROVAL_FOR_ALL ||
txData.type === TRANSACTION_TYPES.TOKEN_METHOD_APPROVE;
const isContractInteraction =
txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION;
const isContractInteractionFromDapp =
txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION &&
(isTokenApproval || isContractInteraction) &&
txData.origin !== 'metamask';
let functionType;
if (isContractInteractionFromDapp) {