Skip to content

Commit 5547897

Browse files
committed
chore: rebase main
1 parent 5862069 commit 5547897

File tree

3 files changed

+7715
-14043
lines changed

3 files changed

+7715
-14043
lines changed

packages/accounts-controller/src/AccountsController.test.ts

+23-49
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ import {
1212
BtcScope,
1313
SolScope,
1414
SolAccountType,
15-
SolMethod,
1615
} from '@metamask/keyring-api';
1716
import { KeyringTypes } from '@metamask/keyring-controller';
1817
import type { InternalAccount } from '@metamask/keyring-internal-api';
1918
import type { NetworkClientId } from '@metamask/network-controller';
2019
import type { SnapControllerState } from '@metamask/snaps-controllers';
2120
import { SnapStatus } from '@metamask/snaps-utils';
22-
import type { CaipChainId, Json } from '@metamask/utils';
21+
import type { CaipChainId } from '@metamask/utils';
2322
import * as uuid from 'uuid';
2423
import type { V4Options } from 'uuid';
2524

@@ -629,8 +628,8 @@ describe('AccountsController', () => {
629628
id: mockAccount4.id,
630629
name: 'Snap Account 2',
631630
address: mockAccount4.address,
632-
keyringType: mockAccount4.metadata.keyring.type,
633-
snapId: mockAccount4.metadata.snap?.id,
631+
keyringType: mockAccount4.metadata.keyring.type as KeyringTypes,
632+
snap: mockAccount4.metadata.snap,
634633
}),
635634
),
636635
]);
@@ -3229,47 +3228,6 @@ describe('AccountsController', () => {
32293228
expect(accountName).toBe('Account 4');
32303229
});
32313230

3232-
it('throws error for snap accounts without entropy source', async () => {
3233-
const messenger = buildMessenger();
3234-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3235-
const accountsController = setupAccountsController({
3236-
initialState: {
3237-
internalAccounts: {
3238-
accounts: {},
3239-
selectedAccount: '',
3240-
},
3241-
},
3242-
messenger,
3243-
});
3244-
3245-
expect(() =>
3246-
messenger.call('AccountsController:getNextAvailableAccountName', {
3247-
keyringType: KeyringTypes.snap,
3248-
}),
3249-
).toThrow('Entropy source is required for snap accounts');
3250-
});
3251-
3252-
it('throws error for non-ETH snap accounts without chainId', async () => {
3253-
const messenger = buildMessenger();
3254-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3255-
const accountsController = setupAccountsController({
3256-
initialState: {
3257-
internalAccounts: {
3258-
accounts: {},
3259-
selectedAccount: '',
3260-
},
3261-
},
3262-
messenger,
3263-
});
3264-
3265-
expect(() =>
3266-
messenger.call('AccountsController:getNextAvailableAccountName', {
3267-
keyringType: KeyringTypes.snap,
3268-
entropySource: 'some-entropy-source',
3269-
}),
3270-
).toThrow('Chain ID is required for non-ETH snap accounts');
3271-
});
3272-
32733231
it('throws error for unsupported chain namespace', async () => {
32743232
const messenger = buildMessenger();
32753233
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -3443,7 +3401,11 @@ describe('AccountsController', () => {
34433401
address: 'solana-address-1',
34443402
keyringType: KeyringTypes.snap,
34453403
type: SolAccountType.DataAccount,
3446-
snapId: 'solana-snap-id',
3404+
snap: {
3405+
id: 'solana-snap-id',
3406+
enabled: true,
3407+
name: 'Solana Snap',
3408+
},
34473409
});
34483410

34493411
const mockBitcoinAccount = createExpectedInternalAccount({
@@ -3452,7 +3414,11 @@ describe('AccountsController', () => {
34523414
address: 'bitcoin-address-2',
34533415
keyringType: KeyringTypes.snap,
34543416
type: BtcAccountType.P2wpkh,
3455-
snapId: 'bitcoin-snap-id',
3417+
snap: {
3418+
id: 'bitcoin-snap-id',
3419+
enabled: true,
3420+
name: 'Bitcoin Snap',
3421+
},
34563422
});
34573423

34583424
const { accountsController } = setupAccountsController({
@@ -3532,7 +3498,11 @@ describe('KeyringController:stateChange handling', () => {
35323498
address: '0x123',
35333499
keyringType: KeyringTypes.snap,
35343500
type: SolAccountType.DataAccount,
3535-
snapId: 'test-snap-id',
3501+
snap: {
3502+
id: 'test-snap-id',
3503+
enabled: true,
3504+
name: 'Solana Snap',
3505+
},
35363506
options: {
35373507
entropySource: 'test-entropy' as string,
35383508
},
@@ -3548,7 +3518,11 @@ describe('KeyringController:stateChange handling', () => {
35483518
address: '0x123',
35493519
keyringType: KeyringTypes.snap,
35503520
type: SolAccountType.DataAccount,
3551-
snapId: 'test-snap-id',
3521+
snap: {
3522+
id: 'test-snap-id',
3523+
enabled: true,
3524+
name: 'Solana Snap',
3525+
},
35523526
});
35533527

35543528
// Ensure entropy source is set correctly

packages/accounts-controller/src/tests/mocks.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
EthScope,
77
BtcScope,
88
SolMethod,
9+
SolAccountType,
10+
SolScope,
911
} from '@metamask/keyring-api';
1012
import type { CaipChainId, KeyringAccountType } from '@metamask/keyring-api';
1113
import { KeyringTypes } from '@metamask/keyring-controller';
@@ -74,11 +76,6 @@ export const createMockInternalAccount = ({
7476
methods: [...Object.values(BtcMethod)],
7577
scopes: [BtcScope.Mainnet],
7678
};
77-
case `${KeyringTypes.trezor}`:
78-
return {
79-
methods: [...Object.values(ETH_EOA_METHODS)],
80-
scopes: [EthScope.Eoa],
81-
};
8279
case `${SolAccountType.DataAccount}`:
8380
return {
8481
methods: [...Object.values(SolMethod)],

0 commit comments

Comments
 (0)