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

Support keyring metadata in KeyringController #5112

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
127 changes: 126 additions & 1 deletion packages/accounts-controller/src/AccountsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import type { SnapControllerState } from '@metamask/snaps-controllers';
import { SnapStatus } from '@metamask/snaps-utils';
import type { CaipChainId } from '@metamask/utils';
import * as uuid from 'uuid';

Check warning on line 18 in packages/accounts-controller/src/AccountsController.test.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

No exported names found in module 'uuid'
import type { V4Options } from 'uuid';

import type {
Expand Down Expand Up @@ -134,7 +134,7 @@
};

class MockNormalAccountUUID {
#accountIds: Record<string, string> = {};

Check warning on line 137 in packages/accounts-controller/src/AccountsController.test.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

Member '#accountIds' is never reassigned; mark it as `readonly`

constructor(accounts: InternalAccount[]) {
for (const account of accounts) {
Expand Down Expand Up @@ -501,6 +501,12 @@
accounts: [mockAccount.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};

messenger.publish(
Expand All @@ -525,7 +531,7 @@

messenger.publish(
'KeyringController:stateChange',
{ isUnlocked: true, keyrings: [] },
{ isUnlocked: true, keyrings: [], keyringsMetadata: [] },
[],
);

Expand All @@ -543,6 +549,13 @@
{
accounts: [mockAccount.address, mockAccount2.address],
type: KeyringTypes.hd,
id: '123',
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
Expand Down Expand Up @@ -581,6 +594,12 @@
accounts: [mockAccount.address, mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -638,6 +657,16 @@
accounts: [mockAccount3.address, mockAccount4.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
{
id: 'mock-id2',
name: 'mock-name2',
},
],
};

const { accountsController } = setupAccountsController({
Expand Down Expand Up @@ -705,6 +734,16 @@
accounts: [mockAccount3.address, mockAccount4.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
{
id: 'mock-id2',
name: 'mock-name2',
},
],
};

const { accountsController } = setupAccountsController({
Expand Down Expand Up @@ -751,6 +790,12 @@
],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -813,6 +858,12 @@
],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -873,6 +924,16 @@
accounts: [mockAccount3.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
{
id: 'mock-id2',
name: 'mock-name2',
},
],
};

const { accountsController } = setupAccountsController({
Expand Down Expand Up @@ -909,6 +970,12 @@
accounts: [mockAccount.address, mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -964,6 +1031,12 @@
accounts: [mockAccount.address, mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};

messenger.publish(
Expand Down Expand Up @@ -995,6 +1068,12 @@
accounts: [mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -1036,6 +1115,12 @@
accounts: [mockAccount.address, mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -1096,6 +1181,12 @@
accounts: [mockAccount.address, mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -1169,6 +1260,12 @@
],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -1239,6 +1336,12 @@
accounts: [mockAccount.address, mockAccount2.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
messenger.publish(
'KeyringController:stateChange',
Expand Down Expand Up @@ -1283,6 +1386,12 @@
accounts: [mockReinitialisedAccount.address],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
const { accountsController } = setupAccountsController({
initialState: {
Expand Down Expand Up @@ -1379,6 +1488,12 @@
],
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
],
};
messenger.publish(
'KeyringController:stateChange',
Expand Down Expand Up @@ -2534,6 +2649,16 @@
accounts: simpleAddressess,
},
],
keyringsMetadata: [
{
id: 'mock-id',
name: 'mock-name',
},
{
id: 'mock-id2',
name: 'mock-name2',
},
],
};
};

Expand Down
9 changes: 7 additions & 2 deletions packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"@metamask/utils": "^11.0.1",
"async-mutex": "^0.5.0",
"ethereumjs-wallet": "^1.0.1",
"immer": "^9.0.6"
"immer": "^9.0.6",
"ulidx": "^2.4.1"
},
"devDependencies": {
"@ethereumjs/common": "^3.2.0",
Expand Down Expand Up @@ -89,6 +90,10 @@
"registry": "https://registry.npmjs.org/"
},
"lavamoat": {
"allowScripts": {}
"allowScripts": {
"@lavamoat/preinstall-always-fail": false,
"ethereumjs-wallet>ethereum-cryptography>keccak": false,
"ethereumjs-wallet>ethereum-cryptography>secp256k1": false
}
}
}
Loading
Loading