Skip to content

Commit 052debe

Browse files
chore(helpers): remove unused ui helper exports (#47518)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Removes unused exports from unowned `ui/helpers` files. Owner set: `(none)` (no CODEOWNERS match). No user-facing behavior change. The declarations are not imported anywhere. Whole-word search only hit the definitions. None of these symbols or files are referenced by an open pull request. Declaration blame is older than 90 days, and the files themselves were not edited in the last 30 days. String values that are still locale message keys remain quoted elsewhere in `ui/`, so `yarn verify-locales` does not lose a message reference. | path | removed (file / symbol / class) | why dead | | --- | --- | --- | | ui/helpers/constants/error-keys.js | INSUFFICIENT_FUNDS_ERROR_KEY | unused export | | ui/helpers/constants/error-keys.js | TRANSACTION_ERROR_KEY | unused export | | ui/helpers/constants/error-keys.js | IS_SIGNING_OR_SUBMITTING | unused export | | ui/helpers/constants/gas.js | PRIORITY_LEVEL_ICON_MAP | unused export | | ui/helpers/constants/connected-sites.js | STATUS_CONNECTED_TO_SNAP | unused export | | ui/helpers/utils/confirm-tx.util.ts | convertTokenToFiat | unused export | | ui/helpers/utils/confirm-tx.util.ts | roundExponential | unused export | | ui/helpers/utils/confirm-tx.util.ts | BigNumber import | cascade from roundExponential | Left in place on purpose: five other unused error-key exports and `getGasFormErrorText`, because each is the only quoted reference to a locale message key. Locales are out of scope. Checks that passed: `yarn lint:tsc`, eslint on the touched files, and `yarn test:unit --coverage=false` for `ui/helpers/utils/confirm-tx.util.test.js` and `ui/helpers/constants` (no snapshot updates). No stylesheets changed. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: Refs: proactive dead-code cleanup (extension counterpart of metamask-mobile#37948) ## **Manual testing steps** N/A — deletes unreachable code. There is no user-facing behavior to click through. ## **Screenshots/Recordings** N/A — no UI change ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Deletes unreachable helper exports only; no runtime paths or security-sensitive logic are modified. > > **Overview** > Removes dead exports from `ui/helpers` that are not imported anywhere—proactive cleanup with no intended user-facing behavior change. > > **Constants:** drops `STATUS_CONNECTED_TO_SNAP`, three error-key constants (`INSUFFICIENT_FUNDS_ERROR_KEY`, `TRANSACTION_ERROR_KEY`, `IS_SIGNING_OR_SUBMITTING`), and the unused `PRIORITY_LEVEL_ICON_MAP` emoji map from gas helpers. > > **Confirm-tx utils:** deletes `convertTokenToFiat` and `roundExponential`, and removes the `bignumber.js` import that only served `roundExponential`. Remaining helpers (gas totals, fee formatting, dapp gas comparison, etc.) are unchanged. > > Other unused symbols were left when they still anchor locale message keys (per PR notes). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2d41c1b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
1 parent 060669f commit 052debe

4 files changed

Lines changed: 0 additions & 57 deletions

File tree

‎ui/helpers/constants/connected-sites.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ export const STATUS_CONNECTED = 'STATUS_CONNECTED';
22
export const STATUS_CONNECTED_TO_ANOTHER_ACCOUNT =
33
'STATUS_CONNECTED_TO_ANOTHER_ACCOUNT';
44
export const STATUS_NOT_CONNECTED = 'STATUS_NOT_CONNECTED';
5-
export const STATUS_CONNECTED_TO_SNAP = 'STATUS_CONNECTED_TO_SNAP';

‎ui/helpers/constants/error-keys.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
export const INSUFFICIENT_FUNDS_ERROR_KEY = 'insufficientFunds';
2-
export const TRANSACTION_ERROR_KEY = 'transactionError';
31
export const ETH_GAS_PRICE_FETCH_WARNING_KEY = 'ethGasPriceFetchWarning';
42
export const GAS_PRICE_FETCH_FAILURE_ERROR_KEY = 'gasPriceFetchFailed';
53
export const GAS_PRICE_EXCESSIVE_ERROR_KEY = 'gasPriceExcessive';
64
export const UNSENDABLE_ASSET_ERROR_KEY = 'unsendableAsset';
75
export const INVALID_ASSET_TYPE = 'invalidAssetType';
8-
export const IS_SIGNING_OR_SUBMITTING = 'isSigningOrSubmitting';
96
export const USER_OP_CONTRACT_DEPLOY_ERROR_KEY = 'userOpContractDeployError';

‎ui/helpers/constants/gas.js‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,3 @@ export function getGasFormErrorText(type, t, { minimumGasLimit } = {}) {
3131
return '';
3232
}
3333
}
34-
35-
export const PRIORITY_LEVEL_ICON_MAP = {
36-
low: '🐢',
37-
medium: '🦊',
38-
high: '🦍',
39-
dappSuggested: '🌐',
40-
dappSuggestedHigh: '🌐',
41-
swapSuggested: '🔄',
42-
tenPercentIncreased: '⬆',
43-
custom: '⚙️',
44-
};

‎ui/helpers/utils/confirm-tx.util.ts‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import currencyFormatter from 'currency-formatter';
22
import currencies from 'currency-formatter/currencies';
3-
import { BigNumber } from 'bignumber.js';
43

54
import { TransactionMeta } from '@metamask/transaction-controller';
65
import { Numeric } from '../../../shared/lib/Numeric';
@@ -72,47 +71,6 @@ export function formatCurrency(
7271
: value;
7372
}
7473

75-
export function convertTokenToFiat({
76-
value,
77-
fromCurrency = EtherDenomination.ETH,
78-
toCurrency,
79-
conversionRate,
80-
contractExchangeRate,
81-
}: {
82-
value: string;
83-
fromCurrency: EtherDenomination;
84-
toCurrency: string;
85-
conversionRate: number;
86-
contractExchangeRate: number;
87-
}): string {
88-
const totalExchangeRate = conversionRate * contractExchangeRate;
89-
90-
let tokenInFiat = new Numeric(value, 10);
91-
92-
if (fromCurrency !== toCurrency && totalExchangeRate) {
93-
tokenInFiat = tokenInFiat.applyConversionRate(totalExchangeRate);
94-
}
95-
96-
return tokenInFiat.round(2).toString();
97-
}
98-
99-
/**
100-
* Rounds the given decimal string to 4 significant digits.
101-
*
102-
* @param decimalString - The base-ten number to round.
103-
* @returns The rounded number, or the original number if no
104-
* rounding was necessary.
105-
*/
106-
export function roundExponential(decimalString: string): string {
107-
const PRECISION = 4;
108-
const bigNumberValue = new BigNumber(decimalString);
109-
110-
// In JS, numbers with exponentials greater than 20 get displayed as an exponential.
111-
return bigNumberValue.e > 20
112-
? bigNumberValue.toPrecision(PRECISION)
113-
: decimalString;
114-
}
115-
11674
export function areDappSuggestedAndTxParamGasFeesTheSame(
11775
txData: TransactionMeta,
11876
): boolean {

0 commit comments

Comments
 (0)