Repository navigation
chore(tron-wallet-snap): type caught error values - #619
Open
ulissesferreira wants to merge 1 commit into
Open
ulissesferreira wants to merge 1 commit into
ulissesferreira wants to merge 1 commit into
Conversation
`sanitizeSensitiveError` took `error: any` and read `error?.message` / `error?.stack` off it, and `SnapAssetsAdapter` destructured the `any` reason of a rejected `Promise.allSettled` entry — both made the error handling opaque to the type checker. - `sanitizeSensitiveError` now takes `unknown` and reads the two fields it inspects through a small `readErrorField` helper (`isObject` + `typeof` guard), so `message` / `stack` are `string` instead of `any`. The signature still returns `Error` because `PrepareErrorForTrackingFn` requires it, and non-sensitive values are still returned untouched (a `null` throw stays `null`, as the existing test asserts). - `SnapAssetsAdapter` re-checks `status === 'rejected'` instead of reusing the `isInactiveAccount` boolean, which is what narrows the settled result, and annotates the rejected reason and the `.catch` callback parameter as `unknown`. Clears 13 suppression entries (2 `no-unsafe-assignment` in `SnapAssetsAdapter`, plus the whole `sensitiveErrors` block: 2 assignment, 4 call, 4 member-access, 1 return) — 607 → 594 for `packages/tron-wallet-snap`. Verification: - `yarn oxlint packages/tron-wallet-snap` clean (suppressions pruned) - `tsc --project tsconfig.json --noEmit` clean - `yarn workspace @metamask/tron-wallet-snap run test` — 63 files / 1052 tests - `oxfmt --check` clean
ulissesferreira
temporarily deployed
to
default-branch
November 17, 2026 00:40 — with
GitHub Actions
Inactive
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fourth slice of the Tron Snap's
oxlint-suppressions.jsondebt, split by type of change. This one clears caught error values that were typedany— 13 entries, 607 → 594 forpackages/tron-wallet-snaponmainafter #611 and #613. It does not touch any of #612's files (no-in-operator).sanitizeSensitiveError(utils/sensitiveErrors.ts, 11 entries) — tookerror: anyand readerror?.message/error?.stackoff it. It now takesunknownand reads exactly those two fields through a smallreadErrorFieldhelper (isObjectfrom@metamask/utils+ atypeofguard), somessageandstackarestringinstead ofany. The return type staysErrorbecausePrepareErrorForTrackingFn((error: unknown) => Error) requires it, and the "no sensitive keywords" path still returns the value untouched — including non-Errorthrowables, which the existing unit test asserts (sanitizeSensitiveError(null)isnull).SnapAssetsAdapter(2 entries) — the rejectedPromise.allSettledentry was destructured through a separateisInactiveAccountboolean, soreasonwasany. The block now re-checksstatus === 'rejected'(which is what narrows the settled result) and annotates the rejected reason and the.catchcallback parameter asunknown. Behaviour is unchanged: the same error is rethrown asAssetFetchError, the same account-not-found case proceeds, and the boolean still drives the TRC20 fallback below.Nothing about which errors are sanitized, tracked, or thrown changes — only the types the code reaches them through.
Verification
yarn oxlint packages/tron-wallet-snap— clean (suppressions pruned)yarn workspace @metamask/tron-wallet-snap exec tsc --project tsconfig.json --noEmit— cleanyarn workspace @metamask/tron-wallet-snap run test— 63 files / 1052 tests passoxfmt --check packages/tron-wallet-snap oxlint-suppressions.json— cleanRelated PRs
#611 (test-related rules) and #613 (redundant type assertions) are merged. #612 (
no-in-operator) is still open and untouched here; #618 (JSON.parseresults and batch arrays) is the previous slice of the same cleanup and touches a disjoint file set.