@metamask/keyring-api 11.0.0 → 11.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 (96) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/KeyringClient.cjs +6 -0
  3. package/dist/KeyringClient.cjs.map +1 -1
  4. package/dist/KeyringClient.d.cts +3 -1
  5. package/dist/KeyringClient.d.cts.map +1 -1
  6. package/dist/KeyringClient.d.mts +3 -1
  7. package/dist/KeyringClient.d.mts.map +1 -1
  8. package/dist/KeyringClient.mjs +7 -1
  9. package/dist/KeyringClient.mjs.map +1 -1
  10. package/dist/api/asset.cjs +83 -0
  11. package/dist/api/asset.cjs.map +1 -0
  12. package/dist/api/asset.d.cts +93 -0
  13. package/dist/api/asset.d.cts.map +1 -0
  14. package/dist/api/asset.d.mts +93 -0
  15. package/dist/api/asset.d.mts.map +1 -0
  16. package/dist/api/asset.mjs +80 -0
  17. package/dist/api/asset.mjs.map +1 -0
  18. package/dist/api/balance.d.cts +1 -1
  19. package/dist/api/balance.d.mts +1 -1
  20. package/dist/api/index.cjs +2 -0
  21. package/dist/api/index.cjs.map +1 -1
  22. package/dist/api/index.d.cts +3 -1
  23. package/dist/api/index.d.cts.map +1 -1
  24. package/dist/api/index.d.mts +3 -1
  25. package/dist/api/index.d.mts.map +1 -1
  26. package/dist/api/index.mjs +2 -0
  27. package/dist/api/index.mjs.map +1 -1
  28. package/dist/api/keyring.cjs.map +1 -1
  29. package/dist/api/keyring.d.cts +14 -0
  30. package/dist/api/keyring.d.cts.map +1 -1
  31. package/dist/api/keyring.d.mts +14 -0
  32. package/dist/api/keyring.d.mts.map +1 -1
  33. package/dist/api/keyring.mjs.map +1 -1
  34. package/dist/api/transaction.cjs +295 -0
  35. package/dist/api/transaction.cjs.map +1 -0
  36. package/dist/api/transaction.d.cts +773 -0
  37. package/dist/api/transaction.d.cts.map +1 -0
  38. package/dist/api/transaction.d.mts +773 -0
  39. package/dist/api/transaction.d.mts.map +1 -0
  40. package/dist/api/transaction.mjs +292 -0
  41. package/dist/api/transaction.mjs.map +1 -0
  42. package/dist/eth/erc4337/types.d.cts +1 -1
  43. package/dist/eth/erc4337/types.d.mts +1 -1
  44. package/dist/internal/api.cjs +12 -1
  45. package/dist/internal/api.cjs.map +1 -1
  46. package/dist/internal/api.d.cts +318 -1
  47. package/dist/internal/api.d.cts.map +1 -1
  48. package/dist/internal/api.d.mts +318 -1
  49. package/dist/internal/api.d.mts.map +1 -1
  50. package/dist/internal/api.mjs +13 -2
  51. package/dist/internal/api.mjs.map +1 -1
  52. package/dist/internal/rpc.cjs +1 -0
  53. package/dist/internal/rpc.cjs.map +1 -1
  54. package/dist/internal/rpc.d.cts +1 -0
  55. package/dist/internal/rpc.d.cts.map +1 -1
  56. package/dist/internal/rpc.d.mts +1 -0
  57. package/dist/internal/rpc.d.mts.map +1 -1
  58. package/dist/internal/rpc.mjs +1 -0
  59. package/dist/internal/rpc.mjs.map +1 -1
  60. package/dist/rpc-handler.cjs +7 -0
  61. package/dist/rpc-handler.cjs.map +1 -1
  62. package/dist/rpc-handler.d.cts.map +1 -1
  63. package/dist/rpc-handler.d.mts.map +1 -1
  64. package/dist/rpc-handler.mjs +8 -1
  65. package/dist/rpc-handler.mjs.map +1 -1
  66. package/dist/superstruct.cjs +29 -0
  67. package/dist/superstruct.cjs.map +1 -1
  68. package/dist/superstruct.d.cts +19 -1
  69. package/dist/superstruct.d.cts.map +1 -1
  70. package/dist/superstruct.d.mts +19 -1
  71. package/dist/superstruct.d.mts.map +1 -1
  72. package/dist/superstruct.mjs +28 -0
  73. package/dist/superstruct.mjs.map +1 -1
  74. package/dist/utils/index.cjs +1 -0
  75. package/dist/utils/index.cjs.map +1 -1
  76. package/dist/utils/index.d.cts +1 -0
  77. package/dist/utils/index.d.cts.map +1 -1
  78. package/dist/utils/index.d.mts +1 -0
  79. package/dist/utils/index.d.mts.map +1 -1
  80. package/dist/utils/index.mjs +1 -0
  81. package/dist/utils/index.mjs.map +1 -1
  82. package/dist/utils/pagination.cjs +28 -0
  83. package/dist/utils/pagination.cjs.map +1 -0
  84. package/dist/utils/pagination.d.cts +59 -0
  85. package/dist/utils/pagination.d.cts.map +1 -0
  86. package/dist/utils/pagination.d.mts +59 -0
  87. package/dist/utils/pagination.d.mts.map +1 -0
  88. package/dist/utils/pagination.mjs +25 -0
  89. package/dist/utils/pagination.mjs.map +1 -0
  90. package/dist/utils/types.cjs.map +1 -1
  91. package/dist/utils/types.d.cts +24 -0
  92. package/dist/utils/types.d.cts.map +1 -1
  93. package/dist/utils/types.d.mts +24 -0
  94. package/dist/utils/types.d.mts.map +1 -1
  95. package/dist/utils/types.mjs.map +1 -1
  96. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ export * from "./pagination.mjs";
1
2
  export * from "./types.mjs";
2
3
  export * from "./typing.mjs";
3
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,6BAAyB","sourcesContent":["export * from './types';\nexport * from './typing';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,iCAA6B;AAC7B,4BAAwB;AACxB,6BAAyB","sourcesContent":["export * from './pagination';\nexport * from './types';\nexport * from './typing';\n"]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaginationStruct = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ const superstruct_2 = require("../superstruct.cjs");
6
+ /**
7
+ * Pagination struct. This struct is used to specify the limit of items to
8
+ * return and the next cursor to iterate over the results.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * {
13
+ * limit: 10,
14
+ * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
15
+ * }
16
+ * ```
17
+ */
18
+ exports.PaginationStruct = (0, superstruct_2.object)({
19
+ /**
20
+ * Maximum number of items to return.
21
+ */
22
+ limit: (0, superstruct_1.number)(),
23
+ /**
24
+ * Next cursor to iterate over the results.
25
+ */
26
+ next: (0, superstruct_2.exactOptional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
27
+ });
28
+ //# sourceMappingURL=pagination.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.cjs","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":";;;AACA,uDAAiE;AAEjE,oDAAuD;AAEvD;;;;;;;;;;;GAWG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IACrC;;OAEG;IACH,KAAK,EAAE,IAAA,oBAAM,GAAE;IAEf;;OAEG;IACH,IAAI,EAAE,IAAA,2BAAa,EAAC,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { nullable, number, string } from '@metamask/superstruct';\n\nimport { exactOptional, object } from '../superstruct';\n\n/**\n * Pagination struct. This struct is used to specify the limit of items to\n * return and the next cursor to iterate over the results.\n *\n * @example\n * ```ts\n * {\n * limit: 10,\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport const PaginationStruct = object({\n /**\n * Maximum number of items to return.\n */\n limit: number(),\n\n /**\n * Next cursor to iterate over the results.\n */\n next: exactOptional(nullable(string())),\n});\n\n/**\n * Pagination object.\n *\n * See {@link PaginationStruct}.\n */\nexport type Pagination = Infer<typeof PaginationStruct>;\n\n/**\n * Page of results. It includes the data and the next cursor to iterate over\n * the results.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Item object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport type Paginated<Type> = {\n /**\n * The list of items for this page.\n */\n data: Type[];\n\n /**\n * Next cursor to iterate over the results if any, will be `null` otherwise.\n */\n next: string | null;\n};\n"]}
@@ -0,0 +1,59 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Pagination struct. This struct is used to specify the limit of items to
4
+ * return and the next cursor to iterate over the results.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * {
9
+ * limit: 10,
10
+ * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
11
+ * }
12
+ * ```
13
+ */
14
+ export declare const PaginationStruct: import("@metamask/superstruct").Struct<{
15
+ limit: number;
16
+ next?: string | null;
17
+ }, {
18
+ /**
19
+ * Maximum number of items to return.
20
+ */
21
+ limit: import("@metamask/superstruct").Struct<number, null>;
22
+ /**
23
+ * Next cursor to iterate over the results.
24
+ */
25
+ next: import("@metamask/superstruct").Struct<string | import("../superstruct.cjs").ExactOptionalTag | null, null>;
26
+ }>;
27
+ /**
28
+ * Pagination object.
29
+ *
30
+ * See {@link PaginationStruct}.
31
+ */
32
+ export type Pagination = Infer<typeof PaginationStruct>;
33
+ /**
34
+ * Page of results. It includes the data and the next cursor to iterate over
35
+ * the results.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * {
40
+ * data: [
41
+ * {
42
+ * // Item object
43
+ * }
44
+ * ],
45
+ * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
46
+ * }
47
+ * ```
48
+ */
49
+ export type Paginated<Type> = {
50
+ /**
51
+ * The list of items for this page.
52
+ */
53
+ data: Type[];
54
+ /**
55
+ * Next cursor to iterate over the results if any, will be `null` otherwise.
56
+ */
57
+ next: string | null;
58
+ };
59
+ //# sourceMappingURL=pagination.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.cts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;;;;IAC3B;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI;IAC5B;;OAEG;IACH,IAAI,EAAE,IAAI,EAAE,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Pagination struct. This struct is used to specify the limit of items to
4
+ * return and the next cursor to iterate over the results.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * {
9
+ * limit: 10,
10
+ * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
11
+ * }
12
+ * ```
13
+ */
14
+ export declare const PaginationStruct: import("@metamask/superstruct").Struct<{
15
+ limit: number;
16
+ next?: string | null;
17
+ }, {
18
+ /**
19
+ * Maximum number of items to return.
20
+ */
21
+ limit: import("@metamask/superstruct").Struct<number, null>;
22
+ /**
23
+ * Next cursor to iterate over the results.
24
+ */
25
+ next: import("@metamask/superstruct").Struct<string | import("../superstruct.mjs").ExactOptionalTag | null, null>;
26
+ }>;
27
+ /**
28
+ * Pagination object.
29
+ *
30
+ * See {@link PaginationStruct}.
31
+ */
32
+ export type Pagination = Infer<typeof PaginationStruct>;
33
+ /**
34
+ * Page of results. It includes the data and the next cursor to iterate over
35
+ * the results.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * {
40
+ * data: [
41
+ * {
42
+ * // Item object
43
+ * }
44
+ * ],
45
+ * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
46
+ * }
47
+ * ```
48
+ */
49
+ export type Paginated<Type> = {
50
+ /**
51
+ * The list of items for this page.
52
+ */
53
+ data: Type[];
54
+ /**
55
+ * Next cursor to iterate over the results if any, will be `null` otherwise.
56
+ */
57
+ next: string | null;
58
+ };
59
+ //# sourceMappingURL=pagination.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.mts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;;;;IAC3B;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI;IAC5B;;OAEG;IACH,IAAI,EAAE,IAAI,EAAE,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { nullable, number, string } from "@metamask/superstruct";
2
+ import { exactOptional, object } from "../superstruct.mjs";
3
+ /**
4
+ * Pagination struct. This struct is used to specify the limit of items to
5
+ * return and the next cursor to iterate over the results.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * {
10
+ * limit: 10,
11
+ * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',
12
+ * }
13
+ * ```
14
+ */
15
+ export const PaginationStruct = object({
16
+ /**
17
+ * Maximum number of items to return.
18
+ */
19
+ limit: number(),
20
+ /**
21
+ * Next cursor to iterate over the results.
22
+ */
23
+ next: exactOptional(nullable(string())),
24
+ });
25
+ //# sourceMappingURL=pagination.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.mjs","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,2BAAuB;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE;IAEf;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { nullable, number, string } from '@metamask/superstruct';\n\nimport { exactOptional, object } from '../superstruct';\n\n/**\n * Pagination struct. This struct is used to specify the limit of items to\n * return and the next cursor to iterate over the results.\n *\n * @example\n * ```ts\n * {\n * limit: 10,\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport const PaginationStruct = object({\n /**\n * Maximum number of items to return.\n */\n limit: number(),\n\n /**\n * Next cursor to iterate over the results.\n */\n next: exactOptional(nullable(string())),\n});\n\n/**\n * Pagination object.\n *\n * See {@link PaginationStruct}.\n */\nexport type Pagination = Infer<typeof PaginationStruct>;\n\n/**\n * Page of results. It includes the data and the next cursor to iterate over\n * the results.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Item object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n */\nexport type Paginated<Type> = {\n /**\n * The list of items for this page.\n */\n data: Type[];\n\n /**\n * Next cursor to iterate over the results if any, will be `null` otherwise.\n */\n next: string | null;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAE3D,oDAA+C;AAE/C;;GAEG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAa,EACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACU,QAAA,SAAS,GAAG,IAAA,oBAAM,EAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAA,2BAAa,EAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAE3D,oDAA+C;AAE/C;;GAEG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAa,EACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACU,QAAA,SAAS,GAAG,IAAA,oBAAM,EAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAA,2BAAa,EAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n\n/**\n * This is a helper type used by the {@link Equals} type.\n */\ntype EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;\n\n/**\n * A utility type that checks whether two types are exactly the same.\n *\n * This type evaluates to `true` if `TypeA` and `TypeB` are identical,\n * otherwise it evaluates to `false`.\n *\n * @template TypeA - The first type to compare.\n * @template TypeB - The second type to compare.\n *\n * @example\n * ```ts\n * // Example usage:\n * type Test1 = Equals<number, number>; // true\n * type Test2 = Equals<number, string>; // false\n * type Test3 = Equals<{ a: string }, { a: string }>; // true\n * type Test4 = Equals<{ a: string }, { a: number }>; // false\n * ```\n */\nexport type Equals<TypeA, TypeB> =\n EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;\n"]}
@@ -15,4 +15,28 @@ export declare const UrlStruct: import("@metamask/superstruct").Struct<string, n
15
15
  */
16
16
  export declare const StringNumberStruct: import("@metamask/superstruct").Struct<string, null>;
17
17
  export type StringNumber = Infer<typeof StringNumberStruct>;
18
+ /**
19
+ * This is a helper type used by the {@link Equals} type.
20
+ */
21
+ type EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;
22
+ /**
23
+ * A utility type that checks whether two types are exactly the same.
24
+ *
25
+ * This type evaluates to `true` if `TypeA` and `TypeB` are identical,
26
+ * otherwise it evaluates to `false`.
27
+ *
28
+ * @template TypeA - The first type to compare.
29
+ * @template TypeB - The second type to compare.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * // Example usage:
34
+ * type Test1 = Equals<number, number>; // true
35
+ * type Test2 = Equals<number, string>; // false
36
+ * type Test3 = Equals<{ a: string }, { a: string }>; // true
37
+ * type Test4 = Equals<{ a: string }, { a: number }>; // false
38
+ * ```
39
+ */
40
+ export type Equals<TypeA, TypeB> = EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;
41
+ export {};
18
42
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,KAAK,EAAE,8BAA8B;AAI3D;;GAEG;AACH,eAAO,MAAM,UAAU,sDAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,sDAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAG9B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,KAAK,EAAE,8BAA8B;AAI3D;;GAEG;AACH,eAAO,MAAM,UAAU,sDAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,sDAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAG9B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5D;;GAEG;AACH,KAAK,YAAY,CAAC,IAAI,IAAI,CAAC,KAAK,OAAO,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,MAAM,CAAC,KAAK,EAAE,KAAK,IAC7B,YAAY,CAAC,KAAK,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC"}
@@ -15,4 +15,28 @@ export declare const UrlStruct: import("@metamask/superstruct").Struct<string, n
15
15
  */
16
16
  export declare const StringNumberStruct: import("@metamask/superstruct").Struct<string, null>;
17
17
  export type StringNumber = Infer<typeof StringNumberStruct>;
18
+ /**
19
+ * This is a helper type used by the {@link Equals} type.
20
+ */
21
+ type EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;
22
+ /**
23
+ * A utility type that checks whether two types are exactly the same.
24
+ *
25
+ * This type evaluates to `true` if `TypeA` and `TypeB` are identical,
26
+ * otherwise it evaluates to `false`.
27
+ *
28
+ * @template TypeA - The first type to compare.
29
+ * @template TypeB - The second type to compare.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * // Example usage:
34
+ * type Test1 = Equals<number, number>; // true
35
+ * type Test2 = Equals<number, string>; // false
36
+ * type Test3 = Equals<{ a: string }, { a: string }>; // true
37
+ * type Test4 = Equals<{ a: string }, { a: number }>; // false
38
+ * ```
39
+ */
40
+ export type Equals<TypeA, TypeB> = EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;
41
+ export {};
18
42
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,KAAK,EAAE,8BAA8B;AAI3D;;GAEG;AACH,eAAO,MAAM,UAAU,sDAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,sDAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAG9B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,KAAK,EAAE,8BAA8B;AAI3D;;GAEG;AACH,eAAO,MAAM,UAAU,sDAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,sDAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,sDAG9B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5D;;GAEG;AACH,KAAK,YAAY,CAAC,IAAI,IAAI,CAAC,KAAK,OAAO,KAAK,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,MAAM,CAAC,KAAK,EAAE,KAAK,IAC7B,YAAY,CAAC,KAAK,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,8BAA8B;AAE3D,OAAO,EAAE,aAAa,EAAE,2BAAuB;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,8BAA8B;AAE3D,OAAO,EAAE,aAAa,EAAE,2BAAuB;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n\n/**\n * This is a helper type used by the {@link Equals} type.\n */\ntype EqualsHelper<Type> = <Dummy>() => Dummy extends Type ? 1 : 2;\n\n/**\n * A utility type that checks whether two types are exactly the same.\n *\n * This type evaluates to `true` if `TypeA` and `TypeB` are identical,\n * otherwise it evaluates to `false`.\n *\n * @template TypeA - The first type to compare.\n * @template TypeB - The second type to compare.\n *\n * @example\n * ```ts\n * // Example usage:\n * type Test1 = Equals<number, number>; // true\n * type Test2 = Equals<number, string>; // false\n * type Test3 = Equals<{ a: string }, { a: string }>; // true\n * type Test4 = Equals<{ a: string }, { a: number }>; // false\n * ```\n */\nexport type Equals<TypeA, TypeB> =\n EqualsHelper<TypeA> extends EqualsHelper<TypeB> ? true : false;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/keyring-api",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "MetaMask Keyring API",
5
5
  "keywords": [
6
6
  "metamask",
@@ -48,7 +48,7 @@
48
48
  "dependencies": {
49
49
  "@metamask/snaps-sdk": "^6.7.0",
50
50
  "@metamask/superstruct": "^3.1.0",
51
- "@metamask/utils": "^9.2.1",
51
+ "@metamask/utils": "^9.3.0",
52
52
  "@types/uuid": "^9.0.8",
53
53
  "bech32": "^2.0.0",
54
54
  "uuid": "^9.0.1",