Skip to content

Commit de7302b

Browse files
authored
Merge branch 'develop' into feat/sentry-performance-monitoring-2
2 parents cae09ad + 3c4e17b commit de7302b

51 files changed

Lines changed: 523 additions & 226 deletions

File tree

Some content is hidden

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

.storybook/test-data.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,28 @@ const state = {
470470
isEns: true,
471471
},
472472
],
473-
contractExchangeRates: {
474-
'0xaD6D458402F60fD3Bd25163575031ACDce07538D': 0,
473+
marketData: {
474+
'0xaa36a7': {
475+
'0xaD6D458402F60fD3Bd25163575031ACDce07538D': {
476+
price: 0,
477+
contractPercentChange1d: 0.004,
478+
priceChange1d: 0.00004,
479+
},
480+
},
481+
'0x1': {
482+
'0xaD6D458402F60fD3Bd25163575031ACDce07538D': {
483+
price: 0,
484+
contractPercentChange1d: 0.004,
485+
priceChange1d: 0.00004,
486+
},
487+
},
488+
'0x5': {
489+
'0xaD6D458402F60fD3Bd25163575031ACDce07538D': {
490+
price: 0,
491+
contractPercentChange1d: 0.004,
492+
priceChange1d: 0.00004,
493+
},
494+
},
475495
},
476496
tokens: [
477497
{

.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/dist/chunk-Z6TBQQE5.js b/dist/chunk-Z6TBQQE5.js
2+
index 2f1b66f2c39794d660553bbdc395697775f90e1d..18d7d5620d827419100c75736f6ec809161da212 100644
3+
--- a/dist/chunk-Z6TBQQE5.js
4+
+++ b/dist/chunk-Z6TBQQE5.js
5+
@@ -295,7 +295,7 @@ var CodefiTokenPricesServiceV2 = class {
6+
(obj, tokenAddress) => {
7+
const lowercasedTokenAddress = tokenAddress.toLowerCase();
8+
const marketData = addressCryptoDataMap[lowercasedTokenAddress];
9+
- if (marketData === void 0) {
10+
+ if (!marketData) {
11+
return obj;
12+
}
13+
const { price } = marketData;

.yarn/patches/@metamask-assets-controllers-patch-0f46262fea.patch

Lines changed: 0 additions & 40 deletions
This file was deleted.

.yarn/patches/@metamask-assets-controllers-patch-7616cc1669.patch

Lines changed: 0 additions & 57 deletions
This file was deleted.

app/scripts/background.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ function saveTimestamp() {
232232
* @property {object} identities - An object matching lower-case hex addresses to Identity objects with "address" and "name" (nickname) keys.
233233
* @property {object} networkConfigurations - A list of network configurations, containing RPC provider details (eg chainId, rpcUrl, rpcPreferences).
234234
* @property {Array} addressBook - A list of previously sent to addresses.
235-
* @property {object} contractExchangeRatesByChainId - Info about current token prices keyed by chainId.
236-
* @property {object} contractExchangeRates - Info about current token prices on current chain.
235+
* @property {object} marketData - A map from chain ID -> contract address -> an object containing the token's market data.
237236
* @property {Array} tokens - Tokens held by the current user, including their balances.
238237
* @property {object} send - TODO: Document
239238
* @property {boolean} useBlockie - Indicates preferred user identicon format. True for blockie, false for Jazzicon.

app/scripts/controllers/swaps.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,14 @@ export default class SwapsController {
706706
}
707707

708708
async _findTopQuoteAndCalculateSavings(quotes = {}) {
709-
const { contractExchangeRates: tokenConversionRates } =
710-
this.getTokenRatesState();
709+
const { marketData } = this.getTokenRatesState();
710+
const chainId = this._getCurrentChainId();
711+
712+
const tokenConversionRates = marketData[chainId];
713+
711714
const {
712715
swapsState: { customGasPrice, customMaxPriorityFeePerGas },
713716
} = this.store.getState();
714-
const chainId = this._getCurrentChainId();
715717

716718
const numQuotes = Object.keys(quotes).length;
717719
if (!numQuotes) {
@@ -836,7 +838,7 @@ export default class SwapsController {
836838
Object.keys(tokenConversionRates).find((tokenAddress) =>
837839
isEqualCaseInsensitive(tokenAddress, destinationToken),
838840
)
839-
];
841+
]?.price;
840842
const conversionRateForSorting = tokenConversionRate || 1;
841843

842844
const ethValueOfTokens = decimalAdjustedDestinationAmount.times(

app/scripts/controllers/swaps.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ const MOCK_FETCH_METADATA = {
8181
};
8282

8383
const MOCK_TOKEN_RATES_STORE = () => ({
84-
contractExchangeRates: {
85-
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 2,
86-
'0x1111111111111111111111111111111111111111': 0.1,
84+
marketData: {
85+
'0x1': {
86+
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': { price: 2 },
87+
'0x1111111111111111111111111111111111111111': { price: 0.1 },
88+
},
8789
},
8890
});
8991

@@ -794,7 +796,9 @@ describe('SwapsController', function () {
794796
.resolves(BigNumber.from(1));
795797

796798
swapsController.getTokenRatesState = () => ({
797-
contractExchangeRates: {},
799+
marketData: {
800+
'0x1': {},
801+
},
798802
});
799803

800804
const [newQuotes, topAggId] = await swapsController.fetchAndSetQuotes(

app/scripts/lib/setupSentry.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ export const SENTRY_BACKGROUND_STATE = {
342342
},
343343
},
344344
TokenRatesController: {
345-
contractExchangeRates: false,
346-
contractExchangeRatesByChainId: false,
345+
marketData: false,
347346
},
348347
TokensController: {
349348
allDetectedTokens: {

app/scripts/metamask-controller.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,10 @@ export default class MetamaskController extends EventEmitter {
657657

658658
const nftControllerMessenger = this.controllerMessenger.getRestricted({
659659
name: 'NftController',
660-
allowedActions: [`${this.approvalController.name}:addRequest`],
660+
allowedActions: [
661+
`${this.approvalController.name}:addRequest`,
662+
`${this.networkController.name}:getNetworkClientById`,
663+
],
661664
});
662665
this.nftController = new NftController(
663666
{
@@ -742,6 +745,9 @@ export default class MetamaskController extends EventEmitter {
742745
: !this.preferencesController.store.getState().useNftDetection,
743746
selectedAddress:
744747
this.preferencesController.store.getState().selectedAddress,
748+
getNetworkClientById: this.networkController.getNetworkClientById.bind(
749+
this.networkController,
750+
),
745751
});
746752

747753
this.metaMetricsController = new MetaMetricsController({

0 commit comments

Comments
 (0)