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

Remove gas editing in Swaps (#14673)

* Remove gas editing in Swaps

* Remove "extraApprovalGas"
This commit is contained in:
Daniel 2022-05-11 20:30:03 +02:00 committed by GitHub
parent b258cbafe7
commit 9a153d2388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 0 additions and 1446 deletions

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Ich stimme zu"
},
"aggregatorFeeCost": {
"message": "Aggregator-Netzwerkgebühr"
},
"airgapVault": {
"message": "AirGap-Tresor"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Netzwerkgebühr für Freigabe und Aggregator"
},
"approvalTxGasCost": {
"message": "Tx-Gaskosten genehmigen"
},
"approve": {
"message": "Genehmigen"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Externe Erweiterung"
},
"extraApprovalGas": {
"message": "+$1 Genehmigungsgas",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Fehlgeschlagen"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Συμφωνώ"
},
"aggregatorFeeCost": {
"message": "Αμοιβή ανταλλακτηρίου"
},
"airgapVault": {
"message": "Θησαυροφυλάκιο AirGap"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Τέλος έγκρισης και δικτύου ανταλλακτηρίου"
},
"approvalTxGasCost": {
"message": "Έγκριση Tx τέλους συναλλαγής"
},
"approve": {
"message": "Έγκριση"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Εξωτερική Επέκταση"
},
"extraApprovalGas": {
"message": "+$1 τέλος συναλλαγής",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Απέτυχε"
},

View File

@ -203,9 +203,6 @@
"affirmAgree": {
"message": "I Agree"
},
"aggregatorFeeCost": {
"message": "Aggregator network fee"
},
"airgapVault": {
"message": "AirGap Vault"
},
@ -263,12 +260,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Approval and aggregator network fee"
},
"approvalTxGasCost": {
"message": "Approval Tx Gas Cost"
},
"approve": {
"message": "Approve spend limit"
},
@ -1185,10 +1176,6 @@
"externalExtension": {
"message": "External Extension"
},
"extraApprovalGas": {
"message": "+$1 approval gas",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Failed"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Acepto"
},
"aggregatorFeeCost": {
"message": "Cuota de red de agregador"
},
"airgapVault": {
"message": "Bóveda AirGap"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Cuota de red de agregador y aprobación"
},
"approvalTxGasCost": {
"message": "Costo de gas por transacción de aprobación"
},
"approve": {
"message": "Aprobar límite de gastos"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Extensión externa"
},
"extraApprovalGas": {
"message": "+$1 gas por aprobación",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Con errores"
},

View File

@ -179,9 +179,6 @@
"affirmAgree": {
"message": "Acepto"
},
"aggregatorFeeCost": {
"message": "Cuota de red de agregador"
},
"alertDisableTooltip": {
"message": "Esto se puede modificar en \"Configuración > Alertas\""
},
@ -233,12 +230,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Cuota de red de agregador y aprobación"
},
"approvalTxGasCost": {
"message": "Costo de gas por transacción de aprobación"
},
"approve": {
"message": "Aprobar límite de gastos"
},
@ -1047,10 +1038,6 @@
"externalExtension": {
"message": "Extensión externa"
},
"extraApprovalGas": {
"message": "+$1 de gas por aprobación",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Con errores"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Je suis daccord"
},
"aggregatorFeeCost": {
"message": "Frais de réseau de lagrégateur"
},
"airgapVault": {
"message": "Coffre-fort AirGap"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Approbation et frais du réseau dagrégateur"
},
"approvalTxGasCost": {
"message": "Approbation du coût de carburant Tx"
},
"approve": {
"message": "Approuver"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Extension externe"
},
"extraApprovalGas": {
"message": "+$1 de carburant approuvé",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Échec"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "मैं सहमत हूं"
},
"aggregatorFeeCost": {
"message": "एग्रीगेटर नेटवर्क शुल्क"
},
"airgapVault": {
"message": "AirGap का वॉल्ट"
},
@ -252,12 +249,6 @@
"message": "MetaMask Fask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "अनुमोदन और एग्रीगेटर नेटवर्क शुल्क"
},
"approvalTxGasCost": {
"message": "अनुमोदन Tx गैस कीमत"
},
"approve": {
"message": "खर्च सीमा अनुमोदित करें"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "बाहरी विस्तार"
},
"extraApprovalGas": {
"message": "+$1 अनुमोदन गैस",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "विफल"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Saya Setuju"
},
"aggregatorFeeCost": {
"message": "Biaya jaringan agregator"
},
"airgapVault": {
"message": "Brankas AirGap"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Persetujuan dan biaya jaringan agregator"
},
"approvalTxGasCost": {
"message": "Persetujuan Ongkos Jaringan Tx"
},
"approve": {
"message": "Setujui batas penggunaan"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Ekstensi Eksternal"
},
"extraApprovalGas": {
"message": "+$1 gas yang disetujui",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Gagal"
},

View File

@ -67,9 +67,6 @@
"affirmAgree": {
"message": "Acconsento"
},
"aggregatorFeeCost": {
"message": "Tassa per la rete aggregatore"
},
"alertDisableTooltip": {
"message": "Può essere cambiato in \"Impostazioni > Avvisi\""
},
@ -117,12 +114,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Tassa di approvazione per la rete aggregatore"
},
"approvalTxGasCost": {
"message": "Costo Gas Approvazione Tx"
},
"approve": {
"message": "Approva"
},
@ -568,10 +559,6 @@
"externalExtension": {
"message": "Estensione Esterna"
},
"extraApprovalGas": {
"message": "+$1 gas approvazione",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Fallita"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "同意する"
},
"aggregatorFeeCost": {
"message": "アグリゲーター ネットワーク料金"
},
"airgapVault": {
"message": "AirGap Vault"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "承認およびアグリゲーターネットワークの手数料"
},
"approvalTxGasCost": {
"message": "承認送信のガス代"
},
"approve": {
"message": "使用限度額の承認"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "外部拡張機能"
},
"extraApprovalGas": {
"message": "+$1承認ガス",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "失敗しました"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "동의함"
},
"aggregatorFeeCost": {
"message": "애그리게이터 네트워크 수수료"
},
"airgapVault": {
"message": "에어갭 볼트"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "승인 및 애그리게이터 네트워크 수수료"
},
"approvalTxGasCost": {
"message": "승인 Tx 가스 비용"
},
"approve": {
"message": "지출 한도 승인"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "외부 확장"
},
"extraApprovalGas": {
"message": "+$1의 승인 가스",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "실패"
},

View File

@ -91,9 +91,6 @@
"affirmAgree": {
"message": "Sang-ayon ako"
},
"aggregatorFeeCost": {
"message": "Bayarin sa aggregator network"
},
"alertDisableTooltip": {
"message": "Mababago ito sa \"Mga Setting > Mga Alerto\""
},
@ -141,12 +138,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Bayarin sa pag-apruba at aggregator network"
},
"approvalTxGasCost": {
"message": "Approval Tx Gas Cost"
},
"approve": {
"message": "Aprubahan ang limitasyon sa paggastos"
},
@ -674,10 +665,6 @@
"externalExtension": {
"message": "External Extension"
},
"extraApprovalGas": {
"message": "+$1 na pag-apruba sa gas",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Hindi matagumpay"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Concordo"
},
"aggregatorFeeCost": {
"message": "Taxa de rede do agregador"
},
"airgapVault": {
"message": "AirGap Vault"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Taxa de aprovação e da rede do agregador"
},
"approvalTxGasCost": {
"message": "Custo em gás da transação de aprovação"
},
"approve": {
"message": "Aprovar"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Extensão externa"
},
"extraApprovalGas": {
"message": "+$1 de gás por aprovação",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Falhou"
},

View File

@ -179,9 +179,6 @@
"affirmAgree": {
"message": "Concordo"
},
"aggregatorFeeCost": {
"message": "Taxa de rede do agregador"
},
"alertDisableTooltip": {
"message": "Isso pode ser alterado em \"Configurações > Alertas\""
},
@ -233,12 +230,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Taxa de aprovação e da rede do agregador"
},
"approvalTxGasCost": {
"message": "Custo em gás da transação de aprovação"
},
"approve": {
"message": "Aprovar limite de gastos"
},
@ -1031,10 +1022,6 @@
"externalExtension": {
"message": "Extensão externa"
},
"extraApprovalGas": {
"message": "+$1 de gás por aprovação",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Falhou"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Я согласен(-на)"
},
"aggregatorFeeCost": {
"message": "Комиссия сети агрегатора"
},
"airgapVault": {
"message": "Хранилище AirGap"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Комиссия сети за одобрение и для агрегатора"
},
"approvalTxGasCost": {
"message": "Стоимость газа для утверждения транзакции"
},
"approve": {
"message": "Одобрить лимит расходов"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Внешнее расширение"
},
"extraApprovalGas": {
"message": "+$1 газа для утверждения",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Не удалось"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Sang-ayon Ako"
},
"aggregatorFeeCost": {
"message": "Bayarin sa aggregator network"
},
"airgapVault": {
"message": "AirGap Vault"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Bayarin sa pag-apruba at aggregator network"
},
"approvalTxGasCost": {
"message": "Pag-apruba Tx Halaga ng Gas"
},
"approve": {
"message": "Aprubahan ang limitasyon sa paggastos"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "External Extension"
},
"extraApprovalGas": {
"message": "+$1 na pag-apruba sa gas",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Hindi matagumpay"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Kabul Ediyorum"
},
"aggregatorFeeCost": {
"message": "Toplayıcı ağ ücreti"
},
"airgapVault": {
"message": "AirGap Kasası"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Onaylayıcı ve toplayıcı ağ ücreti"
},
"approvalTxGasCost": {
"message": "Onaylayıcı İşlem Gaz Maliyeti"
},
"approve": {
"message": "Harcama limitini onayla"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Harici Uzantı"
},
"extraApprovalGas": {
"message": "+1$ onay gazı",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Başarısız oldu"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "Tôi đồng ý"
},
"aggregatorFeeCost": {
"message": "Phí mạng cho trình tổng hợp"
},
"airgapVault": {
"message": "AirGap Vault"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "Phí mạng cho trình tổng hợp và việc phê duyệt"
},
"approvalTxGasCost": {
"message": "Chi phí gas cho giao dịch phê duyệt"
},
"approve": {
"message": "Phê duyệt giới hạn chi tiêu"
},
@ -1174,10 +1165,6 @@
"externalExtension": {
"message": "Tiện ích bên ngoài"
},
"extraApprovalGas": {
"message": "+$1 gas phê duyệt",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "Không thành công"
},

View File

@ -192,9 +192,6 @@
"affirmAgree": {
"message": "我同意"
},
"aggregatorFeeCost": {
"message": "聚合器网络费用"
},
"airgapVault": {
"message": "AirGap Vault"
},
@ -252,12 +249,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "批准和聚合器网络费用"
},
"approvalTxGasCost": {
"message": "批准 Tx 燃料成本"
},
"approve": {
"message": "批准消费限额"
},
@ -1177,10 +1168,6 @@
"externalExtension": {
"message": "外部扩展程序"
},
"extraApprovalGas": {
"message": "额外的 $1 批准燃料",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "失败"
},

View File

@ -179,9 +179,6 @@
"affirmAgree": {
"message": "我同意"
},
"aggregatorFeeCost": {
"message": "聚集器网络手续费"
},
"alertDisableTooltip": {
"message": "这个可以在“设置 > 提醒”中进行更改"
},
@ -233,12 +230,6 @@
"message": "MetaMask Flask",
"description": "The name of the application (Flask)"
},
"approvalAndAggregatorTxFeeCost": {
"message": "批准聚合商网络手续费"
},
"approvalTxGasCost": {
"message": "批准交易燃料成本"
},
"approve": {
"message": "批准消费限额"
},
@ -1017,10 +1008,6 @@
"externalExtension": {
"message": "外部扩展"
},
"extraApprovalGas": {
"message": "+$1 批准燃料",
"description": "Expresses an additional gas amount the user will have to pay, on top of some other displayed amount. $1 is a decimal amount of gas"
},
"failed": {
"message": "失败"
},

View File

@ -10,7 +10,6 @@ import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
// Modal Components
import ConfirmCustomizeGasModal from '../gas-customization/gas-modal-page-container';
import SwapsGasCustomizationModal from '../../../pages/swaps/swaps-gas-customization-modal';
import DepositEtherModal from './deposit-ether-modal';
import AccountDetailsModal from './account-details-modal';
import ExportPrivateKeyModal from './export-private-key-modal';
@ -265,31 +264,6 @@ const MODALS = {
},
},
CUSTOMIZE_METASWAP_GAS: {
contents: <SwapsGasCustomizationModal />,
mobileModalStyle: {
width: '100vw',
height: '100vh',
top: '0',
transform: 'none',
left: '0',
right: '0',
margin: '0 auto',
},
laptopModalStyle: {
width: 'auto',
height: '0px',
top: '80px',
left: '0px',
transform: 'none',
margin: '0 auto',
position: 'relative',
},
contentStyle: {
borderRadius: '8px',
},
},
EDIT_APPROVAL_PERMISSION: {
contents: <EditApprovalPermission />,
mobileModalStyle: {

View File

@ -29,7 +29,6 @@ export default function FeeCard({
primaryFee,
secondaryFee,
hideTokenApprovalRow,
onFeeCardMaxRowClick,
tokenApprovalSourceTokenSymbol,
onTokenApprovalClick,
metaMaskFee,
@ -139,16 +138,6 @@ export default function FeeCard({
{t('maxFee')}
</Typography>
{`: ${secondaryFee.maxFee}`}
{!supportsEIP1559V2 &&
(!smartTransactionsEnabled ||
!smartTransactionsOptInStatus) && (
<span
className="fee-card__edit-link"
onClick={() => onFeeCardMaxRowClick()}
>
{t('edit')}
</span>
)}
</>
)
}
@ -213,7 +202,6 @@ FeeCard.propTypes = {
fee: PropTypes.string.isRequired,
maxFee: PropTypes.string.isRequired,
}),
onFeeCardMaxRowClick: PropTypes.func.isRequired,
hideTokenApprovalRow: PropTypes.bool.isRequired,
tokenApprovalSourceTokenSymbol: PropTypes.string,
onTokenApprovalClick: PropTypes.func,

View File

@ -1,136 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GasCustomizationModalComponent renders the component with initial props 1`] = `
<div
class="page-container__header page-container__header--no-padding-bottom"
data-testid="page-container__header"
>
<div
class="page-container__title"
>
Customize Gas
</div>
<div
class="page-container__subtitle"
>
Increasing fee may decrease processing times, but it is not guaranteed.
</div>
<a
class="button btn-link page-container__header-close-text"
role="button"
tabindex="0"
>
Close
</a>
<ul
class="page-container__tabs"
>
<li
class="tab page-container__tab tab--active"
>
<button>
Basic
</button>
</li>
<li
class="tab page-container__tab"
>
<button>
Advanced
</button>
</li>
</ul>
</div>
`;
exports[`GasCustomizationModalComponent renders the component with initial props 2`] = `
<button
aria-checked="false"
class="button-group__button"
data-testid="button-group__button0"
>
<div>
<div
class="gas-price-button-group__label"
>
Fast
</div>
<div
class="gas-price-button-group__time-estimate"
>
~ 1 min 0 sec
</div>
<div
class="gas-price-button-group__primary-currency"
>
$0.52
</div>
<div
class="gas-price-button-group__secondary-currency"
>
0.0048 ETH
</div>
<div
class="button-check-wrapper"
>
<i
class="fa fa-check fa-sm"
/>
</div>
</div>
</button>
`;
exports[`GasCustomizationModalComponent renders the component with initial props 3`] = `
<div
class="gas-modal-content__info-row__send-info"
data-testid="gas-modal-content__info-row__send-info"
>
<span
class="gas-modal-content__info-row__send-info__label"
>
Send Amount
</span>
<span
class="gas-modal-content__info-row__send-info__value"
>
mockSendAmount
</span>
</div>
`;
exports[`GasCustomizationModalComponent renders the component with initial props 4`] = `
<div
class="gas-modal-content__info-row__transaction-info"
data-testid="gas-modal-content__info-row__transaction-info"
>
<span
class="gas-modal-content__info-row__transaction-info__label"
>
Transaction fee
</span>
<span
class="gas-modal-content__info-row__transaction-info__value"
>
mockTransactionFee
</span>
</div>
`;
exports[`GasCustomizationModalComponent renders the component with initial props 5`] = `
<div
class="gas-modal-content__info-row__total-info"
data-testid="gas-modal-content__info-row__total-info"
>
<span
class="gas-modal-content__info-row__total-info__label"
>
New Total
</span>
<span
class="gas-modal-content__info-row__total-info__value"
>
mockNewTotalEth
</span>
</div>
`;

View File

@ -1,98 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`GasCustomizationModalContainer renders the component with initial props 1`] = `
<div
class="page-container__header page-container__header--no-padding-bottom"
data-testid="page-container__header"
>
<div
class="page-container__title"
>
Customize Gas
</div>
<div
class="page-container__subtitle"
>
Increasing fee may decrease processing times, but it is not guaranteed.
</div>
<a
class="button btn-link page-container__header-close-text"
role="button"
tabindex="0"
>
Close
</a>
<ul
class="page-container__tabs"
>
<li
class="tab page-container__tab tab--active"
>
<button>
Basic
</button>
</li>
<li
class="tab page-container__tab"
>
<button>
Advanced
</button>
</li>
</ul>
</div>
`;
exports[`GasCustomizationModalContainer renders the component with initial props 2`] = `
<div
class="gas-modal-content__info-row__send-info"
data-testid="gas-modal-content__info-row__send-info"
>
<span
class="gas-modal-content__info-row__send-info__label"
>
Send Amount
</span>
<span
class="gas-modal-content__info-row__send-info__value"
>
0 ETH
</span>
</div>
`;
exports[`GasCustomizationModalContainer renders the component with initial props 3`] = `
<div
class="gas-modal-content__info-row__transaction-info"
data-testid="gas-modal-content__info-row__transaction-info"
>
<span
class="gas-modal-content__info-row__transaction-info__label"
>
Transaction fee
</span>
<span
class="gas-modal-content__info-row__transaction-info__value"
>
0 ETH
</span>
</div>
`;
exports[`GasCustomizationModalContainer renders the component with initial props 4`] = `
<div
class="gas-modal-content__info-row__total-info"
data-testid="gas-modal-content__info-row__total-info"
>
<span
class="gas-modal-content__info-row__total-info__label"
>
New Total
</span>
<span
class="gas-modal-content__info-row__total-info__value"
>
0 ETH
</span>
</div>
`;

View File

@ -1 +0,0 @@
export { default } from './swaps-gas-customization-modal.container';

View File

@ -1,281 +0,0 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import PageContainer from '../../../components/ui/page-container';
import { Tabs, Tab } from '../../../components/ui/tabs';
import { calcGasTotal } from '../../send/send.utils';
import { sumHexWEIsToUnformattedFiat } from '../../../helpers/utils/conversions.util';
import AdvancedGasInputs from '../../../components/app/gas-customization/advanced-gas-inputs';
import BasicTabContent from '../../../components/app/gas-customization/gas-modal-page-container/basic-tab-content';
import { GAS_ESTIMATE_TYPES } from '../../../helpers/constants/common';
import { CUSTOM_GAS_ESTIMATE } from '../../../../shared/constants/gas';
import { EVENT } from '../../../../shared/constants/metametrics';
export default class GasModalPageContainer extends Component {
static contextTypes = {
t: PropTypes.func,
trackEvent: PropTypes.func,
};
static propTypes = {
insufficientBalance: PropTypes.bool,
gasPriceButtonGroupProps: PropTypes.object,
infoRowProps: PropTypes.shape({
originalTotalFiat: PropTypes.string,
originalTotalEth: PropTypes.string,
newTotalFiat: PropTypes.string,
newTotalEth: PropTypes.string,
sendAmount: PropTypes.string,
transactionFee: PropTypes.string,
extraInfoRow: PropTypes.shape({
label: PropTypes.string,
value: PropTypes.string,
}),
}),
onSubmit: PropTypes.func,
cancelAndClose: PropTypes.func,
showCustomPriceTooLowWarning: PropTypes.bool,
disableSave: PropTypes.bool,
customGasLimitMessage: PropTypes.string,
customTotalSupplement: PropTypes.string,
usdConversionRate: PropTypes.number,
customGasPrice: PropTypes.string,
customGasLimit: PropTypes.string,
setSwapsCustomizationModalPrice: PropTypes.func,
setSwapsCustomizationModalLimit: PropTypes.func,
gasEstimateLoadingHasFailed: PropTypes.bool,
minimumGasLimit: PropTypes.number.isRequired,
};
state = {
gasSpeedType: '',
};
setGasSpeedType(gasEstimateType) {
if (gasEstimateType === GAS_ESTIMATE_TYPES.AVERAGE) {
this.setState({ gasSpeedType: 'average' });
} else {
this.setState({ gasSpeedType: 'fast' });
}
}
renderBasicTabContent(gasPriceButtonGroupProps) {
return (
<BasicTabContent
gasPriceButtonGroupProps={{
...gasPriceButtonGroupProps,
handleGasPriceSelection: ({ gasPrice, gasEstimateType }) => {
this.setGasSpeedType(gasEstimateType);
this.props.setSwapsCustomizationModalPrice(gasPrice);
},
}}
/>
);
}
renderAdvancedTabContent() {
const {
insufficientBalance,
showCustomPriceTooLowWarning,
infoRowProps: { transactionFee },
customGasLimitMessage,
setSwapsCustomizationModalPrice,
setSwapsCustomizationModalLimit,
customGasPrice,
customGasLimit,
minimumGasLimit,
} = this.props;
return (
<div className="advanced-tab">
<div className="advanced-tab__transaction-data-summary">
<div className="advanced-tab__transaction-data-summary__titles">
<span>{this.context.t('newTransactionFee')}</span>
</div>
<div className="advanced-tab__transaction-data-summary__container">
<div className="advanced-tab__transaction-data-summary__fee">
{transactionFee}
</div>
</div>
</div>
<div className="advanced-tab__fee-chart">
<div className="advanced-tab__gas-inputs">
<AdvancedGasInputs
updateCustomGasPrice={(updatedPrice) => {
this.setState({ gasSpeedType: CUSTOM_GAS_ESTIMATE });
setSwapsCustomizationModalPrice(updatedPrice);
}}
updateCustomGasLimit={(updatedLimit) => {
this.setState({ gasSpeedType: CUSTOM_GAS_ESTIMATE });
setSwapsCustomizationModalLimit(updatedLimit);
}}
customGasPrice={customGasPrice}
customGasLimit={customGasLimit}
insufficientBalance={insufficientBalance}
customPriceIsSafe={!showCustomPriceTooLowWarning}
customGasLimitMessage={customGasLimitMessage}
minimumGasLimit={minimumGasLimit}
/>
</div>
</div>
</div>
);
}
renderInfoRows(
newTotalFiat,
newTotalEth,
sendAmount,
transactionFee,
extraInfoRow,
) {
return (
<div className="gas-modal-content__info-row-wrapper">
<div className="gas-modal-content__info-row">
<div
className="gas-modal-content__info-row__send-info"
data-testid="gas-modal-content__info-row__send-info"
>
<span className="gas-modal-content__info-row__send-info__label">
{this.context.t('sendAmount')}
</span>
<span className="gas-modal-content__info-row__send-info__value">
{sendAmount}
</span>
</div>
<div
className="gas-modal-content__info-row__transaction-info"
data-testid="gas-modal-content__info-row__transaction-info"
>
<span className="gas-modal-content__info-row__transaction-info__label">
{this.context.t('transactionFee')}
</span>
<span className="gas-modal-content__info-row__transaction-info__value">
{transactionFee}
</span>
</div>
{extraInfoRow && (
<div className="gas-modal-content__info-row__transaction-info">
<span className="gas-modal-content__info-row__transaction-info__label">
{extraInfoRow.label}
</span>
<span className="gas-modal-content__info-row__transaction-info__value">
{extraInfoRow.value}
</span>
</div>
)}
<div
className="gas-modal-content__info-row__total-info"
data-testid="gas-modal-content__info-row__total-info"
>
<span className="gas-modal-content__info-row__total-info__label">
{this.context.t('newTotal')}
</span>
<span className="gas-modal-content__info-row__total-info__value">
{newTotalEth}
</span>
</div>
<div className="gas-modal-content__info-row__fiat-total-info">
<span className="gas-modal-content__info-row__fiat-total-info__value">
{newTotalFiat}
</span>
</div>
</div>
</div>
);
}
renderTabs() {
const {
gasPriceButtonGroupProps,
infoRowProps: {
newTotalFiat,
newTotalEth,
sendAmount,
transactionFee,
extraInfoRow,
},
gasEstimateLoadingHasFailed,
} = this.props;
const basicTabInfo = {
name: this.context.t('basic'),
content: this.renderBasicTabContent({
...gasPriceButtonGroupProps,
handleGasPriceSelection: this.props.setSwapsCustomizationModalPrice,
}),
};
const advancedTabInfo = {
name: this.context.t('advanced'),
content: this.renderAdvancedTabContent(),
};
const tabsToRender = gasEstimateLoadingHasFailed
? [advancedTabInfo]
: [basicTabInfo, advancedTabInfo];
return (
<Tabs>
{tabsToRender.map(({ name, content }, i) => (
<Tab name={name} key={`gas-modal-tab-${i}`}>
<div className="gas-modal-content">
{content}
{this.renderInfoRows(
newTotalFiat,
newTotalEth,
sendAmount,
transactionFee,
extraInfoRow,
)}
</div>
</Tab>
))}
</Tabs>
);
}
render() {
const {
cancelAndClose,
onSubmit,
disableSave,
customGasPrice,
customGasLimit,
} = this.props;
return (
<div className="gas-modal-page-container">
<PageContainer
title={this.context.t('customGas')}
subtitle={this.context.t('customGasSubTitle')}
tabsComponent={this.renderTabs()}
disabled={disableSave}
onCancel={() => cancelAndClose()}
onClose={() => cancelAndClose()}
onSubmit={() => {
const newSwapGasTotal = calcGasTotal(
customGasLimit,
customGasPrice,
);
this.context.trackEvent({
event: 'Gas Fees Changed',
category: EVENT.CATEGORIES.SWAPS,
properties: {
speed_set: this.state.gasSpeedType,
gas_fees: sumHexWEIsToUnformattedFiat(
[newSwapGasTotal, this.props.customTotalSupplement],
'usd',
this.props.usdConversionRate,
)?.slice(1),
},
});
onSubmit(customGasLimit, customGasPrice);
}}
submitText={this.context.t('save')}
headerCloseText={this.context.t('close')}
hideCancel
/>
</div>
);
}
}

View File

@ -1,81 +0,0 @@
import React from 'react';
import { renderWithProvider } from '../../../../test/jest';
import GasCustomizationModalComponent from './swaps-gas-customization-modal.component';
const createProps = (customProps = {}) => {
return {
insufficientBalance: false,
onSubmit: jest.fn(),
cancelAndClose: jest.fn(),
minimumGasLimit: 100,
gasPriceButtonGroupProps: {
buttonDataLoading: false,
className: 'gas-price-button-group',
gasButtonInfo: [
{
feeInPrimaryCurrency: '$0.52',
feeInSecondaryCurrency: '0.0048 ETH',
timeEstimate: '~ 1 min 0 sec',
priceInHexWei: '0xa1b2c3f',
gasEstimateType: 'FAST',
},
{
feeInPrimaryCurrency: '$0.39',
feeInSecondaryCurrency: '0.004 ETH',
timeEstimate: '~ 1 min 30 sec',
priceInHexWei: '0xa1b2c39',
gasEstimateType: 'FAST',
},
{
feeInPrimaryCurrency: '$0.30',
feeInSecondaryCurrency: '0.00354 ETH',
timeEstimate: '~ 2 min 1 sec',
priceInHexWei: '0xa1b2c30',
gasEstimateType: 'FAST',
},
],
handleGasPriceSelection: 'mockSelectionFunction',
noButtonActiveByDefault: true,
showCheck: true,
newTotalFiat: 'mockNewTotalFiat',
newTotalEth: 'mockNewTotalEth',
},
infoRowProps: {
originalTotalFiat: 'mockOriginalTotalFiat',
originalTotalEth: 'mockOriginalTotalEth',
newTotalFiat: 'mockNewTotalFiat',
newTotalEth: 'mockNewTotalEth',
sendAmount: 'mockSendAmount',
transactionFee: 'mockTransactionFee',
extraInfoRow: { label: 'mockLabel', value: 'mockValue' },
},
...customProps,
};
};
describe('GasCustomizationModalComponent', () => {
it('renders the component with initial props', () => {
const props = createProps();
const { getByText, getByTestId } = renderWithProvider(
<GasCustomizationModalComponent {...props} />,
);
expect(getByTestId('page-container__header')).toMatchSnapshot();
expect(getByText('$0.52')).toBeInTheDocument();
expect(getByText('0.0048 ETH')).toBeInTheDocument();
expect(getByTestId('button-group__button0')).toMatchSnapshot();
expect(getByText('~ 1 min 30 sec')).toBeInTheDocument();
expect(getByText('$0.39')).toBeInTheDocument();
expect(getByText('0.004 ETH')).toBeInTheDocument();
expect(
getByTestId('gas-modal-content__info-row__send-info'),
).toMatchSnapshot();
expect(
getByTestId('gas-modal-content__info-row__transaction-info'),
).toMatchSnapshot();
expect(
getByTestId('gas-modal-content__info-row__total-info'),
).toMatchSnapshot();
expect(getByText('Save')).toBeInTheDocument();
});
});

View File

@ -1,186 +0,0 @@
import { connect } from 'react-redux';
import BigNumber from 'bignumber.js';
import { hideModal, customSwapsGasParamsUpdated } from '../../../store/actions';
import {
conversionRateSelector as getConversionRate,
getCurrentCurrency,
getCurrentEthBalance,
getDefaultActiveButtonIndex,
getRenderableGasButtonData,
getUSDConversionRate,
getSwapsDefaultToken,
} from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import {
getSwapsCustomizationModalPrice,
getSwapsCustomizationModalLimit,
swapGasEstimateLoadingHasFailed,
swapGasPriceEstimateIsLoading,
getSwapGasPriceEstimateData,
swapCustomGasModalPriceEdited,
swapCustomGasModalLimitEdited,
shouldShowCustomPriceTooLowWarning,
swapCustomGasModalClosed,
} from '../../../ducks/swaps/swaps';
import {
addHexes,
getValueFromWeiHex,
sumHexWEIsToRenderableFiat,
} from '../../../helpers/utils/conversions.util';
import { formatETHFee } from '../../../helpers/utils/formatters';
import { calcGasTotal, isBalanceSufficient } from '../../send/send.utils';
import SwapsGasCustomizationModalComponent from './swaps-gas-customization-modal.component';
const mapStateToProps = (state) => {
const currentCurrency = getCurrentCurrency(state);
const conversionRate = getConversionRate(state);
const nativeCurrencySymbol = getNativeCurrency(state);
const { symbol: swapsDefaultCurrencySymbol } = getSwapsDefaultToken(state);
const usedCurrencySymbol = nativeCurrencySymbol || swapsDefaultCurrencySymbol;
const { modalState: { props: modalProps } = {} } = state.appState.modal || {};
const {
value,
customGasLimitMessage = '',
customTotalSupplement = '',
extraInfoRow = null,
initialGasPrice,
initialGasLimit,
minimumGasLimit,
} = modalProps;
const buttonDataLoading = swapGasPriceEstimateIsLoading(state);
const swapsCustomizationModalPrice = getSwapsCustomizationModalPrice(state);
const swapsCustomizationModalLimit = getSwapsCustomizationModalLimit(state);
const customGasPrice = swapsCustomizationModalPrice || initialGasPrice;
const customGasLimit = swapsCustomizationModalLimit || initialGasLimit;
const customGasTotal = calcGasTotal(customGasLimit, customGasPrice);
const gasEstimates = getSwapGasPriceEstimateData(state);
const gasEstimatesInNewFormat = {
low: gasEstimates.safeLow,
medium: gasEstimates.average,
high: gasEstimates.fast,
};
const { averageEstimateData, fastEstimateData } = getRenderableGasButtonData(
gasEstimatesInNewFormat,
customGasLimit,
true,
conversionRate,
currentCurrency,
usedCurrencySymbol,
);
const gasButtonInfo = [averageEstimateData, fastEstimateData];
const newTotalFiat = sumHexWEIsToRenderableFiat(
[value, customGasTotal, customTotalSupplement],
currentCurrency,
conversionRate,
);
const balance = getCurrentEthBalance(state);
const newTotalEth = sumHexWEIsToRenderableEth(
[value, customGasTotal, customTotalSupplement],
usedCurrencySymbol,
);
const sendAmount = sumHexWEIsToRenderableEth(
[value, '0x0'],
usedCurrencySymbol,
);
const insufficientBalance = !isBalanceSufficient({
amount: value,
gasTotal: customGasTotal,
balance,
conversionRate,
});
const customGasLimitTooLow = new BigNumber(customGasLimit, 16).lt(
minimumGasLimit,
10,
);
return {
customGasPrice,
customGasLimit,
showCustomPriceTooLowWarning: shouldShowCustomPriceTooLowWarning(state),
gasPriceButtonGroupProps: {
buttonDataLoading,
defaultActiveButtonIndex: getDefaultActiveButtonIndex(
gasButtonInfo,
customGasPrice,
),
gasButtonInfo,
},
infoRowProps: {
originalTotalFiat: sumHexWEIsToRenderableFiat(
[value, customGasTotal, customTotalSupplement],
currentCurrency,
conversionRate,
),
originalTotalEth: sumHexWEIsToRenderableEth(
[value, customGasTotal, customTotalSupplement],
usedCurrencySymbol,
),
newTotalFiat,
newTotalEth,
transactionFee: sumHexWEIsToRenderableEth(
['0x0', customGasTotal],
usedCurrencySymbol,
),
sendAmount,
extraInfoRow,
},
gasEstimateLoadingHasFailed: swapGasEstimateLoadingHasFailed(state),
insufficientBalance,
customGasLimitMessage,
customTotalSupplement,
usdConversionRate: getUSDConversionRate(state),
disableSave: insufficientBalance || customGasLimitTooLow,
minimumGasLimit,
};
};
const mapDispatchToProps = (dispatch) => {
return {
cancelAndClose: () => {
dispatch(swapCustomGasModalClosed());
dispatch(hideModal());
},
onSubmit: async (gasLimit, gasPrice) => {
await dispatch(customSwapsGasParamsUpdated(gasLimit, gasPrice));
dispatch(swapCustomGasModalClosed());
dispatch(hideModal());
},
setSwapsCustomizationModalPrice: (newPrice) => {
dispatch(swapCustomGasModalPriceEdited(newPrice));
},
setSwapsCustomizationModalLimit: (newLimit) => {
dispatch(swapCustomGasModalLimitEdited(newLimit));
},
};
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(SwapsGasCustomizationModalComponent);
function sumHexWEIsToRenderableEth(hexWEIs, currencySymbol = 'ETH') {
const hexWEIsSum = hexWEIs.filter(Boolean).reduce(addHexes);
return formatETHFee(
getValueFromWeiHex({
value: hexWEIsSum,
fromCurrency: currencySymbol,
toCurrency: currencySymbol,
numberOfDecimals: 6,
}),
currencySymbol,
);
}

View File

@ -1,34 +0,0 @@
import React from 'react';
import configureMockStore from 'redux-mock-store';
import {
renderWithProvider,
createSwapsMockStore,
} from '../../../../test/jest';
import GasCustomizationModalContainer from '.';
describe('GasCustomizationModalContainer', () => {
it('renders the component with initial props', () => {
const store = configureMockStore()(createSwapsMockStore());
const { getByText, getByTestId } = renderWithProvider(
<GasCustomizationModalContainer />,
store,
);
expect(getByTestId('page-container__header')).toMatchSnapshot();
expect(getByText('Basic')).toBeInTheDocument();
expect(getByText('Advanced')).toBeInTheDocument();
expect(getByText('Estimated Processing Times')).toBeInTheDocument();
expect(getByText('Send Amount')).toBeInTheDocument();
expect(getByText('Transaction fee')).toBeInTheDocument();
expect(
getByTestId('gas-modal-content__info-row__send-info'),
).toMatchSnapshot();
expect(
getByTestId('gas-modal-content__info-row__transaction-info'),
).toMatchSnapshot();
expect(
getByTestId('gas-modal-content__info-row__total-info'),
).toMatchSnapshot();
expect(getByText('Save')).toBeInTheDocument();
});
});

View File

@ -1,253 +0,0 @@
import React, { useEffect, useState } from 'react';
import { Provider } from 'react-redux';
import configureStore from '../../../store/store';
import testData from '../../../../.storybook/test-data';
import { formatETHFee } from '../../../helpers/utils/formatters';
import {
addHexes,
getValueFromWeiHex,
getWeiHexFromDecimalValue,
sumHexWEIsToRenderableFiat,
} from '../../../helpers/utils/conversions.util';
import { ETH } from '../../../helpers/constants/common';
import { calcGasTotal, isBalanceSufficient } from '../../send/send.utils';
import { conversionLessThan } from '../../../../shared/modules/conversion.utils';
import GasModalPageContainer from './swaps-gas-customization-modal.component';
// Using Test Data For Redux
const store = configureStore(testData);
export default {
title: 'Pages/Swaps/GasModalPageContainer',
id: __filename,
component: GasModalPageContainer,
argTypes: {
sendAmountArg: {
name: 'Send Amount (this should be static)',
control: { type: 'number', min: 0, step: 0.01 },
},
walletBalance: {
name: 'Wallet Balance (this should be static)',
control: { type: 'number', min: 0, step: 0.01 },
},
averageGasPrice: {
name: 'Average Gas Price',
control: { type: 'number', min: 0, step: 0.01 },
},
insufficientBalance: {
table: {
disable: true,
},
},
gasPriceButtonGroupProps: {
table: {
disable: true,
},
},
infoRowProps: {
table: {
disable: true,
},
},
onSubmit: {
table: {
disable: true,
},
},
cancelAndClose: {
table: {
disable: true,
},
},
showCustomPriceTooLowWarning: {
table: {
disable: true,
},
},
disableSave: {
table: {
disable: true,
},
},
customGasLimitMessage: {
table: {
disable: true,
},
},
usdConversionRate: {
table: {
disable: true,
},
},
customGasPrice: {
table: {
disable: true,
},
},
customGasLimit: {
table: {
disable: true,
},
},
setSwapsCustomizationModalLimit: {
table: {
disable: true,
},
},
setSwapsCustomizationModalPrice: {
table: {
disable: true,
},
},
customTotalSupplement: {
table: {
disable: true,
},
},
gasEstimateLoadingHasFailed: {
table: {
disable: true,
},
},
minimumGasLimit: {
table: {
disable: true,
},
},
},
args: {
sendAmountArg: 0.01,
walletBalance: 10,
averageGasPrice: 2,
},
decorators: [(story) => <Provider store={store}>{story()}</Provider>],
};
// Convert Hex Wei to Decimal ETH
const sumHexWEIsToRenderableEth = (hexWEIs, currencySymbol = 'ETH') => {
const hexWEIsSum = hexWEIs.filter(Boolean).reduce(addHexes);
return formatETHFee(
getValueFromWeiHex({
value: hexWEIsSum,
fromCurrency: currencySymbol,
toCurrency: currencySymbol,
numberOfDecimals: 6,
}),
currencySymbol,
);
};
export const DefaultStory = (args) => {
const { sendAmountArg, walletBalance, averageGasPrice } = args;
const hexWei = getWeiHexFromDecimalValue({
value: sendAmountArg,
fromCurrency: ETH,
fromDenomination: ETH,
});
// ETH Balance
const balanceHexWei = getWeiHexFromDecimalValue({
value: walletBalance,
fromCurrency: ETH,
fromDenomination: ETH,
});
const sendAmount = sumHexWEIsToRenderableEth([hexWei, '0x0']);
const [gasLimit, setGasLimit] = useState('5208');
const [gasPrice, setGasPrice] = useState('ee6b2800');
const [transactionFee, setTransactionFee] = useState('');
const [totalETH, setTotalETH] = useState('');
const [totalFiat, setTotalFiat] = useState('');
const [isInsufficientBalance, setIsInsufficientBalance] = useState(false);
const { metamask } = store.getState();
const { currentCurrency, conversionRate } = metamask;
useEffect(() => {
// Transfer Fee
const customGasTotal = calcGasTotal(gasLimit, gasPrice);
setTransactionFee(sumHexWEIsToRenderableEth(['0x0', customGasTotal]));
// New Total ETH
setTotalETH(sumHexWEIsToRenderableEth([hexWei, customGasTotal, '']));
// New Total Fiat
setTotalFiat(
sumHexWEIsToRenderableFiat(
[hexWei, customGasTotal, ''],
currentCurrency,
conversionRate,
),
);
// Check If Balance is Sufficient
setIsInsufficientBalance(
!isBalanceSufficient({
amount: hexWei,
gasTotal: customGasTotal,
balance: balanceHexWei,
conversionRate,
}),
);
}, [
gasPrice,
gasLimit,
hexWei,
totalETH,
conversionRate,
currentCurrency,
totalFiat,
balanceHexWei,
]);
// Check If Gas Price Is Too Low
const shouldShowCustomPriceTooLowWarning = () => {
const customGasPrice = gasPrice;
if (!customGasPrice || averageGasPrice === undefined) {
return false;
}
const customPriceRisksSwapFailure = conversionLessThan(
{
value: customGasPrice,
fromNumericBase: 'hex',
fromDenomination: 'WEI',
toDenomination: 'GWEI',
},
{ value: averageGasPrice, fromNumericBase: 'dec' },
);
return customPriceRisksSwapFailure;
};
return (
<GasModalPageContainer
insufficientBalance={isInsufficientBalance}
showCustomPriceTooLowWarning={shouldShowCustomPriceTooLowWarning()}
minimumGasLimit={21000}
infoRowProps={{
sendAmount,
transactionFee,
newTotalEth: totalETH,
newTotalFiat: totalFiat,
}}
gasPriceButtonGroupProps={{
buttonDataLoading: true,
}}
setSwapsCustomizationModalPrice={(newPrice) => {
setGasPrice(newPrice);
}}
setSwapsCustomizationModalLimit={(newLimit) => {
setGasLimit(newLimit);
}}
customGasPrice={gasPrice}
customGasLimit={gasLimit}
disableSave={
isInsufficientBalance || shouldShowCustomPriceTooLowWarning()
}
/>
);
};
DefaultStory.storyName = 'Default';

View File

@ -19,7 +19,6 @@ import { usePrevious } from '../../../hooks/usePrevious';
import { useGasFeeInputs } from '../../../hooks/gasFeeInput/useGasFeeInputs';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import FeeCard from '../fee-card';
import EditGasPopover from '../../../components/app/edit-gas-popover/edit-gas-popover.component';
import {
FALLBACK_GAS_MULTIPLIER,
getQuotes,
@ -89,16 +88,12 @@ import {
} from '../../../helpers/utils/token-util';
import {
decimalToHex,
hexToDecimal,
getValueFromWeiHex,
decGWEIToHexWEI,
hexWEIToDecGWEI,
addHexes,
} from '../../../helpers/utils/conversions.util';
import { GasFeeContextProvider } from '../../../contexts/gasFee';
import { TransactionModalContextProvider } from '../../../contexts/transaction-modal';
import AdvancedGasFeePopover from '../../../components/app/advanced-gas-fee-popover';
import EditGasFeePopover from '../../../components/app/edit-gas-fee-popover';
import MainQuoteSummary from '../main-quote-summary';
import { calcGasTotal } from '../../send/send.utils';
import { getCustomTxParamsData } from '../../confirm-approve/confirm-approve.util';
@ -137,7 +132,6 @@ export default function ViewQuote() {
const [selectQuotePopoverShown, setSelectQuotePopoverShown] = useState(false);
const [warningHidden, setWarningHidden] = useState(false);
const [originalApproveAmount, setOriginalApproveAmount] = useState(null);
const [showEditGasPopover, setShowEditGasPopover] = useState(false);
// We need to have currentTimestamp in state, otherwise it would change with each rerender.
const [currentTimestamp] = useState(Date.now());
@ -391,7 +385,6 @@ export default function ViewQuote() {
rawEthFee: maxRawEthFee,
feeInUsd: maxFeeInUsd,
} = renderableMaxFees;
const { nonGasFee } = renderableMaxFees;
additionalTrackingParams.reg_tx_max_fee_in_usd = Number(maxFeeInUsd);
additionalTrackingParams.reg_tx_max_fee_in_eth = Number(maxRawEthFee);
@ -678,53 +671,6 @@ export default function ViewQuote() {
);
};
const nonGasFeeIsPositive = new BigNumber(nonGasFee, 16).gt(0);
const approveGasTotal = calcGasTotal(
approveGas || '0x0',
networkAndAccountSupports1559 ? baseAndPriorityFeePerGas : gasPrice,
);
const extraNetworkFeeTotalInHexWEI = new BigNumber(nonGasFee, 16)
.plus(approveGasTotal, 16)
.toString(16);
const extraNetworkFeeTotalInEth = getValueFromWeiHex({
value: extraNetworkFeeTotalInHexWEI,
toDenomination: 'ETH',
numberOfDecimals: 4,
});
let extraInfoRowLabel = '';
if (approveGas && nonGasFeeIsPositive) {
extraInfoRowLabel = t('approvalAndAggregatorTxFeeCost');
} else if (approveGas) {
extraInfoRowLabel = t('approvalTxGasCost');
} else if (nonGasFeeIsPositive) {
extraInfoRowLabel = t('aggregatorFeeCost');
}
const onFeeCardMaxRowClick = () => {
networkAndAccountSupports1559
? setShowEditGasPopover(true)
: dispatch(
showModal({
name: 'CUSTOMIZE_METASWAP_GAS',
value: tradeValue,
customGasLimitMessage: approveGas
? t('extraApprovalGas', [hexToDecimal(approveGas)])
: '',
customTotalSupplement: approveGasTotal,
extraInfoRow: extraInfoRowLabel
? {
label: extraInfoRowLabel,
value: `${extraNetworkFeeTotalInEth} ${nativeCurrencySymbol}`,
}
: null,
initialGasPrice: gasPrice,
initialGasLimit: maxGasLimit,
minimumGasLimit: new BigNumber(nonCustomMaxGasLimit, 16).toNumber(),
}),
);
};
const actionableBalanceErrorMessage = tokenBalanceUnavailable
? t('swapTokenBalanceUnavailable', [sourceTokenSymbol])
: t('swapApproveNeedMoreTokens', [
@ -863,10 +809,6 @@ export default function ViewQuote() {
isSwapButtonDisabled,
]);
const onCloseEditGasPopover = () => {
setShowEditGasPopover(false);
};
useEffect(() => {
// Thanks to the next line we will only do quotes polling 3 times before showing a Quote Timeout modal.
dispatch(setSwapsQuotesPollingLimitEnabled(true));
@ -928,25 +870,6 @@ export default function ViewQuote() {
/>
)}
{!supportsEIP1559V2 &&
showEditGasPopover &&
networkAndAccountSupports1559 && (
<EditGasPopover
transaction={transaction}
minimumGasLimit={usedGasLimit}
defaultEstimateToUse={GAS_RECOMMENDATIONS.HIGH}
mode={EDIT_GAS_MODES.SWAPS}
confirmButtonText={t('submit')}
onClose={onCloseEditGasPopover}
/>
)}
{supportsEIP1559V2 && (
<>
<EditGasFeePopover />
<AdvancedGasFeePopover />
</>
)}
<div
className={classnames('view-quote__warning-wrapper', {
'view-quote__warning-wrapper--thin': !isShowingWarning,
@ -1008,7 +931,6 @@ export default function ViewQuote() {
fee: feeInFiat,
maxFee: maxFeeInFiat,
}}
onFeeCardMaxRowClick={onFeeCardMaxRowClick}
hideTokenApprovalRow={
!approveTxParams || (balanceError && !warningHidden)
}