Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/money-account-balance-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Stop including balance amounts in `MoneyAccountBalanceValidationError` messages, which are reported via the messenger's `captureException` ([#10619](https://github.com/MetaMask/core/pull/10619))

## [3.1.1]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,9 @@ describe('MoneyAccountBalanceService', () => {
usedFallback: true,
});
expect(captureException).toHaveBeenCalledWith(
expect.any(MoneyAccountBalanceValidationError),
new MoneyAccountBalanceValidationError(
'Invalid balance invariant: totalBalance must equal musdBalance + vmusdValueInMusd',
),
);
});

Expand Down Expand Up @@ -1856,7 +1858,9 @@ describe('MoneyAccountBalanceService', () => {
usedFallback: true,
});
expect(captureException).toHaveBeenCalledWith(
expect.any(MoneyAccountBalanceValidationError),
new MoneyAccountBalanceValidationError(
'Invalid musdBalance: expected a non-negative integer string',
),
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ const NON_NEGATIVE_INTEGER_STRING_PATTERN = /^\d+$/u;
* Validates that balance amounts are non-negative integer strings and that
* `totalBalance === musdBalance + vmusdValueInMusd`.
*
* Error messages must not include the amounts: these errors are reported to
* error monitoring, and exact balances can identify an account.
*
* @param balance - Balance amounts to validate.
* @throws {@link MoneyAccountBalanceValidationError} when validation fails.
*/
Expand All @@ -140,7 +143,7 @@ function assertValidBalanceAmounts(balance: MoneyAccountBalanceResponse): void {
for (const [field, value] of entries) {
if (!NON_NEGATIVE_INTEGER_STRING_PATTERN.test(value)) {
throw new MoneyAccountBalanceValidationError(
`Invalid ${field}: expected a non-negative integer string, got '${value}'`,
`Invalid ${field}: expected a non-negative integer string`,
);
}
}
Expand All @@ -150,7 +153,7 @@ function assertValidBalanceAmounts(balance: MoneyAccountBalanceResponse): void {
BigInt(balance.totalBalance)
) {
throw new MoneyAccountBalanceValidationError(
`Invalid balance invariant: totalBalance (${balance.totalBalance}) must equal musdBalance (${balance.musdBalance}) + vmusdValueInMusd (${balance.vmusdValueInMusd})`,
'Invalid balance invariant: totalBalance must equal musdBalance + vmusdValueInMusd',
);
}
}
Expand Down
Loading