@metamask-previews/keyring-internal-api 0.0.1-11541a9

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 (123) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +15 -0
  3. package/dist/api.cjs +138 -0
  4. package/dist/api.cjs.map +1 -0
  5. package/dist/api.d.cts +420 -0
  6. package/dist/api.d.cts.map +1 -0
  7. package/dist/api.d.mts +420 -0
  8. package/dist/api.d.mts.map +1 -0
  9. package/dist/api.mjs +135 -0
  10. package/dist/api.mjs.map +1 -0
  11. package/dist/btc/index.cjs +18 -0
  12. package/dist/btc/index.cjs.map +1 -0
  13. package/dist/btc/index.d.cts +2 -0
  14. package/dist/btc/index.d.cts.map +1 -0
  15. package/dist/btc/index.d.mts +2 -0
  16. package/dist/btc/index.d.mts.map +1 -0
  17. package/dist/btc/index.mjs +2 -0
  18. package/dist/btc/index.mjs.map +1 -0
  19. package/dist/btc/types.cjs +40 -0
  20. package/dist/btc/types.cjs.map +1 -0
  21. package/dist/btc/types.d.cts +34 -0
  22. package/dist/btc/types.d.cts.map +1 -0
  23. package/dist/btc/types.d.mts +34 -0
  24. package/dist/btc/types.d.mts.map +1 -0
  25. package/dist/btc/types.mjs +37 -0
  26. package/dist/btc/types.mjs.map +1 -0
  27. package/dist/eth/EthKeyring.cjs +3 -0
  28. package/dist/eth/EthKeyring.cjs.map +1 -0
  29. package/dist/eth/EthKeyring.d.cts +34 -0
  30. package/dist/eth/EthKeyring.d.cts.map +1 -0
  31. package/dist/eth/EthKeyring.d.mts +34 -0
  32. package/dist/eth/EthKeyring.d.mts.map +1 -0
  33. package/dist/eth/EthKeyring.mjs +2 -0
  34. package/dist/eth/EthKeyring.mjs.map +1 -0
  35. package/dist/eth/erc4337/index.cjs +18 -0
  36. package/dist/eth/erc4337/index.cjs.map +1 -0
  37. package/dist/eth/erc4337/index.d.cts +2 -0
  38. package/dist/eth/erc4337/index.d.cts.map +1 -0
  39. package/dist/eth/erc4337/index.d.mts +2 -0
  40. package/dist/eth/erc4337/index.d.mts.map +1 -0
  41. package/dist/eth/erc4337/index.mjs +2 -0
  42. package/dist/eth/erc4337/index.mjs.map +1 -0
  43. package/dist/eth/erc4337/types.cjs +61 -0
  44. package/dist/eth/erc4337/types.cjs.map +1 -0
  45. package/dist/eth/erc4337/types.d.cts +98 -0
  46. package/dist/eth/erc4337/types.d.cts.map +1 -0
  47. package/dist/eth/erc4337/types.d.mts +98 -0
  48. package/dist/eth/erc4337/types.d.mts.map +1 -0
  49. package/dist/eth/erc4337/types.mjs +58 -0
  50. package/dist/eth/erc4337/types.mjs.map +1 -0
  51. package/dist/eth/index.cjs +20 -0
  52. package/dist/eth/index.cjs.map +1 -0
  53. package/dist/eth/index.d.cts +5 -0
  54. package/dist/eth/index.d.cts.map +1 -0
  55. package/dist/eth/index.d.mts +5 -0
  56. package/dist/eth/index.d.mts.map +1 -0
  57. package/dist/eth/index.mjs +4 -0
  58. package/dist/eth/index.mjs.map +1 -0
  59. package/dist/eth/types.cjs +73 -0
  60. package/dist/eth/types.cjs.map +1 -0
  61. package/dist/eth/types.d.cts +81 -0
  62. package/dist/eth/types.d.cts.map +1 -0
  63. package/dist/eth/types.d.mts +81 -0
  64. package/dist/eth/types.d.mts.map +1 -0
  65. package/dist/eth/types.mjs +70 -0
  66. package/dist/eth/types.mjs.map +1 -0
  67. package/dist/eth/utils.cjs +14 -0
  68. package/dist/eth/utils.cjs.map +1 -0
  69. package/dist/eth/utils.d.cts +9 -0
  70. package/dist/eth/utils.d.cts.map +1 -0
  71. package/dist/eth/utils.d.mts +9 -0
  72. package/dist/eth/utils.d.mts.map +1 -0
  73. package/dist/eth/utils.mjs +11 -0
  74. package/dist/eth/utils.mjs.map +1 -0
  75. package/dist/events.cjs +83 -0
  76. package/dist/events.cjs.map +1 -0
  77. package/dist/events.d.cts +172 -0
  78. package/dist/events.d.cts.map +1 -0
  79. package/dist/events.d.mts +172 -0
  80. package/dist/events.d.mts.map +1 -0
  81. package/dist/events.mjs +80 -0
  82. package/dist/events.mjs.map +1 -0
  83. package/dist/index.cjs +24 -0
  84. package/dist/index.cjs.map +1 -0
  85. package/dist/index.d.cts +8 -0
  86. package/dist/index.d.cts.map +1 -0
  87. package/dist/index.d.mts +8 -0
  88. package/dist/index.d.mts.map +1 -0
  89. package/dist/index.mjs +8 -0
  90. package/dist/index.mjs.map +1 -0
  91. package/dist/rpc.cjs +33 -0
  92. package/dist/rpc.cjs.map +1 -0
  93. package/dist/rpc.d.cts +26 -0
  94. package/dist/rpc.d.cts.map +1 -0
  95. package/dist/rpc.d.mts +26 -0
  96. package/dist/rpc.d.mts.map +1 -0
  97. package/dist/rpc.mjs +29 -0
  98. package/dist/rpc.mjs.map +1 -0
  99. package/dist/sol/index.cjs +18 -0
  100. package/dist/sol/index.cjs.map +1 -0
  101. package/dist/sol/index.d.cts +2 -0
  102. package/dist/sol/index.d.cts.map +1 -0
  103. package/dist/sol/index.d.mts +2 -0
  104. package/dist/sol/index.d.mts.map +1 -0
  105. package/dist/sol/index.mjs +2 -0
  106. package/dist/sol/index.mjs.map +1 -0
  107. package/dist/sol/types.cjs +36 -0
  108. package/dist/sol/types.cjs.map +1 -0
  109. package/dist/sol/types.d.cts +39 -0
  110. package/dist/sol/types.d.cts.map +1 -0
  111. package/dist/sol/types.d.mts +39 -0
  112. package/dist/sol/types.d.mts.map +1 -0
  113. package/dist/sol/types.mjs +33 -0
  114. package/dist/sol/types.mjs.map +1 -0
  115. package/dist/types.cjs +56 -0
  116. package/dist/types.cjs.map +1 -0
  117. package/dist/types.d.cts +392 -0
  118. package/dist/types.d.cts.map +1 -0
  119. package/dist/types.d.mts +392 -0
  120. package/dist/types.d.mts.map +1 -0
  121. package/dist/types.mjs +53 -0
  122. package/dist/types.mjs.map +1 -0
  123. package/package.json +90 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types.cjs"), exports);
18
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB","sourcesContent":["export * from './types';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from "./types.cjs";
2
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,4BAAwB"}
@@ -0,0 +1,2 @@
1
+ export * from "./types.mjs";
2
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,4BAAwB"}
@@ -0,0 +1,2 @@
1
+ export * from "./types.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,4BAAwB","sourcesContent":["export * from './types';\n"]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolDataAccountStruct = exports.SolMethod = exports.SolAddressStruct = void 0;
4
+ const keyring_api_1 = require("@metamask/keyring-api");
5
+ const keyring_utils_1 = require("@metamask/keyring-utils");
6
+ const superstruct_1 = require("@metamask/superstruct");
7
+ /**
8
+ * Solana addresses are represented in the format of a 256-bit ed25519 public key and
9
+ * are encoded using base58.
10
+ * They are usually 32 to 44 characters long.
11
+ */
12
+ exports.SolAddressStruct = (0, keyring_utils_1.definePattern)('SolAddress', /^[1-9A-HJ-NP-Za-km-z]{32,44}$/iu);
13
+ /**
14
+ * Supported Solana methods.
15
+ */
16
+ var SolMethod;
17
+ (function (SolMethod) {
18
+ // General transaction methods
19
+ SolMethod["SendAndConfirmTransaction"] = "sendAndConfirmTransaction";
20
+ })(SolMethod || (exports.SolMethod = SolMethod = {}));
21
+ exports.SolDataAccountStruct = (0, keyring_utils_1.object)({
22
+ ...keyring_api_1.KeyringAccountStruct.schema,
23
+ /**
24
+ * Account address.
25
+ */
26
+ address: exports.SolAddressStruct,
27
+ /**
28
+ * Account type.
29
+ */
30
+ type: (0, superstruct_1.literal)(`${keyring_api_1.SolAccountType.DataAccount}`),
31
+ /**
32
+ * Account supported methods.
33
+ */
34
+ methods: (0, superstruct_1.array)((0, superstruct_1.enums)([`${SolMethod.SendAndConfirmTransaction}`])),
35
+ });
36
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":";;;AAAA,uDAA6E;AAC7E,2DAAgE;AAEhE,uDAA8D;AAE9D;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,IAAA,6BAAa,EAC3C,YAAY,EACZ,iCAAiC,CAClC,CAAC;AAEF;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,oEAAuD,CAAA;AACzD,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAEY,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC,GAAG,kCAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAc,CAAC,WAAW,EAAE,CAAC;IAE9C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;CAClE,CAAC,CAAC","sourcesContent":["import { KeyringAccountStruct, SolAccountType } from '@metamask/keyring-api';\nimport { object, definePattern } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\n/**\n * Solana addresses are represented in the format of a 256-bit ed25519 public key and\n * are encoded using base58.\n * They are usually 32 to 44 characters long.\n */\nexport const SolAddressStruct = definePattern(\n 'SolAddress',\n /^[1-9A-HJ-NP-Za-km-z]{32,44}$/iu,\n);\n\n/**\n * Supported Solana methods.\n */\nexport enum SolMethod {\n // General transaction methods\n SendAndConfirmTransaction = 'sendAndConfirmTransaction',\n}\n\nexport const SolDataAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: SolAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${SolAccountType.DataAccount}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${SolMethod.SendAndConfirmTransaction}`])),\n});\n\nexport type SolDataAccount = Infer<typeof SolDataAccountStruct>;\n"]}
@@ -0,0 +1,39 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Solana addresses are represented in the format of a 256-bit ed25519 public key and
4
+ * are encoded using base58.
5
+ * They are usually 32 to 44 characters long.
6
+ */
7
+ export declare const SolAddressStruct: import("@metamask/superstruct").Struct<string, null>;
8
+ /**
9
+ * Supported Solana methods.
10
+ */
11
+ export declare enum SolMethod {
12
+ SendAndConfirmTransaction = "sendAndConfirmTransaction"
13
+ }
14
+ export declare const SolDataAccountStruct: import("@metamask/superstruct").Struct<{
15
+ id: string;
16
+ options: Record<string, import("@metamask/utils").Json>;
17
+ type: "solana:data-account";
18
+ address: string;
19
+ methods: "sendAndConfirmTransaction"[];
20
+ }, {
21
+ /**
22
+ * Account address.
23
+ */
24
+ address: import("@metamask/superstruct").Struct<string, null>;
25
+ /**
26
+ * Account type.
27
+ */
28
+ type: import("@metamask/superstruct").Struct<"solana:data-account", "solana:data-account">;
29
+ /**
30
+ * Account supported methods.
31
+ */
32
+ methods: import("@metamask/superstruct").Struct<"sendAndConfirmTransaction"[], import("@metamask/superstruct").Struct<"sendAndConfirmTransaction", {
33
+ sendAndConfirmTransaction: "sendAndConfirmTransaction";
34
+ }>>;
35
+ id: import("@metamask/superstruct").Struct<string, null>;
36
+ options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
37
+ }>;
38
+ export type SolDataAccount = Infer<typeof SolDataAccountStruct>;
39
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,yBAAyB,8BAA8B;CACxD;AAED,eAAO,MAAM,oBAAoB;;;;;;;IAG/B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Solana addresses are represented in the format of a 256-bit ed25519 public key and
4
+ * are encoded using base58.
5
+ * They are usually 32 to 44 characters long.
6
+ */
7
+ export declare const SolAddressStruct: import("@metamask/superstruct").Struct<string, null>;
8
+ /**
9
+ * Supported Solana methods.
10
+ */
11
+ export declare enum SolMethod {
12
+ SendAndConfirmTransaction = "sendAndConfirmTransaction"
13
+ }
14
+ export declare const SolDataAccountStruct: import("@metamask/superstruct").Struct<{
15
+ id: string;
16
+ options: Record<string, import("@metamask/utils").Json>;
17
+ type: "solana:data-account";
18
+ address: string;
19
+ methods: "sendAndConfirmTransaction"[];
20
+ }, {
21
+ /**
22
+ * Account address.
23
+ */
24
+ address: import("@metamask/superstruct").Struct<string, null>;
25
+ /**
26
+ * Account type.
27
+ */
28
+ type: import("@metamask/superstruct").Struct<"solana:data-account", "solana:data-account">;
29
+ /**
30
+ * Account supported methods.
31
+ */
32
+ methods: import("@metamask/superstruct").Struct<"sendAndConfirmTransaction"[], import("@metamask/superstruct").Struct<"sendAndConfirmTransaction", {
33
+ sendAndConfirmTransaction: "sendAndConfirmTransaction";
34
+ }>>;
35
+ id: import("@metamask/superstruct").Struct<string, null>;
36
+ options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
37
+ }>;
38
+ export type SolDataAccount = Infer<typeof SolDataAccountStruct>;
39
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,yBAAyB,8BAA8B;CACxD;AAED,eAAO,MAAM,oBAAoB;;;;;;;IAG/B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { KeyringAccountStruct, SolAccountType } from "@metamask/keyring-api";
2
+ import { object, definePattern } from "@metamask/keyring-utils";
3
+ import { array, enums, literal } from "@metamask/superstruct";
4
+ /**
5
+ * Solana addresses are represented in the format of a 256-bit ed25519 public key and
6
+ * are encoded using base58.
7
+ * They are usually 32 to 44 characters long.
8
+ */
9
+ export const SolAddressStruct = definePattern('SolAddress', /^[1-9A-HJ-NP-Za-km-z]{32,44}$/iu);
10
+ /**
11
+ * Supported Solana methods.
12
+ */
13
+ export var SolMethod;
14
+ (function (SolMethod) {
15
+ // General transaction methods
16
+ SolMethod["SendAndConfirmTransaction"] = "sendAndConfirmTransaction";
17
+ })(SolMethod || (SolMethod = {}));
18
+ export const SolDataAccountStruct = object({
19
+ ...KeyringAccountStruct.schema,
20
+ /**
21
+ * Account address.
22
+ */
23
+ address: SolAddressStruct,
24
+ /**
25
+ * Account type.
26
+ */
27
+ type: literal(`${SolAccountType.DataAccount}`),
28
+ /**
29
+ * Account supported methods.
30
+ */
31
+ methods: array(enums([`${SolMethod.SendAndConfirmTransaction}`])),
32
+ });
33
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,8BAA8B;AAC7E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,gCAAgC;AAEhE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,YAAY,EACZ,iCAAiC,CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,oEAAuD,CAAA;AACzD,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC,GAAG,oBAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,gBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAE9C;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;CAClE,CAAC,CAAC","sourcesContent":["import { KeyringAccountStruct, SolAccountType } from '@metamask/keyring-api';\nimport { object, definePattern } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\n/**\n * Solana addresses are represented in the format of a 256-bit ed25519 public key and\n * are encoded using base58.\n * They are usually 32 to 44 characters long.\n */\nexport const SolAddressStruct = definePattern(\n 'SolAddress',\n /^[1-9A-HJ-NP-Za-km-z]{32,44}$/iu,\n);\n\n/**\n * Supported Solana methods.\n */\nexport enum SolMethod {\n // General transaction methods\n SendAndConfirmTransaction = 'sendAndConfirmTransaction',\n}\n\nexport const SolDataAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: SolAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${SolAccountType.DataAccount}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${SolMethod.SendAndConfirmTransaction}`])),\n});\n\nexport type SolDataAccount = Infer<typeof SolDataAccountStruct>;\n"]}
package/dist/types.cjs ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
3
+ /* eslint-disable @typescript-eslint/no-duplicate-type-constituents */
4
+ // Those rules seem to be triggering a false positive on the `InternalAccountStructs`
5
+ // and `InternalAccountTypes`.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.InternalAccountStruct = exports.InternalAccountStructs = exports.InternalSolDataAccountStruct = exports.InternalBtcP2wpkhAccountStruct = exports.InternalEthErc4337AccountStruct = exports.InternalEthEoaAccountStruct = exports.InternalAccountMetadataStruct = void 0;
8
+ const keyring_api_1 = require("@metamask/keyring-api");
9
+ const keyring_utils_1 = require("@metamask/keyring-utils");
10
+ const superstruct_1 = require("@metamask/superstruct");
11
+ const types_1 = require("./btc/types.cjs");
12
+ const types_2 = require("./eth/types.cjs");
13
+ const types_3 = require("./sol/types.cjs");
14
+ exports.InternalAccountMetadataStruct = (0, keyring_utils_1.object)({
15
+ metadata: (0, keyring_utils_1.object)({
16
+ name: (0, superstruct_1.string)(),
17
+ nameLastUpdatedAt: (0, keyring_utils_1.exactOptional)((0, superstruct_1.number)()),
18
+ snap: (0, keyring_utils_1.exactOptional)((0, keyring_utils_1.object)({
19
+ id: (0, superstruct_1.string)(),
20
+ enabled: (0, superstruct_1.boolean)(),
21
+ name: (0, superstruct_1.string)(),
22
+ })),
23
+ lastSelected: (0, keyring_utils_1.exactOptional)((0, superstruct_1.number)()),
24
+ importTime: (0, superstruct_1.number)(),
25
+ keyring: (0, keyring_utils_1.object)({
26
+ type: (0, superstruct_1.string)(),
27
+ }),
28
+ }),
29
+ });
30
+ exports.InternalEthEoaAccountStruct = (0, keyring_utils_1.object)({
31
+ ...types_2.EthEoaAccountStruct.schema,
32
+ ...exports.InternalAccountMetadataStruct.schema,
33
+ });
34
+ exports.InternalEthErc4337AccountStruct = (0, keyring_utils_1.object)({
35
+ ...types_2.EthErc4337AccountStruct.schema,
36
+ ...exports.InternalAccountMetadataStruct.schema,
37
+ });
38
+ exports.InternalBtcP2wpkhAccountStruct = (0, keyring_utils_1.object)({
39
+ ...types_1.BtcP2wpkhAccountStruct.schema,
40
+ ...exports.InternalAccountMetadataStruct.schema,
41
+ });
42
+ exports.InternalSolDataAccountStruct = (0, keyring_utils_1.object)({
43
+ ...types_3.SolDataAccountStruct.schema,
44
+ ...exports.InternalAccountMetadataStruct.schema,
45
+ });
46
+ exports.InternalAccountStructs = {
47
+ [`${keyring_api_1.EthAccountType.Eoa}`]: exports.InternalEthEoaAccountStruct,
48
+ [`${keyring_api_1.EthAccountType.Erc4337}`]: exports.InternalEthErc4337AccountStruct,
49
+ [`${keyring_api_1.BtcAccountType.P2wpkh}`]: exports.InternalBtcP2wpkhAccountStruct,
50
+ [`${keyring_api_1.SolAccountType.DataAccount}`]: exports.InternalSolDataAccountStruct,
51
+ };
52
+ exports.InternalAccountStruct = (0, keyring_utils_1.object)({
53
+ ...keyring_api_1.KeyringAccountStruct.schema,
54
+ ...exports.InternalAccountMetadataStruct.schema,
55
+ });
56
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,sEAAsE;AACtE,qFAAqF;AACrF,8BAA8B;;;AAE9B,uDAK+B;AAC/B,2DAAgE;AAEhE,uDAAgE;AAEhE,2CAAqD;AACrD,2CAA2E;AAC3E,2CAAmD;AAOtC,QAAA,6BAA6B,GAAG,IAAA,sBAAM,EAAC;IAClD,QAAQ,EAAE,IAAA,sBAAM,EAAC;QACf,IAAI,EAAE,IAAA,oBAAM,GAAE;QACd,iBAAiB,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;QAC1C,IAAI,EAAE,IAAA,6BAAa,EACjB,IAAA,sBAAM,EAAC;YACL,EAAE,EAAE,IAAA,oBAAM,GAAE;YACZ,OAAO,EAAE,IAAA,qBAAO,GAAE;YAClB,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;QACD,YAAY,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;QACrC,UAAU,EAAE,IAAA,oBAAM,GAAE;QACpB,OAAO,EAAE,IAAA,sBAAM,EAAC;YACd,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEU,QAAA,2BAA2B,GAAG,IAAA,sBAAM,EAAC;IAChD,GAAG,2BAAmB,CAAC,MAAM;IAC7B,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,IAAA,sBAAM,EAAC;IACpD,GAAG,+BAAuB,CAAC,MAAM;IACjC,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,IAAA,sBAAM,EAAC;IACnD,GAAG,8BAAsB,CAAC,MAAM;IAChC,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC;AAEU,QAAA,4BAA4B,GAAG,IAAA,sBAAM,EAAC;IACjD,GAAG,4BAAoB,CAAC,MAAM;IAC9B,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC;AAcU,QAAA,sBAAsB,GAM/B;IACF,CAAC,GAAG,4BAAc,CAAC,GAAG,EAAE,CAAC,EAAE,mCAA2B;IACtD,CAAC,GAAG,4BAAc,CAAC,OAAO,EAAE,CAAC,EAAE,uCAA+B;IAC9D,CAAC,GAAG,4BAAc,CAAC,MAAM,EAAE,CAAC,EAAE,sCAA8B;IAC5D,CAAC,GAAG,4BAAc,CAAC,WAAW,EAAE,CAAC,EAAE,oCAA4B;CAChE,CAAC;AAQW,QAAA,qBAAqB,GAAG,IAAA,sBAAM,EAAC;IAC1C,GAAG,kCAAoB,CAAC,MAAM;IAC9B,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */\n// Those rules seem to be triggering a false positive on the `InternalAccountStructs`\n// and `InternalAccountTypes`.\n\nimport {\n BtcAccountType,\n EthAccountType,\n KeyringAccountStruct,\n SolAccountType,\n} from '@metamask/keyring-api';\nimport { exactOptional, object } from '@metamask/keyring-utils';\nimport type { Infer, Struct } from '@metamask/superstruct';\nimport { boolean, string, number } from '@metamask/superstruct';\n\nimport { BtcP2wpkhAccountStruct } from './btc/types';\nimport { EthEoaAccountStruct, EthErc4337AccountStruct } from './eth/types';\nimport { SolDataAccountStruct } from './sol/types';\n\nexport type InternalAccountType =\n | EthAccountType\n | BtcAccountType\n | SolAccountType;\n\nexport const InternalAccountMetadataStruct = object({\n metadata: object({\n name: string(),\n nameLastUpdatedAt: exactOptional(number()),\n snap: exactOptional(\n object({\n id: string(),\n enabled: boolean(),\n name: string(),\n }),\n ),\n lastSelected: exactOptional(number()),\n importTime: number(),\n keyring: object({\n type: string(),\n }),\n }),\n});\n\nexport const InternalEthEoaAccountStruct = object({\n ...EthEoaAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport const InternalEthErc4337AccountStruct = object({\n ...EthErc4337AccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport const InternalBtcP2wpkhAccountStruct = object({\n ...BtcP2wpkhAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport const InternalSolDataAccountStruct = object({\n ...SolDataAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\nexport type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;\n\nexport type InternalEthErc4337Account = Infer<\n typeof InternalEthErc4337AccountStruct\n>;\n\nexport type InternalBtcP2wpkhAccount = Infer<\n typeof InternalBtcP2wpkhAccountStruct\n>;\n\nexport type InternalSolDataAccount = Infer<typeof InternalSolDataAccountStruct>;\n\nexport const InternalAccountStructs: Record<\n string,\n | Struct<InternalEthEoaAccount>\n | Struct<InternalEthErc4337Account>\n | Struct<InternalBtcP2wpkhAccount>\n | Struct<InternalSolDataAccount>\n> = {\n [`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct,\n [`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct,\n [`${BtcAccountType.P2wpkh}`]: InternalBtcP2wpkhAccountStruct,\n [`${SolAccountType.DataAccount}`]: InternalSolDataAccountStruct,\n};\n\nexport type InternalAccountTypes =\n | InternalEthEoaAccount\n | InternalEthErc4337Account\n | InternalBtcP2wpkhAccount\n | InternalSolDataAccount;\n\nexport const InternalAccountStruct = object({\n ...KeyringAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\n/**\n * Internal account representation.\n *\n * This type is used internally by MetaMask to add additional metadata to the\n * account object. It's should not be used by external applications.\n */\nexport type InternalAccount = Infer<typeof InternalAccountStruct>;\n"]}