Skip to content

Commit

Permalink
Upgrade assets-controllers to v9
Browse files Browse the repository at this point in the history
The `@metamask/assets-controllers` package has been updated to v9. This
covers changes that were made as a part of the [v53][1] and [v55][2]
releases.

There were a lot of breaking changes that needed to be addressed as a
result of the upgrade. Please see the changelog notes for those releases
for the full list.

In addition, there were a couple of Yarn patches that were made to bring
in a partial set of functionality from these versions. These have been
removed, since they are no longer needed.

[1]: https://github.com/MetaMask/core/releases/tag/v53.0.0
[2]: https://github.com/MetaMask/core/releases/tag/v55.0.0
  • Loading branch information
mcmire committed Jun 8, 2023
1 parent 006d90f commit 388c7f0
Show file tree
Hide file tree
Showing 34 changed files with 1,603 additions and 637 deletions.
4 changes: 3 additions & 1 deletion .iyarc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ GHSA-257v-vj4p-3w2h

# request library is subject to SSRF.
# addressed by temporary patch in .yarn/patches/request-npm-2.88.2-f4a57c72c4.patch
GHSA-p8p7-x288-28g6
# NOTE: Disabled for now since this library seems to have been removed from the
# dependency tree — we can re-enable this line later if it appears again
#GHSA-p8p7-x288-28g6

This file was deleted.

211 changes: 0 additions & 211 deletions .yarn/patches/@metamask-assets-controllers-npm-7.0.0-9dec51787d.patch

This file was deleted.

24 changes: 4 additions & 20 deletions app/scripts/controllers/detect-tokens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TokensController,
AssetsContractController,
} from '@metamask/assets-controllers';
import { convertHexToDecimal } from '@metamask/controller-utils';
import { toHex } from '@metamask/controller-utils';
import { NETWORK_TYPES } from '../../../shared/constants/network';
import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils';
import DetectTokensController from './detect-tokens';
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('DetectTokensController', function () {
name: 'TokenListController',
});
tokenListController = new TokenListController({
chainId: '1',
chainId: toHex(1),
preventPollingOnNetworkRestart: false,
onNetworkStateChange: sinon.spy(),
onPreferencesStateChange: sinon.spy(),
Expand Down Expand Up @@ -246,23 +246,7 @@ describe('DetectTokensController', function () {
onPreferencesStateChange: preferences.store.subscribe.bind(
preferences.store,
),
onNetworkStateChange: (cb) =>
networkControllerMessenger.subscribe(
'NetworkController:networkDidChange',
() => {
const networkState = network.store.getState();
const modifiedNetworkState = {
...networkState,
providerConfig: {
...networkState.providerConfig,
chainId: convertHexToDecimal(
networkState.providerConfig.chainId,
),
},
};
return cb(modifiedNetworkState);
},
),
onNetworkStateChange: network.store.subscribe.bind(network.store),
});
});

Expand Down Expand Up @@ -311,7 +295,7 @@ describe('DetectTokensController', function () {
name: 'TokenListController',
});
tokenListController = new TokenListController({
chainId: '11155111',
chainId: toHex(11155111),
onNetworkStateChange: sinon.spy(),
onPreferencesStateChange: sinon.spy(),
messenger: tokenListMessengerSepolia,
Expand Down
13 changes: 8 additions & 5 deletions app/scripts/controllers/metametrics.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { strict as assert } from 'assert';
import sinon from 'sinon';
import { toHex } from '@metamask/controller-utils';
import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../shared/constants/app';
import { createSegmentMock } from '../lib/segment';
import {
Expand Down Expand Up @@ -885,7 +886,7 @@ describe('MetaMetricsController', function () {
describe('_buildUserTraitsObject', function () {
it('should return full user traits object on first call', function () {
const MOCK_ALL_TOKENS = {
'0x1': {
[toHex(1)]: {
'0x1235ce91d74254f29d4609f25932fe6d97bf4842': [
{
address: '0xd2cea331e5f5d8ee9fb1055c297795937645de91',
Expand All @@ -900,7 +901,7 @@ describe('MetaMetricsController', function () {
},
],
},
'0x4': {
[toHex(4)]: {
'0x1235ce91d74254f29d4609f25932fe6d97bf4842': [
{
address: '0xd2cea331e5f5d8ee9fb1055c297795937645de91',
Expand All @@ -920,7 +921,7 @@ describe('MetaMetricsController', function () {
},
allNfts: {
'0xac706cE8A9BF27Afecf080fB298d0ee13cfb978A': {
56: [
[toHex(56)]: [
{
address: '0xd2cea331e5f5d8ee9fb1055c297795937645de91',
tokenId: '100',
Expand All @@ -936,7 +937,7 @@ describe('MetaMetricsController', function () {
],
},
'0xe04AB39684A24D8D4124b114F3bd6FBEB779cacA': {
69: [
[toHex(59)]: [
{
address: '0x63d646bc7380562376d5de205123a57b1718184d',
tokenId: '14',
Expand Down Expand Up @@ -1022,7 +1023,9 @@ describe('MetaMetricsController', function () {
[CHAIN_IDS.GOERLI]: [{ address: '0x' }, { address: '0x0' }],
},
allTokens: {
'0x1': { '0xabcde': [{ '0x12345': { address: '0xtestAddress' } }] },
[toHex(1)]: {
'0xabcde': [{ '0x12345': { address: '0xtestAddress' } }],
},
},
networkConfigurations: {
'network-configuration-id-1': { chainId: CHAIN_IDS.MAINNET },
Expand Down
Loading

0 comments on commit 388c7f0

Please sign in to comment.