From e2c481639492d46b2712b1201916013fdb4a0650 Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Sat, 26 Aug 2023 19:58:26 -0500 Subject: [PATCH] split advancedGasFee by network and erase previous options (#20576) * Split out advanced gas fees by network and delete old values * use arrow functions in preferences test * changes * added back priorityFeeProperCase to en messages * update types * remove case change --- app/_locales/de/messages.json | 9 - app/_locales/el/messages.json | 9 - app/_locales/en/messages.json | 9 +- app/_locales/es/messages.json | 9 - app/_locales/es_419/messages.json | 9 - app/_locales/fr/messages.json | 9 - app/_locales/hi/messages.json | 9 - app/_locales/id/messages.json | 9 - app/_locales/it/messages.json | 6 - app/_locales/ja/messages.json | 9 - app/_locales/ko/messages.json | 9 - app/_locales/pt/messages.json | 9 - app/_locales/pt_BR/messages.json | 9 - app/_locales/ru/messages.json | 9 - app/_locales/tl/messages.json | 9 - app/_locales/tr/messages.json | 9 - app/_locales/vi/messages.json | 9 - app/_locales/zh_CN/messages.json | 9 - app/scripts/controllers/app-state.js | 4 + app/scripts/controllers/preferences.js | 16 +- app/scripts/controllers/preferences.test.js | 24 ++- app/scripts/controllers/transactions/index.js | 8 +- .../controllers/transactions/index.test.js | 3 + app/scripts/migrations/092.3.test.ts | 184 ++++++++++++++++++ app/scripts/migrations/092.3.ts | 98 ++++++++++ app/scripts/migrations/index.js | 2 + test/data/mock-state.json | 7 +- ...rs-after-init-opt-in-background-state.json | 1 + .../errors-after-init-opt-in-ui-state.json | 1 + .../advanced-gas-fee-defaults.js | 25 ++- .../advanced-gas-fee-defaults.test.js | 57 +++--- .../priority-fee-input.test.js | 3 +- .../edit-gas-fee-popover.test.js | 1 + .../edit-gas-item/edit-gas-item.test.js | 11 +- .../signature-request-header.test.js.snap | 4 +- .../signature-request-original.test.js.snap | 4 +- .../signature-request-siwe.test.js.snap | 4 +- ...ture-request-header.component.test.js.snap | 4 +- ui/selectors/selectors.js | 33 ++-- ui/selectors/selectors.test.js | 5 - ui/store/actions.ts | 2 +- 41 files changed, 413 insertions(+), 247 deletions(-) create mode 100644 app/scripts/migrations/092.3.test.ts create mode 100644 app/scripts/migrations/092.3.ts diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index d7a90dc46..3876d50be 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Erweiterte Einstellungen" }, - "advancedGasFeeDefaultOptIn": { - "message": "Speichern Sie diese $1 als Standard für \"Erweitert\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Immer diese Werte und erweiterte Einstellung als Standard verwenden." - }, "advancedGasFeeModalTitle": { "message": "Erweiterte Gasgebühr" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Token importiert" }, - "newValues": { - "message": "neue Werte" - }, "next": { "message": "Weiter" }, diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index af006198f..bcff6bc6f 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Προηγμένη ρύθμιση παραμέτρων" }, - "advancedGasFeeDefaultOptIn": { - "message": "Αποθηκεύστε αυτά τα $1 ως προεπιλογή μου για το \"Προηγμένο\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Να χρησιμοποιούνται πάντα αυτές τις τιμές και η ρύθμιση για προχωρημένους." - }, "advancedGasFeeModalTitle": { "message": "Προηγμένη χρέωση τελών συναλλαγής" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Τα token εισήχθησαν" }, - "newValues": { - "message": "νέες τιμές" - }, "next": { "message": "Επόμενο" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index c267d5feb..3fbc3e374 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -306,10 +306,8 @@ "message": "Advanced configuration" }, "advancedGasFeeDefaultOptIn": { - "message": "Save these $1 as my default for \"Advanced\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Always use these values and advanced setting as default." + "message": "Save these values as my default for the $1 network.", + "description": "$1 is the current network name." }, "advancedGasFeeModalTitle": { "message": "Advanced gas fee" @@ -2483,9 +2481,6 @@ "newTokensImportedTitle": { "message": "Token imported" }, - "newValues": { - "message": "new values" - }, "next": { "message": "Next" }, diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 22f8a2071..58fae7bac 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Configuración avanzada" }, - "advancedGasFeeDefaultOptIn": { - "message": "Guarda estos 1$ como mi valor predeterminado para \"Avanzado\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Usar siempre estos valores y la configuración avanzada como valores predeterminados." - }, "advancedGasFeeModalTitle": { "message": "Tarifa de gas avanzada" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Token importado" }, - "newValues": { - "message": "nuevos valores" - }, "next": { "message": "Siguiente" }, diff --git a/app/_locales/es_419/messages.json b/app/_locales/es_419/messages.json index 74d738b6e..260bd4501 100644 --- a/app/_locales/es_419/messages.json +++ b/app/_locales/es_419/messages.json @@ -148,12 +148,6 @@ "advancedBaseGasFeeToolTip": { "message": "Cuando su transacción se incluya en el bloque, se reembolsará cualquier diferencia entre su tarifa base máxima y la tarifa base real. El importe total se calcula como tarifa base máxima (en GWEI) * límite de gas." }, - "advancedGasFeeDefaultOptIn": { - "message": "Guarda estos 1$ como mi valor predeterminado para \"Avanzado\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Usar siempre estos valores y la configuración avanzada como valores predeterminados." - }, "advancedGasFeeModalTitle": { "message": "Tarifa de gas avanzada" }, @@ -1431,9 +1425,6 @@ "newPassword": { "message": "Contraseña nueva (mín. de 8 caracteres)" }, - "newValues": { - "message": "nuevos valores" - }, "next": { "message": "Siguiente" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index a8974ea1d..3a5e98789 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Configuration avancée" }, - "advancedGasFeeDefaultOptIn": { - "message": "Enregistrer ces $1 comme valeur par défaut pour « Avancé »" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Toujours utiliser par défaut ces valeurs et les paramètres avancés." - }, "advancedGasFeeModalTitle": { "message": "Frais de carburant avancés" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Jeton importé" }, - "newValues": { - "message": "nouvelles valeurs" - }, "next": { "message": "Suivant" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index b0ffcb805..55e2cd873 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "उन्नत कंफिगुरेशन" }, - "advancedGasFeeDefaultOptIn": { - "message": "इन $1 को \"एडवांस\" के लिए मेरे डिफॉल्ट के रूप में सहेजें" - }, - "advancedGasFeeDefaultOptOut": { - "message": "हमेशा इन मूल्यों और एडवांस सेटिंग को डिफॉल्ट के रूप में उपयोग करें।" - }, "advancedGasFeeModalTitle": { "message": "एडवांस गैस शुल्क" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "टोकन इम्पोर्ट हो गया" }, - "newValues": { - "message": "नए मान" - }, "next": { "message": "अगला" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index cf38c0ad8..479345522 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Konfigurasi lanjutan" }, - "advancedGasFeeDefaultOptIn": { - "message": "Simpan $1 ini sebagai default saya untuk \"Lanjutan\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Selalu gunakan nilai ini dan pengaturan lanjutan sebagai default." - }, "advancedGasFeeModalTitle": { "message": "Biaya gas lanjutan" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Token diimpor" }, - "newValues": { - "message": "nilai baru" - }, "next": { "message": "Berikutnya" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 05b14eaaf..d6000ff93 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -213,12 +213,6 @@ "advancedBaseGasFeeToolTip": { "message": "Quando la tua transazione viene inclusa nel blocco, ogni differenza tra la tua offerta massima di gas e il gas effettivamente utilizzato viene restituita a te. Il totale viene calcolato come offerta massima di gas (in GEWI) * limite di gas." }, - "advancedGasFeeDefaultOptIn": { - "message": "Salva queste $1 come mie preferite per \"Avanzate\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Utilizzare sempre questi valori e l'impostazione avanzata come predefiniti." - }, "advancedGasFeeModalTitle": { "message": "Tariffa gas avanzata" }, diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index f9738e5a1..bd1137b30 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "詳細設定" }, - "advancedGasFeeDefaultOptIn": { - "message": "これらの$1を「高度な設定」のデフォルトとして保存" - }, - "advancedGasFeeDefaultOptOut": { - "message": "常にこれらの値と高度な設定をデフォルトとして使用します。" - }, "advancedGasFeeModalTitle": { "message": "高度なガス代" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "トークンがインポートされました" }, - "newValues": { - "message": "新しい値" - }, "next": { "message": "次へ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index f45b9eca4..5735d71c8 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "고급 옵션" }, - "advancedGasFeeDefaultOptIn": { - "message": "이 $1 옵션을 \"고급\"의 기본값으로 저장합니다" - }, - "advancedGasFeeDefaultOptOut": { - "message": "항상 이 값과 고급 설정을 기본값으로 사용합니다." - }, "advancedGasFeeModalTitle": { "message": "고급 가스 요금" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "불러온 토큰" }, - "newValues": { - "message": "새로운 가치" - }, "next": { "message": "다음" }, diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index 85e6744f6..82bec5580 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Configurações avançadas" }, - "advancedGasFeeDefaultOptIn": { - "message": "Salvar estes $1 como meu padrão para \"Avançado\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Sempre utilizar esses valores e a configuração avançada por padrão." - }, "advancedGasFeeModalTitle": { "message": "Taxa de gás avançada" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Token importado" }, - "newValues": { - "message": "novos valores" - }, "next": { "message": "Próximo" }, diff --git a/app/_locales/pt_BR/messages.json b/app/_locales/pt_BR/messages.json index 3ddc1aa19..1f049e28b 100644 --- a/app/_locales/pt_BR/messages.json +++ b/app/_locales/pt_BR/messages.json @@ -148,12 +148,6 @@ "advancedBaseGasFeeToolTip": { "message": "Quando a sua transação for incluída no bloco, qualquer diferença entre a sua taxa de base máxima e a taxa de base real será reembolsada. O cálculo do valor total é feito da seguinte forma: taxa de base máxima (em GWEI) * limite de gás." }, - "advancedGasFeeDefaultOptIn": { - "message": "Salvar estes $1 como meu padrão para \"Avançado\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Sempre utilizar esses valores e a configuração avançada por padrão." - }, "advancedGasFeeModalTitle": { "message": "Taxa de gás avançada" }, @@ -1431,9 +1425,6 @@ "newPassword": { "message": "Nova senha (no mínimo 8 caracteres)" }, - "newValues": { - "message": "novos valores" - }, "next": { "message": "Seguinte" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index a72f54a58..45e602cfd 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Расширенная конфигурация" }, - "advancedGasFeeDefaultOptIn": { - "message": "Сохранить этот $1 в качестве моего значения по умолчанию для «Дополнительной» настройки" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Всегда использовать эти значения и дополнительную настройку по умолчанию." - }, "advancedGasFeeModalTitle": { "message": "Дополнительная плата за газ" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Токен импортирован" }, - "newValues": { - "message": "новые значения" - }, "next": { "message": "Далее" }, diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json index 9203fa22b..cb0a2f75a 100644 --- a/app/_locales/tl/messages.json +++ b/app/_locales/tl/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Advanced na pagsasaayos" }, - "advancedGasFeeDefaultOptIn": { - "message": "I-save itong mga $1bilang aking default para sa \"Advanced\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Laging gamitin ang mga value na ito at advanced setting bilang default." - }, "advancedGasFeeModalTitle": { "message": "Advanced na gas fee" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Na-import ang token" }, - "newValues": { - "message": "bagong value" - }, "next": { "message": "Susunod" }, diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json index 9a6f53aad..cd04f8aff 100644 --- a/app/_locales/tr/messages.json +++ b/app/_locales/tr/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Gelişmiş yapılandırma" }, - "advancedGasFeeDefaultOptIn": { - "message": "\"Gelişmiş\" için şunları varsayılanım olarak kaydet: $1" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Varsayılan olarak her zaman bu değerleri ve gelişmiş ayarı kullan." - }, "advancedGasFeeModalTitle": { "message": "Gelişmiş gaz ücreti" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Token içe aktarıldı" }, - "newValues": { - "message": "yeni değerler" - }, "next": { "message": "Sonraki" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index 4cee139f5..2acb4f625 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "Cấu hình nâng cao" }, - "advancedGasFeeDefaultOptIn": { - "message": "Lưu $1 này làm mặc định của tôi cho \"Nâng cao\"" - }, - "advancedGasFeeDefaultOptOut": { - "message": "Luôn sử dụng các giá trị và thiết lập nâng cao này làm mặc định." - }, "advancedGasFeeModalTitle": { "message": "Phí gas nâng cao" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "Đã nhập token" }, - "newValues": { - "message": "giá trị mới" - }, "next": { "message": "Tiếp theo" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index c36fcce77..9107f71a2 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -275,12 +275,6 @@ "advancedConfiguration": { "message": "高级配置" }, - "advancedGasFeeDefaultOptIn": { - "message": "将这些 $1 保存为“高级”默认值" - }, - "advancedGasFeeDefaultOptOut": { - "message": "始终使用这些值和高级设置作为默认值。" - }, "advancedGasFeeModalTitle": { "message": "高级燃料费" }, @@ -2101,9 +2095,6 @@ "newTokensImportedTitle": { "message": "已导入代币" }, - "newValues": { - "message": "新的值" - }, "next": { "message": "下一步" }, diff --git a/app/scripts/controllers/app-state.js b/app/scripts/controllers/app-state.js index 1bbf4a4f8..3eec99a87 100644 --- a/app/scripts/controllers/app-state.js +++ b/app/scripts/controllers/app-state.js @@ -52,6 +52,10 @@ export default class AppStateController extends EventEmitter { ...initState, qrHardware: {}, nftsDropdownState: {}, + // This key is only used for checking if the user had set advancedGasFee + // prior to Migration 92.3 where we split out the setting to support + // multiple networks. + hadAdvancedGasFeesSetPriorToMigration92_3: false, usedNetworks: { '0x1': true, '0x5': true, diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 9be792c49..a30d83d76 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -41,7 +41,7 @@ export default class PreferencesController { useNftDetection: false, useCurrencyRateCheck: true, openSeaEnabled: false, - advancedGasFee: null, + advancedGasFee: {}, // WARNING: Do not use feature flags for security-sensitive things. // Feature flag toggling is available in the global namespace @@ -188,10 +188,18 @@ export default class PreferencesController { /** * Setter for the `advancedGasFee` property * - * @param {object} val - holds the maxBaseFee and PriorityFee that the user set as default advanced settings. + * @param {object} options + * @param {string} options.chainId - The chainId the advancedGasFees should be set on + * @param {object} options.gasFeePreferences - The advancedGasFee options to set */ - setAdvancedGasFee(val) { - this.store.updateState({ advancedGasFee: val }); + setAdvancedGasFee({ chainId, gasFeePreferences }) { + const { advancedGasFee } = this.store.getState(); + this.store.updateState({ + advancedGasFee: { + ...advancedGasFee, + [chainId]: gasFeePreferences, + }, + }); } /** diff --git a/app/scripts/controllers/preferences.test.js b/app/scripts/controllers/preferences.test.js index af740eddc..3a1e39aac 100644 --- a/app/scripts/controllers/preferences.test.js +++ b/app/scripts/controllers/preferences.test.js @@ -2,6 +2,7 @@ import { strict as assert } from 'assert'; import sinon from 'sinon'; import { ControllerMessenger } from '@metamask/base-controller'; import { TokenListController } from '@metamask/assets-controllers'; +import { CHAIN_IDS } from '../../../shared/constants/network'; import PreferencesController from './preferences'; describe('preferences controller', function () { @@ -250,24 +251,31 @@ describe('preferences controller', function () { }); describe('setAdvancedGasFee', function () { - it('should default to null', function () { - const state = preferencesController.store.getState(); - assert.equal(state.advancedGasFee, null); + it('should default to an empty object', function () { + assert.deepEqual( + preferencesController.store.getState().advancedGasFee, + {}, + ); }); it('should set the setAdvancedGasFee property in state', function () { const state = preferencesController.store.getState(); - assert.equal(state.advancedGasFee, null); + assert.deepEqual(state.advancedGasFee, {}); preferencesController.setAdvancedGasFee({ - maxBaseFee: '1.5', - priorityFee: '2', + chainId: CHAIN_IDS.GOERLI, + gasFeePreferences: { + maxBaseFee: '1.5', + priorityFee: '2', + }, }); assert.equal( - preferencesController.store.getState().advancedGasFee.maxBaseFee, + preferencesController.store.getState().advancedGasFee[CHAIN_IDS.GOERLI] + .maxBaseFee, '1.5', ); assert.equal( - preferencesController.store.getState().advancedGasFee.priorityFee, + preferencesController.store.getState().advancedGasFee[CHAIN_IDS.GOERLI] + .priorityFee, '2', ); }); diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 37de2830e..3388828b6 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -1962,9 +1962,13 @@ export default class TransactionController extends EventEmitter { */ this.getTransactions = (opts) => this.txStateManager.getTransactions(opts); - /** @returns {object} the saved default values for advancedGasFee */ + /** + * @returns {object} the saved default values for advancedGasFee + */ this.getAdvancedGasFee = () => - this.preferencesStore.getState().advancedGasFee; + this.preferencesStore.getState().advancedGasFee[ + this._getCurrentChainId() + ]; } // called once on startup diff --git a/app/scripts/controllers/transactions/index.test.js b/app/scripts/controllers/transactions/index.test.js index 8600f08dc..04a170e4e 100644 --- a/app/scripts/controllers/transactions/index.test.js +++ b/app/scripts/controllers/transactions/index.test.js @@ -59,6 +59,7 @@ describe('Transaction Controller', function () { fromAccount, fragmentExists, networkStatusStore, + preferencesStore, getCurrentChainId, messengerMock, resultCallbacksMock, @@ -81,6 +82,7 @@ describe('Transaction Controller', function () { }).provider; networkStatusStore = new ObservableStore(currentNetworkStatus); + preferencesStore = new ObservableStore({ advancedGasFee: {} }); fromAccount = getTestAccounts()[0]; const blockTrackerStub = new EventEmitter(); @@ -129,6 +131,7 @@ describe('Transaction Controller', function () { getAccountType: () => 'MetaMask', getDeviceModel: () => 'N/A', securityProviderRequest: () => undefined, + preferencesStore, messenger: messengerMock, }); diff --git a/app/scripts/migrations/092.3.test.ts b/app/scripts/migrations/092.3.test.ts new file mode 100644 index 000000000..f55ea30c6 --- /dev/null +++ b/app/scripts/migrations/092.3.test.ts @@ -0,0 +1,184 @@ +import { migrate } from './092.3'; + +const PREFERENCES_CONTROLLER_MOCK = { + useBlockie: false, + useNonceField: false, + usePhishDetect: true, + dismissSeedBackUpReminder: false, + disabledRpcMethodPreferences: { + eth_sign: false, + }, + useMultiAccountBalanceChecker: true, + useTokenDetection: false, + useNftDetection: false, + use4ByteResolution: true, + useCurrencyRateCheck: true, + openSeaEnabled: false, + advancedGasFee: null, + featureFlags: { + showIncomingTransactions: true, + }, + knownMethodData: {}, + currentLocale: 'EN', + identities: {}, + lostIdentities: {}, + forgottenPassword: false, + preferences: { + autoLockTimeLimit: undefined, + showFiatInTestnets: false, + showTestNetworks: false, + useNativeCurrencyAsPrimaryCurrency: true, + hideZeroBalanceTokens: false, + }, + // ENS decentralized website resolution + ipfsGateway: '', + useAddressBarEnsResolution: true, + infuraBlocked: null, + ledgerTransportType: 'U2F', + snapRegistryList: {}, + transactionSecurityCheckEnabled: false, + theme: 'OS', + isLineaMainnetReleased: false, +}; + +describe('migration #92.3', () => { + it('updates the version metadata', async () => { + const oldStorage = { + meta: { version: 92.2 }, + data: {}, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.meta).toStrictEqual({ version: 92.3 }); + }); + + it('does nothing if no PreferencesController state', async () => { + const oldData = { + some: 'data', + }; + + const oldStorage = { + meta: { version: 92.2 }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.data).toStrictEqual(oldData); + }); + + it('does nothing if no AppStateController state', async () => { + const oldData = { + some: 'data', + }; + + const oldStorage = { + meta: { version: 92.2 }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.data).toStrictEqual(oldData); + }); + + it('changes advancedGasFee from null to an empty object, and sets hadAdvancedGasFeesSetPriorToMigration92_3 to false', async () => { + const oldData = { + some: 'data', + PreferencesController: { + ...PREFERENCES_CONTROLLER_MOCK, + }, + AppStateController: {}, + }; + + const oldStorage = { + meta: { version: 92.2 }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.data).toStrictEqual({ + some: oldData.some, + PreferencesController: { + ...PREFERENCES_CONTROLLER_MOCK, + advancedGasFee: {}, + }, + AppStateController: { + hadAdvancedGasFeesSetPriorToMigration92_3: false, + }, + }); + }); + + it('changes advancedGasFee from an object of values to an empty object and sets hadAdvancedGasFeesSetPriorToMigration92_3 to true', async () => { + const oldData = { + some: 'data', + PreferencesController: { + ...PREFERENCES_CONTROLLER_MOCK, + advancedGasFee: { + priorityFee: '0x1', + maxBaseFee: '0x1', + }, + }, + AppStateController: {}, + }; + + const oldStorage = { + meta: { version: 92.2 }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.data).toStrictEqual({ + some: oldData.some, + PreferencesController: { + ...PREFERENCES_CONTROLLER_MOCK, + advancedGasFee: {}, + }, + AppStateController: { + hadAdvancedGasFeesSetPriorToMigration92_3: true, + }, + }); + }); + + it('does not erase advancedGasFee if it does not contain the expected data prior to this migration', async () => { + const oldData = { + some: 'data', + PreferencesController: { + ...PREFERENCES_CONTROLLER_MOCK, + advancedGasFee: { + '0x5': { + priorityFee: '0x1', + maxBaseFee: '0x1', + }, + }, + }, + AppStateController: {}, + }; + + const oldStorage = { + meta: { version: 92.2 }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.data).toStrictEqual({ + some: oldData.some, + PreferencesController: { + ...PREFERENCES_CONTROLLER_MOCK, + advancedGasFee: { + '0x5': { + priorityFee: '0x1', + maxBaseFee: '0x1', + }, + }, + }, + AppStateController: { + hadAdvancedGasFeesSetPriorToMigration92_3: false, + }, + }); + }); +}); diff --git a/app/scripts/migrations/092.3.ts b/app/scripts/migrations/092.3.ts new file mode 100644 index 000000000..a2659068f --- /dev/null +++ b/app/scripts/migrations/092.3.ts @@ -0,0 +1,98 @@ +import { hasProperty, isNullOrUndefined, isObject } from '@metamask/utils'; +import { cloneDeep } from 'lodash'; +import log from 'loglevel'; + +type VersionedData = { + meta: { version: number }; + data: Record; +}; + +export const version = 92.3; + +/** + * This migration does the following: + * + * - Deletes currently stored advancedGasFee in preferences controller, + * replacing the default with an empty object + * - Sets hadAdvancedGasFeesSetPriorToMigration92_3 flag on AppStateController + * to indicate if the user had previously had advancedGasFee set in their + * preferences. This will be used to display a whats new entry to inform users + * that we wiped these settings and made them apply per network. + * + * @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist. + * @param originalVersionedData.meta - State metadata. + * @param originalVersionedData.meta.version - The current state version. + * @param originalVersionedData.data - The persisted MetaMask state, keyed by controller. + * @returns Updated versioned MetaMask extension state. + */ +export async function migrate( + originalVersionedData: VersionedData, +): Promise { + const versionedData = cloneDeep(originalVersionedData); + versionedData.meta.version = version; + migrateData(versionedData.data); + return versionedData; +} + +function migrateData(state: Record): void { + changeShapeAndRemoveOldAdvancedGasFeePreference(state); +} + +function changeShapeAndRemoveOldAdvancedGasFeePreference( + state: Record, +) { + if (isNullOrUndefined(state.PreferencesController)) { + log.warn( + `Migration #${version}: preferences controller null or undefined, skipping migration`, + ); + return; + } + + if ( + hasProperty(state, 'AppStateController') && + isObject(state.AppStateController) && + hasProperty(state, 'PreferencesController') && + isObject(state.PreferencesController) + ) { + const possibleOriginalValue = state.PreferencesController?.advancedGasFee; + + // Will be false if the keys set on the object are anything other than the + // maxBaseFee or priorityFee. Essentially if the object is already keyed + // by chainId it won't show as hadFeesSet. + const hadFeesSet = + isObject(possibleOriginalValue) && + hasFeePreferenceKeys(possibleOriginalValue); + + state.AppStateController.hadAdvancedGasFeesSetPriorToMigration92_3 = + hadFeesSet; + + if ( + state.PreferencesController.advancedGasFee === null || + (isObject(state.PreferencesController.advancedGasFee) && + hasFeePreferenceKeys(state.PreferencesController.advancedGasFee)) + ) { + state.PreferencesController.advancedGasFee = {}; + } + } else if (isObject(state.AppStateController) === false) { + global.sentry?.captureException?.( + new Error( + `typeof state.AppStateController is ${typeof state.AppStateController}`, + ), + ); + } else if (isObject(state.PreferencesController) === false) { + global.sentry?.captureException?.( + new Error( + `typeof state.PreferencesController is ${typeof state.PreferencesController}`, + ), + ); + } +} + +function hasFeePreferenceKeys(objectToCheck: Record): boolean { + const keys = Object.keys(objectToCheck); + + if (keys.includes('maxBaseFee') || keys.includes('priorityFee')) { + return true; + } + return false; +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index f5c169a1f..3dcbf1b26 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -97,6 +97,7 @@ import * as m090 from './090'; import * as m091 from './091'; import * as m092 from './092'; import * as m092point1 from './092.1'; +import * as m092point3 from './092.3'; const migrations = [ m002, @@ -191,6 +192,7 @@ const migrations = [ m091, m092, m092point1, + m092point3, ]; export default migrations; diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 77d17841f..6cfd84ea0 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -113,6 +113,7 @@ "networkStatus": "available", "providerConfig": { "type": "rpc", + "nickname": "goerli", "chainId": "0x5", "ticker": "ETH", "id": "chain5" @@ -339,8 +340,10 @@ "useTokenDetection": true, "useCurrencyRateCheck": true, "advancedGasFee": { - "maxBaseFee": "75", - "priorityFee": "2" + "0x5": { + "maxBaseFee": "75", + "priorityFee": "2" + } }, "nftsDropdownState": { "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": { diff --git a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json index f8045ea4a..a01f4d664 100644 --- a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-background-state.json @@ -33,6 +33,7 @@ "qrHardware": "object", "usedNetworks": "object", "snapsInstallPrivacyWarningShown": "boolean", + "hadAdvancedGasFeesSetPriorToMigration92_3": "boolean", "serviceWorkerLastActiveTime": "number" }, "ApprovalController": "object", diff --git a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json index 74cbdb1fc..ff188c72f 100644 --- a/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -55,6 +55,7 @@ "qrHardware": "object", "usedNetworks": "object", "snapsInstallPrivacyWarningShown": "boolean", + "hadAdvancedGasFeesSetPriorToMigration92_3": "boolean", "serviceWorkerLastActiveTime": "number", "currentAppVersion": "10.35.0", "previousAppVersion": "", diff --git a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.js b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.js index b764b2351..c4762f614 100644 --- a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.js +++ b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.js @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; +import { capitalize } from 'lodash'; import { useTransactionEventFragment } from '../../../../hooks/useTransactionEventFragment'; import { EditGasModes } from '../../../../../shared/constants/gas'; import Box from '../../../ui/box'; @@ -11,7 +12,11 @@ import { TextColor, TextVariant, } from '../../../../helpers/constants/design-system'; -import { getAdvancedGasFeeValues } from '../../../../selectors'; +import { + getAdvancedGasFeeValues, + getCurrentChainId, + getNetworkIdentifier, +} from '../../../../selectors'; import { setAdvancedGasFee } from '../../../../store/actions'; import { useGasFeeContext } from '../../../../contexts/gasFee'; import { useAdvancedGasFeePopoverContext } from '../context'; @@ -24,6 +29,9 @@ const AdvancedGasFeeDefaults = () => { const { gasErrors, maxBaseFee, maxPriorityFeePerGas } = useAdvancedGasFeePopoverContext(); const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues); + // This will need to use a different chainId in multinetwork + const chainId = useSelector(getCurrentChainId); + const networkIdentifier = useSelector(getNetworkIdentifier); const { updateTransactionEventFragment } = useTransactionEventFragment(); const { editGasMode } = useGasFeeContext(); const [isDefaultSettingsSelected, setDefaultSettingsSelected] = useState( @@ -42,7 +50,7 @@ const AdvancedGasFeeDefaults = () => { const handleUpdateDefaultSettings = () => { if (isDefaultSettingsSelected) { - dispatch(setAdvancedGasFee(null)); + dispatch(setAdvancedGasFee({ chainId, gasFeePreferences: undefined })); setDefaultSettingsSelected(false); updateTransactionEventFragment({ properties: { @@ -53,8 +61,11 @@ const AdvancedGasFeeDefaults = () => { } else { dispatch( setAdvancedGasFee({ - maxBaseFee, - priorityFee: maxPriorityFeePerGas, + chainId, + gasFeePreferences: { + maxBaseFee, + priorityFee: maxPriorityFeePerGas, + }, }), ); updateTransactionEventFragment({ @@ -91,11 +102,7 @@ const AdvancedGasFeeDefaults = () => { as="h6" color={TextColor.textAlternative} > - {isDefaultSettingsSelected - ? t('advancedGasFeeDefaultOptOut') - : t('advancedGasFeeDefaultOptIn', [ - {t('newValues')}, - ])} + {t('advancedGasFeeDefaultOptIn', [capitalize(networkIdentifier)])} diff --git a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js index ca6253774..e93c1c44a 100644 --- a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js +++ b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-defaults/advanced-gas-fee-defaults.test.js @@ -15,8 +15,11 @@ import { GasFeeContextProvider } from '../../../../contexts/gasFee'; import configureStore from '../../../../store/store'; import AdvancedGasFeeInputs from '../advanced-gas-fee-inputs'; +import { CHAIN_IDS } from '../../../../../shared/constants/network'; import AdvancedGasFeeDefaults from './advanced-gas-fee-defaults'; +const TEXT_SELECTOR = 'Save these values as my default for the Goerli network.'; + jest.mock('../../../../store/actions', () => ({ disconnectGasFeeEstimatePoller: jest.fn(), getGasFeeEstimatesAndStartPolling: jest @@ -62,68 +65,58 @@ const render = (defaultGasParams, contextParams) => { }; describe('AdvancedGasFeeDefaults', () => { it('should renders correct message when the default is not set', () => { - render({ advancedGasFee: null }); - expect(screen.queryByText('new values')).toBeInTheDocument(); + render({ advancedGasFee: {} }); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); }); it('should renders correct message when the default values are set', () => { render({ - advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, + advancedGasFee: { + [CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 }, + }, }); - expect( - screen.queryByText( - 'Always use these values and advanced setting as default.', - ), - ).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); }); it('should renders correct message when the default values are set and the maxBaseFee values are updated', () => { render({ - advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, + advancedGasFee: { + [CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 }, + }, }); expect(document.getElementsByTagName('input')[2]).toBeChecked(); - expect( - screen.queryByText( - 'Always use these values and advanced setting as default.', - ), - ).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); fireEvent.change(document.getElementsByTagName('input')[0], { target: { value: 75 }, }); expect(document.getElementsByTagName('input')[0]).toHaveValue(75); - expect(screen.queryByText('new values')).toBeInTheDocument(); - expect( - screen.queryByText('Save these as my default for "Advanced"'), - ).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); }); it('should renders correct message when the default values are set and the priorityFee values are updated', () => { render({ - advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, + advancedGasFee: { + [CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 }, + }, }); expect(document.getElementsByTagName('input')[2]).toBeChecked(); - expect( - screen.queryByText( - 'Always use these values and advanced setting as default.', - ), - ).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); fireEvent.change(document.getElementsByTagName('input')[1], { target: { value: 5 }, }); expect(document.getElementsByTagName('input')[1]).toHaveValue(5); - expect(screen.queryByText('new values')).toBeInTheDocument(); - expect( - screen.queryByText('Save these as my default for "Advanced"'), - ).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); + expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument(); }); it('should call action setAdvancedGasFee when checkbox or label text is clicked', () => { render({ - advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, + advancedGasFee: { + [CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 }, + }, }); const mock = jest .spyOn(Actions, 'setAdvancedGasFee') .mockReturnValue({ type: 'test' }); - const checkboxLabel = screen.queryByText( - 'Always use these values and advanced setting as default.', - ); + const checkboxLabel = screen.queryByText(TEXT_SELECTOR); fireEvent.click(checkboxLabel); expect(mock).toHaveBeenCalledTimes(1); const checkbox = document.querySelector('input[type=checkbox]'); diff --git a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-inputs/priority-fee-input/priority-fee-input.test.js b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-inputs/priority-fee-input/priority-fee-input.test.js index 83540a3cd..eab4d43ac 100644 --- a/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-inputs/priority-fee-input/priority-fee-input.test.js +++ b/ui/components/app/advanced-gas-fee-popover/advanced-gas-fee-inputs/priority-fee-input/priority-fee-input.test.js @@ -13,6 +13,7 @@ import configureStore from '../../../../../store/store'; import { AdvancedGasFeePopoverContextProvider } from '../../context'; import AdvancedGasFeeGasLimit from '../../advanced-gas-fee-gas-limit'; +import { CHAIN_IDS } from '../../../../../../shared/constants/network'; import PriorityfeeInput from './priority-fee-input'; jest.mock('../../../../../store/actions', () => ({ @@ -34,7 +35,7 @@ const render = (txProps, contextProps) => { balance: '0x1F4', }, }, - advancedGasFee: { priorityFee: 100 }, + advancedGasFee: { [CHAIN_IDS.GOERLI]: { priorityFee: 100 } }, featureFlags: { advancedInlineGas: true }, gasFeeEstimates: mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates, diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js index 7d9c0adfa..b7382bc5d 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js @@ -67,6 +67,7 @@ const render = ({ txProps, contextProps } = {}) => { selectedAddress: '0xAddress', featureFlags: { advancedInlineGas: true }, gasFeeEstimates: MOCK_FEE_ESTIMATE, + advancedGasFee: {}, }, }); diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js index 86f5ba097..ea3191e2d 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js @@ -10,6 +10,7 @@ import { ETH } from '../../../../helpers/constants/common'; import configureStore from '../../../../store/store'; import { GasFeeContextProvider } from '../../../../contexts/gasFee'; +import { CHAIN_IDS } from '../../../../../shared/constants/network'; import EditGasItem from './edit-gas-item'; jest.mock('../../../../store/actions', () => ({ @@ -59,7 +60,9 @@ const renderComponent = ({ const store = configureStore({ metamask: { nativeCurrency: ETH, - providerConfig: {}, + providerConfig: { + chainId: CHAIN_IDS.GOERLI, + }, cachedBalances: {}, accounts: { '0xAddress': { @@ -75,8 +78,10 @@ const renderComponent = ({ gasEstimateType: 'fee-market', gasFeeEstimates: MOCK_FEE_ESTIMATE, advancedGasFee: { - maxBaseFee: '100', - priorityFee: '2', + [CHAIN_IDS.GOERLI]: { + maxBaseFee: '100', + priorityFee: '2', + }, }, }, }); diff --git a/ui/components/app/signature-request-header/__snapshots__/signature-request-header.test.js.snap b/ui/components/app/signature-request-header/__snapshots__/signature-request-header.test.js.snap index 58642cc3e..1f9dedfed 100644 --- a/ui/components/app/signature-request-header/__snapshots__/signature-request-header.test.js.snap +++ b/ui/components/app/signature-request-header/__snapshots__/signature-request-header.test.js.snap @@ -61,7 +61,7 @@ exports[`SignatureRequestHeader should match snapshot 1`] = ` - U + G @@ -71,7 +71,7 @@ exports[`SignatureRequestHeader should match snapshot 1`] = `
- Unknown private network + goerli
- U + G @@ -147,7 +147,7 @@ exports[`SignatureRequestOriginal should match snapshot 1`] = `
- Unknown private network + goerli
- U + G @@ -144,7 +144,7 @@ exports[`SignatureRequestSIWE (Sign in with Ethereum) should match snapshot 1`]
- Unknown private network + goerli
- Private network + goerli @@ -127,7 +127,7 @@ exports[`SignatureRequestHeader renders correctly without fromAccount 1`] = ` - Private network + goerli diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 4129cdcd2..3c7006a86 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -1331,23 +1331,26 @@ export function getIsMultiLayerFeeNetwork(state) { * To retrieve the maxBaseFee and priorityFee the user has set as default * * @param {*} state - * @returns Boolean + * @returns {{maxBaseFee: string, priorityFee: string} | undefined} */ export function getAdvancedGasFeeValues(state) { - return state.metamask.advancedGasFee; -} - -/** - * To check if the user has set advanced gas fee settings as default with a non empty maxBaseFee and priotityFee. - * - * @param {*} state - * @returns Boolean - */ -export function getIsAdvancedGasFeeDefault(state) { - const { advancedGasFee } = state.metamask; - return ( - Boolean(advancedGasFee?.maxBaseFee) && Boolean(advancedGasFee?.priorityFee) - ); + // This will not work when we switch to supporting multi-chain. + // There are four non-test files that use this selector. + // advanced-gas-fee-defaults + // base-fee-input + // priority-fee-input + // useGasItemFeeDetails + // The first three are part of the AdvancedGasFeePopover + // The latter is used by the EditGasPopover + // Both of those are used in Confirmations as well as transaction-list-item + // All of the call sites have access to the GasFeeContext, which has a + // transaction object set on it, but there are currently no guarantees that + // the transaction has a chainId associated with it. To have this method + // support multichain we'll need a reliable way for the chainId of the + // transaction being modified to be available to all callsites and either + // pass it in to the selector as a second parameter, or access it at the + // callsite. + return state.metamask.advancedGasFee[getCurrentChainId(state)]; } /** diff --git a/ui/selectors/selectors.test.js b/ui/selectors/selectors.test.js index e63252ee7..4c7f44df9 100644 --- a/ui/selectors/selectors.test.js +++ b/ui/selectors/selectors.test.js @@ -600,11 +600,6 @@ describe('Selectors', () => { priorityFee: '2', }); }); - it('#getIsAdvancedGasFeeDefault', () => { - const isAdvancedGasFeeDefault = - selectors.getIsAdvancedGasFeeDefault(mockState); - expect(isAdvancedGasFeeDefault).toStrictEqual(true); - }); it('#getAppIsLoading', () => { const appIsLoading = selectors.getAppIsLoading(mockState); expect(appIsLoading).toStrictEqual(false); diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 8040b01b8..a07eed427 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -3035,7 +3035,7 @@ export function detectNfts(): ThunkAction< } export function setAdvancedGasFee( - val: { maxBaseFee?: Hex; priorityFee?: Hex } | null, + val: { chainId: Hex; maxBaseFee?: Hex; priorityFee?: Hex } | null, ): ThunkAction { return (dispatch: MetaMaskReduxDispatch) => { dispatch(showLoadingIndication());