1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

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
This commit is contained in:
Brad Decker 2023-08-26 19:58:26 -05:00 committed by Mark Stacey
parent b684c094cb
commit e2c4816394
41 changed files with 413 additions and 247 deletions

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Erweiterte Einstellungen" "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": { "advancedGasFeeModalTitle": {
"message": "Erweiterte Gasgebühr" "message": "Erweiterte Gasgebühr"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Token importiert" "message": "Token importiert"
}, },
"newValues": {
"message": "neue Werte"
},
"next": { "next": {
"message": "Weiter" "message": "Weiter"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Προηγμένη ρύθμιση παραμέτρων" "message": "Προηγμένη ρύθμιση παραμέτρων"
}, },
"advancedGasFeeDefaultOptIn": {
"message": "Αποθηκεύστε αυτά τα $1 ως προεπιλογή μου για το \"Προηγμένο\""
},
"advancedGasFeeDefaultOptOut": {
"message": "Να χρησιμοποιούνται πάντα αυτές τις τιμές και η ρύθμιση για προχωρημένους."
},
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "Προηγμένη χρέωση τελών συναλλαγής" "message": "Προηγμένη χρέωση τελών συναλλαγής"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Τα token εισήχθησαν" "message": "Τα token εισήχθησαν"
}, },
"newValues": {
"message": "νέες τιμές"
},
"next": { "next": {
"message": "Επόμενο" "message": "Επόμενο"
}, },

View File

@ -306,10 +306,8 @@
"message": "Advanced configuration" "message": "Advanced configuration"
}, },
"advancedGasFeeDefaultOptIn": { "advancedGasFeeDefaultOptIn": {
"message": "Save these $1 as my default for \"Advanced\"" "message": "Save these values as my default for the $1 network.",
}, "description": "$1 is the current network name."
"advancedGasFeeDefaultOptOut": {
"message": "Always use these values and advanced setting as default."
}, },
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "Advanced gas fee" "message": "Advanced gas fee"
@ -2483,9 +2481,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Token imported" "message": "Token imported"
}, },
"newValues": {
"message": "new values"
},
"next": { "next": {
"message": "Next" "message": "Next"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Configuración avanzada" "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": { "advancedGasFeeModalTitle": {
"message": "Tarifa de gas avanzada" "message": "Tarifa de gas avanzada"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Token importado" "message": "Token importado"
}, },
"newValues": {
"message": "nuevos valores"
},
"next": { "next": {
"message": "Siguiente" "message": "Siguiente"
}, },

View File

@ -148,12 +148,6 @@
"advancedBaseGasFeeToolTip": { "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." "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": { "advancedGasFeeModalTitle": {
"message": "Tarifa de gas avanzada" "message": "Tarifa de gas avanzada"
}, },
@ -1431,9 +1425,6 @@
"newPassword": { "newPassword": {
"message": "Contraseña nueva (mín. de 8 caracteres)" "message": "Contraseña nueva (mín. de 8 caracteres)"
}, },
"newValues": {
"message": "nuevos valores"
},
"next": { "next": {
"message": "Siguiente" "message": "Siguiente"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Configuration avancée" "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": { "advancedGasFeeModalTitle": {
"message": "Frais de carburant avancés" "message": "Frais de carburant avancés"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Jeton importé" "message": "Jeton importé"
}, },
"newValues": {
"message": "nouvelles valeurs"
},
"next": { "next": {
"message": "Suivant" "message": "Suivant"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "उन्नत कंफिगुरेशन" "message": "उन्नत कंफिगुरेशन"
}, },
"advancedGasFeeDefaultOptIn": {
"message": "इन $1 को \"एडवांस\" के लिए मेरे डिफॉल्ट के रूप में सहेजें"
},
"advancedGasFeeDefaultOptOut": {
"message": "हमेशा इन मूल्यों और एडवांस सेटिंग को डिफॉल्ट के रूप में उपयोग करें।"
},
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "एडवांस गैस शुल्क" "message": "एडवांस गैस शुल्क"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "टोकन इम्पोर्ट हो गया" "message": "टोकन इम्पोर्ट हो गया"
}, },
"newValues": {
"message": "नए मान"
},
"next": { "next": {
"message": "अगला" "message": "अगला"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Konfigurasi lanjutan" "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": { "advancedGasFeeModalTitle": {
"message": "Biaya gas lanjutan" "message": "Biaya gas lanjutan"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Token diimpor" "message": "Token diimpor"
}, },
"newValues": {
"message": "nilai baru"
},
"next": { "next": {
"message": "Berikutnya" "message": "Berikutnya"
}, },

View File

@ -213,12 +213,6 @@
"advancedBaseGasFeeToolTip": { "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." "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": { "advancedGasFeeModalTitle": {
"message": "Tariffa gas avanzata" "message": "Tariffa gas avanzata"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "詳細設定" "message": "詳細設定"
}, },
"advancedGasFeeDefaultOptIn": {
"message": "これらの$1を「高度な設定」のデフォルトとして保存"
},
"advancedGasFeeDefaultOptOut": {
"message": "常にこれらの値と高度な設定をデフォルトとして使用します。"
},
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "高度なガス代" "message": "高度なガス代"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "トークンがインポートされました" "message": "トークンがインポートされました"
}, },
"newValues": {
"message": "新しい値"
},
"next": { "next": {
"message": "次へ" "message": "次へ"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "고급 옵션" "message": "고급 옵션"
}, },
"advancedGasFeeDefaultOptIn": {
"message": "이 $1 옵션을 \"고급\"의 기본값으로 저장합니다"
},
"advancedGasFeeDefaultOptOut": {
"message": "항상 이 값과 고급 설정을 기본값으로 사용합니다."
},
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "고급 가스 요금" "message": "고급 가스 요금"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "불러온 토큰" "message": "불러온 토큰"
}, },
"newValues": {
"message": "새로운 가치"
},
"next": { "next": {
"message": "다음" "message": "다음"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Configurações avançadas" "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": { "advancedGasFeeModalTitle": {
"message": "Taxa de gás avançada" "message": "Taxa de gás avançada"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Token importado" "message": "Token importado"
}, },
"newValues": {
"message": "novos valores"
},
"next": { "next": {
"message": "Próximo" "message": "Próximo"
}, },

View File

@ -148,12 +148,6 @@
"advancedBaseGasFeeToolTip": { "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." "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": { "advancedGasFeeModalTitle": {
"message": "Taxa de gás avançada" "message": "Taxa de gás avançada"
}, },
@ -1431,9 +1425,6 @@
"newPassword": { "newPassword": {
"message": "Nova senha (no mínimo 8 caracteres)" "message": "Nova senha (no mínimo 8 caracteres)"
}, },
"newValues": {
"message": "novos valores"
},
"next": { "next": {
"message": "Seguinte" "message": "Seguinte"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Расширенная конфигурация" "message": "Расширенная конфигурация"
}, },
"advancedGasFeeDefaultOptIn": {
"message": "Сохранить этот $1 в качестве моего значения по умолчанию для «Дополнительной» настройки"
},
"advancedGasFeeDefaultOptOut": {
"message": "Всегда использовать эти значения и дополнительную настройку по умолчанию."
},
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "Дополнительная плата за газ" "message": "Дополнительная плата за газ"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Токен импортирован" "message": "Токен импортирован"
}, },
"newValues": {
"message": "новые значения"
},
"next": { "next": {
"message": "Далее" "message": "Далее"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Advanced na pagsasaayos" "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": { "advancedGasFeeModalTitle": {
"message": "Advanced na gas fee" "message": "Advanced na gas fee"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Na-import ang token" "message": "Na-import ang token"
}, },
"newValues": {
"message": "bagong value"
},
"next": { "next": {
"message": "Susunod" "message": "Susunod"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Gelişmiş yapılandırma" "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": { "advancedGasFeeModalTitle": {
"message": "Gelişmiş gaz ücreti" "message": "Gelişmiş gaz ücreti"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Token içe aktarıldı" "message": "Token içe aktarıldı"
}, },
"newValues": {
"message": "yeni değerler"
},
"next": { "next": {
"message": "Sonraki" "message": "Sonraki"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "Cấu hình nâng cao" "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": { "advancedGasFeeModalTitle": {
"message": "Phí gas nâng cao" "message": "Phí gas nâng cao"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "Đã nhập token" "message": "Đã nhập token"
}, },
"newValues": {
"message": "giá trị mới"
},
"next": { "next": {
"message": "Tiếp theo" "message": "Tiếp theo"
}, },

View File

@ -275,12 +275,6 @@
"advancedConfiguration": { "advancedConfiguration": {
"message": "高级配置" "message": "高级配置"
}, },
"advancedGasFeeDefaultOptIn": {
"message": "将这些 $1 保存为“高级”默认值"
},
"advancedGasFeeDefaultOptOut": {
"message": "始终使用这些值和高级设置作为默认值。"
},
"advancedGasFeeModalTitle": { "advancedGasFeeModalTitle": {
"message": "高级燃料费" "message": "高级燃料费"
}, },
@ -2101,9 +2095,6 @@
"newTokensImportedTitle": { "newTokensImportedTitle": {
"message": "已导入代币" "message": "已导入代币"
}, },
"newValues": {
"message": "新的值"
},
"next": { "next": {
"message": "下一步" "message": "下一步"
}, },

View File

@ -52,6 +52,10 @@ export default class AppStateController extends EventEmitter {
...initState, ...initState,
qrHardware: {}, qrHardware: {},
nftsDropdownState: {}, 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: { usedNetworks: {
'0x1': true, '0x1': true,
'0x5': true, '0x5': true,

View File

@ -41,7 +41,7 @@ export default class PreferencesController {
useNftDetection: false, useNftDetection: false,
useCurrencyRateCheck: true, useCurrencyRateCheck: true,
openSeaEnabled: false, openSeaEnabled: false,
advancedGasFee: null, advancedGasFee: {},
// WARNING: Do not use feature flags for security-sensitive things. // WARNING: Do not use feature flags for security-sensitive things.
// Feature flag toggling is available in the global namespace // Feature flag toggling is available in the global namespace
@ -188,10 +188,18 @@ export default class PreferencesController {
/** /**
* Setter for the `advancedGasFee` property * 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) { setAdvancedGasFee({ chainId, gasFeePreferences }) {
this.store.updateState({ advancedGasFee: val }); const { advancedGasFee } = this.store.getState();
this.store.updateState({
advancedGasFee: {
...advancedGasFee,
[chainId]: gasFeePreferences,
},
});
} }
/** /**

View File

@ -2,6 +2,7 @@ import { strict as assert } from 'assert';
import sinon from 'sinon'; import sinon from 'sinon';
import { ControllerMessenger } from '@metamask/base-controller'; import { ControllerMessenger } from '@metamask/base-controller';
import { TokenListController } from '@metamask/assets-controllers'; import { TokenListController } from '@metamask/assets-controllers';
import { CHAIN_IDS } from '../../../shared/constants/network';
import PreferencesController from './preferences'; import PreferencesController from './preferences';
describe('preferences controller', function () { describe('preferences controller', function () {
@ -250,24 +251,31 @@ describe('preferences controller', function () {
}); });
describe('setAdvancedGasFee', function () { describe('setAdvancedGasFee', function () {
it('should default to null', function () { it('should default to an empty object', function () {
const state = preferencesController.store.getState(); assert.deepEqual(
assert.equal(state.advancedGasFee, null); preferencesController.store.getState().advancedGasFee,
{},
);
}); });
it('should set the setAdvancedGasFee property in state', function () { it('should set the setAdvancedGasFee property in state', function () {
const state = preferencesController.store.getState(); const state = preferencesController.store.getState();
assert.equal(state.advancedGasFee, null); assert.deepEqual(state.advancedGasFee, {});
preferencesController.setAdvancedGasFee({ preferencesController.setAdvancedGasFee({
maxBaseFee: '1.5', chainId: CHAIN_IDS.GOERLI,
priorityFee: '2', gasFeePreferences: {
maxBaseFee: '1.5',
priorityFee: '2',
},
}); });
assert.equal( assert.equal(
preferencesController.store.getState().advancedGasFee.maxBaseFee, preferencesController.store.getState().advancedGasFee[CHAIN_IDS.GOERLI]
.maxBaseFee,
'1.5', '1.5',
); );
assert.equal( assert.equal(
preferencesController.store.getState().advancedGasFee.priorityFee, preferencesController.store.getState().advancedGasFee[CHAIN_IDS.GOERLI]
.priorityFee,
'2', '2',
); );
}); });

View File

@ -1962,9 +1962,13 @@ export default class TransactionController extends EventEmitter {
*/ */
this.getTransactions = (opts) => this.txStateManager.getTransactions(opts); 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.getAdvancedGasFee = () =>
this.preferencesStore.getState().advancedGasFee; this.preferencesStore.getState().advancedGasFee[
this._getCurrentChainId()
];
} }
// called once on startup // called once on startup

View File

@ -59,6 +59,7 @@ describe('Transaction Controller', function () {
fromAccount, fromAccount,
fragmentExists, fragmentExists,
networkStatusStore, networkStatusStore,
preferencesStore,
getCurrentChainId, getCurrentChainId,
messengerMock, messengerMock,
resultCallbacksMock, resultCallbacksMock,
@ -81,6 +82,7 @@ describe('Transaction Controller', function () {
}).provider; }).provider;
networkStatusStore = new ObservableStore(currentNetworkStatus); networkStatusStore = new ObservableStore(currentNetworkStatus);
preferencesStore = new ObservableStore({ advancedGasFee: {} });
fromAccount = getTestAccounts()[0]; fromAccount = getTestAccounts()[0];
const blockTrackerStub = new EventEmitter(); const blockTrackerStub = new EventEmitter();
@ -129,6 +131,7 @@ describe('Transaction Controller', function () {
getAccountType: () => 'MetaMask', getAccountType: () => 'MetaMask',
getDeviceModel: () => 'N/A', getDeviceModel: () => 'N/A',
securityProviderRequest: () => undefined, securityProviderRequest: () => undefined,
preferencesStore,
messenger: messengerMock, messenger: messengerMock,
}); });

View File

@ -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,
},
});
});
});

View File

@ -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<string, unknown>;
};
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<VersionedData> {
const versionedData = cloneDeep(originalVersionedData);
versionedData.meta.version = version;
migrateData(versionedData.data);
return versionedData;
}
function migrateData(state: Record<string, unknown>): void {
changeShapeAndRemoveOldAdvancedGasFeePreference(state);
}
function changeShapeAndRemoveOldAdvancedGasFeePreference(
state: Record<string, unknown>,
) {
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<string, unknown>): boolean {
const keys = Object.keys(objectToCheck);
if (keys.includes('maxBaseFee') || keys.includes('priorityFee')) {
return true;
}
return false;
}

View File

@ -97,6 +97,7 @@ import * as m090 from './090';
import * as m091 from './091'; import * as m091 from './091';
import * as m092 from './092'; import * as m092 from './092';
import * as m092point1 from './092.1'; import * as m092point1 from './092.1';
import * as m092point3 from './092.3';
const migrations = [ const migrations = [
m002, m002,
@ -191,6 +192,7 @@ const migrations = [
m091, m091,
m092, m092,
m092point1, m092point1,
m092point3,
]; ];
export default migrations; export default migrations;

View File

@ -113,6 +113,7 @@
"networkStatus": "available", "networkStatus": "available",
"providerConfig": { "providerConfig": {
"type": "rpc", "type": "rpc",
"nickname": "goerli",
"chainId": "0x5", "chainId": "0x5",
"ticker": "ETH", "ticker": "ETH",
"id": "chain5" "id": "chain5"
@ -339,8 +340,10 @@
"useTokenDetection": true, "useTokenDetection": true,
"useCurrencyRateCheck": true, "useCurrencyRateCheck": true,
"advancedGasFee": { "advancedGasFee": {
"maxBaseFee": "75", "0x5": {
"priorityFee": "2" "maxBaseFee": "75",
"priorityFee": "2"
}
}, },
"nftsDropdownState": { "nftsDropdownState": {
"0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": { "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc": {

View File

@ -33,6 +33,7 @@
"qrHardware": "object", "qrHardware": "object",
"usedNetworks": "object", "usedNetworks": "object",
"snapsInstallPrivacyWarningShown": "boolean", "snapsInstallPrivacyWarningShown": "boolean",
"hadAdvancedGasFeesSetPriorToMigration92_3": "boolean",
"serviceWorkerLastActiveTime": "number" "serviceWorkerLastActiveTime": "number"
}, },
"ApprovalController": "object", "ApprovalController": "object",

View File

@ -55,6 +55,7 @@
"qrHardware": "object", "qrHardware": "object",
"usedNetworks": "object", "usedNetworks": "object",
"snapsInstallPrivacyWarningShown": "boolean", "snapsInstallPrivacyWarningShown": "boolean",
"hadAdvancedGasFeesSetPriorToMigration92_3": "boolean",
"serviceWorkerLastActiveTime": "number", "serviceWorkerLastActiveTime": "number",
"currentAppVersion": "10.35.0", "currentAppVersion": "10.35.0",
"previousAppVersion": "", "previousAppVersion": "",

View File

@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useSelector, useDispatch } from 'react-redux'; import { useSelector, useDispatch } from 'react-redux';
import { capitalize } from 'lodash';
import { useTransactionEventFragment } from '../../../../hooks/useTransactionEventFragment'; import { useTransactionEventFragment } from '../../../../hooks/useTransactionEventFragment';
import { EditGasModes } from '../../../../../shared/constants/gas'; import { EditGasModes } from '../../../../../shared/constants/gas';
import Box from '../../../ui/box'; import Box from '../../../ui/box';
@ -11,7 +12,11 @@ import {
TextColor, TextColor,
TextVariant, TextVariant,
} from '../../../../helpers/constants/design-system'; } from '../../../../helpers/constants/design-system';
import { getAdvancedGasFeeValues } from '../../../../selectors'; import {
getAdvancedGasFeeValues,
getCurrentChainId,
getNetworkIdentifier,
} from '../../../../selectors';
import { setAdvancedGasFee } from '../../../../store/actions'; import { setAdvancedGasFee } from '../../../../store/actions';
import { useGasFeeContext } from '../../../../contexts/gasFee'; import { useGasFeeContext } from '../../../../contexts/gasFee';
import { useAdvancedGasFeePopoverContext } from '../context'; import { useAdvancedGasFeePopoverContext } from '../context';
@ -24,6 +29,9 @@ const AdvancedGasFeeDefaults = () => {
const { gasErrors, maxBaseFee, maxPriorityFeePerGas } = const { gasErrors, maxBaseFee, maxPriorityFeePerGas } =
useAdvancedGasFeePopoverContext(); useAdvancedGasFeePopoverContext();
const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues); 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 { updateTransactionEventFragment } = useTransactionEventFragment();
const { editGasMode } = useGasFeeContext(); const { editGasMode } = useGasFeeContext();
const [isDefaultSettingsSelected, setDefaultSettingsSelected] = useState( const [isDefaultSettingsSelected, setDefaultSettingsSelected] = useState(
@ -42,7 +50,7 @@ const AdvancedGasFeeDefaults = () => {
const handleUpdateDefaultSettings = () => { const handleUpdateDefaultSettings = () => {
if (isDefaultSettingsSelected) { if (isDefaultSettingsSelected) {
dispatch(setAdvancedGasFee(null)); dispatch(setAdvancedGasFee({ chainId, gasFeePreferences: undefined }));
setDefaultSettingsSelected(false); setDefaultSettingsSelected(false);
updateTransactionEventFragment({ updateTransactionEventFragment({
properties: { properties: {
@ -53,8 +61,11 @@ const AdvancedGasFeeDefaults = () => {
} else { } else {
dispatch( dispatch(
setAdvancedGasFee({ setAdvancedGasFee({
maxBaseFee, chainId,
priorityFee: maxPriorityFeePerGas, gasFeePreferences: {
maxBaseFee,
priorityFee: maxPriorityFeePerGas,
},
}), }),
); );
updateTransactionEventFragment({ updateTransactionEventFragment({
@ -91,11 +102,7 @@ const AdvancedGasFeeDefaults = () => {
as="h6" as="h6"
color={TextColor.textAlternative} color={TextColor.textAlternative}
> >
{isDefaultSettingsSelected {t('advancedGasFeeDefaultOptIn', [capitalize(networkIdentifier)])}
? t('advancedGasFeeDefaultOptOut')
: t('advancedGasFeeDefaultOptIn', [
<strong key="default-value-change">{t('newValues')}</strong>,
])}
</Text> </Text>
</label> </label>
</Box> </Box>

View File

@ -15,8 +15,11 @@ import { GasFeeContextProvider } from '../../../../contexts/gasFee';
import configureStore from '../../../../store/store'; import configureStore from '../../../../store/store';
import AdvancedGasFeeInputs from '../advanced-gas-fee-inputs'; import AdvancedGasFeeInputs from '../advanced-gas-fee-inputs';
import { CHAIN_IDS } from '../../../../../shared/constants/network';
import AdvancedGasFeeDefaults from './advanced-gas-fee-defaults'; import AdvancedGasFeeDefaults from './advanced-gas-fee-defaults';
const TEXT_SELECTOR = 'Save these values as my default for the Goerli network.';
jest.mock('../../../../store/actions', () => ({ jest.mock('../../../../store/actions', () => ({
disconnectGasFeeEstimatePoller: jest.fn(), disconnectGasFeeEstimatePoller: jest.fn(),
getGasFeeEstimatesAndStartPolling: jest getGasFeeEstimatesAndStartPolling: jest
@ -62,68 +65,58 @@ const render = (defaultGasParams, contextParams) => {
}; };
describe('AdvancedGasFeeDefaults', () => { describe('AdvancedGasFeeDefaults', () => {
it('should renders correct message when the default is not set', () => { it('should renders correct message when the default is not set', () => {
render({ advancedGasFee: null }); render({ advancedGasFee: {} });
expect(screen.queryByText('new values')).toBeInTheDocument(); expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
}); });
it('should renders correct message when the default values are set', () => { it('should renders correct message when the default values are set', () => {
render({ render({
advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, advancedGasFee: {
[CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 },
},
}); });
expect( expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
screen.queryByText(
'Always use these values and advanced setting as default.',
),
).toBeInTheDocument();
}); });
it('should renders correct message when the default values are set and the maxBaseFee values are updated', () => { it('should renders correct message when the default values are set and the maxBaseFee values are updated', () => {
render({ render({
advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, advancedGasFee: {
[CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 },
},
}); });
expect(document.getElementsByTagName('input')[2]).toBeChecked(); expect(document.getElementsByTagName('input')[2]).toBeChecked();
expect( expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
screen.queryByText(
'Always use these values and advanced setting as default.',
),
).toBeInTheDocument();
fireEvent.change(document.getElementsByTagName('input')[0], { fireEvent.change(document.getElementsByTagName('input')[0], {
target: { value: 75 }, target: { value: 75 },
}); });
expect(document.getElementsByTagName('input')[0]).toHaveValue(75); expect(document.getElementsByTagName('input')[0]).toHaveValue(75);
expect(screen.queryByText('new values')).toBeInTheDocument(); expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
expect( expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
screen.queryByText('Save these as my default for "Advanced"'),
).toBeInTheDocument();
}); });
it('should renders correct message when the default values are set and the priorityFee values are updated', () => { it('should renders correct message when the default values are set and the priorityFee values are updated', () => {
render({ render({
advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, advancedGasFee: {
[CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 },
},
}); });
expect(document.getElementsByTagName('input')[2]).toBeChecked(); expect(document.getElementsByTagName('input')[2]).toBeChecked();
expect( expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
screen.queryByText(
'Always use these values and advanced setting as default.',
),
).toBeInTheDocument();
fireEvent.change(document.getElementsByTagName('input')[1], { fireEvent.change(document.getElementsByTagName('input')[1], {
target: { value: 5 }, target: { value: 5 },
}); });
expect(document.getElementsByTagName('input')[1]).toHaveValue(5); expect(document.getElementsByTagName('input')[1]).toHaveValue(5);
expect(screen.queryByText('new values')).toBeInTheDocument(); expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
expect( expect(screen.queryByText(TEXT_SELECTOR)).toBeInTheDocument();
screen.queryByText('Save these as my default for "Advanced"'),
).toBeInTheDocument();
}); });
it('should call action setAdvancedGasFee when checkbox or label text is clicked', () => { it('should call action setAdvancedGasFee when checkbox or label text is clicked', () => {
render({ render({
advancedGasFee: { maxBaseFee: 50, priorityFee: 2 }, advancedGasFee: {
[CHAIN_IDS.GOERLI]: { maxBaseFee: 50, priorityFee: 2 },
},
}); });
const mock = jest const mock = jest
.spyOn(Actions, 'setAdvancedGasFee') .spyOn(Actions, 'setAdvancedGasFee')
.mockReturnValue({ type: 'test' }); .mockReturnValue({ type: 'test' });
const checkboxLabel = screen.queryByText( const checkboxLabel = screen.queryByText(TEXT_SELECTOR);
'Always use these values and advanced setting as default.',
);
fireEvent.click(checkboxLabel); fireEvent.click(checkboxLabel);
expect(mock).toHaveBeenCalledTimes(1); expect(mock).toHaveBeenCalledTimes(1);
const checkbox = document.querySelector('input[type=checkbox]'); const checkbox = document.querySelector('input[type=checkbox]');

View File

@ -13,6 +13,7 @@ import configureStore from '../../../../../store/store';
import { AdvancedGasFeePopoverContextProvider } from '../../context'; import { AdvancedGasFeePopoverContextProvider } from '../../context';
import AdvancedGasFeeGasLimit from '../../advanced-gas-fee-gas-limit'; import AdvancedGasFeeGasLimit from '../../advanced-gas-fee-gas-limit';
import { CHAIN_IDS } from '../../../../../../shared/constants/network';
import PriorityfeeInput from './priority-fee-input'; import PriorityfeeInput from './priority-fee-input';
jest.mock('../../../../../store/actions', () => ({ jest.mock('../../../../../store/actions', () => ({
@ -34,7 +35,7 @@ const render = (txProps, contextProps) => {
balance: '0x1F4', balance: '0x1F4',
}, },
}, },
advancedGasFee: { priorityFee: 100 }, advancedGasFee: { [CHAIN_IDS.GOERLI]: { priorityFee: 100 } },
featureFlags: { advancedInlineGas: true }, featureFlags: { advancedInlineGas: true },
gasFeeEstimates: gasFeeEstimates:
mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates, mockEstimates[GasEstimateTypes.feeMarket].gasFeeEstimates,

View File

@ -67,6 +67,7 @@ const render = ({ txProps, contextProps } = {}) => {
selectedAddress: '0xAddress', selectedAddress: '0xAddress',
featureFlags: { advancedInlineGas: true }, featureFlags: { advancedInlineGas: true },
gasFeeEstimates: MOCK_FEE_ESTIMATE, gasFeeEstimates: MOCK_FEE_ESTIMATE,
advancedGasFee: {},
}, },
}); });

View File

@ -10,6 +10,7 @@ import { ETH } from '../../../../helpers/constants/common';
import configureStore from '../../../../store/store'; import configureStore from '../../../../store/store';
import { GasFeeContextProvider } from '../../../../contexts/gasFee'; import { GasFeeContextProvider } from '../../../../contexts/gasFee';
import { CHAIN_IDS } from '../../../../../shared/constants/network';
import EditGasItem from './edit-gas-item'; import EditGasItem from './edit-gas-item';
jest.mock('../../../../store/actions', () => ({ jest.mock('../../../../store/actions', () => ({
@ -59,7 +60,9 @@ const renderComponent = ({
const store = configureStore({ const store = configureStore({
metamask: { metamask: {
nativeCurrency: ETH, nativeCurrency: ETH,
providerConfig: {}, providerConfig: {
chainId: CHAIN_IDS.GOERLI,
},
cachedBalances: {}, cachedBalances: {},
accounts: { accounts: {
'0xAddress': { '0xAddress': {
@ -75,8 +78,10 @@ const renderComponent = ({
gasEstimateType: 'fee-market', gasEstimateType: 'fee-market',
gasFeeEstimates: MOCK_FEE_ESTIMATE, gasFeeEstimates: MOCK_FEE_ESTIMATE,
advancedGasFee: { advancedGasFee: {
maxBaseFee: '100', [CHAIN_IDS.GOERLI]: {
priorityFee: '2', maxBaseFee: '100',
priorityFee: '2',
},
}, },
}, },
}); });

View File

@ -61,7 +61,7 @@ exports[`SignatureRequestHeader should match snapshot 1`] = `
<span <span
class="icon-with-fallback__fallback" class="icon-with-fallback__fallback"
> >
U G
</span> </span>
</div> </div>
</div> </div>
@ -71,7 +71,7 @@ exports[`SignatureRequestHeader should match snapshot 1`] = `
<h6 <h6
class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative" class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative"
> >
Unknown private network goerli
</h6> </h6>
<h6 <h6
class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default" class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default"

View File

@ -137,7 +137,7 @@ exports[`SignatureRequestOriginal should match snapshot 1`] = `
<span <span
class="icon-with-fallback__fallback" class="icon-with-fallback__fallback"
> >
U G
</span> </span>
</div> </div>
</div> </div>
@ -147,7 +147,7 @@ exports[`SignatureRequestOriginal should match snapshot 1`] = `
<h6 <h6
class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative" class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative"
> >
Unknown private network goerli
</h6> </h6>
<h6 <h6
class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default" class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default"

View File

@ -134,7 +134,7 @@ exports[`SignatureRequestSIWE (Sign in with Ethereum) should match snapshot 1`]
<span <span
class="icon-with-fallback__fallback" class="icon-with-fallback__fallback"
> >
U G
</span> </span>
</div> </div>
</div> </div>
@ -144,7 +144,7 @@ exports[`SignatureRequestSIWE (Sign in with Ethereum) should match snapshot 1`]
<h6 <h6
class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative" class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative"
> >
Unknown private network goerli
</h6> </h6>
<h6 <h6
class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default" class="box mm-text mm-text--body-sm mm-text--font-weight-bold box--flex-direction-row box--color-text-default"

View File

@ -89,7 +89,7 @@ exports[`SignatureRequestHeader renders correctly with fromAccount 1`] = `
<span <span
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography chip__label typography--h7 typography--weight-normal typography--style-normal typography--color-text-alternative" class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography chip__label typography--h7 typography--weight-normal typography--style-normal typography--color-text-alternative"
> >
Private network goerli
</span> </span>
</div> </div>
</div> </div>
@ -127,7 +127,7 @@ exports[`SignatureRequestHeader renders correctly without fromAccount 1`] = `
<span <span
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography chip__label typography--h7 typography--weight-normal typography--style-normal typography--color-text-alternative" class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography chip__label typography--h7 typography--weight-normal typography--style-normal typography--color-text-alternative"
> >
Private network goerli
</span> </span>
</div> </div>
</div> </div>

View File

@ -1331,23 +1331,26 @@ export function getIsMultiLayerFeeNetwork(state) {
* To retrieve the maxBaseFee and priorityFee the user has set as default * To retrieve the maxBaseFee and priorityFee the user has set as default
* *
* @param {*} state * @param {*} state
* @returns Boolean * @returns {{maxBaseFee: string, priorityFee: string} | undefined}
*/ */
export function getAdvancedGasFeeValues(state) { export function getAdvancedGasFeeValues(state) {
return state.metamask.advancedGasFee; // 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
* To check if the user has set advanced gas fee settings as default with a non empty maxBaseFee and priotityFee. // priority-fee-input
* // useGasItemFeeDetails
* @param {*} state // The first three are part of the AdvancedGasFeePopover
* @returns Boolean // The latter is used by the EditGasPopover
*/ // Both of those are used in Confirmations as well as transaction-list-item
export function getIsAdvancedGasFeeDefault(state) { // All of the call sites have access to the GasFeeContext, which has a
const { advancedGasFee } = state.metamask; // transaction object set on it, but there are currently no guarantees that
return ( // the transaction has a chainId associated with it. To have this method
Boolean(advancedGasFee?.maxBaseFee) && Boolean(advancedGasFee?.priorityFee) // 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)];
} }
/** /**

View File

@ -600,11 +600,6 @@ describe('Selectors', () => {
priorityFee: '2', priorityFee: '2',
}); });
}); });
it('#getIsAdvancedGasFeeDefault', () => {
const isAdvancedGasFeeDefault =
selectors.getIsAdvancedGasFeeDefault(mockState);
expect(isAdvancedGasFeeDefault).toStrictEqual(true);
});
it('#getAppIsLoading', () => { it('#getAppIsLoading', () => {
const appIsLoading = selectors.getAppIsLoading(mockState); const appIsLoading = selectors.getAppIsLoading(mockState);
expect(appIsLoading).toStrictEqual(false); expect(appIsLoading).toStrictEqual(false);

View File

@ -3035,7 +3035,7 @@ export function detectNfts(): ThunkAction<
} }
export function setAdvancedGasFee( export function setAdvancedGasFee(
val: { maxBaseFee?: Hex; priorityFee?: Hex } | null, val: { chainId: Hex; maxBaseFee?: Hex; priorityFee?: Hex } | null,
): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> { ): ThunkAction<void, MetaMaskReduxState, unknown, AnyAction> {
return (dispatch: MetaMaskReduxDispatch) => { return (dispatch: MetaMaskReduxDispatch) => {
dispatch(showLoadingIndication()); dispatch(showLoadingIndication());