Skip to content

Commit daf1c18

Browse files
committed
Merge branch 'main' into n3ps/fix-confirmation-snap
2 parents 0075809 + 57eb9f3 commit daf1c18

File tree

178 files changed

+4045
-2481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+4045
-2481
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
diff --git a/dist/CurrencyRateController.cjs b/dist/CurrencyRateController.cjs
2+
index 9329fa3772bad655112451929bd107d99d95b34e..57683eb3b5501085f8d12fabdf0720ced0479ba8 100644
3+
--- a/dist/CurrencyRateController.cjs
4+
+++ b/dist/CurrencyRateController.cjs
5+
@@ -42,6 +42,7 @@ const defaultState = {
6+
},
7+
},
8+
};
9+
+const boundedPrecisionNumber = (value, precision = 9) => Number(value.toFixed(precision));
10+
/**
11+
* Controller that passively polls on a set interval for an exchange rate from the current network
12+
* asset to the user's preferred currency.
13+
@@ -169,8 +170,12 @@ _CurrencyRateController_tokenPricesService = new WeakMap(), _CurrencyRateControl
14+
const rate = priceApiExchangeRatesResponse[fetchedCurrency.toLowerCase()];
15+
acc[nativeCurrency] = {
16+
conversionDate: rate !== undefined ? Date.now() / 1000 : null,
17+
- conversionRate: rate?.value ? Number(1 / rate?.value) : null,
18+
- usdConversionRate: rate?.usd ? Number(1 / rate?.usd) : null,
19+
+ conversionRate: rate?.value
20+
+ ? boundedPrecisionNumber(1 / rate.value)
21+
+ : null,
22+
+ usdConversionRate: rate?.usd
23+
+ ? boundedPrecisionNumber(1 / rate.usd)
24+
+ : null,
25+
};
26+
return acc;
27+
}, {});
28+
@@ -211,7 +216,9 @@ _CurrencyRateController_tokenPricesService = new WeakMap(), _CurrencyRateControl
29+
return {
30+
nativeCurrency,
31+
conversionDate: tokenPrice ? Date.now() / 1000 : null,
32+
- conversionRate: tokenPrice?.price ?? null,
33+
+ conversionRate: tokenPrice?.price
34+
+ ? boundedPrecisionNumber(tokenPrice.price)
35+
+ : null,
36+
usdConversionRate: null, // Token prices service doesn't provide USD rate in this context
37+
};
38+
}));
39+
@@ -232,8 +239,12 @@ _CurrencyRateController_tokenPricesService = new WeakMap(), _CurrencyRateControl
40+
const ratesFromTokenPricesService = ratesFromTokenPrices.reduce((acc, rate) => {
41+
acc[rate.nativeCurrency] = {
42+
conversionDate: rate.conversionDate,
43+
- conversionRate: rate.conversionRate,
44+
- usdConversionRate: rate.usdConversionRate,
45+
+ conversionRate: rate.conversionRate
46+
+ ? boundedPrecisionNumber(rate.conversionRate)
47+
+ : null,
48+
+ usdConversionRate: rate.usdConversionRate
49+
+ ? boundedPrecisionNumber(rate.usdConversionRate)
50+
+ : null,
51+
};
52+
return acc;
53+
}, {});
54+
diff --git a/dist/CurrencyRateController.mjs b/dist/CurrencyRateController.mjs
55+
index d9c312e93b9ea6d37ad55321b2588248a61e5442..62280a33f6f67efcc173b5699b4f9bb13eea1c05 100644
56+
--- a/dist/CurrencyRateController.mjs
57+
+++ b/dist/CurrencyRateController.mjs
58+
@@ -39,6 +39,7 @@ const defaultState = {
59+
},
60+
},
61+
};
62+
+const boundedPrecisionNumber = (value, precision = 9) => Number(value.toFixed(precision));
63+
/**
64+
* Controller that passively polls on a set interval for an exchange rate from the current network
65+
* asset to the user's preferred currency.
66+
@@ -165,8 +166,12 @@ _CurrencyRateController_tokenPricesService = new WeakMap(), _CurrencyRateControl
67+
const rate = priceApiExchangeRatesResponse[fetchedCurrency.toLowerCase()];
68+
acc[nativeCurrency] = {
69+
conversionDate: rate !== undefined ? Date.now() / 1000 : null,
70+
- conversionRate: rate?.value ? Number(1 / rate?.value) : null,
71+
- usdConversionRate: rate?.usd ? Number(1 / rate?.usd) : null,
72+
+ conversionRate: rate?.value
73+
+ ? boundedPrecisionNumber(1 / rate.value)
74+
+ : null,
75+
+ usdConversionRate: rate?.usd
76+
+ ? boundedPrecisionNumber(1 / rate.usd)
77+
+ : null,
78+
};
79+
return acc;
80+
}, {});
81+
@@ -207,7 +212,9 @@ _CurrencyRateController_tokenPricesService = new WeakMap(), _CurrencyRateControl
82+
return {
83+
nativeCurrency,
84+
conversionDate: tokenPrice ? Date.now() / 1000 : null,
85+
- conversionRate: tokenPrice?.price ?? null,
86+
+ conversionRate: tokenPrice?.price
87+
+ ? boundedPrecisionNumber(tokenPrice.price)
88+
+ : null,
89+
usdConversionRate: null, // Token prices service doesn't provide USD rate in this context
90+
};
91+
}));
92+
@@ -228,8 +235,12 @@ _CurrencyRateController_tokenPricesService = new WeakMap(), _CurrencyRateControl
93+
const ratesFromTokenPricesService = ratesFromTokenPrices.reduce((acc, rate) => {
94+
acc[rate.nativeCurrency] = {
95+
conversionDate: rate.conversionDate,
96+
- conversionRate: rate.conversionRate,
97+
- usdConversionRate: rate.usdConversionRate,
98+
+ conversionRate: rate.conversionRate
99+
+ ? boundedPrecisionNumber(rate.conversionRate)
100+
+ : null,
101+
+ usdConversionRate: rate.usdConversionRate
102+
+ ? boundedPrecisionNumber(rate.usdConversionRate)
103+
+ : null,
104+
};
105+
return acc;
106+
}, {});

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ npmAuditIgnoreAdvisories:
4646
# Material UI dependencies are planned for removal
4747
- '@material-ui/core (deprecation)'
4848
- '@material-ui/styles (deprecation)'
49+
- '@material-ui/pickers (deprecation)'
4950

5051
# Dependencies brought in by @truffle/decoder that are deprecated:
5152
- 'cids (deprecation)' # via @ensdomains/content-hash

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [13.12.1]
11+
12+
### Fixed
13+
14+
- Adds bounds to currencyRates (#38591)
15+
1016
## [13.12.0]
1117

1218
### Added
@@ -1391,7 +1397,8 @@ authorized by the user.` error until the user fully revoked dapp
13911397
- This changelog was split off with 12.22.0
13921398
- All older changes can be found in [docs/CHANGELOG_older.md](https://github.com/MetaMask/metamask-extension/blob/main/docs/CHANGELOG_older.md)
13931399

1394-
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v13.12.0...HEAD
1400+
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v13.12.1...HEAD
1401+
[13.12.1]: https://github.com/MetaMask/metamask-extension/compare/v13.12.0...v13.12.1
13951402
[13.12.0]: https://github.com/MetaMask/metamask-extension/compare/v13.11.2...v13.12.0
13961403
[13.11.2]: https://github.com/MetaMask/metamask-extension/compare/v13.11.1...v13.11.2
13971404
[13.11.1]: https://github.com/MetaMask/metamask-extension/compare/v13.11.0...v13.11.1

app/_locales/en/messages.json

Lines changed: 7 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

Lines changed: 7 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/scripts/background.js

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { finished } from 'readable-stream';
1515
import log from 'loglevel';
1616
import browser from 'webextension-polyfill';
1717
import { isObject, hasProperty } from '@metamask/utils';
18-
import { NotificationServicesController } from '@metamask/notification-services-controller';
1918
import { ExtensionPortStream } from 'extension-port-stream';
2019
import { withResolvers } from '../../shared/lib/promise-with-resolvers';
2120
import { FirstTimeFlowType } from '../../shared/constants/onboarding';
@@ -109,8 +108,6 @@ const lazyListener =
109108

110109
// eslint-disable-next-line @metamask/design-tokens/color-no-hex
111110
const BADGE_COLOR_APPROVAL = '#0376C9';
112-
// eslint-disable-next-line @metamask/design-tokens/color-no-hex
113-
const BADGE_COLOR_NOTIFICATION = '#D73847';
114111
const BADGE_MAX_COUNT = 9;
115112

116113
const inTest = process.env.IN_TEST;
@@ -1455,16 +1452,12 @@ export function setupController(
14551452
*/
14561453
function updateBadge() {
14571454
const pendingApprovalCount = getPendingApprovalCount();
1458-
const unreadNotificationsCount = getUnreadNotificationsCount();
14591455

14601456
let label = '';
1461-
let badgeColor = BADGE_COLOR_APPROVAL;
1457+
const badgeColor = BADGE_COLOR_APPROVAL;
14621458

14631459
if (pendingApprovalCount) {
14641460
label = getBadgeLabel(pendingApprovalCount, BADGE_MAX_COUNT);
1465-
} else if (unreadNotificationsCount > 0) {
1466-
label = getBadgeLabel(unreadNotificationsCount, BADGE_MAX_COUNT);
1467-
badgeColor = BADGE_COLOR_NOTIFICATION;
14681461
}
14691462

14701463
try {
@@ -1495,55 +1488,6 @@ export function setupController(
14951488
}
14961489
}
14971490

1498-
function getUnreadNotificationsCount() {
1499-
try {
1500-
const { isNotificationServicesEnabled, isFeatureAnnouncementsEnabled } =
1501-
controller.notificationServicesController.state;
1502-
1503-
const snapNotificationCount = Object.values(
1504-
controller.notificationServicesController.state
1505-
.metamaskNotificationsList,
1506-
).filter(
1507-
(notification) =>
1508-
notification.type ===
1509-
NotificationServicesController.Constants.TRIGGER_TYPES.SNAP &&
1510-
notification.readDate === null,
1511-
).length;
1512-
1513-
const featureAnnouncementCount = isFeatureAnnouncementsEnabled
1514-
? controller.notificationServicesController.state.metamaskNotificationsList.filter(
1515-
(notification) =>
1516-
!notification.isRead &&
1517-
notification.type ===
1518-
NotificationServicesController.Constants.TRIGGER_TYPES
1519-
.FEATURES_ANNOUNCEMENT,
1520-
).length
1521-
: 0;
1522-
1523-
const walletNotificationCount = isNotificationServicesEnabled
1524-
? controller.notificationServicesController.state.metamaskNotificationsList.filter(
1525-
(notification) =>
1526-
!notification.isRead &&
1527-
notification.type !==
1528-
NotificationServicesController.Constants.TRIGGER_TYPES
1529-
.FEATURES_ANNOUNCEMENT &&
1530-
notification.type !==
1531-
NotificationServicesController.Constants.TRIGGER_TYPES.SNAP,
1532-
).length
1533-
: 0;
1534-
1535-
const unreadNotificationsCount =
1536-
snapNotificationCount +
1537-
featureAnnouncementCount +
1538-
walletNotificationCount;
1539-
1540-
return unreadNotificationsCount;
1541-
} catch (error) {
1542-
console.error('Failed to get unread notifications count:', error);
1543-
return 0;
1544-
}
1545-
}
1546-
15471491
notificationManager.on(
15481492
NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,
15491493
({ automaticallyClosed }) => {

0 commit comments

Comments
 (0)