Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add scopes field to KeyringAccount #29195

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
f6d5942
refactor: use new accounts packages
ccharly Sep 12, 2024
cbd9f36
chore: lavamoat:auto
ccharly Dec 3, 2024
bf4405f
chore: yarn dedupe
ccharly Dec 3, 2024
de54690
chore: update resolutions
ccharly Dec 5, 2024
356eab7
Merge branch 'main' into refactor/use-new-accounts-packages
ccharly Dec 5, 2024
0584a61
chore: update resolutions
ccharly Dec 11, 2024
0fb1493
Merge branch 'main' into refactor/use-new-accounts-packages
ccharly Dec 11, 2024
a2b7d0b
chore: dedupe + lavamoat:auto
ccharly Dec 11, 2024
a39c3df
chore: update deps
ccharly Dec 11, 2024
6dce397
chore: lint
ccharly Dec 11, 2024
238f522
chore: update deps
ccharly Dec 11, 2024
ab65f1f
chore: remove preview builds
ccharly Dec 11, 2024
7cf8701
Merge branch 'main' into refactor/use-new-accounts-packages
ccharly Dec 12, 2024
dfa88e1
chore: dedupe
ccharly Dec 12, 2024
9584e9e
Merge branch 'main' into refactor/use-new-accounts-packages
ccharly Dec 12, 2024
dc10d94
Merge branch 'main' into refactor/use-new-accounts-packages
ccharly Dec 12, 2024
5ea8323
chore: lavamoat:auto
ccharly Dec 12, 2024
45784bb
chore: dedupe
ccharly Dec 12, 2024
50035f3
Merge branch 'main' into refactor/use-new-accounts-packages
ccharly Dec 12, 2024
384c9e9
Merge branch 'main' into refactor/use-new-accounts-packages
HowardBraham Dec 12, 2024
281c5bf
ci: add flags.circleci.timeoutMinutes
HowardBraham Dec 12, 2024
5a28bd5
feat: use new scopes from KeyringAccount
ccharly Dec 13, 2024
98e9e2d
fix: add resolution for keyring-snap-client
ccharly Dec 13, 2024
f013c1c
fix: fix tests (missing scopes)
ccharly Dec 13, 2024
e0e5664
feat: add migration to inject account.scopes
ccharly Dec 13, 2024
00e8194
chore: force migration 135 (hack, needs to be removed)
ccharly Dec 13, 2024
370f06e
chore: add local bitcoin snap (hack, needs to be removed)
ccharly Dec 13, 2024
6070c38
chore: update preview deps
ccharly Jan 6, 2025
409801b
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 6, 2025
670e89a
chore: update resolutions
ccharly Jan 6, 2025
59e5bde
chore: lint + dedupe
ccharly Jan 7, 2025
8a91bc6
chore: lavamost:auto
ccharly Jan 7, 2025
57e5b2d
Update LavaMoat policies
metamaskbot Jan 7, 2025
840eef9
fix: missing scopes in test + force type in migration 105
ccharly Jan 7, 2025
1cd78ab
chore: rename account.scopes migration (135 -> 136)
ccharly Jan 7, 2025
c3e5137
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 7, 2025
c628911
fix: disable forced migration
ccharly Jan 7, 2025
7b62692
test(user-ops): use [email protected]
ccharly Jan 8, 2025
74aba6a
Revert "chore: add local bitcoin snap (hack, needs to be removed)"
ccharly Jan 8, 2025
4a19134
test(btc): use [email protected]
ccharly Jan 8, 2025
393f6e8
test(btc): update privacy snapshot + mock sat protection service
ccharly Jan 9, 2025
b3d4ae8
test(btc): fix BTC balance mocking when Sat Protection is enabled
ccharly Jan 9, 2025
117e74a
chore: update resolutions
ccharly Jan 9, 2025
77e5f17
test(sol): use [email protected]
ccharly Jan 9, 2025
6918983
chore: lint
ccharly Jan 9, 2025
49a676b
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 9, 2025
400d2d3
chore: update privacy-snapshot.json for solana support
ccharly Jan 9, 2025
6500635
fix: rename migration 136 -> 137
ccharly Jan 13, 2025
b90b572
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 13, 2025
43ed0e6
chore: remove use of preview builds
ccharly Jan 14, 2025
2068b06
refactor(migration): check for .scopes content too + use error
ccharly Jan 14, 2025
804e8c1
chore: lint
ccharly Jan 14, 2025
15895ce
feat(mocks): add solana/bitcoin (mainnet/testnet) support in createMo…
ccharly Jan 14, 2025
f9a2d5f
chore: lint
ccharly Jan 14, 2025
d619ad7
feat(migration): add bitcoin/solana account scopes migration
ccharly Jan 14, 2025
63403a8
test(migration): cover everything for scopes migration
ccharly Jan 14, 2025
fe0326e
Update LavaMoat policies
metamaskbot Jan 14, 2025
6ca076c
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 14, 2025
c32ccfb
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 14, 2025
c014c35
test: fix unit test
ccharly Jan 14, 2025
3da5933
test: fix unit test
ccharly Jan 14, 2025
7fc4b83
refactor(migration): 137 -> 138
ccharly Jan 15, 2025
0183026
refactor(migration): remove forced migration
ccharly Jan 15, 2025
c512ad5
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 15, 2025
784dec7
test(solana): mock new network calls
ccharly Jan 15, 2025
d61277d
refactor(migration/105): rename InternalAccount -> InternalAccountV1
ccharly Jan 15, 2025
e671cc3
refactor: remove migration
ccharly Jan 16, 2025
734de66
chore: bump eth-snap-keyring to 8.1.0
ccharly Jan 16, 2025
08a1d11
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 16, 2025
14977ad
chore: dedupe + lavamoat:auto
ccharly Jan 16, 2025
c70c99a
chore: bump accounts-controller to 21.0.1
ccharly Jan 17, 2025
739071f
Merge branch 'main' into feat/keyring-account-scopes
ccharly Jan 17, 2025
ca66450
refactor: use account type and scopes constants
ccharly Jan 17, 2025
9e94e59
refactor: use account type/scopes/methods constants for solana
ccharly Jan 17, 2025
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
1 change: 1 addition & 0 deletions app/scripts/controllers/alert-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('AlertController', () => {
address: '0x1234567',
options: {},
methods: [],
scopes: ['eip155'],
type: 'eip155:eoa',
metadata: {
name: '',
Expand Down
1 change: 1 addition & 0 deletions app/scripts/lib/snap-keyring/snap-keyring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const mockAccount = {
id: '3afa663e-0600-4d93-868a-61c2e553013b',
address,
methods: [],
scopes: ['eip155'],
options: {},
};
const mockInternalAccount = {
Expand Down
10 changes: 2 additions & 8 deletions app/scripts/migrations/105.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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 type { Identity, InternalAccountV1 } from './105';

const MOCK_ADDRESS = '0x0';
const MOCK_ADDRESS_2 = '0x1';
Expand All @@ -22,12 +22,6 @@ function addressToUUID(address: string): string {
});
}

type Identity = {
name: string;
address: string;
lastSelected?: number;
};

type Identities = {
[key: string]: Identity;
};
Expand Down Expand Up @@ -62,7 +56,7 @@ function expectedInternalAccount(
address: string,
nickname: string,
lastSelected?: number,
): InternalAccount {
): InternalAccountV1 {
return {
address,
id: addressToUUID(address),
Expand Down
28 changes: 22 additions & 6 deletions app/scripts/migrations/105.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
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 = {
meta: { version: number };
data: Record<string, unknown>;
};

type Identity = {
export type Identity = {
name: string;
address: string;
lastSelected?: number;
};

export type InternalAccountV1 = {
type: string;
id: string;
options: Record<string, Json>;
metadata: {
name: string;
importTime: number;
keyring: {
type: string;
};
lastSelected?: number;
};
address: string;
methods: string[];
};

export const version = 105;

/**
Expand Down Expand Up @@ -51,11 +67,11 @@ function findInternalAccountByAddress(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
state: Record<string, any>,
address: string,
): InternalAccount | undefined {
return Object.values<InternalAccount>(
): InternalAccountV1 | undefined {
return Object.values<InternalAccountV1>(
state.AccountsController.internalAccounts.accounts,
).find(
(account: InternalAccount) =>
(account: InternalAccountV1) =>
account.address.toLowerCase() === address.toLowerCase(),
);
}
Expand Down Expand Up @@ -84,7 +100,7 @@ function createInternalAccountsForAccountsController(
return;
}

const accounts: Record<string, InternalAccount> = {};
const accounts: Record<string, InternalAccountV1> = {};

Object.values(identities).forEach((identity) => {
const expectedId = uuid({
Expand Down
57 changes: 11 additions & 46 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils": {
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": true
"@metamask/eth-snap-keyring>@metamask/utils": true
}
},
"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils": {
Expand Down Expand Up @@ -846,7 +846,7 @@
"@metamask/eth-snap-keyring": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/utils": true,
"@metamask/accounts-controller>@metamask/utils": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"uuid": true
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/utils": true,
"@metamask/eth-snap-keyring>@metamask/utils": true,
"@metamask/utils>@scure/base": true,
"browserify>buffer": true,
"@ethereumjs/tx>ethereum-cryptography": true,
Expand Down Expand Up @@ -1190,13 +1190,15 @@
"@metamask/eth-snap-keyring": {
"globals": {
"URL": true,
"console.error": true
"console.error": true,
"console.info": true
},
"packages": {
"@ethereumjs/tx": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util": true,
"@metamask/keyring-api": true,
"@metamask/eth-snap-keyring>@metamask/keyring-internal-snap-client": true,
"@metamask/keyring-api>@metamask/keyring-utils": true,
"@metamask/utils>@metamask/superstruct": true,
"@metamask/eth-snap-keyring>@metamask/utils": true,
"webpack>events": true,
Expand Down Expand Up @@ -1352,14 +1354,6 @@
"@metamask/keyring-api>bech32": true
}
},
"@metamask/profile-sync-controller>@metamask/keyring-api": {
"packages": {
"@metamask/keyring-api>@metamask/keyring-utils": true,
"@metamask/utils>@metamask/superstruct": true,
"@metamask/profile-sync-controller>@metamask/keyring-api>@metamask/utils": true,
"@metamask/keyring-api>bech32": true
}
},
"@metamask/keyring-controller": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
Expand Down Expand Up @@ -1392,7 +1386,8 @@
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/keyring-api>@metamask/keyring-utils>@metamask/utils": true
"@metamask/keyring-api>@metamask/keyring-utils>@metamask/utils": true,
"bitcoin-address-validation": true
}
},
"@metamask/logging-controller": {
Expand Down Expand Up @@ -1612,7 +1607,7 @@
},
"packages": {
"@metamask/base-controller": true,
"@metamask/profile-sync-controller>@metamask/keyring-api": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/network-controller": true,
"@metamask/profile-sync-controller>@noble/ciphers": true,
Expand Down Expand Up @@ -1920,7 +1915,7 @@
"semver": true
}
},
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": {
"@metamask/signature-controller>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
Expand All @@ -1935,7 +1930,7 @@
"semver": true
}
},
"@metamask/signature-controller>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": {
"@metamask/accounts-controller>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
Expand Down Expand Up @@ -2085,21 +2080,6 @@
"semver": true
}
},
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@noble/hashes": true,
"@metamask/utils>@scure/base": true,
"browserify>buffer": true,
"nock>debug": true,
"@metamask/utils>pony-cause": true,
"semver": true
}
},
"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/utils": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -2220,21 +2200,6 @@
"semver": true
}
},
"@metamask/profile-sync-controller>@metamask/keyring-api>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@noble/hashes": true,
"@metamask/utils>@scure/base": true,
"browserify>buffer": true,
"nock>debug": true,
"@metamask/utils>pony-cause": true,
"semver": true
}
},
"@metamask/keyring-controller>@metamask/utils": {
"globals": {
"TextDecoder": true,
Expand Down
57 changes: 11 additions & 46 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils": {
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": true
"@metamask/eth-snap-keyring>@metamask/utils": true
}
},
"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/abi-utils": {
Expand Down Expand Up @@ -846,7 +846,7 @@
"@metamask/eth-snap-keyring": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/utils": true,
"@metamask/accounts-controller>@metamask/utils": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"uuid": true
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/utils": true,
"@metamask/eth-snap-keyring>@metamask/utils": true,
"@metamask/utils>@scure/base": true,
"browserify>buffer": true,
"@ethereumjs/tx>ethereum-cryptography": true,
Expand Down Expand Up @@ -1190,13 +1190,15 @@
"@metamask/eth-snap-keyring": {
"globals": {
"URL": true,
"console.error": true
"console.error": true,
"console.info": true
},
"packages": {
"@ethereumjs/tx": true,
"@metamask/eth-snap-keyring>@metamask/eth-sig-util": true,
"@metamask/keyring-api": true,
"@metamask/eth-snap-keyring>@metamask/keyring-internal-snap-client": true,
"@metamask/keyring-api>@metamask/keyring-utils": true,
"@metamask/utils>@metamask/superstruct": true,
"@metamask/eth-snap-keyring>@metamask/utils": true,
"webpack>events": true,
Expand Down Expand Up @@ -1352,14 +1354,6 @@
"@metamask/keyring-api>bech32": true
}
},
"@metamask/profile-sync-controller>@metamask/keyring-api": {
"packages": {
"@metamask/keyring-api>@metamask/keyring-utils": true,
"@metamask/utils>@metamask/superstruct": true,
"@metamask/profile-sync-controller>@metamask/keyring-api>@metamask/utils": true,
"@metamask/keyring-api>bech32": true
}
},
"@metamask/keyring-controller": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
Expand Down Expand Up @@ -1392,7 +1386,8 @@
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@metamask/keyring-api>@metamask/keyring-utils>@metamask/utils": true
"@metamask/keyring-api>@metamask/keyring-utils>@metamask/utils": true,
"bitcoin-address-validation": true
}
},
"@metamask/logging-controller": {
Expand Down Expand Up @@ -1612,7 +1607,7 @@
},
"packages": {
"@metamask/base-controller": true,
"@metamask/profile-sync-controller>@metamask/keyring-api": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/network-controller": true,
"@metamask/profile-sync-controller>@noble/ciphers": true,
Expand Down Expand Up @@ -1920,7 +1915,7 @@
"semver": true
}
},
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": {
"@metamask/signature-controller>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
Expand All @@ -1935,7 +1930,7 @@
"semver": true
}
},
"@metamask/signature-controller>@metamask/eth-sig-util>@metamask/abi-utils>@metamask/utils": {
"@metamask/accounts-controller>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
Expand Down Expand Up @@ -2085,21 +2080,6 @@
"semver": true
}
},
"@metamask/eth-snap-keyring>@metamask/eth-sig-util>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@noble/hashes": true,
"@metamask/utils>@scure/base": true,
"browserify>buffer": true,
"nock>debug": true,
"@metamask/utils>pony-cause": true,
"semver": true
}
},
"@metamask/eth-trezor-keyring>@metamask/eth-sig-util>@metamask/utils": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -2220,21 +2200,6 @@
"semver": true
}
},
"@metamask/profile-sync-controller>@metamask/keyring-api>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/utils>@metamask/superstruct": true,
"@noble/hashes": true,
"@metamask/utils>@scure/base": true,
"browserify>buffer": true,
"nock>debug": true,
"@metamask/utils>pony-cause": true,
"semver": true
}
},
"@metamask/keyring-controller>@metamask/utils": {
"globals": {
"TextDecoder": true,
Expand Down
Loading
Loading