mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Remove dupe Prettier config from ESLint config (#13234)
The ESLint config for the extension explicitly includes support for Prettier. However, this is already being provided by our global ESLint config (`@metamask/eslint-config`). Therefore there is no need to include it here. In fact, this is causing weird issues where the `curly` option is getting overridden somehow. After this change, these syntaxes are invalid: ``` javascript if (foo) return; ``` ``` javascript if (foo) return 'bar'; ```
This commit is contained in:
parent
0c531f8b01
commit
af971cd5b6
@ -39,13 +39,9 @@ module.exports = {
|
|||||||
'storybook-build/**',
|
'storybook-build/**',
|
||||||
],
|
],
|
||||||
|
|
||||||
extends: [
|
extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],
|
||||||
'@metamask/eslint-config',
|
|
||||||
'@metamask/eslint-config-nodejs',
|
|
||||||
'prettier',
|
|
||||||
],
|
|
||||||
|
|
||||||
plugins: ['@babel', 'import', 'prettier'],
|
plugins: ['@babel', 'import'],
|
||||||
|
|
||||||
globals: {
|
globals: {
|
||||||
document: 'readonly',
|
document: 'readonly',
|
||||||
|
@ -679,8 +679,11 @@ describe('TransactionStateManager', function () {
|
|||||||
// transaction
|
// transaction
|
||||||
const txs = generateTransactions(limit + 5, {
|
const txs = generateTransactions(limit + 5, {
|
||||||
chainId: (i) => {
|
chainId: (i) => {
|
||||||
if (i === 0 || i === 1) return MAINNET_CHAIN_ID;
|
if (i === 0 || i === 1) {
|
||||||
else if (i === 4 || i === 5) return RINKEBY_CHAIN_ID;
|
return MAINNET_CHAIN_ID;
|
||||||
|
} else if (i === 4 || i === 5) {
|
||||||
|
return RINKEBY_CHAIN_ID;
|
||||||
|
}
|
||||||
return currentChainId;
|
return currentChainId;
|
||||||
},
|
},
|
||||||
to: VALID_ADDRESS,
|
to: VALID_ADDRESS,
|
||||||
@ -726,8 +729,11 @@ describe('TransactionStateManager', function () {
|
|||||||
to: VALID_ADDRESS,
|
to: VALID_ADDRESS,
|
||||||
from: VALID_ADDRESS_TWO,
|
from: VALID_ADDRESS_TWO,
|
||||||
nonce: (i) => {
|
nonce: (i) => {
|
||||||
if (i === 1) return '0';
|
if (i === 1) {
|
||||||
else if (i === 5) return '4';
|
return '0';
|
||||||
|
} else if (i === 5) {
|
||||||
|
return '4';
|
||||||
|
}
|
||||||
return `${i}`;
|
return `${i}`;
|
||||||
},
|
},
|
||||||
status: (i) =>
|
status: (i) =>
|
||||||
|
@ -450,7 +450,9 @@ function createFactoredBuild({
|
|||||||
// create entry points for each file
|
// create entry points for each file
|
||||||
for (const [groupLabel, groupSet] of sizeGroupMap.entries()) {
|
for (const [groupLabel, groupSet] of sizeGroupMap.entries()) {
|
||||||
// skip "common" group, they are added to all other groups
|
// skip "common" group, they are added to all other groups
|
||||||
if (groupSet === commonSet) continue;
|
if (groupSet === commonSet) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (groupLabel) {
|
switch (groupLabel) {
|
||||||
case 'ui': {
|
case 'ui': {
|
||||||
|
@ -16,7 +16,9 @@ module.exports = {
|
|||||||
|
|
||||||
async function getHighlightAnnouncement({ changedFiles, artifactBase }) {
|
async function getHighlightAnnouncement({ changedFiles, artifactBase }) {
|
||||||
const highlights = await getHighlights({ changedFiles });
|
const highlights = await getHighlights({ changedFiles });
|
||||||
if (!highlights.length) return null;
|
if (!highlights.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const highlightsBody = highlights
|
const highlightsBody = highlights
|
||||||
.map((entry) => `\n- [${entry}](${urlForStoryFile(entry, artifactBase)})`)
|
.map((entry) => `\n- [${entry}](${urlForStoryFile(entry, artifactBase)})`)
|
||||||
.join('');
|
.join('');
|
||||||
|
@ -65,8 +65,9 @@ const PriorityFeeInput = () => {
|
|||||||
if (
|
if (
|
||||||
estimateUsed !== PRIORITY_LEVELS.CUSTOM &&
|
estimateUsed !== PRIORITY_LEVELS.CUSTOM &&
|
||||||
advancedGasFeeValues?.priorityFee
|
advancedGasFeeValues?.priorityFee
|
||||||
)
|
) {
|
||||||
return advancedGasFeeValues.priorityFee;
|
return advancedGasFeeValues.priorityFee;
|
||||||
|
}
|
||||||
return maxPriorityFeePerGas;
|
return maxPriorityFeePerGas;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@ const AdvancedGasFeePopover = () => {
|
|||||||
currentModal,
|
currentModal,
|
||||||
} = useTransactionModalContext();
|
} = useTransactionModalContext();
|
||||||
|
|
||||||
if (currentModal !== 'advancedGasFee') return null;
|
if (currentModal !== 'advancedGasFee') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdvancedGasFeePopoverContextProvider>
|
<AdvancedGasFeePopoverContextProvider>
|
||||||
|
@ -28,7 +28,9 @@ const EditGasFeePopover = () => {
|
|||||||
openModalCount,
|
openModalCount,
|
||||||
} = useTransactionModalContext();
|
} = useTransactionModalContext();
|
||||||
|
|
||||||
if (currentModal !== 'editGasFee') return null;
|
if (currentModal !== 'editGasFee') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let popupTitle = 'editGasFeeModalTitle';
|
let popupTitle = 'editGasFeeModalTitle';
|
||||||
if (editGasMode === EDIT_GAS_MODES.CANCEL) {
|
if (editGasMode === EDIT_GAS_MODES.CANCEL) {
|
||||||
|
@ -37,8 +37,9 @@ export const useCustomTimeEstimate = ({
|
|||||||
isGasEstimatesLoading ||
|
isGasEstimatesLoading ||
|
||||||
gasEstimateType !== GAS_ESTIMATE_TYPES.FEE_MARKET ||
|
gasEstimateType !== GAS_ESTIMATE_TYPES.FEE_MARKET ||
|
||||||
!maxPriorityFeePerGas
|
!maxPriorityFeePerGas
|
||||||
)
|
) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (isUnknownLow) {
|
if (isUnknownLow) {
|
||||||
// getGasFeeTimeEstimate requires parameters in string format
|
// getGasFeeTimeEstimate requires parameters in string format
|
||||||
getGasFeeTimeEstimate(
|
getGasFeeTimeEstimate(
|
||||||
|
@ -28,7 +28,9 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
|
|
||||||
const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences);
|
const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences);
|
||||||
|
|
||||||
if (hasSimulationError && !userAcknowledgedGasMissing) return null;
|
if (hasSimulationError && !userAcknowledgedGasMissing) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransactionDetailItem
|
<TransactionDetailItem
|
||||||
|
@ -32,7 +32,9 @@ const QRHardwareSignRequest = ({ request, handleCancel, setErrorTitle }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (status === 'play') return renderPlayer();
|
if (status === 'play') {
|
||||||
|
return renderPlayer();
|
||||||
|
}
|
||||||
return renderReader();
|
return renderReader();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@ export default function LoadingHeartBeat() {
|
|||||||
useShouldAnimateGasEstimations();
|
useShouldAnimateGasEstimations();
|
||||||
const active = useSelector(getGasLoadingAnimationIsShowing);
|
const active = useSelector(getGasLoadingAnimationIsShowing);
|
||||||
|
|
||||||
if (process.env.IN_TEST) return null;
|
if (process.env.IN_TEST) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -30,7 +30,9 @@ export default function NumericInput({
|
|||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const newValue = e.target.value;
|
const newValue = e.target.value;
|
||||||
const match = DECIMAL_REGEX.exec(newValue);
|
const match = DECIMAL_REGEX.exec(newValue);
|
||||||
if (match?.[1]?.length >= 15) return;
|
if (match?.[1]?.length >= 15) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
onChange?.(parseFloat(newValue || 0, 10));
|
onChange?.(parseFloat(newValue || 0, 10));
|
||||||
}}
|
}}
|
||||||
min="0"
|
min="0"
|
||||||
|
@ -38,7 +38,9 @@ export const TransactionModalContextProvider = ({
|
|||||||
|
|
||||||
const closeModal = (modalName) => {
|
const closeModal = (modalName) => {
|
||||||
const index = openModals.indexOf(modalName);
|
const index = openModals.indexOf(modalName);
|
||||||
if (openModals < 0) return;
|
if (openModals < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const modals = [...openModals];
|
const modals = [...openModals];
|
||||||
modals.splice(index, 1);
|
modals.splice(index, 1);
|
||||||
setOpenModals(modals);
|
setOpenModals(modals);
|
||||||
@ -49,7 +51,9 @@ export const TransactionModalContextProvider = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openModal = (modalName) => {
|
const openModal = (modalName) => {
|
||||||
if (openModals.includes(modalName)) return;
|
if (openModals.includes(modalName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
captureEventEnabled && captureEvent();
|
captureEventEnabled && captureEvent();
|
||||||
const modals = [...openModals];
|
const modals = [...openModals];
|
||||||
modals.push(modalName);
|
modals.push(modalName);
|
||||||
|
@ -28,7 +28,9 @@ export const gasEstimateGreaterThanGasUsedPlusTenPercent = (
|
|||||||
* @returns {string | undefined} - hex value in WEI 10% higher than the param.
|
* @returns {string | undefined} - hex value in WEI 10% higher than the param.
|
||||||
*/
|
*/
|
||||||
export function addTenPercent(hexStringValue, conversionOptions = {}) {
|
export function addTenPercent(hexStringValue, conversionOptions = {}) {
|
||||||
if (hexStringValue === undefined) return undefined;
|
if (hexStringValue === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return addHexPrefix(
|
return addHexPrefix(
|
||||||
multiplyCurrencies(hexStringValue, 1.1, {
|
multiplyCurrencies(hexStringValue, 1.1, {
|
||||||
toNumericBase: 'hex',
|
toNumericBase: 'hex',
|
||||||
|
@ -65,7 +65,9 @@ export function isDefaultMetaMaskChain(chainId) {
|
|||||||
|
|
||||||
// Both inputs should be strings. This method is currently used to compare tokenAddress hex strings.
|
// Both inputs should be strings. This method is currently used to compare tokenAddress hex strings.
|
||||||
export function isEqualCaseInsensitive(value1, value2) {
|
export function isEqualCaseInsensitive(value1, value2) {
|
||||||
if (typeof value1 !== 'string' || typeof value2 !== 'string') return false;
|
if (typeof value1 !== 'string' || typeof value2 !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return value1.toLowerCase() === value2.toLowerCase();
|
return value1.toLowerCase() === value2.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +433,9 @@ const MINUTE_CUTOFF = 90 * 60;
|
|||||||
const SECOND_CUTOFF = 90;
|
const SECOND_CUTOFF = 90;
|
||||||
|
|
||||||
export const toHumanReadableTime = (t, milliseconds) => {
|
export const toHumanReadableTime = (t, milliseconds) => {
|
||||||
if (milliseconds === undefined || milliseconds === null) return '';
|
if (milliseconds === undefined || milliseconds === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
const seconds = Math.ceil(milliseconds / 1000);
|
const seconds = Math.ceil(milliseconds / 1000);
|
||||||
if (seconds <= SECOND_CUTOFF) {
|
if (seconds <= SECOND_CUTOFF) {
|
||||||
return t('gasTimingSecondsShort', [seconds]);
|
return t('gasTimingSecondsShort', [seconds]);
|
||||||
|
@ -26,12 +26,16 @@ const validateGasLimit = (gasLimit, minimumGasLimit) => {
|
|||||||
{ value: minimumGasLimit || GAS_LIMITS.SIMPLE, fromNumericBase: 'hex' },
|
{ value: minimumGasLimit || GAS_LIMITS.SIMPLE, fromNumericBase: 'hex' },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (gasLimitTooLow) return GAS_FORM_ERRORS.GAS_LIMIT_OUT_OF_BOUNDS;
|
if (gasLimitTooLow) {
|
||||||
|
return GAS_FORM_ERRORS.GAS_LIMIT_OUT_OF_BOUNDS;
|
||||||
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const validateMaxPriorityFee = (maxPriorityFeePerGas, supportsEIP1559) => {
|
const validateMaxPriorityFee = (maxPriorityFeePerGas, supportsEIP1559) => {
|
||||||
if (!supportsEIP1559) return undefined;
|
if (!supportsEIP1559) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
if (bnLessThanEqualTo(maxPriorityFeePerGas, 0)) {
|
if (bnLessThanEqualTo(maxPriorityFeePerGas, 0)) {
|
||||||
return GAS_FORM_ERRORS.MAX_PRIORITY_FEE_BELOW_MINIMUM;
|
return GAS_FORM_ERRORS.MAX_PRIORITY_FEE_BELOW_MINIMUM;
|
||||||
}
|
}
|
||||||
@ -44,7 +48,9 @@ const validateMaxFee = (
|
|||||||
maxPriorityFeePerGas,
|
maxPriorityFeePerGas,
|
||||||
supportsEIP1559,
|
supportsEIP1559,
|
||||||
) => {
|
) => {
|
||||||
if (maxPriorityFeeError || !supportsEIP1559) return undefined;
|
if (maxPriorityFeeError || !supportsEIP1559) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
if (bnGreaterThan(maxPriorityFeePerGas, maxFeePerGas)) {
|
if (bnGreaterThan(maxPriorityFeePerGas, maxFeePerGas)) {
|
||||||
return GAS_FORM_ERRORS.MAX_FEE_IMBALANCE;
|
return GAS_FORM_ERRORS.MAX_FEE_IMBALANCE;
|
||||||
}
|
}
|
||||||
@ -57,7 +63,9 @@ const validateGasPrice = (
|
|||||||
supportsEIP1559,
|
supportsEIP1559,
|
||||||
transaction,
|
transaction,
|
||||||
) => {
|
) => {
|
||||||
if (supportsEIP1559 && isFeeMarketGasEstimate) return undefined;
|
if (supportsEIP1559 && isFeeMarketGasEstimate) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
(!supportsEIP1559 || transaction?.txParams?.gasPrice) &&
|
(!supportsEIP1559 || transaction?.txParams?.gasPrice) &&
|
||||||
bnLessThanEqualTo(gasPrice, 0)
|
bnLessThanEqualTo(gasPrice, 0)
|
||||||
@ -74,8 +82,9 @@ const getMaxPriorityFeeWarning = (
|
|||||||
maxPriorityFeePerGas,
|
maxPriorityFeePerGas,
|
||||||
supportsEIP1559,
|
supportsEIP1559,
|
||||||
) => {
|
) => {
|
||||||
if (!supportsEIP1559 || !isFeeMarketGasEstimate || isGasEstimatesLoading)
|
if (!supportsEIP1559 || !isFeeMarketGasEstimate || isGasEstimatesLoading) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
bnLessThan(
|
bnLessThan(
|
||||||
maxPriorityFeePerGas,
|
maxPriorityFeePerGas,
|
||||||
@ -219,17 +228,29 @@ export function useGasFeeErrors({
|
|||||||
|
|
||||||
const gasErrors = useMemo(() => {
|
const gasErrors = useMemo(() => {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
if (gasLimitError) errors.gasLimit = gasLimitError;
|
if (gasLimitError) {
|
||||||
if (maxPriorityFeeError) errors.maxPriorityFee = maxPriorityFeeError;
|
errors.gasLimit = gasLimitError;
|
||||||
if (maxFeeError) errors.maxFee = maxFeeError;
|
}
|
||||||
if (gasPriceError) errors.gasPrice = gasPriceError;
|
if (maxPriorityFeeError) {
|
||||||
|
errors.maxPriorityFee = maxPriorityFeeError;
|
||||||
|
}
|
||||||
|
if (maxFeeError) {
|
||||||
|
errors.maxFee = maxFeeError;
|
||||||
|
}
|
||||||
|
if (gasPriceError) {
|
||||||
|
errors.gasPrice = gasPriceError;
|
||||||
|
}
|
||||||
return errors;
|
return errors;
|
||||||
}, [gasLimitError, maxPriorityFeeError, maxFeeError, gasPriceError]);
|
}, [gasLimitError, maxPriorityFeeError, maxFeeError, gasPriceError]);
|
||||||
|
|
||||||
const gasWarnings = useMemo(() => {
|
const gasWarnings = useMemo(() => {
|
||||||
const warnings = {};
|
const warnings = {};
|
||||||
if (maxPriorityFeeWarning) warnings.maxPriorityFee = maxPriorityFeeWarning;
|
if (maxPriorityFeeWarning) {
|
||||||
if (maxFeeWarning) warnings.maxFee = maxFeeWarning;
|
warnings.maxPriorityFee = maxPriorityFeeWarning;
|
||||||
|
}
|
||||||
|
if (maxFeeWarning) {
|
||||||
|
warnings.maxFee = maxFeeWarning;
|
||||||
|
}
|
||||||
return warnings;
|
return warnings;
|
||||||
}, [maxPriorityFeeWarning, maxFeeWarning]);
|
}, [maxPriorityFeeWarning, maxFeeWarning]);
|
||||||
|
|
||||||
|
@ -116,9 +116,12 @@ export function useGasFeeInputs(
|
|||||||
userPrefersAdvancedGas &&
|
userPrefersAdvancedGas &&
|
||||||
transaction?.txParams?.maxPriorityFeePerGas &&
|
transaction?.txParams?.maxPriorityFeePerGas &&
|
||||||
transaction?.txParams?.maxFeePerGas
|
transaction?.txParams?.maxFeePerGas
|
||||||
)
|
) {
|
||||||
return null;
|
return null;
|
||||||
if (transaction) return transaction?.userFeeLevel || null;
|
}
|
||||||
|
if (transaction) {
|
||||||
|
return transaction?.userFeeLevel || null;
|
||||||
|
}
|
||||||
return defaultEstimateToUse;
|
return defaultEstimateToUse;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,8 +61,9 @@ export function useMaxFeePerGasInput({
|
|||||||
// transitional because it is only used to modify a transaction in the
|
// transitional because it is only used to modify a transaction in the
|
||||||
// metamask (background) state tree.
|
// metamask (background) state tree.
|
||||||
const [maxFeePerGas, setMaxFeePerGas] = useState(() => {
|
const [maxFeePerGas, setMaxFeePerGas] = useState(() => {
|
||||||
if (initialMaxFeePerGas && feeParamsAreCustom(transaction))
|
if (initialMaxFeePerGas && feeParamsAreCustom(transaction)) {
|
||||||
return initialMaxFeePerGas;
|
return initialMaxFeePerGas;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,8 +57,9 @@ export function useMaxPriorityFeePerGasInput({
|
|||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState(() => {
|
const [maxPriorityFeePerGas, setMaxPriorityFeePerGas] = useState(() => {
|
||||||
if (initialMaxPriorityFeePerGas && feeParamsAreCustom(transaction))
|
if (initialMaxPriorityFeePerGas && feeParamsAreCustom(transaction)) {
|
||||||
return initialMaxPriorityFeePerGas;
|
return initialMaxPriorityFeePerGas;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ const validateGasLimit = (gasLimit, minimumGasLimit) => {
|
|||||||
{ value: minimumGasLimit || GAS_LIMITS.SIMPLE, fromNumericBase: 'hex' },
|
{ value: minimumGasLimit || GAS_LIMITS.SIMPLE, fromNumericBase: 'hex' },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (gasLimitTooLow) return GAS_FORM_ERRORS.GAS_LIMIT_OUT_OF_BOUNDS;
|
if (gasLimitTooLow) {
|
||||||
|
return GAS_FORM_ERRORS.GAS_LIMIT_OUT_OF_BOUNDS;
|
||||||
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,7 +45,9 @@ const validateMaxFee = (
|
|||||||
maxPriorityFeePerGasToUse,
|
maxPriorityFeePerGasToUse,
|
||||||
supportsEIP1559,
|
supportsEIP1559,
|
||||||
) => {
|
) => {
|
||||||
if (maxPriorityFeeError) return undefined;
|
if (maxPriorityFeeError) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
supportsEIP1559 &&
|
supportsEIP1559 &&
|
||||||
bnGreaterThan(maxPriorityFeePerGasToUse, maxFeePerGasToUse)
|
bnGreaterThan(maxPriorityFeePerGasToUse, maxFeePerGasToUse)
|
||||||
@ -76,8 +80,9 @@ const getMaxPriorityFeeWarning = (
|
|||||||
maxPriorityFeePerGasToUse,
|
maxPriorityFeePerGasToUse,
|
||||||
supportsEIP1559,
|
supportsEIP1559,
|
||||||
) => {
|
) => {
|
||||||
if (!supportsEIP1559 || !isFeeMarketGasEstimate || isGasEstimatesLoading)
|
if (!supportsEIP1559 || !isFeeMarketGasEstimate || isGasEstimatesLoading) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
bnLessThan(
|
bnLessThan(
|
||||||
maxPriorityFeePerGasToUse,
|
maxPriorityFeePerGasToUse,
|
||||||
@ -220,17 +225,29 @@ export function useGasFeeErrors({
|
|||||||
|
|
||||||
const gasErrors = useMemo(() => {
|
const gasErrors = useMemo(() => {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
if (gasLimitError) errors.gasLimit = gasLimitError;
|
if (gasLimitError) {
|
||||||
if (maxPriorityFeeError) errors.maxPriorityFee = maxPriorityFeeError;
|
errors.gasLimit = gasLimitError;
|
||||||
if (maxFeeError) errors.maxFee = maxFeeError;
|
}
|
||||||
if (gasPriceError) errors.gasPrice = gasPriceError;
|
if (maxPriorityFeeError) {
|
||||||
|
errors.maxPriorityFee = maxPriorityFeeError;
|
||||||
|
}
|
||||||
|
if (maxFeeError) {
|
||||||
|
errors.maxFee = maxFeeError;
|
||||||
|
}
|
||||||
|
if (gasPriceError) {
|
||||||
|
errors.gasPrice = gasPriceError;
|
||||||
|
}
|
||||||
return errors;
|
return errors;
|
||||||
}, [gasLimitError, maxPriorityFeeError, maxFeeError, gasPriceError]);
|
}, [gasLimitError, maxPriorityFeeError, maxFeeError, gasPriceError]);
|
||||||
|
|
||||||
const gasWarnings = useMemo(() => {
|
const gasWarnings = useMemo(() => {
|
||||||
const warnings = {};
|
const warnings = {};
|
||||||
if (maxPriorityFeeWarning) warnings.maxPriorityFee = maxPriorityFeeWarning;
|
if (maxPriorityFeeWarning) {
|
||||||
if (maxFeeWarning) warnings.maxFee = maxFeeWarning;
|
warnings.maxPriorityFee = maxPriorityFeeWarning;
|
||||||
|
}
|
||||||
|
if (maxFeeWarning) {
|
||||||
|
warnings.maxFee = maxFeeWarning;
|
||||||
|
}
|
||||||
return warnings;
|
return warnings;
|
||||||
}, [maxPriorityFeeWarning, maxFeeWarning]);
|
}, [maxPriorityFeeWarning, maxFeeWarning]);
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ const TransactionAlerts = ({
|
|||||||
const pendingTransactions = useSelector(submittedPendingTransactionsSelector);
|
const pendingTransactions = useSelector(submittedPendingTransactionsSelector);
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
|
|
||||||
if (!supportsEIP1559V2) return null;
|
if (!supportsEIP1559V2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="transaction-alerts">
|
<div className="transaction-alerts">
|
||||||
|
@ -89,7 +89,9 @@ class RestoreVaultPage extends Component {
|
|||||||
handleImport = (event) => {
|
handleImport = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const { password, seedPhrase, disabled } = this.state;
|
const { password, seedPhrase, disabled } = this.state;
|
||||||
if (disabled) return;
|
if (disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {
|
const {
|
||||||
// eslint-disable-next-line no-shadow
|
// eslint-disable-next-line no-shadow
|
||||||
createNewVaultAndRestore,
|
createNewVaultAndRestore,
|
||||||
|
@ -55,10 +55,13 @@ export default class SendContent extends Component {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let gasError;
|
let gasError;
|
||||||
if (gasIsExcessive) gasError = GAS_PRICE_EXCESSIVE_ERROR_KEY;
|
if (gasIsExcessive) {
|
||||||
else if (noGasPrice) gasError = GAS_PRICE_FETCH_FAILURE_ERROR_KEY;
|
gasError = GAS_PRICE_EXCESSIVE_ERROR_KEY;
|
||||||
else if (getIsBalanceInsufficient)
|
} else if (noGasPrice) {
|
||||||
|
gasError = GAS_PRICE_FETCH_FAILURE_ERROR_KEY;
|
||||||
|
} else if (getIsBalanceInsufficient) {
|
||||||
gasError = INSUFFICIENT_FUNDS_FOR_GAS_ERROR_KEY;
|
gasError = INSUFFICIENT_FUNDS_FOR_GAS_ERROR_KEY;
|
||||||
|
}
|
||||||
const showHexData =
|
const showHexData =
|
||||||
this.props.showHexData && asset.type !== ASSET_TYPES.TOKEN;
|
this.props.showHexData && asset.type !== ASSET_TYPES.TOKEN;
|
||||||
|
|
||||||
|
@ -40,7 +40,9 @@ export default class SendFooter extends Component {
|
|||||||
sendStage,
|
sendStage,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
if (draftTransactionID) cancelTx({ id: draftTransactionID });
|
if (draftTransactionID) {
|
||||||
|
cancelTx({ id: draftTransactionID });
|
||||||
|
}
|
||||||
resetSendState();
|
resetSendState();
|
||||||
|
|
||||||
const nextRoute =
|
const nextRoute =
|
||||||
|
@ -836,6 +836,8 @@ export const getSwapsLivenessForNetwork = (swapsFeatureFlags = {}, chainId) => {
|
|||||||
* @returns number
|
* @returns number
|
||||||
*/
|
*/
|
||||||
export const countDecimals = (value) => {
|
export const countDecimals = (value) => {
|
||||||
if (!value || Math.floor(value) === value) return 0;
|
if (!value || Math.floor(value) === value) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return value.toString().split('.')[1]?.length || 0;
|
return value.toString().split('.')[1]?.length || 0;
|
||||||
};
|
};
|
||||||
|
@ -90,11 +90,15 @@ export function getCurrentQRHardwareState(state) {
|
|||||||
|
|
||||||
export function hasUnsignedQRHardwareTransaction(state) {
|
export function hasUnsignedQRHardwareTransaction(state) {
|
||||||
const { txParams } = state.confirmTransaction.txData;
|
const { txParams } = state.confirmTransaction.txData;
|
||||||
if (!txParams) return false;
|
if (!txParams) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const { from } = txParams;
|
const { from } = txParams;
|
||||||
const { keyrings } = state.metamask;
|
const { keyrings } = state.metamask;
|
||||||
const qrKeyring = keyrings.find((kr) => kr.type === KEYRING_TYPES.QR);
|
const qrKeyring = keyrings.find((kr) => kr.type === KEYRING_TYPES.QR);
|
||||||
if (!qrKeyring) return false;
|
if (!qrKeyring) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return Boolean(
|
return Boolean(
|
||||||
qrKeyring.accounts.find(
|
qrKeyring.accounts.find(
|
||||||
(account) => account.toLowerCase() === from.toLowerCase(),
|
(account) => account.toLowerCase() === from.toLowerCase(),
|
||||||
@ -110,7 +114,9 @@ export function hasUnsignedQRHardwareMessage(state) {
|
|||||||
const { from } = msgParams;
|
const { from } = msgParams;
|
||||||
const { keyrings } = state.metamask;
|
const { keyrings } = state.metamask;
|
||||||
const qrKeyring = keyrings.find((kr) => kr.type === KEYRING_TYPES.QR);
|
const qrKeyring = keyrings.find((kr) => kr.type === KEYRING_TYPES.QR);
|
||||||
if (!qrKeyring) return false;
|
if (!qrKeyring) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MESSAGE_TYPE.ETH_SIGN_TYPED_DATA:
|
case MESSAGE_TYPE.ETH_SIGN_TYPED_DATA:
|
||||||
case MESSAGE_TYPE.ETH_SIGN:
|
case MESSAGE_TYPE.ETH_SIGN:
|
||||||
|
@ -431,8 +431,9 @@ export function connectHardware(deviceName, page, hdPath, t) {
|
|||||||
dispatch(displayWarning(t('ledgerDeviceOpenFailureMessage')));
|
dispatch(displayWarning(t('ledgerDeviceOpenFailureMessage')));
|
||||||
throw new Error(t('ledgerDeviceOpenFailureMessage'));
|
throw new Error(t('ledgerDeviceOpenFailureMessage'));
|
||||||
} else {
|
} else {
|
||||||
if (deviceName !== DEVICE_NAMES.QR)
|
if (deviceName !== DEVICE_NAMES.QR) {
|
||||||
dispatch(displayWarning(error.message));
|
dispatch(displayWarning(error.message));
|
||||||
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user