Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {
AccountsControllerAccountAddedEvent,
AccountsControllerListAccountsAction,
} from '@metamask/accounts-controller';
import { Messenger } from '@metamask/messenger';
import { TransactionControllerTransactionConfirmedEvent } from '@metamask/transaction-controller';
import {
Expand All @@ -10,20 +6,25 @@ import {
} from '@metamask/keyring-controller';

import { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';
import {
AccountTreeControllerGetAccountsFromSelectedAccountGroupAction,
AccountTreeControllerSelectedAccountGroupChangeEvent,
} from '@metamask/account-tree-controller';
import { MetaMetricsControllerTrackEventAction } from '../../../controllers/metametrics-controller';
import { RootMessenger } from '../../../lib/messenger';

export type DefiPositionsControllerMessenger = ReturnType<
typeof getDeFiPositionsControllerMessenger
>;

type AllowedActions = AccountsControllerListAccountsAction;
type AllowedActions =
AccountTreeControllerGetAccountsFromSelectedAccountGroupAction;

type AllowedEvents =
| KeyringControllerUnlockEvent
| KeyringControllerLockEvent
| TransactionControllerTransactionConfirmedEvent
| AccountsControllerAccountAddedEvent;
| AccountTreeControllerSelectedAccountGroupChangeEvent;

/**
* Get a restricted messenger for the Defi Positions controller. This is scoped to the
Expand All @@ -46,12 +47,12 @@ export function getDeFiPositionsControllerMessenger(
});
messenger.delegate({
messenger: controllerMessenger,
actions: ['AccountsController:listAccounts'],
actions: ['AccountTreeController:getAccountsFromSelectedAccountGroup'],
events: [
'KeyringController:unlock',
'KeyringController:lock',
'TransactionController:transactionConfirmed',
'AccountsController:accountAdded',
'AccountTreeController:selectedAccountGroupChange',
],
});
return controllerMessenger;
Expand Down
18 changes: 18 additions & 0 deletions app/scripts/metamask-controller.actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ describe('MetaMaskController', function () {
{ url: '127.0.0.1', targetList: 'blocklist', timestamp: 0 },
]),
);

nock('https://price.api.cx.metamask.io')
.get('/v1/supportedNetworks')
.reply(
200,
JSON.stringify({
fullSupport: [
1, 10, 56, 100, 137, 250, 324, 8453, 42161, 43114, 59144,
],
partialSupport: {
spotPricesV2: [
25, 57, 66, 70, 82, 88, 106, 122, 128, 143, 146, 288, 321, 336,
361, 1088, 1101, 1284, 1285, 1329, 5000, 10000, 42220, 42262,
81457, 97741, 167000, 333999, 534352, 1313161554, 1666600000,
],
},
}),
);
metamaskController = new MetaMaskController({
showUserConfirmation: noop,
encryptor: mockEncryptor,
Expand Down
18 changes: 18 additions & 0 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,24 @@ describe('MetaMaskController', () => {
]),
);

nock('https://price.api.cx.metamask.io')
.get('/v1/supportedNetworks')
.reply(
200,
JSON.stringify({
fullSupport: [
1, 10, 56, 100, 137, 250, 324, 8453, 42161, 43114, 59144,
],
partialSupport: {
spotPricesV2: [
25, 57, 66, 70, 82, 88, 106, 122, 128, 143, 146, 288, 321, 336,
361, 1088, 1101, 1284, 1285, 1329, 5000, 10000, 42220, 42262,
81457, 97741, 167000, 333999, 534352, 1313161554, 1666600000,
],
},
}),
);

globalThis.sentry = {
withIsolationScope: jest.fn(),
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
"@metamask/address-book-controller": "^7.0.0",
"@metamask/announcement-controller": "^8.0.0",
"@metamask/approval-controller": "^8.0.0",
"@metamask/assets-controllers": "^86.0.0",
"@metamask/assets-controllers": "npm:@metamask-previews/assets-controllers@87.0.0-preview-8315c2ec",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be changed after new version is released

"@metamask/base-controller": "^9.0.0",
"@metamask/bitcoin-wallet-snap": "^1.4.3",
"@metamask/bridge-controller": "^56.0.3",
Expand Down
1 change: 1 addition & 0 deletions shared/types/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export type ControllerStatePropertiesEnumerated = {
preventPollingOnNetworkRestart: TokenListState['preventPollingOnNetworkRestart'];
tokensChainsCache: TokenListState['tokensChainsCache'];
marketData: TokenRatesControllerState['marketData'];
supportedChainIds: TokenRatesControllerState['supportedChainIds'];
lastFetchedBlockNumbers: TransactionControllerState['lastFetchedBlockNumbers'];
methodData: TransactionControllerState['methodData'];
transactions: TransactionControllerState['transactions'];
Expand Down
4 changes: 4 additions & 0 deletions test/data/confirmations/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export const getMockTypedSignConfirmStateForRequest = (
unapprovedTypedMessages: {
[signature.id]: signature,
},
supportedChainIds: {
timestamp: 0,
data: [],
},
},
});

Expand Down
Loading