@metamask-previews/accounts-controller 24.0.1-preview-5dad659d → 24.0.1-preview-def92ff7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -5
- package/dist/AccountsController.cjs +85 -37
- package/dist/AccountsController.cjs.map +1 -1
- package/dist/AccountsController.d.cts +13 -5
- package/dist/AccountsController.d.cts.map +1 -1
- package/dist/AccountsController.d.mts +13 -5
- package/dist/AccountsController.d.mts.map +1 -1
- package/dist/AccountsController.mjs +86 -38
- package/dist/AccountsController.mjs.map +1 -1
- package/dist/tests/mocks.cjs +29 -49
- package/dist/tests/mocks.cjs.map +1 -1
- package/dist/tests/mocks.d.cts +2 -29
- package/dist/tests/mocks.d.cts.map +1 -1
- package/dist/tests/mocks.d.mts +2 -29
- package/dist/tests/mocks.d.mts.map +1 -1
- package/dist/tests/mocks.mjs +29 -48
- package/dist/tests/mocks.mjs.map +1 -1
- package/package.json +1 -2
package/dist/tests/mocks.d.cts
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import type { CaipChainId, KeyringAccountType } from "@metamask/keyring-api";
|
1
|
+
import type { KeyringAccountType } from "@metamask/keyring-api";
|
3
2
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
4
3
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
5
|
-
export declare const
|
6
|
-
export declare const ETH_ERC_4337_METHODS: readonly [EthMethod.PatchUserOperation, EthMethod.PrepareUserOperation, EthMethod.SignUserOperation];
|
7
|
-
export declare const createMockInternalAccount: ({ id, address, type, name, keyringType, snap, methods, scopes, importTime, lastSelected, }?: {
|
4
|
+
export declare const createMockInternalAccount: ({ id, address, type, name, keyringType, snap, importTime, lastSelected, }?: {
|
8
5
|
id?: string | undefined;
|
9
6
|
address?: string | undefined;
|
10
7
|
type?: KeyringAccountType | undefined;
|
11
8
|
name?: string | undefined;
|
12
9
|
keyringType?: KeyringTypes | undefined;
|
13
|
-
scopes?: `${string}:${string}`[] | undefined;
|
14
|
-
methods?: (EthMethod | BtcMethod)[] | undefined;
|
15
10
|
snap?: {
|
16
11
|
id: string;
|
17
12
|
enabled: boolean;
|
@@ -20,26 +15,4 @@ export declare const createMockInternalAccount: ({ id, address, type, name, keyr
|
|
20
15
|
importTime?: number | undefined;
|
21
16
|
lastSelected?: number | undefined;
|
22
17
|
}) => InternalAccount;
|
23
|
-
export declare const createExpectedInternalAccount: (args: Parameters<typeof createMockInternalAccount>[0]) => {
|
24
|
-
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh" | "solana:data-account";
|
25
|
-
id: string;
|
26
|
-
options: Record<string, import("@metamask/utils").Json>;
|
27
|
-
metadata: {
|
28
|
-
name: string;
|
29
|
-
importTime: number;
|
30
|
-
keyring: {
|
31
|
-
type: string;
|
32
|
-
};
|
33
|
-
nameLastUpdatedAt?: number | undefined;
|
34
|
-
snap?: {
|
35
|
-
name: string;
|
36
|
-
id: string;
|
37
|
-
enabled: boolean;
|
38
|
-
} | undefined;
|
39
|
-
lastSelected?: number | undefined;
|
40
|
-
};
|
41
|
-
address: string;
|
42
|
-
scopes: `${string}:${string}`[];
|
43
|
-
methods: string[];
|
44
|
-
};
|
45
18
|
//# sourceMappingURL=mocks.d.cts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mocks.d.cts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"mocks.d.cts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,8BAA8B;AAChE,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,eAAO,MAAM,yBAAyB;;;;;;;YAgB9B,MAAM;iBACD,OAAO;cACV,MAAM;;;;MAIP,eA0CR,CAAC"}
|
package/dist/tests/mocks.d.mts
CHANGED
@@ -1,17 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import type { CaipChainId, KeyringAccountType } from "@metamask/keyring-api";
|
1
|
+
import type { KeyringAccountType } from "@metamask/keyring-api";
|
3
2
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
4
3
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
5
|
-
export declare const
|
6
|
-
export declare const ETH_ERC_4337_METHODS: readonly [EthMethod.PatchUserOperation, EthMethod.PrepareUserOperation, EthMethod.SignUserOperation];
|
7
|
-
export declare const createMockInternalAccount: ({ id, address, type, name, keyringType, snap, methods, scopes, importTime, lastSelected, }?: {
|
4
|
+
export declare const createMockInternalAccount: ({ id, address, type, name, keyringType, snap, importTime, lastSelected, }?: {
|
8
5
|
id?: string | undefined;
|
9
6
|
address?: string | undefined;
|
10
7
|
type?: KeyringAccountType | undefined;
|
11
8
|
name?: string | undefined;
|
12
9
|
keyringType?: KeyringTypes | undefined;
|
13
|
-
scopes?: `${string}:${string}`[] | undefined;
|
14
|
-
methods?: (EthMethod | BtcMethod)[] | undefined;
|
15
10
|
snap?: {
|
16
11
|
id: string;
|
17
12
|
enabled: boolean;
|
@@ -20,26 +15,4 @@ export declare const createMockInternalAccount: ({ id, address, type, name, keyr
|
|
20
15
|
importTime?: number | undefined;
|
21
16
|
lastSelected?: number | undefined;
|
22
17
|
}) => InternalAccount;
|
23
|
-
export declare const createExpectedInternalAccount: (args: Parameters<typeof createMockInternalAccount>[0]) => {
|
24
|
-
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh" | "solana:data-account";
|
25
|
-
id: string;
|
26
|
-
options: Record<string, import("@metamask/utils").Json>;
|
27
|
-
metadata: {
|
28
|
-
name: string;
|
29
|
-
importTime: number;
|
30
|
-
keyring: {
|
31
|
-
type: string;
|
32
|
-
};
|
33
|
-
nameLastUpdatedAt?: number | undefined;
|
34
|
-
snap?: {
|
35
|
-
name: string;
|
36
|
-
id: string;
|
37
|
-
enabled: boolean;
|
38
|
-
} | undefined;
|
39
|
-
lastSelected?: number | undefined;
|
40
|
-
};
|
41
|
-
address: string;
|
42
|
-
scopes: `${string}:${string}`[];
|
43
|
-
methods: string[];
|
44
|
-
};
|
45
18
|
//# sourceMappingURL=mocks.d.mts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"mocks.d.mts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,8BAA8B;AAChE,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,eAAO,MAAM,yBAAyB;;;;;;;YAgB9B,MAAM;iBACD,OAAO;cACV,MAAM;;;;MAIP,eA0CR,CAAC"}
|
package/dist/tests/mocks.mjs
CHANGED
@@ -1,64 +1,45 @@
|
|
1
|
-
import { BtcAccountType, EthAccountType, BtcMethod, EthMethod
|
1
|
+
import { BtcAccountType, EthAccountType, BtcMethod, EthMethod } from "@metamask/keyring-api";
|
2
2
|
import { KeyringTypes } from "@metamask/keyring-controller";
|
3
3
|
import { v4 } from "uuid";
|
4
|
-
export const
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
case `${BtcAccountType.P2wpkh}`:
|
31
|
-
return {
|
32
|
-
methods: [...Object.values(BtcMethod)],
|
33
|
-
scopes: [BtcScope.Mainnet],
|
34
|
-
};
|
35
|
-
default:
|
36
|
-
throw new Error(`Unknown account type: ${type}`);
|
37
|
-
}
|
38
|
-
};
|
39
|
-
const defaults = getInternalAccountDefaults();
|
4
|
+
export const createMockInternalAccount = ({ id = v4(), address = '0x2990079bcdee240329a520d2444386fc119da21a', type = EthAccountType.Eoa, name = 'Account 1', keyringType = KeyringTypes.hd, snap, importTime = Date.now(), lastSelected = Date.now(), } = {}) => {
|
5
|
+
let methods;
|
6
|
+
switch (type) {
|
7
|
+
case EthAccountType.Eoa:
|
8
|
+
methods = [
|
9
|
+
EthMethod.PersonalSign,
|
10
|
+
EthMethod.Sign,
|
11
|
+
EthMethod.SignTransaction,
|
12
|
+
EthMethod.SignTypedDataV1,
|
13
|
+
EthMethod.SignTypedDataV3,
|
14
|
+
EthMethod.SignTypedDataV4,
|
15
|
+
];
|
16
|
+
break;
|
17
|
+
case EthAccountType.Erc4337:
|
18
|
+
methods = [
|
19
|
+
EthMethod.PatchUserOperation,
|
20
|
+
EthMethod.PrepareUserOperation,
|
21
|
+
EthMethod.SignUserOperation,
|
22
|
+
];
|
23
|
+
break;
|
24
|
+
case BtcAccountType.P2wpkh:
|
25
|
+
methods = [BtcMethod.SendBitcoin];
|
26
|
+
break;
|
27
|
+
default:
|
28
|
+
throw new Error(`Unknown account type: ${type}`);
|
29
|
+
}
|
40
30
|
return {
|
41
31
|
id,
|
42
32
|
address,
|
43
33
|
options: {},
|
44
|
-
methods
|
45
|
-
scopes: scopes ?? defaults.scopes,
|
34
|
+
methods,
|
46
35
|
type,
|
47
36
|
metadata: {
|
48
37
|
name,
|
49
38
|
keyring: { type: keyringType },
|
50
39
|
importTime,
|
51
40
|
lastSelected,
|
52
|
-
|
53
|
-
...(snap ? { snap } : {}),
|
41
|
+
snap,
|
54
42
|
},
|
55
43
|
};
|
56
44
|
};
|
57
|
-
export const createExpectedInternalAccount = (args) => {
|
58
|
-
return createMockInternalAccount({
|
59
|
-
...args,
|
60
|
-
importTime: expect.any(Number),
|
61
|
-
lastSelected: expect.any(Number),
|
62
|
-
});
|
63
|
-
};
|
64
45
|
//# sourceMappingURL=mocks.mjs.map
|
package/dist/tests/mocks.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,
|
1
|
+
{"version":3,"file":"mocks.mjs","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,EACV,8BAA8B;AAE/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAE5D,OAAO,EAAE,EAAE,EAAE,aAAa;AAE1B,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,EAAE,GAAG,EAAE,EAAE,EACT,OAAO,GAAG,4CAA4C,EACtD,IAAI,GAAG,cAAc,CAAC,GAAG,EACzB,IAAI,GAAG,WAAW,EAClB,WAAW,GAAG,YAAY,CAAC,EAAE,EAC7B,IAAI,EACJ,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,EACvB,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,MAcvB,EAAE,EAAmB,EAAE;IACzB,IAAI,OAAO,CAAC;IAEZ,QAAQ,IAAI,EAAE;QACZ,KAAK,cAAc,CAAC,GAAG;YACrB,OAAO,GAAG;gBACR,SAAS,CAAC,YAAY;gBACtB,SAAS,CAAC,IAAI;gBACd,SAAS,CAAC,eAAe;gBACzB,SAAS,CAAC,eAAe;gBACzB,SAAS,CAAC,eAAe;gBACzB,SAAS,CAAC,eAAe;aAC1B,CAAC;YACF,MAAM;QACR,KAAK,cAAc,CAAC,OAAO;YACzB,OAAO,GAAG;gBACR,SAAS,CAAC,kBAAkB;gBAC5B,SAAS,CAAC,oBAAoB;gBAC9B,SAAS,CAAC,iBAAiB;aAC5B,CAAC;YACF,MAAM;QACR,KAAK,cAAc,CAAC,MAAM;YACxB,OAAO,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAClC,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAc,EAAE,CAAC,CAAC;KAC9D;IAED,OAAO;QACL,EAAE;QACF,OAAO;QACP,OAAO,EAAE,EAAE;QACX,OAAO;QACP,IAAI;QACJ,QAAQ,EAAE;YACR,IAAI;YACJ,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;YAC9B,UAAU;YACV,YAAY;YACZ,IAAI;SACL;KACiB,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import {\n BtcAccountType,\n EthAccountType,\n BtcMethod,\n EthMethod,\n} from '@metamask/keyring-api';\nimport type { KeyringAccountType } from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { v4 } from 'uuid';\n\nexport const createMockInternalAccount = ({\n id = v4(),\n address = '0x2990079bcdee240329a520d2444386fc119da21a',\n type = EthAccountType.Eoa,\n name = 'Account 1',\n keyringType = KeyringTypes.hd,\n snap,\n importTime = Date.now(),\n lastSelected = Date.now(),\n}: {\n id?: string;\n address?: string;\n type?: KeyringAccountType;\n name?: string;\n keyringType?: KeyringTypes;\n snap?: {\n id: string;\n enabled: boolean;\n name: string;\n };\n importTime?: number;\n lastSelected?: number;\n} = {}): InternalAccount => {\n let methods;\n\n switch (type) {\n case EthAccountType.Eoa:\n methods = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n ];\n break;\n case EthAccountType.Erc4337:\n methods = [\n EthMethod.PatchUserOperation,\n EthMethod.PrepareUserOperation,\n EthMethod.SignUserOperation,\n ];\n break;\n case BtcAccountType.P2wpkh:\n methods = [BtcMethod.SendBitcoin];\n break;\n default:\n throw new Error(`Unknown account type: ${type as string}`);\n }\n\n return {\n id,\n address,\n options: {},\n methods,\n type,\n metadata: {\n name,\n keyring: { type: keyringType },\n importTime,\n lastSelected,\n snap,\n },\n } as InternalAccount;\n};\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@metamask-previews/accounts-controller",
|
3
|
-
"version": "24.0.1-preview-
|
3
|
+
"version": "24.0.1-preview-def92ff7",
|
4
4
|
"description": "Manages internal accounts",
|
5
5
|
"keywords": [
|
6
6
|
"MetaMask",
|
@@ -52,7 +52,6 @@
|
|
52
52
|
"@metamask/eth-snap-keyring": "^11.1.0",
|
53
53
|
"@metamask/keyring-api": "^17.2.0",
|
54
54
|
"@metamask/keyring-internal-api": "^4.0.3",
|
55
|
-
"@metamask/keyring-utils": "^2.3.1",
|
56
55
|
"@metamask/network-controller": "^22.2.1",
|
57
56
|
"@metamask/snaps-sdk": "^6.17.1",
|
58
57
|
"@metamask/snaps-utils": "^8.10.0",
|