@metamask/keyring-api 18.0.0 → 19.1.0

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/api/account-options.cjs +122 -0
  3. package/dist/api/account-options.cjs.map +1 -0
  4. package/dist/api/account-options.d.cts +131 -0
  5. package/dist/api/account-options.d.cts.map +1 -0
  6. package/dist/api/account-options.d.mts +131 -0
  7. package/dist/api/account-options.d.mts.map +1 -0
  8. package/dist/api/account-options.mjs +119 -0
  9. package/dist/api/account-options.mjs.map +1 -0
  10. package/dist/api/account.cjs +12 -3
  11. package/dist/api/account.cjs.map +1 -1
  12. package/dist/api/account.d.cts +33 -5
  13. package/dist/api/account.d.cts.map +1 -1
  14. package/dist/api/account.d.mts +33 -5
  15. package/dist/api/account.d.mts.map +1 -1
  16. package/dist/api/account.mjs +12 -3
  17. package/dist/api/account.mjs.map +1 -1
  18. package/dist/api/discovery.d.cts +2 -2
  19. package/dist/api/discovery.d.mts +2 -2
  20. package/dist/api/index.cjs +1 -0
  21. package/dist/api/index.cjs.map +1 -1
  22. package/dist/api/index.d.cts +1 -0
  23. package/dist/api/index.d.cts.map +1 -1
  24. package/dist/api/index.d.mts +1 -0
  25. package/dist/api/index.d.mts.map +1 -1
  26. package/dist/api/index.mjs +1 -0
  27. package/dist/api/index.mjs.map +1 -1
  28. package/dist/btc/types.d.cts +88 -8
  29. package/dist/btc/types.d.cts.map +1 -1
  30. package/dist/btc/types.d.mts +88 -8
  31. package/dist/btc/types.d.mts.map +1 -1
  32. package/dist/eth/types.d.cts +44 -4
  33. package/dist/eth/types.d.cts.map +1 -1
  34. package/dist/eth/types.d.mts +44 -4
  35. package/dist/eth/types.d.mts.map +1 -1
  36. package/dist/events.d.cts +98 -16
  37. package/dist/events.d.cts.map +1 -1
  38. package/dist/events.d.mts +98 -16
  39. package/dist/events.d.mts.map +1 -1
  40. package/dist/rpc.d.cts +140 -26
  41. package/dist/rpc.d.cts.map +1 -1
  42. package/dist/rpc.d.mts +140 -26
  43. package/dist/rpc.d.mts.map +1 -1
  44. package/dist/sol/types.d.cts +22 -2
  45. package/dist/sol/types.d.cts.map +1 -1
  46. package/dist/sol/types.d.mts +22 -2
  47. package/dist/sol/types.d.mts.map +1 -1
  48. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [19.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add generic account type ([#318](https://github.com/metamask/accounts/pull/318))
15
+ - This account type can be used during the integration of new chains.
16
+ - It's allowed only Flask builds of MetaMask clients.
17
+
18
+ ## [19.0.0]
19
+
20
+ ### Changed
21
+
22
+ - **BREAKING:** Add typed `KeyringAccount.options` ([#316](https://github.com/MetaMask/accounts/pull/316))
23
+ - We still support the old `Record<string, Json>` type for `options`, however we now constrain 2 fields (`entropy` and `exportable`) and type their shapes to meet new requirements.
24
+
10
25
  ## [18.0.0]
11
26
 
12
27
  ### Changed
@@ -583,7 +598,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
583
598
  - SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
584
599
  - Helper functions to create keyring handler in the snap.
585
600
 
586
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@18.0.0...HEAD
601
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@19.1.0...HEAD
602
+ [19.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@19.0.0...@metamask/keyring-api@19.1.0
603
+ [19.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@18.0.0...@metamask/keyring-api@19.0.0
587
604
  [18.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@17.6.0...@metamask/keyring-api@18.0.0
588
605
  [17.6.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@17.5.0...@metamask/keyring-api@17.6.0
589
606
  [17.5.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@17.4.0...@metamask/keyring-api@17.5.0
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyringAccountOptionsStruct = exports.KeyringAccountEntropyOptionsStruct = exports.KeyringAccountEntropyPrivateKeyOptionsStruct = exports.KeyringAccountEntropyMnemonicOptionsStruct = exports.KeyringAccountEntropyTypeOption = void 0;
4
+ const keyring_utils_1 = require("@metamask/keyring-utils");
5
+ const superstruct_1 = require("@metamask/superstruct");
6
+ const utils_1 = require("@metamask/utils");
7
+ /**
8
+ * Keyring account entropy valid types.
9
+ */
10
+ var KeyringAccountEntropyTypeOption;
11
+ (function (KeyringAccountEntropyTypeOption) {
12
+ /**
13
+ * Indicates that the account was created from a mnemonic phrase.
14
+ */
15
+ KeyringAccountEntropyTypeOption["Mnemonic"] = "mnemonic";
16
+ /**
17
+ * Indicates that the account was imported from a private key.
18
+ */
19
+ KeyringAccountEntropyTypeOption["PrivateKey"] = "private-key";
20
+ })(KeyringAccountEntropyTypeOption || (exports.KeyringAccountEntropyTypeOption = KeyringAccountEntropyTypeOption = {}));
21
+ /**
22
+ * Keyring account options struct for mnemonics (BIP-44).
23
+ */
24
+ exports.KeyringAccountEntropyMnemonicOptionsStruct = (0, superstruct_1.object)({
25
+ /**
26
+ * Indicates that the account was created from a mnemonic phrase.
27
+ */
28
+ type: (0, superstruct_1.literal)(`${KeyringAccountEntropyTypeOption.Mnemonic}`),
29
+ /**
30
+ * The ID of the entropy source.
31
+ */
32
+ id: (0, superstruct_1.string)(), // TODO: Define a struct for entropy source.
33
+ /**
34
+ * The BIP-44 derivation path used to derive the account.
35
+ */
36
+ derivationPath: (0, superstruct_1.string)(),
37
+ /**
38
+ * Index used to group accounts in the UI.
39
+ *
40
+ * Accounts sharing the same `groupIndex` are displayed together as a
41
+ * multichain account group.
42
+ */
43
+ groupIndex: (0, superstruct_1.number)(),
44
+ });
45
+ /**
46
+ * Keyring account options struct for private keys.
47
+ */
48
+ exports.KeyringAccountEntropyPrivateKeyOptionsStruct = (0, superstruct_1.object)({
49
+ /**
50
+ * Indicates that the account was imported from a private key.
51
+ */
52
+ type: (0, superstruct_1.literal)(`${KeyringAccountEntropyTypeOption.PrivateKey}`),
53
+ });
54
+ /**
55
+ * Keyring account entropy options struct.
56
+ */
57
+ exports.KeyringAccountEntropyOptionsStruct = (0, keyring_utils_1.selectiveUnion)((value) => {
58
+ return (0, utils_1.isPlainObject)(value) &&
59
+ value.type === KeyringAccountEntropyTypeOption.PrivateKey
60
+ ? exports.KeyringAccountEntropyPrivateKeyOptionsStruct
61
+ : exports.KeyringAccountEntropyMnemonicOptionsStruct;
62
+ });
63
+ /**
64
+ * Keyring options struct. This represents various options for a Keyring account object.
65
+ *
66
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
67
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * {
72
+ * entropy: {
73
+ * type: 'mnemonic',
74
+ * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',
75
+ * derivationPath: "m/44'/60'/0'/0/0",
76
+ * groupIndex: 0,
77
+ * },
78
+ * }
79
+ * ```
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * {
84
+ * entropy: {
85
+ * type: 'private-key',
86
+ * },
87
+ * exportable: true,
88
+ * }
89
+ * ```
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * {
94
+ * some: {
95
+ * untyped: 'options',
96
+ * something: true,
97
+ * },
98
+ * }
99
+ * ```
100
+ */
101
+ exports.KeyringAccountOptionsStruct = (0, superstruct_1.intersection)([
102
+ // Non-Typed options (retro-compatibility):
103
+ (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
104
+ // Typed options. We use `type` instead of `object` here, to allow
105
+ // extra properties. Also, since we use `record` + `intersection` we
106
+ // are guaranteed that all field values will match the `JsonStruct`.
107
+ //
108
+ // READ THIS CAREFULLY:
109
+ // Previous options that can be matched by this struct will be breaking
110
+ // existing keyring account options.
111
+ (0, keyring_utils_1.type)({
112
+ /**
113
+ * Entropy options.
114
+ */
115
+ entropy: (0, keyring_utils_1.exactOptional)(exports.KeyringAccountEntropyOptionsStruct),
116
+ /**
117
+ * Indicates whether the account can be exported.
118
+ */
119
+ exportable: (0, keyring_utils_1.exactOptional)((0, superstruct_1.boolean)()),
120
+ }),
121
+ ]);
122
+ //# sourceMappingURL=account-options.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-options.cjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":";;;AAAA,2DAA8E;AAE9E,uDAQ+B;AAC/B,2CAA4D;AAE5D;;GAEG;AACH,IAAY,+BAUX;AAVD,WAAY,+BAA+B;IACzC;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;IACH,6DAA0B,CAAA;AAC5B,CAAC,EAVW,+BAA+B,+CAA/B,+BAA+B,QAU1C;AAED;;GAEG;AACU,QAAA,0CAA0C,GAAG,IAAA,oBAAM,EAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAAC;IAE5D;;OAEG;IACH,EAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,4CAA4C;IAE1D;;OAEG;IACH,cAAc,EAAE,IAAA,oBAAM,GAAE;IAExB;;;;;OAKG;IACH,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,4CAA4C,GAAG,IAAA,oBAAM,EAAC;IACjE;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,+BAA+B,CAAC,UAAU,EAAE,CAAC;CAC/D,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,kCAAkC,GAAG,IAAA,8BAAc,EAC9D,CAAC,KAAU,EAAE,EAAE;IACb,OAAO,IAAA,qBAAa,EAAC,KAAK,CAAC;QACzB,KAAK,CAAC,IAAI,KAAK,+BAA+B,CAAC,UAAU;QACzD,CAAC,CAAC,oDAA4C;QAC9C,CAAC,CAAC,kDAA0C,CAAC;AACjD,CAAC,CACF,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACU,QAAA,2BAA2B,GAAG,IAAA,0BAAY,EAAC;IACtD,2CAA2C;IAC3C,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,uBAAuB;IACvB,uEAAuE;IACvE,oCAAoC;IACpC,IAAA,oBAAI,EAAC;QACH;;WAEG;QACH,OAAO,EAAE,IAAA,6BAAa,EAAC,0CAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,IAAA,6BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n return isPlainObject(value) &&\n value.type === KeyringAccountEntropyTypeOption.PrivateKey\n ? KeyringAccountEntropyPrivateKeyOptionsStruct\n : KeyringAccountEntropyMnemonicOptionsStruct;\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
@@ -0,0 +1,131 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Keyring account entropy valid types.
4
+ */
5
+ export declare enum KeyringAccountEntropyTypeOption {
6
+ /**
7
+ * Indicates that the account was created from a mnemonic phrase.
8
+ */
9
+ Mnemonic = "mnemonic",
10
+ /**
11
+ * Indicates that the account was imported from a private key.
12
+ */
13
+ PrivateKey = "private-key"
14
+ }
15
+ /**
16
+ * Keyring account options struct for mnemonics (BIP-44).
17
+ */
18
+ export declare const KeyringAccountEntropyMnemonicOptionsStruct: import("@metamask/superstruct").Struct<{
19
+ type: "mnemonic";
20
+ id: string;
21
+ derivationPath: string;
22
+ groupIndex: number;
23
+ }, {
24
+ /**
25
+ * Indicates that the account was created from a mnemonic phrase.
26
+ */
27
+ type: import("@metamask/superstruct").Struct<"mnemonic", "mnemonic">;
28
+ /**
29
+ * The ID of the entropy source.
30
+ */
31
+ id: import("@metamask/superstruct").Struct<string, null>;
32
+ /**
33
+ * The BIP-44 derivation path used to derive the account.
34
+ */
35
+ derivationPath: import("@metamask/superstruct").Struct<string, null>;
36
+ /**
37
+ * Index used to group accounts in the UI.
38
+ *
39
+ * Accounts sharing the same `groupIndex` are displayed together as a
40
+ * multichain account group.
41
+ */
42
+ groupIndex: import("@metamask/superstruct").Struct<number, null>;
43
+ }>;
44
+ /**
45
+ * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.
46
+ */
47
+ export type KeyringAccountEntropyMnemonicOptions = Infer<typeof KeyringAccountEntropyMnemonicOptionsStruct>;
48
+ /**
49
+ * Keyring account options struct for private keys.
50
+ */
51
+ export declare const KeyringAccountEntropyPrivateKeyOptionsStruct: import("@metamask/superstruct").Struct<{
52
+ type: "private-key";
53
+ }, {
54
+ /**
55
+ * Indicates that the account was imported from a private key.
56
+ */
57
+ type: import("@metamask/superstruct").Struct<"private-key", "private-key">;
58
+ }>;
59
+ /**
60
+ * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
61
+ */
62
+ export type KeyringAccountEntropyPrivateKeyOptions = Infer<typeof KeyringAccountEntropyPrivateKeyOptionsStruct>;
63
+ /**
64
+ * Keyring account entropy options struct.
65
+ */
66
+ export declare const KeyringAccountEntropyOptionsStruct: import("@metamask/superstruct").Struct<{
67
+ type: "mnemonic";
68
+ id: string;
69
+ derivationPath: string;
70
+ groupIndex: number;
71
+ } | {
72
+ type: "private-key";
73
+ }, null>;
74
+ /**
75
+ * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.
76
+ */
77
+ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOptionsStruct>;
78
+ /**
79
+ * Keyring options struct. This represents various options for a Keyring account object.
80
+ *
81
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
82
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * {
87
+ * entropy: {
88
+ * type: 'mnemonic',
89
+ * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',
90
+ * derivationPath: "m/44'/60'/0'/0/0",
91
+ * groupIndex: 0,
92
+ * },
93
+ * }
94
+ * ```
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * {
99
+ * entropy: {
100
+ * type: 'private-key',
101
+ * },
102
+ * exportable: true,
103
+ * }
104
+ * ```
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * {
109
+ * some: {
110
+ * untyped: 'options',
111
+ * something: true,
112
+ * },
113
+ * }
114
+ * ```
115
+ */
116
+ export declare const KeyringAccountOptionsStruct: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
117
+ entropy?: {
118
+ type: "mnemonic";
119
+ id: string;
120
+ derivationPath: string;
121
+ groupIndex: number;
122
+ } | {
123
+ type: "private-key";
124
+ };
125
+ exportable?: boolean;
126
+ }, null>;
127
+ /**
128
+ * Keyring account options {@link KeyringAccountOptionsStruct}.
129
+ */
130
+ export type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;
131
+ //# sourceMappingURL=account-options.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-options.d.cts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;QAO9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;QAsBtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,131 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Keyring account entropy valid types.
4
+ */
5
+ export declare enum KeyringAccountEntropyTypeOption {
6
+ /**
7
+ * Indicates that the account was created from a mnemonic phrase.
8
+ */
9
+ Mnemonic = "mnemonic",
10
+ /**
11
+ * Indicates that the account was imported from a private key.
12
+ */
13
+ PrivateKey = "private-key"
14
+ }
15
+ /**
16
+ * Keyring account options struct for mnemonics (BIP-44).
17
+ */
18
+ export declare const KeyringAccountEntropyMnemonicOptionsStruct: import("@metamask/superstruct").Struct<{
19
+ type: "mnemonic";
20
+ id: string;
21
+ derivationPath: string;
22
+ groupIndex: number;
23
+ }, {
24
+ /**
25
+ * Indicates that the account was created from a mnemonic phrase.
26
+ */
27
+ type: import("@metamask/superstruct").Struct<"mnemonic", "mnemonic">;
28
+ /**
29
+ * The ID of the entropy source.
30
+ */
31
+ id: import("@metamask/superstruct").Struct<string, null>;
32
+ /**
33
+ * The BIP-44 derivation path used to derive the account.
34
+ */
35
+ derivationPath: import("@metamask/superstruct").Struct<string, null>;
36
+ /**
37
+ * Index used to group accounts in the UI.
38
+ *
39
+ * Accounts sharing the same `groupIndex` are displayed together as a
40
+ * multichain account group.
41
+ */
42
+ groupIndex: import("@metamask/superstruct").Struct<number, null>;
43
+ }>;
44
+ /**
45
+ * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.
46
+ */
47
+ export type KeyringAccountEntropyMnemonicOptions = Infer<typeof KeyringAccountEntropyMnemonicOptionsStruct>;
48
+ /**
49
+ * Keyring account options struct for private keys.
50
+ */
51
+ export declare const KeyringAccountEntropyPrivateKeyOptionsStruct: import("@metamask/superstruct").Struct<{
52
+ type: "private-key";
53
+ }, {
54
+ /**
55
+ * Indicates that the account was imported from a private key.
56
+ */
57
+ type: import("@metamask/superstruct").Struct<"private-key", "private-key">;
58
+ }>;
59
+ /**
60
+ * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
61
+ */
62
+ export type KeyringAccountEntropyPrivateKeyOptions = Infer<typeof KeyringAccountEntropyPrivateKeyOptionsStruct>;
63
+ /**
64
+ * Keyring account entropy options struct.
65
+ */
66
+ export declare const KeyringAccountEntropyOptionsStruct: import("@metamask/superstruct").Struct<{
67
+ type: "mnemonic";
68
+ id: string;
69
+ derivationPath: string;
70
+ groupIndex: number;
71
+ } | {
72
+ type: "private-key";
73
+ }, null>;
74
+ /**
75
+ * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.
76
+ */
77
+ export type KeyringAccountEntropyOptions = Infer<typeof KeyringAccountEntropyOptionsStruct>;
78
+ /**
79
+ * Keyring options struct. This represents various options for a Keyring account object.
80
+ *
81
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
82
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * {
87
+ * entropy: {
88
+ * type: 'mnemonic',
89
+ * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',
90
+ * derivationPath: "m/44'/60'/0'/0/0",
91
+ * groupIndex: 0,
92
+ * },
93
+ * }
94
+ * ```
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * {
99
+ * entropy: {
100
+ * type: 'private-key',
101
+ * },
102
+ * exportable: true,
103
+ * }
104
+ * ```
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * {
109
+ * some: {
110
+ * untyped: 'options',
111
+ * something: true,
112
+ * },
113
+ * }
114
+ * ```
115
+ */
116
+ export declare const KeyringAccountOptionsStruct: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
117
+ entropy?: {
118
+ type: "mnemonic";
119
+ id: string;
120
+ derivationPath: string;
121
+ groupIndex: number;
122
+ } | {
123
+ type: "private-key";
124
+ };
125
+ exportable?: boolean;
126
+ }, null>;
127
+ /**
128
+ * Keyring account options {@link KeyringAccountOptionsStruct}.
129
+ */
130
+ export type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;
131
+ //# sourceMappingURL=account-options.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-options.d.mts","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAYnD;;GAEG;AACH,oBAAY,+BAA+B;IACzC;;OAEG;IACH,QAAQ,aAAa;IAErB;;OAEG;IACH,UAAU,gBAAgB;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,0CAA0C;;;;;;IACrD;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;;;;OAKG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG,KAAK,CACtD,OAAO,0CAA0C,CAClD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4CAA4C;;;IACvD;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG,KAAK,CACxD,OAAO,4CAA4C,CACpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;QAO9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;QAsBtC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,119 @@
1
+ import { exactOptional, selectiveUnion, type } from "@metamask/keyring-utils";
2
+ import { boolean, intersection, literal, number, object, record, string } from "@metamask/superstruct";
3
+ import { isPlainObject, JsonStruct } from "@metamask/utils";
4
+ /**
5
+ * Keyring account entropy valid types.
6
+ */
7
+ export var KeyringAccountEntropyTypeOption;
8
+ (function (KeyringAccountEntropyTypeOption) {
9
+ /**
10
+ * Indicates that the account was created from a mnemonic phrase.
11
+ */
12
+ KeyringAccountEntropyTypeOption["Mnemonic"] = "mnemonic";
13
+ /**
14
+ * Indicates that the account was imported from a private key.
15
+ */
16
+ KeyringAccountEntropyTypeOption["PrivateKey"] = "private-key";
17
+ })(KeyringAccountEntropyTypeOption || (KeyringAccountEntropyTypeOption = {}));
18
+ /**
19
+ * Keyring account options struct for mnemonics (BIP-44).
20
+ */
21
+ export const KeyringAccountEntropyMnemonicOptionsStruct = object({
22
+ /**
23
+ * Indicates that the account was created from a mnemonic phrase.
24
+ */
25
+ type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),
26
+ /**
27
+ * The ID of the entropy source.
28
+ */
29
+ id: string(), // TODO: Define a struct for entropy source.
30
+ /**
31
+ * The BIP-44 derivation path used to derive the account.
32
+ */
33
+ derivationPath: string(),
34
+ /**
35
+ * Index used to group accounts in the UI.
36
+ *
37
+ * Accounts sharing the same `groupIndex` are displayed together as a
38
+ * multichain account group.
39
+ */
40
+ groupIndex: number(),
41
+ });
42
+ /**
43
+ * Keyring account options struct for private keys.
44
+ */
45
+ export const KeyringAccountEntropyPrivateKeyOptionsStruct = object({
46
+ /**
47
+ * Indicates that the account was imported from a private key.
48
+ */
49
+ type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),
50
+ });
51
+ /**
52
+ * Keyring account entropy options struct.
53
+ */
54
+ export const KeyringAccountEntropyOptionsStruct = selectiveUnion((value) => {
55
+ return isPlainObject(value) &&
56
+ value.type === KeyringAccountEntropyTypeOption.PrivateKey
57
+ ? KeyringAccountEntropyPrivateKeyOptionsStruct
58
+ : KeyringAccountEntropyMnemonicOptionsStruct;
59
+ });
60
+ /**
61
+ * Keyring options struct. This represents various options for a Keyring account object.
62
+ *
63
+ * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and
64
+ * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * {
69
+ * entropy: {
70
+ * type: 'mnemonic',
71
+ * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',
72
+ * derivationPath: "m/44'/60'/0'/0/0",
73
+ * groupIndex: 0,
74
+ * },
75
+ * }
76
+ * ```
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * {
81
+ * entropy: {
82
+ * type: 'private-key',
83
+ * },
84
+ * exportable: true,
85
+ * }
86
+ * ```
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * {
91
+ * some: {
92
+ * untyped: 'options',
93
+ * something: true,
94
+ * },
95
+ * }
96
+ * ```
97
+ */
98
+ export const KeyringAccountOptionsStruct = intersection([
99
+ // Non-Typed options (retro-compatibility):
100
+ record(string(), JsonStruct),
101
+ // Typed options. We use `type` instead of `object` here, to allow
102
+ // extra properties. Also, since we use `record` + `intersection` we
103
+ // are guaranteed that all field values will match the `JsonStruct`.
104
+ //
105
+ // READ THIS CAREFULLY:
106
+ // Previous options that can be matched by this struct will be breaking
107
+ // existing keyring account options.
108
+ type({
109
+ /**
110
+ * Entropy options.
111
+ */
112
+ entropy: exactOptional(KeyringAccountEntropyOptionsStruct),
113
+ /**
114
+ * Indicates whether the account can be exported.
115
+ */
116
+ exportable: exactOptional(boolean()),
117
+ }),
118
+ ]);
119
+ //# sourceMappingURL=account-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-options.mjs","sourceRoot":"","sources":["../../src/api/account-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,gCAAgC;AAE9E,OAAO,EACL,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,wBAAwB;AAE5D;;GAEG;AACH,MAAM,CAAN,IAAY,+BAUX;AAVD,WAAY,+BAA+B;IACzC;;OAEG;IACH,wDAAqB,CAAA;IAErB;;OAEG;IACH,6DAA0B,CAAA;AAC5B,CAAC,EAVW,+BAA+B,KAA/B,+BAA+B,QAU1C;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC;IAC/D;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAAC;IAE5D;;OAEG;IACH,EAAE,EAAE,MAAM,EAAE,EAAE,4CAA4C;IAE1D;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE;IAExB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,EAAE;CACrB,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,MAAM,CAAC;IACjE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,+BAA+B,CAAC,UAAU,EAAE,CAAC;CAC/D,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,cAAc,CAC9D,CAAC,KAAU,EAAE,EAAE;IACb,OAAO,aAAa,CAAC,KAAK,CAAC;QACzB,KAAK,CAAC,IAAI,KAAK,+BAA+B,CAAC,UAAU;QACzD,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,0CAA0C,CAAC;AACjD,CAAC,CACF,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC;IACtD,2CAA2C;IAC3C,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAE5B,kEAAkE;IAClE,oEAAoE;IACpE,oEAAoE;IACpE,EAAE;IACF,uBAAuB;IACvB,uEAAuE;IACvE,oCAAoC;IACpC,IAAI,CAAC;QACH;;WAEG;QACH,OAAO,EAAE,aAAa,CAAC,kCAAkC,CAAC;QAE1D;;WAEG;QACH,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, selectiveUnion, type } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n boolean,\n intersection,\n literal,\n number,\n object,\n record,\n string,\n} from '@metamask/superstruct';\nimport { isPlainObject, JsonStruct } from '@metamask/utils';\n\n/**\n * Keyring account entropy valid types.\n */\nexport enum KeyringAccountEntropyTypeOption {\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n Mnemonic = 'mnemonic',\n\n /**\n * Indicates that the account was imported from a private key.\n */\n PrivateKey = 'private-key',\n}\n\n/**\n * Keyring account options struct for mnemonics (BIP-44).\n */\nexport const KeyringAccountEntropyMnemonicOptionsStruct = object({\n /**\n * Indicates that the account was created from a mnemonic phrase.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.Mnemonic}`),\n\n /**\n * The ID of the entropy source.\n */\n id: string(), // TODO: Define a struct for entropy source.\n\n /**\n * The BIP-44 derivation path used to derive the account.\n */\n derivationPath: string(),\n\n /**\n * Index used to group accounts in the UI.\n *\n * Accounts sharing the same `groupIndex` are displayed together as a\n * multichain account group.\n */\n groupIndex: number(),\n});\n\n/**\n * Keyring account options for mnemonics (BIP-44) {@link KeyringAccountEntropyMnemonicOptionsStruct}.\n */\nexport type KeyringAccountEntropyMnemonicOptions = Infer<\n typeof KeyringAccountEntropyMnemonicOptionsStruct\n>;\n\n/**\n * Keyring account options struct for private keys.\n */\nexport const KeyringAccountEntropyPrivateKeyOptionsStruct = object({\n /**\n * Indicates that the account was imported from a private key.\n */\n type: literal(`${KeyringAccountEntropyTypeOption.PrivateKey}`),\n});\n\n/**\n * Keyring account options for private keys {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n */\nexport type KeyringAccountEntropyPrivateKeyOptions = Infer<\n typeof KeyringAccountEntropyPrivateKeyOptionsStruct\n>;\n\n/**\n * Keyring account entropy options struct.\n */\nexport const KeyringAccountEntropyOptionsStruct = selectiveUnion(\n (value: any) => {\n return isPlainObject(value) &&\n value.type === KeyringAccountEntropyTypeOption.PrivateKey\n ? KeyringAccountEntropyPrivateKeyOptionsStruct\n : KeyringAccountEntropyMnemonicOptionsStruct;\n },\n);\n\n/**\n * Keyring account entropy options {@link KeyringAccountEntropyOptionsStruct}.\n */\nexport type KeyringAccountEntropyOptions = Infer<\n typeof KeyringAccountEntropyOptionsStruct\n>;\n\n/**\n * Keyring options struct. This represents various options for a Keyring account object.\n *\n * See {@link KeyringAccountEntropyMnemonicOptionsStruct} and\n * {@link KeyringAccountEntropyPrivateKeyOptionsStruct}.\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'mnemonic',\n * id: '01K0BX6VDR5DPDPGGNA8PZVBVB',\n * derivationPath: \"m/44'/60'/0'/0/0\",\n * groupIndex: 0,\n * },\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * entropy: {\n * type: 'private-key',\n * },\n * exportable: true,\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * some: {\n * untyped: 'options',\n * something: true,\n * },\n * }\n * ```\n */\nexport const KeyringAccountOptionsStruct = intersection([\n // Non-Typed options (retro-compatibility):\n record(string(), JsonStruct),\n\n // Typed options. We use `type` instead of `object` here, to allow\n // extra properties. Also, since we use `record` + `intersection` we\n // are guaranteed that all field values will match the `JsonStruct`.\n //\n // READ THIS CAREFULLY:\n // Previous options that can be matched by this struct will be breaking\n // existing keyring account options.\n type({\n /**\n * Entropy options.\n */\n entropy: exactOptional(KeyringAccountEntropyOptionsStruct),\n\n /**\n * Indicates whether the account can be exported.\n */\n exportable: exactOptional(boolean()),\n }),\n]);\n\n/**\n * Keyring account options {@link KeyringAccountOptionsStruct}.\n */\nexport type KeyringAccountOptions = Infer<typeof KeyringAccountOptionsStruct>;\n"]}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeyringAccountStruct = exports.SolAccountType = exports.BtcAccountType = exports.EthAccountType = void 0;
3
+ exports.KeyringAccountStruct = exports.AnyAccountType = exports.SolAccountType = exports.BtcAccountType = exports.EthAccountType = void 0;
4
4
  const keyring_utils_1 = require("@metamask/keyring-utils");
5
5
  const superstruct_1 = require("@metamask/superstruct");
6
- const utils_1 = require("@metamask/utils");
6
+ const account_options_1 = require("./account-options.cjs");
7
7
  const caip_1 = require("./caip.cjs");
8
8
  /**
9
9
  * Supported Ethereum account types.
@@ -30,6 +30,14 @@ var SolAccountType;
30
30
  (function (SolAccountType) {
31
31
  SolAccountType["DataAccount"] = "solana:data-account";
32
32
  })(SolAccountType || (exports.SolAccountType = SolAccountType = {}));
33
+ /**
34
+ * A generic account type. It can be used to represent any account type that is
35
+ * not covered by the other account types. It only applies to non-EVM chains.
36
+ */
37
+ var AnyAccountType;
38
+ (function (AnyAccountType) {
39
+ AnyAccountType["Account"] = "any:account";
40
+ })(AnyAccountType || (exports.AnyAccountType = AnyAccountType = {}));
33
41
  /**
34
42
  * A struct which represents a Keyring account object. It is abstract enough to
35
43
  * be used with any blockchain. Specific blockchain account types should extend
@@ -53,6 +61,7 @@ exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
53
61
  `${BtcAccountType.P2wpkh}`,
54
62
  `${BtcAccountType.P2tr}`,
55
63
  `${SolAccountType.DataAccount}`,
64
+ `${AnyAccountType.Account}`,
56
65
  ]),
57
66
  /**
58
67
  * Account main address.
@@ -65,7 +74,7 @@ exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
65
74
  /**
66
75
  * Account options.
67
76
  */
68
- options: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
77
+ options: account_options_1.KeyringAccountOptionsStruct,
69
78
  /**
70
79
  * Account supported methods.
71
80
  */
@@ -1 +1 @@
1
- {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,2DAAkE;AAElE,uDAA+E;AAC/E,2CAA6C;AAE7C,qCAA2C;AAE3C;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,wCAAsB,CAAA;IACtB,sCAAoB,CAAA;IACpB,0CAAwB,CAAA;IACxB,sCAAoB,CAAA;AACtB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAcD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,+BAAe;IAEnB;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,KAAK,EAAE;QACzB,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,WAAW,EAAE;KAChC,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import { AccountIdStruct, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { CaipChainIdStruct } from './caip';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2pkh = 'bip122:p2pkh',\n P2sh = 'bip122:p2sh',\n P2wpkh = 'bip122:p2wpkh',\n P2tr = 'bip122:p2tr',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2pkh}`\n | `${BtcAccountType.P2sh}`\n | `${BtcAccountType.P2wpkh}`\n | `${BtcAccountType.P2tr}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: AccountIdStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2pkh}`,\n `${BtcAccountType.P2sh}`,\n `${BtcAccountType.P2wpkh}`,\n `${BtcAccountType.P2tr}`,\n `${SolAccountType.DataAccount}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
1
+ {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,2DAAkE;AAElE,uDAAuE;AAEvE,2DAAgE;AAChE,qCAA2C;AAE3C;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,wCAAsB,CAAA;IACtB,sCAAoB,CAAA;IACpB,0CAAwB,CAAA;IACxB,sCAAoB,CAAA;AACtB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;;GAGG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,yCAAuB,CAAA;AACzB,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAeD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,+BAAe;IAEnB;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,KAAK,EAAE;QACzB,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,IAAI,EAAE;QACxB,GAAG,cAAc,CAAC,WAAW,EAAE;QAC/B,GAAG,cAAc,CAAC,OAAO,EAAE;KAC5B,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,6CAA2B;IAEpC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import { AccountIdStruct, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, string } from '@metamask/superstruct';\n\nimport { KeyringAccountOptionsStruct } from './account-options';\nimport { CaipChainIdStruct } from './caip';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2pkh = 'bip122:p2pkh',\n P2sh = 'bip122:p2sh',\n P2wpkh = 'bip122:p2wpkh',\n P2tr = 'bip122:p2tr',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * A generic account type. It can be used to represent any account type that is\n * not covered by the other account types. It only applies to non-EVM chains.\n */\nexport enum AnyAccountType {\n Account = 'any:account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2pkh}`\n | `${BtcAccountType.P2sh}`\n | `${BtcAccountType.P2wpkh}`\n | `${BtcAccountType.P2tr}`\n | `${SolAccountType.DataAccount}`\n | `${AnyAccountType.Account}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: AccountIdStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2pkh}`,\n `${BtcAccountType.P2sh}`,\n `${BtcAccountType.P2wpkh}`,\n `${BtcAccountType.P2tr}`,\n `${SolAccountType.DataAccount}`,\n `${AnyAccountType.Account}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account options.\n */\n options: KeyringAccountOptionsStruct,\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}