1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01: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 GitHub
parent 0992dd5437
commit 22fc60a341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,
@ -164,6 +165,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

@ -1162,8 +1162,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) {