@metamask-previews/keyring-api 10.1.0-3416820 → 11.0.0-22cd5fe

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 +9 -1
  2. package/dist/api/account.cjs +4 -0
  3. package/dist/api/account.cjs.map +1 -1
  4. package/dist/api/account.d.cts +5 -0
  5. package/dist/api/account.d.cts.map +1 -1
  6. package/dist/api/account.d.mts +5 -0
  7. package/dist/api/account.d.mts.map +1 -1
  8. package/dist/api/account.mjs +6 -2
  9. package/dist/api/account.mjs.map +1 -1
  10. package/dist/api/caip.cjs +3 -3
  11. package/dist/api/caip.cjs.map +1 -1
  12. package/dist/btc/constants.cjs +13 -0
  13. package/dist/btc/constants.cjs.map +1 -0
  14. package/dist/btc/constants.d.cts +9 -0
  15. package/dist/btc/constants.d.cts.map +1 -0
  16. package/dist/btc/constants.d.mts +9 -0
  17. package/dist/btc/constants.d.mts.map +1 -0
  18. package/dist/btc/constants.mjs +10 -0
  19. package/dist/btc/constants.mjs.map +1 -0
  20. package/dist/btc/index.cjs +1 -0
  21. package/dist/btc/index.cjs.map +1 -1
  22. package/dist/btc/index.d.cts +1 -0
  23. package/dist/btc/index.d.cts.map +1 -1
  24. package/dist/btc/index.d.mts +1 -0
  25. package/dist/btc/index.d.mts.map +1 -1
  26. package/dist/btc/index.mjs +1 -0
  27. package/dist/btc/index.mjs.map +1 -1
  28. package/dist/btc/types.d.cts +2 -0
  29. package/dist/btc/types.d.cts.map +1 -1
  30. package/dist/btc/types.d.mts +2 -0
  31. package/dist/btc/types.d.mts.map +1 -1
  32. package/dist/eth/constants.cjs +12 -0
  33. package/dist/eth/constants.cjs.map +1 -0
  34. package/dist/eth/constants.d.cts +8 -0
  35. package/dist/eth/constants.d.cts.map +1 -0
  36. package/dist/eth/constants.d.mts +8 -0
  37. package/dist/eth/constants.d.mts.map +1 -0
  38. package/dist/eth/constants.mjs +9 -0
  39. package/dist/eth/constants.mjs.map +1 -0
  40. package/dist/eth/index.cjs +1 -0
  41. package/dist/eth/index.cjs.map +1 -1
  42. package/dist/eth/index.d.cts +1 -0
  43. package/dist/eth/index.d.cts.map +1 -1
  44. package/dist/eth/index.d.mts +1 -0
  45. package/dist/eth/index.d.mts.map +1 -1
  46. package/dist/eth/index.mjs +1 -0
  47. package/dist/eth/index.mjs.map +1 -1
  48. package/dist/eth/types.d.cts +4 -0
  49. package/dist/eth/types.d.cts.map +1 -1
  50. package/dist/eth/types.d.mts +4 -0
  51. package/dist/eth/types.d.mts.map +1 -1
  52. package/dist/eth/utils.cjs +1 -2
  53. package/dist/eth/utils.cjs.map +1 -1
  54. package/dist/internal/api.d.cts +11 -0
  55. package/dist/internal/api.d.cts.map +1 -1
  56. package/dist/internal/api.d.mts +11 -0
  57. package/dist/internal/api.d.mts.map +1 -1
  58. package/dist/internal/events.d.cts +8 -0
  59. package/dist/internal/events.d.cts.map +1 -1
  60. package/dist/internal/events.d.mts +8 -0
  61. package/dist/internal/events.d.mts.map +1 -1
  62. package/dist/internal/rpc.cjs +2 -2
  63. package/dist/internal/rpc.cjs.map +1 -1
  64. package/dist/internal/types.d.cts +10 -0
  65. package/dist/internal/types.d.cts.map +1 -1
  66. package/dist/internal/types.d.mts +10 -0
  67. package/dist/internal/types.d.mts.map +1 -1
  68. package/dist/rpc-handler.cjs +2 -2
  69. package/dist/rpc-handler.cjs.map +1 -1
  70. package/dist/snap-utils.cjs +1 -2
  71. package/dist/snap-utils.cjs.map +1 -1
  72. package/dist/sol/constants.cjs +14 -0
  73. package/dist/sol/constants.cjs.map +1 -0
  74. package/dist/sol/constants.d.cts +10 -0
  75. package/dist/sol/constants.d.cts.map +1 -0
  76. package/dist/sol/constants.d.mts +10 -0
  77. package/dist/sol/constants.d.mts.map +1 -0
  78. package/dist/sol/constants.mjs +11 -0
  79. package/dist/sol/constants.mjs.map +1 -0
  80. package/dist/sol/index.cjs +1 -0
  81. package/dist/sol/index.cjs.map +1 -1
  82. package/dist/sol/index.d.cts +1 -0
  83. package/dist/sol/index.d.cts.map +1 -1
  84. package/dist/sol/index.d.mts +1 -0
  85. package/dist/sol/index.d.mts.map +1 -1
  86. package/dist/sol/index.mjs +1 -0
  87. package/dist/sol/index.mjs.map +1 -1
  88. package/dist/sol/types.d.cts +2 -0
  89. package/dist/sol/types.d.cts.map +1 -1
  90. package/dist/sol/types.d.mts +2 -0
  91. package/dist/sol/types.d.mts.map +1 -1
  92. package/dist/superstruct.cjs +4 -5
  93. package/dist/superstruct.cjs.map +1 -1
  94. package/dist/utils/typing.cjs +1 -2
  95. package/dist/utils/typing.cjs.map +1 -1
  96. package/package.json +2 -2
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolScopes = void 0;
4
+ /**
5
+ * Scopes for Solana account type. See {@link KeyringAccount.scopes}.
6
+ */
7
+ var SolScopes;
8
+ (function (SolScopes) {
9
+ SolScopes["Namespace"] = "solana";
10
+ SolScopes["Devnet"] = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
11
+ SolScopes["Mainnet"] = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
12
+ SolScopes["Testnet"] = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
13
+ })(SolScopes || (exports.SolScopes = SolScopes = {}));
14
+ //# sourceMappingURL=constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../src/sol/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,iCAAoB,CAAA;IACpB,+DAAkD,CAAA;IAClD,gEAAmD,CAAA;IACnD,gEAAmD,CAAA;AACrD,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB","sourcesContent":["/**\n * Scopes for Solana account type. See {@link KeyringAccount.scopes}.\n */\nexport enum SolScopes {\n Namespace = 'solana',\n Devnet = 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n Mainnet = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n Testnet = 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Scopes for Solana account type. See {@link KeyringAccount.scopes}.
3
+ */
4
+ export declare enum SolScopes {
5
+ Namespace = "solana",
6
+ Devnet = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
7
+ Mainnet = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
8
+ Testnet = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"
9
+ }
10
+ //# sourceMappingURL=constants.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/sol/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,SAAS;IACnB,SAAS,WAAW;IACpB,MAAM,4CAA4C;IAClD,OAAO,4CAA4C;IACnD,OAAO,4CAA4C;CACpD"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Scopes for Solana account type. See {@link KeyringAccount.scopes}.
3
+ */
4
+ export declare enum SolScopes {
5
+ Namespace = "solana",
6
+ Devnet = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
7
+ Mainnet = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
8
+ Testnet = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"
9
+ }
10
+ //# sourceMappingURL=constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../src/sol/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,SAAS;IACnB,SAAS,WAAW;IACpB,MAAM,4CAA4C;IAClD,OAAO,4CAA4C;IACnD,OAAO,4CAA4C;CACpD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scopes for Solana account type. See {@link KeyringAccount.scopes}.
3
+ */
4
+ export var SolScopes;
5
+ (function (SolScopes) {
6
+ SolScopes["Namespace"] = "solana";
7
+ SolScopes["Devnet"] = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
8
+ SolScopes["Mainnet"] = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
9
+ SolScopes["Testnet"] = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
10
+ })(SolScopes || (SolScopes = {}));
11
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../src/sol/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,iCAAoB,CAAA;IACpB,+DAAkD,CAAA;IAClD,gEAAmD,CAAA;IACnD,gEAAmD,CAAA;AACrD,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB","sourcesContent":["/**\n * Scopes for Solana account type. See {@link KeyringAccount.scopes}.\n */\nexport enum SolScopes {\n Namespace = 'solana',\n Devnet = 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n Mainnet = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n Testnet = 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n}\n"]}
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants.cjs"), exports);
17
18
  __exportStar(require("./types.cjs"), exports);
18
19
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB","sourcesContent":["export * from './types';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,8CAAwB","sourcesContent":["export * from './constants';\nexport * from './types';\n"]}
@@ -1,2 +1,3 @@
1
+ export * from "./constants.cjs";
1
2
  export * from "./types.cjs";
2
3
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,4BAAwB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,4BAAwB"}
@@ -1,2 +1,3 @@
1
+ export * from "./constants.mjs";
1
2
  export * from "./types.mjs";
2
3
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,4BAAwB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,4BAAwB"}
@@ -1,2 +1,3 @@
1
+ export * from "./constants.mjs";
1
2
  export * from "./types.mjs";
2
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,4BAAwB","sourcesContent":["export * from './types';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/sol/index.ts"],"names":[],"mappings":"AAAA,gCAA4B;AAC5B,4BAAwB","sourcesContent":["export * from './constants';\nexport * from './types';\n"]}
@@ -15,6 +15,7 @@ export declare const SolDataAccountStruct: import("@metamask/superstruct").Struc
15
15
  type: "solana:data-account";
16
16
  id: string;
17
17
  address: string;
18
+ scopes: string[];
18
19
  options: Record<string, import("@metamask/utils").Json>;
19
20
  methods: "sendAndConfirmTransaction"[];
20
21
  }, {
@@ -33,6 +34,7 @@ export declare const SolDataAccountStruct: import("@metamask/superstruct").Struc
33
34
  sendAndConfirmTransaction: "sendAndConfirmTransaction";
34
35
  }>>;
35
36
  id: import("@metamask/superstruct").Struct<string, null>;
37
+ scopes: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
36
38
  options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
37
39
  }>;
38
40
  export type SolDataAccount = Infer<typeof SolDataAccountStruct>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;;;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"}
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;;;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"}
@@ -15,6 +15,7 @@ export declare const SolDataAccountStruct: import("@metamask/superstruct").Struc
15
15
  type: "solana:data-account";
16
16
  id: string;
17
17
  address: string;
18
+ scopes: string[];
18
19
  options: Record<string, import("@metamask/utils").Json>;
19
20
  methods: "sendAndConfirmTransaction"[];
20
21
  }, {
@@ -33,6 +34,7 @@ export declare const SolDataAccountStruct: import("@metamask/superstruct").Struc
33
34
  sendAndConfirmTransaction: "sendAndConfirmTransaction";
34
35
  }>>;
35
36
  id: import("@metamask/superstruct").Struct<string, null>;
37
+ scopes: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
36
38
  options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
37
39
  }>;
38
40
  export type SolDataAccount = Infer<typeof SolDataAccountStruct>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;;;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"}
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/sol/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD;;;;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"}
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.strictMask = exports.definePattern = exports.exactOptional = exports.object = void 0;
3
+ exports.object = object;
4
+ exports.exactOptional = exactOptional;
5
+ exports.definePattern = definePattern;
6
+ exports.strictMask = strictMask;
4
7
  const superstruct_1 = require("@metamask/superstruct");
5
8
  /**
6
9
  * Change the return type of a superstruct object struct to support exact
@@ -12,7 +15,6 @@ const superstruct_1 = require("@metamask/superstruct");
12
15
  function object(schema) {
13
16
  return (0, superstruct_1.object)(schema);
14
17
  }
15
- exports.object = object;
16
18
  /**
17
19
  * Check if the current property is present in its parent object.
18
20
  *
@@ -44,7 +46,6 @@ function exactOptional(struct) {
44
46
  refiner: (value, ctx) => !hasOptional(ctx) || struct.refiner(value, ctx),
45
47
  });
46
48
  }
47
- exports.exactOptional = exactOptional;
48
49
  /**
49
50
  * Defines a new string-struct matching a regular expression.
50
51
  *
@@ -61,7 +62,6 @@ exports.exactOptional = exactOptional;
61
62
  function definePattern(name, pattern) {
62
63
  return (0, superstruct_1.define)(name, (value) => typeof value === 'string' && pattern.test(value));
63
64
  }
64
- exports.definePattern = definePattern;
65
65
  /**
66
66
  * Assert that a value is valid according to a struct.
67
67
  *
@@ -77,5 +77,4 @@ function strictMask(value, struct, message) {
77
77
  (0, superstruct_1.assert)(value, struct, message);
78
78
  return value;
79
79
  }
80
- exports.strictMask = strictMask;
81
80
  //# sourceMappingURL=superstruct.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"superstruct.cjs","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":";;;AAAA,uDAK+B;AAqD/B;;;;;;GAMG;AACH,SAAgB,MAAM,CACpB,MAAc;IAEd,OAAO,IAAA,oBAAQ,EAAC,MAAM,CAAQ,CAAC;AACjC,CAAC;AAJD,wBAIC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,QAAQ,GAAW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAA4B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,QAAQ,IAAI,MAAM,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,MAA4B;IAE5B,OAAO,IAAI,oBAAM,CAAC;QAChB,GAAG,MAAM;QAET,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACxB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAEnD,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACtB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,GAAG,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC;AAZD,sCAYC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,IAAY,EACZ,OAAe;IAEf,OAAO,IAAA,oBAAM,EACX,IAAI,EACJ,CAAC,KAAc,EAAW,EAAE,CAC1B,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CACnD,CAAC;AACJ,CAAC;AATD,sCASC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CACxB,KAAc,EACd,MAA4B,EAC5B,OAAgB;IAEhB,IAAA,oBAAM,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,gCAOC","sourcesContent":["import {\n Struct,\n assert,\n define,\n object as stObject,\n} from '@metamask/superstruct';\nimport type {\n Infer,\n Context,\n ObjectSchema,\n OmitBy,\n Optionalize,\n PickBy,\n Simplify,\n} from '@metamask/superstruct';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare const ExactOptionalSymbol: unique symbol;\n\nexport type ExactOptionalTag = {\n type: typeof ExactOptionalSymbol;\n};\n\n/**\n * Exclude type `Type` from the properties of `Obj`.\n *\n * ```ts\n * type Foo = { a: string | null; b: number };\n * type Bar = ExcludeType<Foo, null>;\n * // Bar = { a: string, b: number }\n * ```\n */\nexport type ExcludeType<Obj, Type> = {\n [K in keyof Obj]: Exclude<Obj[K], Type>;\n};\n\n/**\n * Make optional all properties that have the `ExactOptionalTag` type.\n *\n * ```ts\n * type Foo = { a: string | ExactOptionalTag; b: number};\n * type Bar = ExactOptionalize<Foo>;\n * // Bar = { a?: string; b: number}\n * ```\n */\nexport type ExactOptionalize<Schema extends object> = OmitBy<\n Schema,\n ExactOptionalTag\n> &\n Partial<ExcludeType<PickBy<Schema, ExactOptionalTag>, ExactOptionalTag>>;\n\n/**\n * Infer a type from an superstruct object schema.\n */\nexport type ObjectType<Schema extends ObjectSchema> = Simplify<\n ExactOptionalize<Optionalize<{ [K in keyof Schema]: Infer<Schema[K]> }>>\n>;\n\n/**\n * Change the return type of a superstruct object struct to support exact\n * optional properties.\n *\n * @param schema - The object schema.\n * @returns A struct representing an object with a known set of properties.\n */\nexport function object<Schema extends ObjectSchema>(\n schema: Schema,\n): Struct<ObjectType<Schema>, Schema> {\n return stObject(schema) as any;\n}\n\n/**\n * Check if the current property is present in its parent object.\n *\n * @param ctx - The context to check.\n * @returns `true` if the property is present, `false` otherwise.\n */\nfunction hasOptional(ctx: Context): boolean {\n const property: string = ctx.path[ctx.path.length - 1];\n const parent: Record<string, unknown> = ctx.branch[ctx.branch.length - 2];\n\n return property in parent;\n}\n\n/**\n * Augment a struct to allow exact-optional values. Exact-optional values can\n * be omitted but cannot be `undefined`.\n *\n * ```ts\n * const foo = object({ bar: exactOptional(string()) });\n * type Foo = Infer<typeof foo>;\n * // Foo = { bar?: string }\n * ```\n *\n * @param struct - The struct to augment.\n * @returns The augmented struct.\n */\nexport function exactOptional<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Type | ExactOptionalTag, Schema> {\n return new Struct({\n ...struct,\n\n validator: (value, ctx) =>\n !hasOptional(ctx) || struct.validator(value, ctx),\n\n refiner: (value, ctx) =>\n !hasOptional(ctx) || struct.refiner(value as Type, ctx),\n });\n}\n\n/**\n * Defines a new string-struct matching a regular expression.\n *\n * Example:\n *\n * ```ts\n * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);\n * ```\n *\n * @param name - Type name.\n * @param pattern - Regular expression to match.\n * @returns A new string-struct that matches the given pattern.\n */\nexport function definePattern(\n name: string,\n pattern: RegExp,\n): Struct<string, null> {\n return define<string>(\n name,\n (value: unknown): boolean =>\n typeof value === 'string' && pattern.test(value),\n );\n}\n\n/**\n * Assert that a value is valid according to a struct.\n *\n * It is similar to superstruct's mask function, but it does not ignore extra\n * properties.\n *\n * @param value - Value to check.\n * @param struct - Struct to validate the value against.\n * @param message - Error message to throw if the value is not valid.\n * @returns The value if it is valid.\n */\nexport function strictMask<Type, Schema>(\n value: unknown,\n struct: Struct<Type, Schema>,\n message?: string,\n): Type {\n assert(value, struct, message);\n return value;\n}\n"]}
1
+ {"version":3,"file":"superstruct.cjs","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":";;AAiEA,wBAIC;AA4BD,sCAYC;AAeD,sCASC;AAaD,gCAOC;AAzJD,uDAK+B;AAqD/B;;;;;;GAMG;AACH,SAAgB,MAAM,CACpB,MAAc;IAEd,OAAO,IAAA,oBAAQ,EAAC,MAAM,CAAQ,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,QAAQ,GAAW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAA4B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,QAAQ,IAAI,MAAM,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,MAA4B;IAE5B,OAAO,IAAI,oBAAM,CAAC;QAChB,GAAG,MAAM;QAET,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACxB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAEnD,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACtB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,GAAG,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,IAAY,EACZ,OAAe;IAEf,OAAO,IAAA,oBAAM,EACX,IAAI,EACJ,CAAC,KAAc,EAAW,EAAE,CAC1B,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CACnD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CACxB,KAAc,EACd,MAA4B,EAC5B,OAAgB;IAEhB,IAAA,oBAAM,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import {\n Struct,\n assert,\n define,\n object as stObject,\n} from '@metamask/superstruct';\nimport type {\n Infer,\n Context,\n ObjectSchema,\n OmitBy,\n Optionalize,\n PickBy,\n Simplify,\n} from '@metamask/superstruct';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare const ExactOptionalSymbol: unique symbol;\n\nexport type ExactOptionalTag = {\n type: typeof ExactOptionalSymbol;\n};\n\n/**\n * Exclude type `Type` from the properties of `Obj`.\n *\n * ```ts\n * type Foo = { a: string | null; b: number };\n * type Bar = ExcludeType<Foo, null>;\n * // Bar = { a: string, b: number }\n * ```\n */\nexport type ExcludeType<Obj, Type> = {\n [K in keyof Obj]: Exclude<Obj[K], Type>;\n};\n\n/**\n * Make optional all properties that have the `ExactOptionalTag` type.\n *\n * ```ts\n * type Foo = { a: string | ExactOptionalTag; b: number};\n * type Bar = ExactOptionalize<Foo>;\n * // Bar = { a?: string; b: number}\n * ```\n */\nexport type ExactOptionalize<Schema extends object> = OmitBy<\n Schema,\n ExactOptionalTag\n> &\n Partial<ExcludeType<PickBy<Schema, ExactOptionalTag>, ExactOptionalTag>>;\n\n/**\n * Infer a type from an superstruct object schema.\n */\nexport type ObjectType<Schema extends ObjectSchema> = Simplify<\n ExactOptionalize<Optionalize<{ [K in keyof Schema]: Infer<Schema[K]> }>>\n>;\n\n/**\n * Change the return type of a superstruct object struct to support exact\n * optional properties.\n *\n * @param schema - The object schema.\n * @returns A struct representing an object with a known set of properties.\n */\nexport function object<Schema extends ObjectSchema>(\n schema: Schema,\n): Struct<ObjectType<Schema>, Schema> {\n return stObject(schema) as any;\n}\n\n/**\n * Check if the current property is present in its parent object.\n *\n * @param ctx - The context to check.\n * @returns `true` if the property is present, `false` otherwise.\n */\nfunction hasOptional(ctx: Context): boolean {\n const property: string = ctx.path[ctx.path.length - 1];\n const parent: Record<string, unknown> = ctx.branch[ctx.branch.length - 2];\n\n return property in parent;\n}\n\n/**\n * Augment a struct to allow exact-optional values. Exact-optional values can\n * be omitted but cannot be `undefined`.\n *\n * ```ts\n * const foo = object({ bar: exactOptional(string()) });\n * type Foo = Infer<typeof foo>;\n * // Foo = { bar?: string }\n * ```\n *\n * @param struct - The struct to augment.\n * @returns The augmented struct.\n */\nexport function exactOptional<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Type | ExactOptionalTag, Schema> {\n return new Struct({\n ...struct,\n\n validator: (value, ctx) =>\n !hasOptional(ctx) || struct.validator(value, ctx),\n\n refiner: (value, ctx) =>\n !hasOptional(ctx) || struct.refiner(value as Type, ctx),\n });\n}\n\n/**\n * Defines a new string-struct matching a regular expression.\n *\n * Example:\n *\n * ```ts\n * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);\n * ```\n *\n * @param name - Type name.\n * @param pattern - Regular expression to match.\n * @returns A new string-struct that matches the given pattern.\n */\nexport function definePattern(\n name: string,\n pattern: RegExp,\n): Struct<string, null> {\n return define<string>(\n name,\n (value: unknown): boolean =>\n typeof value === 'string' && pattern.test(value),\n );\n}\n\n/**\n * Assert that a value is valid according to a struct.\n *\n * It is similar to superstruct's mask function, but it does not ignore extra\n * properties.\n *\n * @param value - Value to check.\n * @param struct - Struct to validate the value against.\n * @param message - Error message to throw if the value is not valid.\n * @returns The value if it is valid.\n */\nexport function strictMask<Type, Schema>(\n value: unknown,\n struct: Struct<Type, Schema>,\n message?: string,\n): Type {\n assert(value, struct, message);\n return value;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expectTrue = void 0;
3
+ exports.expectTrue = expectTrue;
4
4
  /**
5
5
  * Assert that a type extends `true`. It can be used, for example, to assert
6
6
  * that a given type extends another type.
@@ -17,5 +17,4 @@ exports.expectTrue = void 0;
17
17
  function expectTrue() {
18
18
  // Intentionally empty
19
19
  }
20
- exports.expectTrue = expectTrue;
21
20
  //# sourceMappingURL=typing.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"typing.cjs","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":";;;AAuBA;;;;;;;;;;;GAWG;AACH,6DAA6D;AAC7D,SAAgB,UAAU;IACxB,sBAAsB;AACxB,CAAC;AAFD,gCAEC","sourcesContent":["/**\n * Omit keys from a union type.\n *\n * The normal `Omit` type does not distribute over unions. So we use this\n * workaround that applies `Omit` to each member of the union.\n *\n * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>\n */\nexport type OmitUnion<Type, Key extends keyof any> = Type extends any\n ? Omit<Type, Key>\n : never;\n\n/**\n * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.\n *\n * @example\n * ```ts\n * type A = Extends<{a: string, b: string}, {a: string}>; // true\n * type B = Extends<{a: string}, {a: string, b: string}>; // false\n * ```\n */\nexport type Extends<Child, Base> = Child extends Base ? true : false;\n\n/**\n * Assert that a type extends `true`. It can be used, for example, to assert\n * that a given type extends another type.\n *\n * @example\n * ```ts\n * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok\n * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error\n * ```\n *\n * This function follows the naming pattern used on `tsd`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function expectTrue<Type extends true>(): void {\n // Intentionally empty\n}\n"]}
1
+ {"version":3,"file":"typing.cjs","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":";;AAoCA,gCAEC;AAfD;;;;;;;;;;;GAWG;AACH,6DAA6D;AAC7D,SAAgB,UAAU;IACxB,sBAAsB;AACxB,CAAC","sourcesContent":["/**\n * Omit keys from a union type.\n *\n * The normal `Omit` type does not distribute over unions. So we use this\n * workaround that applies `Omit` to each member of the union.\n *\n * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>\n */\nexport type OmitUnion<Type, Key extends keyof any> = Type extends any\n ? Omit<Type, Key>\n : never;\n\n/**\n * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.\n *\n * @example\n * ```ts\n * type A = Extends<{a: string, b: string}, {a: string}>; // true\n * type B = Extends<{a: string}, {a: string, b: string}>; // false\n * ```\n */\nexport type Extends<Child, Base> = Child extends Base ? true : false;\n\n/**\n * Assert that a type extends `true`. It can be used, for example, to assert\n * that a given type extends another type.\n *\n * @example\n * ```ts\n * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok\n * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error\n * ```\n *\n * This function follows the naming pattern used on `tsd`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function expectTrue<Type extends true>(): void {\n // Intentionally empty\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/keyring-api",
3
- "version": "10.1.0-3416820",
3
+ "version": "11.0.0-22cd5fe",
4
4
  "description": "MetaMask Keyring API",
5
5
  "keywords": [
6
6
  "metamask",
@@ -71,7 +71,7 @@
71
71
  "ts-node": "^10.9.2",
72
72
  "tsd": "^0.31.0",
73
73
  "typedoc": "^0.25.13",
74
- "typescript": "~5.4.5"
74
+ "typescript": "~5.6.3"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@metamask/providers": "^18.1.0"