diff --git a/app/scripts/controllers/alert-controller.test.ts b/app/scripts/controllers/alert-controller.test.ts index de314c31f050..190879dc4334 100644 --- a/app/scripts/controllers/alert-controller.test.ts +++ b/app/scripts/controllers/alert-controller.test.ts @@ -163,6 +163,7 @@ describe('AlertController', () => { address: '0x1234567', options: {}, methods: [], + scopes: ['eip155'], type: 'eip155:eoa', metadata: { name: '', diff --git a/app/scripts/lib/snap-keyring/snap-keyring.test.ts b/app/scripts/lib/snap-keyring/snap-keyring.test.ts index 0e778b2268d7..c2ea66cff4fe 100644 --- a/app/scripts/lib/snap-keyring/snap-keyring.test.ts +++ b/app/scripts/lib/snap-keyring/snap-keyring.test.ts @@ -40,6 +40,7 @@ const mockAccount = { id: '3afa663e-0600-4d93-868a-61c2e553013b', address, methods: [], + scopes: ['eip155'], options: {}, }; const mockInternalAccount = { diff --git a/app/scripts/migrations/105.test.ts b/app/scripts/migrations/105.test.ts index b7d5ac0303e6..9b354b23cee3 100644 --- a/app/scripts/migrations/105.test.ts +++ b/app/scripts/migrations/105.test.ts @@ -1,8 +1,7 @@ import { v4 as uuid } from 'uuid'; import { sha256FromString } from 'ethereumjs-util'; -import { InternalAccount } from '@metamask/keyring-internal-api'; import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods'; -import { migrate } from './105'; +import { migrate, Identity, InternalAccount } from './105'; const MOCK_ADDRESS = '0x0'; const MOCK_ADDRESS_2 = '0x1'; @@ -22,12 +21,6 @@ function addressToUUID(address: string): string { }); } -type Identity = { - name: string; - address: string; - lastSelected?: number; -}; - type Identities = { [key: string]: Identity; }; diff --git a/app/scripts/migrations/105.ts b/app/scripts/migrations/105.ts index 5febcb0479f2..c36798a10cab 100644 --- a/app/scripts/migrations/105.ts +++ b/app/scripts/migrations/105.ts @@ -1,8 +1,8 @@ import { EthAccountType } from '@metamask/keyring-api'; -import { InternalAccount } from '@metamask/keyring-internal-api'; import { sha256FromString } from 'ethereumjs-util'; import { v4 as uuid } from 'uuid'; import { cloneDeep } from 'lodash'; +import { Json } from '@metamask/utils'; import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods'; type VersionedData = { @@ -16,6 +16,28 @@ type Identity = { lastSelected?: number; }; +type InternalAccount = { + type: string; + id: string; + options: Record; + metadata: { + name: string; + importTime: number; + keyring: { + type: string; + }; + nameLastUpdatedAt?: number; + snap?: { + name: string; + id: string; + enabled: boolean; + }; + lastSelected?: number; + }; + address: string; + methods: string[]; +}; + export const version = 105; /** diff --git a/test/data/mock-accounts.ts b/test/data/mock-accounts.ts index eab4cd4aa74d..c65a6b7bd162 100644 --- a/test/data/mock-accounts.ts +++ b/test/data/mock-accounts.ts @@ -4,6 +4,8 @@ import { EthAccountType, BtcMethod, BtcAccountType, + EthScopes, + BtcScopes, } from '@metamask/keyring-api'; import { ETH_EOA_METHODS, @@ -15,6 +17,7 @@ export const MOCK_ACCOUNT_EOA: InternalAccount = { address: '0x123', options: {}, methods: ETH_EOA_METHODS, + scopes: [EthScopes.Namespace], type: EthAccountType.Eoa, metadata: { name: 'Account 1', @@ -29,6 +32,8 @@ export const MOCK_ACCOUNT_ERC4337: InternalAccount = { address: '0x123', options: {}, methods: ETH_EOA_METHODS.concat(ETH_4337_METHODS), + // Smart accounts might not be available on every EVM chains, but that's ok for mock purposes. + scopes: [EthScopes.Namespace], type: EthAccountType.Erc4337, metadata: { name: 'Account 2', @@ -43,6 +48,7 @@ export const MOCK_ACCOUNT_BIP122_P2WPKH: InternalAccount = { address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k', options: {}, methods: [BtcMethod.SendBitcoin], + scopes: [BtcScopes.Mainnet], type: BtcAccountType.P2wpkh, metadata: { name: 'Bitcoin Account', @@ -57,6 +63,7 @@ export const MOCK_ACCOUNT_BIP122_P2WPKH_TESTNET: InternalAccount = { address: 'tb1q6rmsq3vlfdhjdhtkxlqtuhhlr6pmj09y6w43g8', options: {}, methods: [BtcMethod.SendBitcoin], + scopes: [BtcScopes.Testnet], type: BtcAccountType.P2wpkh, metadata: { name: 'Bitcoin Testnet Account', diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 9ea2e674e7a3..fc31c0f68d8d 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -448,6 +448,7 @@ "eth_signTypedData_v3", "eth_signTypedData_v4" ], + "scopes": ["eip155"], "type": "eip155:eoa" }, "07c2cfec-36c9-46c4-8115-3836d3ac9047": { @@ -468,6 +469,7 @@ "eth_signTypedData_v3", "eth_signTypedData_v4" ], + "scopes": ["eip155"], "type": "eip155:eoa" }, "15e69915-2a1a-4019-93b3-916e11fd432f": { @@ -488,6 +490,7 @@ "eth_signTypedData_v3", "eth_signTypedData_v4" ], + "scopes": ["eip155"], "type": "eip155:eoa" }, "784225f4-d30b-4e77-a900-c8bbce735b88": { @@ -508,6 +511,7 @@ "eth_signTypedData_v3", "eth_signTypedData_v4" ], + "scopes": ["eip155"], "type": "eip155:eoa" }, "694225f4-d30b-4e77-a900-c8bbce735b42": { @@ -528,6 +532,7 @@ "eth_signTypedData_v3", "eth_signTypedData_v4" ], + "scopes": ["eip155"], "type": "eip155:eoa" }, "c3deeb99-ba0d-4a4e-a0aa-033fc1f79ae3": { @@ -553,6 +558,7 @@ "eth_signTypedData_v3", "eth_signTypedData_v4" ], + "scopes": ["eip155"], "type": "eip155:eoa" } }, diff --git a/ui/components/multichain/permission-details-modal/permission-details-modal.test.tsx b/ui/components/multichain/permission-details-modal/permission-details-modal.test.tsx index 3c3d5ff18bfa..5a2e941c4715 100644 --- a/ui/components/multichain/permission-details-modal/permission-details-modal.test.tsx +++ b/ui/components/multichain/permission-details-modal/permission-details-modal.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import configureStore from 'redux-mock-store'; -import { EthAccountType, EthMethod } from '@metamask/keyring-api'; +import { EthAccountType, EthMethod, EthScopes } from '@metamask/keyring-api'; import { fireEvent, renderWithProvider } from '../../../../test/jest'; import { mockNetworkState } from '../../../../test/stub/networks'; import { CHAIN_IDS } from '../../../../shared/constants/network'; @@ -45,6 +45,7 @@ describe('PermissionDetailsModal', () => { }, options: {}, methods: [...Object.values(EthMethod)], + scopes: [EthScopes.Namespace], type: EthAccountType.Eoa, }, '07c2cfec-36c9-46c4-8115-3836d3ac9047': { @@ -61,6 +62,7 @@ describe('PermissionDetailsModal', () => { }, options: {}, methods: [...Object.values(EthMethod)], + scopes: [EthScopes.Namespace], type: EthAccountType.Eoa, }, }, @@ -128,6 +130,7 @@ describe('PermissionDetailsModal', () => { }, options: {}, methods: ETH_EOA_METHODS, + scopes: [EthScopes.Namespace], type: EthAccountType.Eoa, label: '', }, diff --git a/ui/selectors/accounts.test.ts b/ui/selectors/accounts.test.ts index 033d88c30faa..caf875ca101b 100644 --- a/ui/selectors/accounts.test.ts +++ b/ui/selectors/accounts.test.ts @@ -1,4 +1,4 @@ -import { EthAccountType } from '@metamask/keyring-api'; +import { EthAccountType, EthScopes } from '@metamask/keyring-api'; import { ETH_EOA_METHODS } from '../../shared/constants/eth-methods'; import { MOCK_ACCOUNTS, @@ -88,6 +88,7 @@ describe('Accounts Selectors', () => { }, options: {}, methods: ETH_EOA_METHODS, + scopes: [EthScopes.Namespace], type: EthAccountType.Eoa, }; expect(