From 2955b97f975741f620d515778bec97d5981c6ba0 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 4 Aug 2022 17:20:32 -0230 Subject: [PATCH] Prevent confirm screen from showing method name from contract registry for txes created within MetaMask (#15472) * Prevent confirm screen from showing method name from contract registry for txes created within MetaMask * Ensure method name does not get sent in state when sending to a contract, with tx data, from metamask send screen --- .../confirm-transaction-base.component.js | 5 ++++- .../confirm-transaction.component.js | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js index 5e2d9861a..21c78f0ae 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -1048,7 +1048,10 @@ export default class ConfirmTransactionBase extends Component { } = this.getNavigateTxData(); let functionType; - if (txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION) { + if ( + txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION && + txData.origin !== 'metamask' + ) { functionType = getMethodName(name); } diff --git a/ui/pages/confirm-transaction/confirm-transaction.component.js b/ui/pages/confirm-transaction/confirm-transaction.component.js index 01e876fdb..fb853741f 100644 --- a/ui/pages/confirm-transaction/confirm-transaction.component.js +++ b/ui/pages/confirm-transaction/confirm-transaction.component.js @@ -68,7 +68,7 @@ export default class ConfirmTransaction extends Component { sendTo, history, mostRecentOverviewPage, - transaction: { txParams: { data } = {} } = {}, + transaction: { txParams: { data } = {}, origin } = {}, getContractMethodData, transactionId, paramsTransactionId, @@ -91,7 +91,9 @@ export default class ConfirmTransaction extends Component { return; } - getContractMethodData(data); + if (origin !== 'metamask') { + getContractMethodData(data); + } const txId = transactionId || paramsTransactionId; if (txId) { @@ -107,7 +109,7 @@ export default class ConfirmTransaction extends Component { componentDidUpdate(prevProps) { const { setTransactionToConfirm, - transaction: { txData: { txParams: { data } = {} } = {} }, + transaction: { txData: { txParams: { data } = {}, origin } = {} }, clearConfirmTransaction, getContractMethodData, paramsTransactionId, @@ -124,8 +126,10 @@ export default class ConfirmTransaction extends Component { prevProps.paramsTransactionId !== paramsTransactionId ) { clearConfirmTransaction(); - getContractMethodData(data); setTransactionToConfirm(paramsTransactionId); + if (origin !== 'metamask') { + getContractMethodData(data); + } } else if ( prevProps.transactionId && !transactionId &&