1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Remove duplicate gas simulation error messages (#14409)

* Remove duplicate gas simulation error messages

* Fixing locales

* Fixing unit tests

* Fixing e2e

Co-authored-by: ryanml <ryanlanese@gmail.com>
This commit is contained in:
Dan J Miller 2022-04-13 12:30:10 -02:30 committed by GitHub
parent 4b3977044f
commit e768119dd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 23 additions and 167 deletions

View File

@ -2459,9 +2459,6 @@
"signed": {
"message": "Unterschrieben"
},
"simulationErrorMessage": {
"message": "Diese Transaktion wird voraussichtlich fehlschlagen. Der Versuch, sie auszuführen, wird voraussichtlich teuer aber fehlschlagen und wird nicht empfohlen."
},
"simulationErrorMessageV2": {
"message": "Wir konnten das Gas nicht schätzen. Es könnte einen Fehler im Vertrag geben und diese Transaktion könnte fehlschlagen."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Erneut versuchen"
},
"tryAnywayOption": {
"message": "Ich werde es trotzdem versuchen"
},
"turnOnTokenDetection": {
"message": "Erweiterte Token-Erkennung aktivieren"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "Συνδεδεμένος"
},
"simulationErrorMessage": {
"message": "Αυτή η συναλλαγή αναμένεται να αποτύχει. Η προσπάθεια εκτέλεσης αναμένεται να είναι δαπανηρή αλλά να αποτύχει και δεν συνιστάται."
},
"simulationErrorMessageV2": {
"message": "Δεν ήμασταν σε θέση να εκτιμήσουμε το τέλος συναλλαγής. Μπορεί να υπάρχει σφάλμα στο συμβόλαιο και αυτή η συναλλαγή μπορεί να αποτύχει."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Δοκιμάστε ξανά"
},
"tryAnywayOption": {
"message": "Θα προσπαθήσω ούτως ή άλλως"
},
"turnOnTokenDetection": {
"message": "Ενεργοποιήστε την ενισχυμένη ανίχνευση token"
},

View File

@ -2879,9 +2879,6 @@
"signed": {
"message": "Signed"
},
"simulationErrorMessage": {
"message": "This transaction is expected to fail. Trying to execute it is expected to be expensive but fail, and is not recommended."
},
"simulationErrorMessageV2": {
"message": "We were not able to estimate gas. There might be an error in the contract and this transaction may fail."
},
@ -3757,9 +3754,6 @@
"tryAgain": {
"message": "Try again"
},
"tryAnywayOption": {
"message": "I will try anyway"
},
"turnOnTokenDetection": {
"message": "Turn on enhanced token detection"
},

View File

@ -2514,9 +2514,6 @@
"signed": {
"message": "Firmado"
},
"simulationErrorMessage": {
"message": "Se anticipa que esta transacción falle. En caso de intentar ejecutarla, se anticipa que eso sea costoso y a la vez falle, y por lo tanto no se recomienda."
},
"simulationErrorMessageV2": {
"message": "No pudimos estimar el gas. Podría haber un error en el contrato y esta transacción podría fallar."
},
@ -3188,9 +3185,6 @@
"tryAgain": {
"message": "Vuelva a intentarlo"
},
"tryAnywayOption": {
"message": "Lo intentaré de todos modos"
},
"turnOnTokenDetection": {
"message": "Activar la detección mejorada de tokens"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "Signé"
},
"simulationErrorMessage": {
"message": "Cette transaction devrait échouer. Si vous choisissez de lexécuter, cela devrait à la fois être coûteux et voué à léchec. Ce nest donc pas recommandé."
},
"simulationErrorMessageV2": {
"message": "Nous navons pas pu estimer le prix de carburant. Par conséquent, il se peut quil y ait une erreur dans le contrat et que cette transaction échoue."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Réessayez"
},
"tryAnywayOption": {
"message": "Je veux quand même essayer"
},
"turnOnTokenDetection": {
"message": "Activer la détection améliorée des jetons"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "हस्ताक्षर किया गया"
},
"simulationErrorMessage": {
"message": "यह लेन-देन विफल होने की उम्मीद है। इसे निष्पादित करने के प्रयास के महंगा होने की उम्मीद है लेकिन विफल है, और इसकी अनुशंसा नहीं की जाती है।"
},
"simulationErrorMessageV2": {
"message": "हम गैस का अनुमान नहीं लगा पाए। अनुबंध में कोई त्रुटि हो सकती है और यह लेन-देन विफल हो सकता है।"
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "पुनः प्रयास करें"
},
"tryAnywayOption": {
"message": "मैं फिर भी कोशिश करूंगा"
},
"turnOnTokenDetection": {
"message": "उन्नत टोकन डिटेक्शन चालू करें"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "Ditandatangani"
},
"simulationErrorMessage": {
"message": "Transaksi ini diperkirakan akan gagal. Pelaksanaannya diperkirakan akan mahal dan berpotensi gagal, dan tidak direkomendasikan."
},
"simulationErrorMessageV2": {
"message": "Kami tidak dapat memperkirakan gas. Tampaknya ada kesalahan dalam kontrak dan transaksi ini berpotensi gagal."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Coba lagi"
},
"tryAnywayOption": {
"message": "Saya akan tetap mencobanya"
},
"turnOnTokenDetection": {
"message": "Nyalakan deteksi token yang ditingkatkan"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "署名が完了しました"
},
"simulationErrorMessage": {
"message": "このトランザクションは失敗する見込みです。実行しようとすると多くのコストがかかるうえに失敗する可能性が高いため、お勧めしません。"
},
"simulationErrorMessageV2": {
"message": "ガス代を見積もれませんでした。コントラクトにエラーがある可能性があり、このトランザクションは失敗するかもしれません。"
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "再試行"
},
"tryAnywayOption": {
"message": "とにかく試してみる"
},
"turnOnTokenDetection": {
"message": "強化されたトークン検出をオンにする"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "서명완료"
},
"simulationErrorMessage": {
"message": "이 거래는 실패할 것으로 예상됩니다. 실행하려면 비용이 많이 들지만 실패할 것으로 예상되어 권장하지 않습니다."
},
"simulationErrorMessageV2": {
"message": "가스 요금을 추정할 수 없었습니다. 계약에 오류가 있을 수 있으며 이 거래가 실패할 수 있습니다."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "다시 시도"
},
"tryAnywayOption": {
"message": "계속 시도"
},
"turnOnTokenDetection": {
"message": "향상된 토큰 감지 켜기"
},

View File

@ -2498,9 +2498,6 @@
"signed": {
"message": "Assinado"
},
"simulationErrorMessage": {
"message": "É esperado que essa transação falhe. Como é esperado que sua tentativa de execução seja dispendiosa e falhe, ela não é recomendada."
},
"simulationErrorMessageV2": {
"message": "Não conseguimos estimar o preço do gás. Pode haver um erro no contrato, e essa transação poderá falhar."
},
@ -3172,9 +3169,6 @@
"tryAgain": {
"message": "Tente novamente"
},
"tryAnywayOption": {
"message": "Vou tentar mesmo assim"
},
"turnOnTokenDetection": {
"message": "Ativar detecção avançada de token"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "Подписано"
},
"simulationErrorMessage": {
"message": "Ожидается, что эта транзакция завершится неудачно. Предполагается, что попытка выполнить ее будет дорогостоящей, но потерпит неудачу, и поэтому ее не рекомендуется выполнять."
},
"simulationErrorMessageV2": {
"message": "Мы не смогли оценить размер платы за газ. В контракте может быть ошибка, и эта транзакция может завершиться неудачно."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Попробуйте еще раз"
},
"tryAnywayOption": {
"message": "Я все равно попробую"
},
"turnOnTokenDetection": {
"message": "Включите расширенное обнаружение токенов"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "Nilagdaan"
},
"simulationErrorMessage": {
"message": "Inaasahang mabibigo ang transaksyong ito. Ang pagsisikap na isagawa ito ay inaasahang magastos ngunit nabigo, at hindi inirerekomenda."
},
"simulationErrorMessageV2": {
"message": "Hindi namin nagawang tantyahin ang gas. Maaaring may error sa kontrata at maaaring mabigo ang transaksyong ito."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Subukan ulit"
},
"tryAnywayOption": {
"message": "Susubukan ko pa rin"
},
"turnOnTokenDetection": {
"message": "I-on ang pinahusay na pag-detect ng token"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "İmzalandı"
},
"simulationErrorMessage": {
"message": "Bu işlemin başarısız olması bekleniyor. Gerçekleştirmeye çalışıldığında maliyetli olması ancak başarısız olması bekleniyor ve önerilmiyor."
},
"simulationErrorMessageV2": {
"message": "Gaz tahmini yapamadık. Sözleşmede bir hata olabilir ve bu işlem başarısız olabilir."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Tekrar dene"
},
"tryAnywayOption": {
"message": "Yine de deneyeceğim"
},
"turnOnTokenDetection": {
"message": "Gelişmiş token algılamayıın"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "Đã ký"
},
"simulationErrorMessage": {
"message": "Giao dịch này có khả năng thất bại. Việc cố gắng thực hiện sẽ được cho là gây tốn kém nhưng lại không thành công và không được khuyến khích."
},
"simulationErrorMessageV2": {
"message": "Chúng tôi không thể ước tính gas. Có thể đã xảy ra lỗi trong hợp đồng và giao dịch này có thể thất bại."
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "Thử lại"
},
"tryAnywayOption": {
"message": "Tôi vẫn sẽ thử"
},
"turnOnTokenDetection": {
"message": "Bật phát hiện token nâng cao"
},

View File

@ -2462,9 +2462,6 @@
"signed": {
"message": "已签名"
},
"simulationErrorMessage": {
"message": "此交易预计将失败。尝试执行该交易预计将是昂贵的,但失败,不推荐。"
},
"simulationErrorMessageV2": {
"message": "我们无法估计燃料。合同中可能有一个错误,这笔交易可能失败。"
},
@ -3130,9 +3127,6 @@
"tryAgain": {
"message": "重试"
},
"tryAnywayOption": {
"message": "我仍然会试"
},
"turnOnTokenDetection": {
"message": "打开增强代币检测"
},

View File

@ -76,7 +76,7 @@ describe('Failing contract interaction ', function () {
// display warning when transaction is expected to fail
const warningText =
'This transaction is expected to fail. Trying to execute it is expected to be expensive but fail, and is not recommended.';
'We were not able to estimate gas. There might be an error in the contract and this transaction may fail.';
const warning = await driver.findElement(
'.actionable-message__message',
);
@ -87,7 +87,10 @@ describe('Failing contract interaction ', function () {
assert.equal(await confirmButton.isEnabled(), false);
// dismiss warning and confirm the transaction
await driver.clickElement({ text: 'I will try anyway', tag: 'button' });
await driver.clickElement({
text: 'I want to proceed anyway',
tag: 'button',
});
await driver.clickElement({ text: 'Confirm', tag: 'button' });
await driver.waitUntilXWindowHandles(2);
await driver.switchToWindow(extension);

View File

@ -25,7 +25,6 @@ export default class ConfirmPageContainerContent extends Component {
detailsComponent: PropTypes.node,
errorKey: PropTypes.string,
errorMessage: PropTypes.string,
hasSimulationError: PropTypes.bool,
hideSubtitle: PropTypes.bool,
tokenAddress: PropTypes.string,
nonce: PropTypes.string,
@ -41,10 +40,8 @@ export default class ConfirmPageContainerContent extends Component {
onCancel: PropTypes.func,
cancelText: PropTypes.string,
onSubmit: PropTypes.func,
setUserAcknowledgedGasMissing: PropTypes.func,
submitText: PropTypes.string,
disabled: PropTypes.bool,
hideUserAcknowledgedGasMissing: PropTypes.bool,
unapprovedTxCount: PropTypes.number,
rejectNText: PropTypes.string,
hideTitle: PropTypes.bool,
@ -100,7 +97,6 @@ export default class ConfirmPageContainerContent extends Component {
action,
errorKey,
errorMessage,
hasSimulationError,
title,
image,
titleComponent,
@ -122,8 +118,6 @@ export default class ConfirmPageContainerContent extends Component {
origin,
ethGasPriceWarning,
hideTitle,
setUserAcknowledgedGasMissing,
hideUserAcknowledgedGasMissing,
supportsEIP1559V2,
hasTopBorder,
currentTransaction,
@ -135,17 +129,10 @@ export default class ConfirmPageContainerContent extends Component {
isBuyableChain,
} = this.props;
const primaryAction = hideUserAcknowledgedGasMissing
? null
: {
label: this.context.t('tryAnywayOption'),
onClick: setUserAcknowledgedGasMissing,
};
const { t } = this.context;
const showInsuffienctFundsError =
supportsEIP1559V2 &&
!hasSimulationError &&
(errorKey || errorMessage) &&
errorKey === INSUFFICIENT_FUNDS_ERROR_KEY;
@ -159,15 +146,6 @@ export default class ConfirmPageContainerContent extends Component {
{ethGasPriceWarning && (
<ConfirmPageContainerWarning warning={ethGasPriceWarning} />
)}
{hasSimulationError && (
<div className="confirm-page-container-content__error-container">
<ActionableMessage
type="danger"
primaryAction={primaryAction}
message={t('simulationErrorMessage')}
/>
</div>
)}
<ConfirmPageContainerSummary
className={classnames({
'confirm-page-container-summary--border':
@ -188,7 +166,6 @@ export default class ConfirmPageContainerContent extends Component {
/>
{this.renderContent()}
{!supportsEIP1559V2 &&
!hasSimulationError &&
(errorKey || errorMessage) &&
currentTransaction.type !== TRANSACTION_TYPES.SIMPLE_SEND && (
<div className="confirm-page-container-content__error-container">

View File

@ -39,7 +39,6 @@ describe('Confirm Page Container Content', () => {
action: ' Withdraw Stake',
errorMessage: null,
errorKey: null,
hasSimulationError: true,
onCancelAll: mockOnCancelAll,
onCancel: mockOnCancel,
cancelText: 'Reject',
@ -52,38 +51,7 @@ describe('Confirm Page Container Content', () => {
};
});
it('render ConfirmPageContainer component with simulation error', async () => {
const { queryByText, getByText } = renderWithProvider(
<ConfirmPageContainerContent {...props} />,
store,
);
expect(
queryByText('Transaction Error. Exception thrown in contract code.'),
).not.toBeInTheDocument();
expect(
queryByText(
'This transaction is expected to fail. Trying to execute it is expected to be expensive but fail, and is not recommended.',
),
).toBeInTheDocument();
expect(queryByText('I will try anyway')).toBeInTheDocument();
const confirmButton = getByText('Confirm');
expect(getByText('Confirm').closest('button')).toBeDisabled();
fireEvent.click(confirmButton);
expect(props.onSubmit).toHaveBeenCalledTimes(0);
const iWillTryButton = getByText('I will try anyway');
fireEvent.click(iWillTryButton);
expect(props.setUserAcknowledgedGasMissing).toHaveBeenCalledTimes(1);
const cancelButton = getByText('Reject');
fireEvent.click(cancelButton);
expect(props.onCancel).toHaveBeenCalledTimes(1);
});
it('render ConfirmPageContainer component with another error', async () => {
props.hasSimulationError = false;
props.disabled = true;
props.errorKey = TRANSACTION_ERROR_KEY;
props.currentTransaction = {
@ -96,10 +64,10 @@ describe('Confirm Page Container Content', () => {
expect(
queryByText(
'This transaction is expected to fail. Trying to execute it is expected to be expensive but fail, and is not recommended.',
'We were not able to estimate gas. There might be an error in the contract and this transaction may fail.',
),
).not.toBeInTheDocument();
expect(queryByText('I will try anyway')).not.toBeInTheDocument();
expect(queryByText('I want to proceed anyway')).not.toBeInTheDocument();
expect(getByText('Confirm').closest('button')).toBeDisabled();
expect(
getByText('Transaction Error. Exception thrown in contract code.'),
@ -111,7 +79,6 @@ describe('Confirm Page Container Content', () => {
});
it('render ConfirmPageContainer component with no errors', async () => {
props.hasSimulationError = false;
props.disabled = false;
const { queryByText, getByText } = renderWithProvider(
<ConfirmPageContainerContent {...props} />,
@ -120,13 +87,13 @@ describe('Confirm Page Container Content', () => {
expect(
queryByText(
'This transaction is expected to fail. Trying to execute it is expected to be expensive but fail, and is not recommended.',
'We were not able to estimate gas. There might be an error in the contract and this transaction may fail.',
),
).not.toBeInTheDocument();
expect(
queryByText('Transaction Error. Exception thrown in contract code.'),
).not.toBeInTheDocument();
expect(queryByText('I will try anyway')).not.toBeInTheDocument();
expect(queryByText('I want to proceed anyway')).not.toBeInTheDocument();
const confirmButton = getByText('Confirm');
fireEvent.click(confirmButton);
@ -138,7 +105,6 @@ describe('Confirm Page Container Content', () => {
});
it('render contract address name from addressBook in title for contract', async () => {
props.hasSimulationError = false;
props.disabled = false;
props.toAddress = '0x06195827297c7A80a443b6894d3BDB8824b43896';
props.transactionType = TRANSACTION_TYPES.CONTRACT_INTERACTION;
@ -151,7 +117,6 @@ describe('Confirm Page Container Content', () => {
});
it('render simple title without address name for simple send', async () => {
props.hasSimulationError = false;
props.disabled = false;
props.toAddress = '0x06195827297c7A80a443b6894d3BDB8824b43896';
props.transactionType = TRANSACTION_TYPES.SIMPLE_SEND;

View File

@ -560,13 +560,18 @@ export default class ConfirmTransactionBase extends Component {
const simulationFailureWarning = () => (
<div className="confirm-page-container-content__error-container">
<ActionableMessage
message={t('simulationErrorMessageV2')}
useIcon
iconFillColor="var(--color-error-default)"
type="danger"
primaryAction={{
label: this.context.t('tryAnywayOption'),
onClick: () => this.setUserAcknowledgedGasMissing(),
}}
message={this.context.t('simulationErrorMessage')}
roundedButtons
primaryActionV2={
userAcknowledgedGasMissing === true
? undefined
: {
label: t('proceedWithTransaction'),
onClick: () => this.setUserAcknowledgedGasMissing(),
}
}
/>
</div>
);
@ -593,7 +598,9 @@ export default class ConfirmTransactionBase extends Component {
: () => this.handleEditGas()
}
rows={[
renderSimulationFailureWarning && simulationFailureWarning(),
renderSimulationFailureWarning &&
!this.supportsEIP1559V2 &&
simulationFailureWarning(),
!renderSimulationFailureWarning &&
!isMultiLayerFeeNetwork &&
renderGasDetailsItem(),
@ -1034,10 +1041,6 @@ export default class ConfirmTransactionBase extends Component {
requestsWaitingText,
} = this.getNavigateTxData();
const isDisabled = () => {
return userAcknowledgedGasMissing ? false : !valid;
};
let functionType;
if (txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION) {
functionType = getMethodName(name);
@ -1089,7 +1092,6 @@ export default class ConfirmTransactionBase extends Component {
lastTx={lastTx}
ofText={ofText}
requestsWaitingText={requestsWaitingText}
hideUserAcknowledgedGasMissing={!isDisabled()}
disabled={
renderSimulationFailureWarning ||
!valid ||
@ -1101,7 +1103,6 @@ export default class ConfirmTransactionBase extends Component {
onCancelAll={() => this.handleCancelAll()}
onCancel={() => this.handleCancel()}
onSubmit={() => this.handleSubmit()}
setUserAcknowledgedGasMissing={this.setUserAcknowledgedGasMissing}
hideSenderToRecipient={hideSenderToRecipient}
origin={txData.origin}
ethGasPriceWarning={ethGasPriceWarning}