@metamask-previews/wallet 1.0.1-preview-e15374a5d → 2.0.0-preview-3a34409

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 (92) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/Wallet.cjs +7 -3
  3. package/dist/Wallet.cjs.map +1 -1
  4. package/dist/Wallet.d.cts.map +1 -1
  5. package/dist/Wallet.d.mts.map +1 -1
  6. package/dist/Wallet.mjs +7 -3
  7. package/dist/Wallet.mjs.map +1 -1
  8. package/dist/initialization/defaults.cjs.map +1 -1
  9. package/dist/initialization/defaults.d.cts +2 -2
  10. package/dist/initialization/defaults.d.cts.map +1 -1
  11. package/dist/initialization/defaults.d.mts +2 -2
  12. package/dist/initialization/defaults.d.mts.map +1 -1
  13. package/dist/initialization/defaults.mjs.map +1 -1
  14. package/dist/initialization/initialization.cjs.map +1 -1
  15. package/dist/initialization/initialization.d.cts.map +1 -1
  16. package/dist/initialization/initialization.d.mts.map +1 -1
  17. package/dist/initialization/initialization.mjs.map +1 -1
  18. package/dist/initialization/instances/approval-controller/approval-controller.cjs +39 -0
  19. package/dist/initialization/instances/approval-controller/approval-controller.cjs.map +1 -0
  20. package/dist/initialization/instances/approval-controller/approval-controller.d.cts +4 -0
  21. package/dist/initialization/instances/approval-controller/approval-controller.d.cts.map +1 -0
  22. package/dist/initialization/instances/approval-controller/approval-controller.d.mts +4 -0
  23. package/dist/initialization/instances/approval-controller/approval-controller.d.mts.map +1 -0
  24. package/dist/initialization/instances/approval-controller/approval-controller.mjs +36 -0
  25. package/dist/initialization/instances/approval-controller/approval-controller.mjs.map +1 -0
  26. package/dist/initialization/instances/approval-controller/types.cjs +3 -0
  27. package/dist/initialization/instances/approval-controller/types.cjs.map +1 -0
  28. package/dist/initialization/instances/approval-controller/types.d.cts +18 -0
  29. package/dist/initialization/instances/approval-controller/types.d.cts.map +1 -0
  30. package/dist/initialization/instances/approval-controller/types.d.mts +18 -0
  31. package/dist/initialization/instances/approval-controller/types.d.mts.map +1 -0
  32. package/dist/initialization/instances/approval-controller/types.mjs +2 -0
  33. package/dist/initialization/instances/approval-controller/types.mjs.map +1 -0
  34. package/dist/initialization/instances/index.cjs +6 -2
  35. package/dist/initialization/instances/index.cjs.map +1 -1
  36. package/dist/initialization/instances/index.d.cts +3 -1
  37. package/dist/initialization/instances/index.d.cts.map +1 -1
  38. package/dist/initialization/instances/index.d.mts +3 -1
  39. package/dist/initialization/instances/index.d.mts.map +1 -1
  40. package/dist/initialization/instances/index.mjs +3 -1
  41. package/dist/initialization/instances/index.mjs.map +1 -1
  42. package/dist/initialization/instances/{keyring-controller.cjs → keyring-controller/encryptor.cjs} +2 -17
  43. package/dist/initialization/instances/keyring-controller/encryptor.cjs.map +1 -0
  44. package/dist/initialization/instances/{keyring-controller.d.mts → keyring-controller/encryptor.d.cts} +1 -4
  45. package/dist/initialization/instances/keyring-controller/encryptor.d.cts.map +1 -0
  46. package/dist/initialization/instances/{keyring-controller.d.cts → keyring-controller/encryptor.d.mts} +1 -4
  47. package/dist/initialization/instances/keyring-controller/encryptor.d.mts.map +1 -0
  48. package/dist/initialization/instances/{keyring-controller.mjs → keyring-controller/encryptor.mjs} +1 -16
  49. package/dist/initialization/instances/keyring-controller/encryptor.mjs.map +1 -0
  50. package/dist/initialization/instances/keyring-controller/keyring-controller.cjs +21 -0
  51. package/dist/initialization/instances/keyring-controller/keyring-controller.cjs.map +1 -0
  52. package/dist/initialization/instances/keyring-controller/keyring-controller.d.cts +4 -0
  53. package/dist/initialization/instances/keyring-controller/keyring-controller.d.cts.map +1 -0
  54. package/dist/initialization/instances/keyring-controller/keyring-controller.d.mts +4 -0
  55. package/dist/initialization/instances/keyring-controller/keyring-controller.d.mts.map +1 -0
  56. package/dist/initialization/instances/keyring-controller/keyring-controller.mjs +18 -0
  57. package/dist/initialization/instances/keyring-controller/keyring-controller.mjs.map +1 -0
  58. package/dist/initialization/instances/keyring-controller/types.cjs +3 -0
  59. package/dist/initialization/instances/keyring-controller/types.cjs.map +1 -0
  60. package/dist/initialization/instances/keyring-controller/types.d.cts +22 -0
  61. package/dist/initialization/instances/keyring-controller/types.d.cts.map +1 -0
  62. package/dist/initialization/instances/keyring-controller/types.d.mts +22 -0
  63. package/dist/initialization/instances/keyring-controller/types.d.mts.map +1 -0
  64. package/dist/initialization/instances/keyring-controller/types.mjs +2 -0
  65. package/dist/initialization/instances/keyring-controller/types.mjs.map +1 -0
  66. package/dist/initialization/instances/storage-service/storage-service.cjs +17 -0
  67. package/dist/initialization/instances/storage-service/storage-service.cjs.map +1 -0
  68. package/dist/initialization/instances/storage-service/storage-service.d.cts +5 -0
  69. package/dist/initialization/instances/storage-service/storage-service.d.cts.map +1 -0
  70. package/dist/initialization/instances/storage-service/storage-service.d.mts +5 -0
  71. package/dist/initialization/instances/storage-service/storage-service.d.mts.map +1 -0
  72. package/dist/initialization/instances/storage-service/storage-service.mjs +14 -0
  73. package/dist/initialization/instances/storage-service/storage-service.mjs.map +1 -0
  74. package/dist/initialization/instances/storage-service/types.cjs +3 -0
  75. package/dist/initialization/instances/storage-service/types.cjs.map +1 -0
  76. package/dist/initialization/instances/storage-service/types.d.cts +12 -0
  77. package/dist/initialization/instances/storage-service/types.d.cts.map +1 -0
  78. package/dist/initialization/instances/storage-service/types.d.mts +12 -0
  79. package/dist/initialization/instances/storage-service/types.d.mts.map +1 -0
  80. package/dist/initialization/instances/storage-service/types.mjs +2 -0
  81. package/dist/initialization/instances/storage-service/types.mjs.map +1 -0
  82. package/dist/types.cjs.map +1 -1
  83. package/dist/types.d.cts +7 -7
  84. package/dist/types.d.cts.map +1 -1
  85. package/dist/types.d.mts +7 -7
  86. package/dist/types.d.mts.map +1 -1
  87. package/dist/types.mjs.map +1 -1
  88. package/package.json +4 -1
  89. package/dist/initialization/instances/keyring-controller.cjs.map +0 -1
  90. package/dist/initialization/instances/keyring-controller.d.cts.map +0 -1
  91. package/dist/initialization/instances/keyring-controller.d.mts.map +0 -1
  92. package/dist/initialization/instances/keyring-controller.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Added
11
11
 
12
+ - **BREAKING:** Wire `ApprovalController` into the default wallet initialization ([#8953](https://github.com/MetaMask/core/pull/8953))
13
+ - The default `Wallet` now constructs an `ApprovalController` and registers its `ApprovalController:*` messenger actions. Consumers that pass their own `messenger` and already wire an `ApprovalController` must remove their own before upgrading, or the duplicate registration will collide.
14
+ - Adds an `approvalController` slot to `instanceOptions` with `showApprovalRequest` (the callback that surfaces pending approval requests to the user; defaults to a no-op) and `typesExcludedFromRateLimiting` (the approval types exempt from per-origin rate limiting; defaults to a baseline of EVM approval types). Both let consumers (extension, mobile, wallet-cli) inject their platform-specific values.
15
+
16
+ ## [2.0.0]
17
+
18
+ ### Added
19
+
20
+ - Add `keyringV2Builders` to the `keyringController` instance options, forwarded to the `KeyringController` constructor ([#8956](https://github.com/MetaMask/core/pull/8956))
21
+ - **BREAKING:** Add `StorageService` initialization ([#8946](https://github.com/MetaMask/core/pull/8946))
22
+ - Passing `instanceOptions.storageService.storage` is now required.
12
23
  - Export `importSecretRecoveryPhrase` from the package root ([#8952](https://github.com/MetaMask/core/pull/8952))
13
24
 
14
25
  ## [1.0.1]
@@ -23,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
34
 
24
35
  - Initial release ([#8838](https://github.com/MetaMask/core/pull/8838))
25
36
 
26
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/wallet@1.0.1...HEAD
37
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/wallet@2.0.0...HEAD
38
+ [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/wallet@1.0.1...@metamask/wallet@2.0.0
27
39
  [1.0.1]: https://github.com/MetaMask/core/compare/@metamask/wallet@1.0.0...@metamask/wallet@1.0.1
28
40
  [1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/wallet@1.0.0
package/dist/Wallet.cjs CHANGED
@@ -44,7 +44,10 @@ class Wallet {
44
44
  }), "f");
45
45
  __classPrivateFieldSet(this, _Wallet_controllerMetadata, Object.fromEntries(Object.entries(__classPrivateFieldGet(this, _Wallet_instances, "f"))
46
46
  .filter(([_, instance]) => (0, utils_1.hasProperty)(instance, 'metadata'))
47
- .map(([name, instance]) => [name, instance.metadata])), "f");
47
+ .map(([name, instance]) => [
48
+ name,
49
+ instance.metadata,
50
+ ])), "f");
48
51
  }
49
52
  /**
50
53
  * @returns The root messenger of the wallet.
@@ -60,7 +63,9 @@ class Wallet {
60
63
  */
61
64
  get state() {
62
65
  return Object.entries(__classPrivateFieldGet(this, _Wallet_instances, "f")).reduce((totalState, [name, instance]) => {
63
- if (instance.state) {
66
+ // We do actually want to check the prototype here.
67
+ // eslint-disable-next-line no-restricted-syntax
68
+ if ('state' in instance && instance.state) {
64
69
  totalState[name] = instance.state;
65
70
  }
66
71
  return totalState;
@@ -100,7 +105,6 @@ class Wallet {
100
105
  // @ts-expect-error Accessing protected property.
101
106
  if (typeof instance.destroy === 'function') {
102
107
  // @ts-expect-error Accessing protected property.
103
- // eslint-disable-next-line @typescript-eslint/await-thenable
104
108
  return await instance.destroy();
105
109
  }
106
110
  /* istanbul ignore next */
@@ -1 +1 @@
1
- {"version":3,"file":"Wallet.cjs","sourceRoot":"","sources":["../src/Wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mDAAgD;AAChD,2CAA8C;AAS9C,wEAA6D;AAG7D,MAAa,MAAM;IAYjB;;;;;;;;;;OAUG;IACH,YAAY,OAAsB;QAtBlC,oEAAoE;QAC3D,oCAAyD;QAEzD,oCAA6B;QAE7B,6CAEP;QAEF,8BAAe,KAAK,EAAC;QAcnB,uBAAA,IAAI,qBACF,OAAO,CAAC,SAAS;YACjB,IAAI,qBAAS,CAAC;gBACZ,SAAS,EAAE,MAAM;aAClB,CAAC,MAAA,C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BAAkB,CAAC,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAUD;;;;;;OAMG;IACH,WAAW,CACT,IAAY;QAEZ,OAAO,uBAAA,IAAI,yBAAW,CAAC,IAA8B,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,uBAAA,IAAI,2BAAa,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,uBAAA,IAAI,uBAAgB,IAAI,MAAA,CAAC;QAEzB,MAAM,OAAO,CAAC,UAAU,CACtB,MAAM,CAAC,MAAM,CAAC,uBAAA,IAAI,yBAAW,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YACpD,iDAAiD;YACjD,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3C,iDAAiD;gBACjD,6DAA6D;gBAC7D,OAAO,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;YAClC,CAAC;YACD,0BAA0B;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAjID,wBAiIC","sourcesContent":["import type { StateMetadataConstraint } from '@metamask/base-controller';\nimport { Messenger } from '@metamask/messenger';\nimport { hasProperty } from '@metamask/utils';\n\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n DefaultState,\n RootMessenger,\n} from './initialization/defaults';\nimport { initialize } from './initialization/initialization';\nimport { WalletOptions } from './types';\n\nexport class Wallet {\n // TODO: Expand default types when passing additionalConfigurations.\n readonly #messenger: RootMessenger<DefaultActions, DefaultEvents>;\n\n readonly #instances: DefaultInstances;\n\n readonly #controllerMetadata: Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n >;\n\n #isDestroyed = false;\n\n /**\n * Creates a `Wallet` instance, initializing all instances as specified by the passed options.\n *\n * @param options - Options bag.\n * @param options.messenger - An optional messenger to override the default one.\n * @param options.state - An optional state blob.\n * @param options.initializationConfigurations - An optional list of additional initialization configurations\n * required beyond the ones included by default.\n * @param options.instanceOptions - An optional object containing options that should be passed\n * to specific instances for additional customization.\n */\n constructor(options: WalletOptions) {\n this.#messenger =\n options.messenger ??\n new Messenger({\n namespace: 'Root',\n });\n\n this.#instances = initialize({\n ...options,\n messenger: this.#messenger,\n });\n\n this.#controllerMetadata = Object.fromEntries(\n Object.entries(this.#instances)\n .filter(([_, instance]) => hasProperty(instance, 'metadata'))\n .map(([name, instance]) => [name, instance.metadata]),\n );\n }\n\n /**\n * @returns The root messenger of the wallet.\n */\n get messenger(): Readonly<RootMessenger<DefaultActions, DefaultEvents>> {\n return this.#messenger;\n }\n\n set messenger(_) {\n throw new Error('The messenger cannot be directly mutated.');\n }\n\n /**\n * @returns The combined state of the wallet.\n */\n get state(): DefaultState {\n return Object.entries(this.#instances).reduce<Record<string, unknown>>(\n (totalState, [name, instance]) => {\n if (instance.state) {\n totalState[name] = instance.state;\n }\n return totalState;\n },\n {},\n ) as DefaultState;\n }\n\n set state(_) {\n throw new Error('Wallet state cannot be directly mutated.');\n }\n\n /**\n * @returns The controller metadata; containing per-controller information about what properties to persist etc.\n */\n get controllerMetadata(): Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n > {\n return this.#controllerMetadata;\n }\n\n set controllerMetadata(_) {\n throw new Error('The controller metadata cannot be directly mutated.');\n }\n\n getInstance<Name extends keyof DefaultInstances>(\n name: Name,\n ): DefaultInstances[Name];\n\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined;\n\n /**\n * Get an instantiated controller or service.\n *\n * @param name - The name.\n * @returns The instance, if it exists.\n * @deprecated - Please use the messenger instead of direct access.\n */\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined {\n return this.#instances[name as keyof DefaultInstances];\n }\n\n /**\n * Destroy the wallet instance.\n */\n async destroy(): Promise<void> {\n if (this.#isDestroyed) {\n return;\n }\n\n this.#isDestroyed = true;\n\n await Promise.allSettled(\n Object.values(this.#instances).map(async (instance) => {\n // @ts-expect-error Accessing protected property.\n if (typeof instance.destroy === 'function') {\n // @ts-expect-error Accessing protected property.\n // eslint-disable-next-line @typescript-eslint/await-thenable\n return await instance.destroy();\n }\n /* istanbul ignore next */\n return undefined;\n }),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"Wallet.cjs","sourceRoot":"","sources":["../src/Wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mDAAgD;AAChD,2CAA8C;AAS9C,wEAA6D;AAG7D,MAAa,MAAM;IAYjB;;;;;;;;;;OAUG;IACH,YAAY,OAAsB;QAtBlC,oEAAoE;QAC3D,oCAAyD;QAEzD,oCAA6B;QAE7B,6CAEP;QAEF,8BAAe,KAAK,EAAC;QAcnB,uBAAA,IAAI,qBACF,OAAO,CAAC,SAAS;YACjB,IAAI,qBAAS,CAAC;gBACZ,SAAS,EAAE,MAAM;aAClB,CAAC,MAAA,CAAC;QAEL,uBAAA,IAAI,qBAAc,IAAA,2BAAU,EAAC;YAC3B,GAAG,OAAO;YACV,SAAS,EAAE,uBAAA,IAAI,yBAAW;SAC3B,CAAC,MAAA,CAAC;QAEH,uBAAA,IAAI,8BAAuB,MAAM,CAAC,WAAW,CAC3C,MAAM,CAAC,OAAO,CAAC,uBAAA,IAAI,yBAAW,CAAC;aAC5B,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAA,mBAAW,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;aAC5D,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;YACzB,IAAI;YACH,QAAkD,CAAC,QAAQ;SAC7D,CAAC,CACL,MAAA,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,uBAAA,IAAI,yBAAW,CAAC;IACzB,CAAC;IAED,IAAI,SAAS,CAAC,CA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iD;gBACjD,OAAO,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;YAClC,CAAC;YACD,0BAA0B;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AArID,wBAqIC","sourcesContent":["import type { StateMetadataConstraint } from '@metamask/base-controller';\nimport { Messenger } from '@metamask/messenger';\nimport { hasProperty } from '@metamask/utils';\n\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n DefaultState,\n RootMessenger,\n} from './initialization/defaults';\nimport { initialize } from './initialization/initialization';\nimport { WalletOptions } from './types';\n\nexport class Wallet {\n // TODO: Expand default types when passing additionalConfigurations.\n readonly #messenger: RootMessenger<DefaultActions, DefaultEvents>;\n\n readonly #instances: DefaultInstances;\n\n readonly #controllerMetadata: Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n >;\n\n #isDestroyed = false;\n\n /**\n * Creates a `Wallet` instance, initializing all instances as specified by the passed options.\n *\n * @param options - Options bag.\n * @param options.messenger - An optional messenger to override the default one.\n * @param options.state - An optional state blob.\n * @param options.initializationConfigurations - An optional list of additional initialization configurations\n * required beyond the ones included by default.\n * @param options.instanceOptions - An optional object containing options that should be passed\n * to specific instances for additional customization.\n */\n constructor(options: WalletOptions) {\n this.#messenger =\n options.messenger ??\n new Messenger({\n namespace: 'Root',\n });\n\n this.#instances = initialize({\n ...options,\n messenger: this.#messenger,\n });\n\n this.#controllerMetadata = Object.fromEntries(\n Object.entries(this.#instances)\n .filter(([_, instance]) => hasProperty(instance, 'metadata'))\n .map(([name, instance]) => [\n name,\n (instance as { metadata: StateMetadataConstraint }).metadata,\n ]),\n );\n }\n\n /**\n * @returns The root messenger of the wallet.\n */\n get messenger(): Readonly<RootMessenger<DefaultActions, DefaultEvents>> {\n return this.#messenger;\n }\n\n set messenger(_) {\n throw new Error('The messenger cannot be directly mutated.');\n }\n\n /**\n * @returns The combined state of the wallet.\n */\n get state(): DefaultState {\n return Object.entries(this.#instances).reduce<Record<string, unknown>>(\n (totalState, [name, instance]) => {\n // We do actually want to check the prototype here.\n // eslint-disable-next-line no-restricted-syntax\n if ('state' in instance && instance.state) {\n totalState[name] = instance.state;\n }\n return totalState;\n },\n {},\n ) as DefaultState;\n }\n\n set state(_) {\n throw new Error('Wallet state cannot be directly mutated.');\n }\n\n /**\n * @returns The controller metadata; containing per-controller information about what properties to persist etc.\n */\n get controllerMetadata(): Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n > {\n return this.#controllerMetadata;\n }\n\n set controllerMetadata(_) {\n throw new Error('The controller metadata cannot be directly mutated.');\n }\n\n getInstance<Name extends keyof DefaultInstances>(\n name: Name,\n ): DefaultInstances[Name];\n\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined;\n\n /**\n * Get an instantiated controller or service.\n *\n * @param name - The name.\n * @returns The instance, if it exists.\n * @deprecated - Please use the messenger instead of direct access.\n */\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined {\n return this.#instances[name as keyof DefaultInstances];\n }\n\n /**\n * Destroy the wallet instance.\n */\n async destroy(): Promise<void> {\n if (this.#isDestroyed) {\n return;\n }\n\n this.#isDestroyed = true;\n\n await Promise.allSettled(\n Object.values(this.#instances).map(async (instance) => {\n // @ts-expect-error Accessing protected property.\n if (typeof instance.destroy === 'function') {\n // @ts-expect-error Accessing protected property.\n return await instance.destroy();\n }\n /* istanbul ignore next */\n return undefined;\n }),\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Wallet.d.cts","sourceRoot":"","sources":["../src/Wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,kCAAkC;AAIzE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACd,sCAAkC;AAEnC,OAAO,EAAE,aAAa,EAAE,oBAAgB;AAExC,qBAAa,MAAM;;IAYjB;;;;;;;;;;OAUG;gB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ChC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAClD,CAEA;IAED,IAAI,kBAAkB,CAAC,CAAC,EANE,QAAQ,CAChC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAK3B,EAEvB;IAED,WAAW,CAAC,IAAI,SAAS,MAAM,gBAAgB,EAC7C,IAAI,EAAE,IAAI,GACT,gBAAgB,CAAC,IAAI,CAAC;IAEzB,WAAW,CACT,IAAI,EAAE,MAAM,GACX,gBAAgB,CAAC,MAAM,gBAAgB,CAAC,GAAG,SAAS;IAevD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAmB/B"}
package/dist/Wallet.mjs CHANGED
@@ -41,7 +41,10 @@ export class Wallet {
41
41
  }), "f");
42
42
  __classPrivateFieldSet(this, _Wallet_controllerMetadata, Object.fromEntries(Object.entries(__classPrivateFieldGet(this, _Wallet_instances, "f"))
43
43
  .filter(([_, instance]) => hasProperty(instance, 'metadata'))
44
- .map(([name, instance]) => [name, instance.metadata])), "f");
44
+ .map(([name, instance]) => [
45
+ name,
46
+ instance.metadata,
47
+ ])), "f");
45
48
  }
46
49
  /**
47
50
  * @returns The root messenger of the wallet.
@@ -57,7 +60,9 @@ export class Wallet {
57
60
  */
58
61
  get state() {
59
62
  return Object.entries(__classPrivateFieldGet(this, _Wallet_instances, "f")).reduce((totalState, [name, instance]) => {
60
- if (instance.state) {
63
+ // We do actually want to check the prototype here.
64
+ // eslint-disable-next-line no-restricted-syntax
65
+ if ('state' in instance && instance.state) {
61
66
  totalState[name] = instance.state;
62
67
  }
63
68
  return totalState;
@@ -97,7 +102,6 @@ export class Wallet {
97
102
  // @ts-expect-error Accessing protected property.
98
103
  if (typeof instance.destroy === 'function') {
99
104
  // @ts-expect-error Accessing protected property.
100
- // eslint-disable-next-line @typescript-eslint/await-thenable
101
105
  return await instance.destroy();
102
106
  }
103
107
  /* istanbul ignore next */
@@ -1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';\nimport { Messenger } from '@metamask/messenger';\nimport { hasProperty } from '@metamask/utils';\n\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n DefaultState,\n RootMessenger,\n} from './initialization/defaults';\nimport { initialize } from './initialization/initialization';\nimport { WalletOptions } from './types';\n\nexport class Wallet {\n // TODO: Expand default types when passing additionalConfigurations.\n readonly #messenger: RootMessenger<DefaultActions, DefaultEvents>;\n\n readonly #instances: DefaultInstances;\n\n readonly #controllerMetadata: Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n >;\n\n #isDestroyed = false;\n\n /**\n * Creates a `Wallet` instance, initializing all instances as specified by the passed options.\n *\n * @param options - Options bag.\n * @param options.messenger - An optional messenger to override the default one.\n * @param options.state - An optional state blob.\n * @param options.initializationConfigurations - An optional list of additional initialization configurations\n * required beyond the ones included by default.\n * @param options.instanceOptions - An optional object containing options that should be passed\n * to specific instances for additional customization.\n */\n constructor(options: WalletOptions) {\n this.#messenger =\n options.messenger ??\n new Messenger({\n namespace: 'Root',\n });\n\n this.#instances = initialize({\n ...options,\n messenger: this.#messenger,\n });\n\n this.#controllerMetadata = Object.fromEntries(\n Object.entries(this.#instances)\n .filter(([_, instance]) => hasProperty(instance, 'metadata'))\n .map(([name, instance]) => [name, instance.metadata]),\n );\n }\n\n /**\n * @returns The root messenger of the wallet.\n */\n get messenger(): Readonly<RootMessenger<DefaultActions, DefaultEvents>> {\n return this.#messenger;\n }\n\n set messenger(_) {\n throw new Error('The messenger cannot be directly mutated.');\n }\n\n /**\n * @returns The combined state of the wallet.\n */\n get state(): DefaultState {\n return Object.entries(this.#instances).reduce<Record<string, unknown>>(\n (totalState, [name, instance]) => {\n if (instance.state) {\n totalState[name] = instance.state;\n }\n return totalState;\n },\n {},\n ) as DefaultState;\n }\n\n set state(_) {\n throw new Error('Wallet state cannot be directly mutated.');\n }\n\n /**\n * @returns The controller metadata; containing per-controller information about what properties to persist etc.\n */\n get controllerMetadata(): Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n > {\n return this.#controllerMetadata;\n }\n\n set controllerMetadata(_) {\n throw new Error('The controller metadata cannot be directly mutated.');\n }\n\n getInstance<Name extends keyof DefaultInstances>(\n name: Name,\n ): DefaultInstances[Name];\n\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined;\n\n /**\n * Get an instantiated controller or service.\n *\n * @param name - The name.\n * @returns The instance, if it exists.\n * @deprecated - Please use the messenger instead of direct access.\n */\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined {\n return this.#instances[name as keyof DefaultInstances];\n }\n\n /**\n * Destroy the wallet instance.\n */\n async destroy(): Promise<void> {\n if (this.#isDestroyed) {\n return;\n }\n\n this.#isDestroyed = true;\n\n await Promise.allSettled(\n Object.values(this.#instances).map(async (instance) => {\n // @ts-expect-error Accessing protected property.\n if (typeof instance.destroy === 'function') {\n // @ts-expect-error Accessing protected property.\n // eslint-disable-next-line @typescript-eslint/await-thenable\n return await instance.destroy();\n }\n /* istanbul ignore next */\n return undefined;\n }),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"Wallet.mjs","sourceRoot":"","sources":["../src/Wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAChD,OAAO,EAAE,WAAW,EAAE,wBAAwB;AAS9C,OAAO,EAAE,UAAU,EAAE,4CAAwC;AAG7D,MAAM,OAAO,MAAM;IAYjB;;;;;;;;;;OAUG;IACH,YAAY,OAAsB;QAtBlC,oEAAoE;QAC3D,oCAAyD;QAEzD,oCAA6B;QAE7B,6CAEP;QAEF,8BAAe,KAAK,EAAC;QAcnB,uBAAA,IAAI,qBACF,OAAO,CAAC,SAAS;YACjB,IAAI,SAAS,CAAC;gBACZ,SAAS,EAAE,MAAM;aAClB,CAAC,MAAA,CAAC;QAEL,uBAAA,IAAI,qBAAc,UAAU,CAAC;YAC3B,GAAG,OAAO;YACV,SAAS,EAAE,uBAAA,IAAI,yBAAW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AAC,CAAC;IACzE,CAAC;IAUD;;;;;;OAMG;IACH,WAAW,CACT,IAAY;QAEZ,OAAO,uBAAA,IAAI,yBAAW,CAAC,IAA8B,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,uBAAA,IAAI,2BAAa,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,uBAAA,IAAI,uBAAgB,IAAI,MAAA,CAAC;QAEzB,MAAM,OAAO,CAAC,UAAU,CACtB,MAAM,CAAC,MAAM,CAAC,uBAAA,IAAI,yBAAW,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YACpD,iDAAiD;YACjD,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3C,iDAAiD;gBACjD,OAAO,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;YAClC,CAAC;YACD,0BAA0B;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { StateMetadataConstraint } from '@metamask/base-controller';\nimport { Messenger } from '@metamask/messenger';\nimport { hasProperty } from '@metamask/utils';\n\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n DefaultState,\n RootMessenger,\n} from './initialization/defaults';\nimport { initialize } from './initialization/initialization';\nimport { WalletOptions } from './types';\n\nexport class Wallet {\n // TODO: Expand default types when passing additionalConfigurations.\n readonly #messenger: RootMessenger<DefaultActions, DefaultEvents>;\n\n readonly #instances: DefaultInstances;\n\n readonly #controllerMetadata: Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n >;\n\n #isDestroyed = false;\n\n /**\n * Creates a `Wallet` instance, initializing all instances as specified by the passed options.\n *\n * @param options - Options bag.\n * @param options.messenger - An optional messenger to override the default one.\n * @param options.state - An optional state blob.\n * @param options.initializationConfigurations - An optional list of additional initialization configurations\n * required beyond the ones included by default.\n * @param options.instanceOptions - An optional object containing options that should be passed\n * to specific instances for additional customization.\n */\n constructor(options: WalletOptions) {\n this.#messenger =\n options.messenger ??\n new Messenger({\n namespace: 'Root',\n });\n\n this.#instances = initialize({\n ...options,\n messenger: this.#messenger,\n });\n\n this.#controllerMetadata = Object.fromEntries(\n Object.entries(this.#instances)\n .filter(([_, instance]) => hasProperty(instance, 'metadata'))\n .map(([name, instance]) => [\n name,\n (instance as { metadata: StateMetadataConstraint }).metadata,\n ]),\n );\n }\n\n /**\n * @returns The root messenger of the wallet.\n */\n get messenger(): Readonly<RootMessenger<DefaultActions, DefaultEvents>> {\n return this.#messenger;\n }\n\n set messenger(_) {\n throw new Error('The messenger cannot be directly mutated.');\n }\n\n /**\n * @returns The combined state of the wallet.\n */\n get state(): DefaultState {\n return Object.entries(this.#instances).reduce<Record<string, unknown>>(\n (totalState, [name, instance]) => {\n // We do actually want to check the prototype here.\n // eslint-disable-next-line no-restricted-syntax\n if ('state' in instance && instance.state) {\n totalState[name] = instance.state;\n }\n return totalState;\n },\n {},\n ) as DefaultState;\n }\n\n set state(_) {\n throw new Error('Wallet state cannot be directly mutated.');\n }\n\n /**\n * @returns The controller metadata; containing per-controller information about what properties to persist etc.\n */\n get controllerMetadata(): Readonly<\n Record<string, Readonly<StateMetadataConstraint>>\n > {\n return this.#controllerMetadata;\n }\n\n set controllerMetadata(_) {\n throw new Error('The controller metadata cannot be directly mutated.');\n }\n\n getInstance<Name extends keyof DefaultInstances>(\n name: Name,\n ): DefaultInstances[Name];\n\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined;\n\n /**\n * Get an instantiated controller or service.\n *\n * @param name - The name.\n * @returns The instance, if it exists.\n * @deprecated - Please use the messenger instead of direct access.\n */\n getInstance(\n name: string,\n ): DefaultInstances[keyof DefaultInstances] | undefined {\n return this.#instances[name as keyof DefaultInstances];\n }\n\n /**\n * Destroy the wallet instance.\n */\n async destroy(): Promise<void> {\n if (this.#isDestroyed) {\n return;\n }\n\n this.#isDestroyed = true;\n\n await Promise.allSettled(\n Object.values(this.#instances).map(async (instance) => {\n // @ts-expect-error Accessing protected property.\n if (typeof instance.destroy === 'function') {\n // @ts-expect-error Accessing protected property.\n return await instance.destroy();\n }\n /* istanbul ignore next */\n return undefined;\n }),\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.cjs","sourceRoot":"","sources":["../../src/initialization/defaults.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,6EAAqD;AAG5C,sDAAqB","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n Messenger,\n MessengerActions,\n MessengerEvents,\n} from '@metamask/messenger';\n\nimport * as defaultConfigurations from './instances';\nimport type { InitializationConfiguration, InstanceState } from './types';\n\nexport { defaultConfigurations };\n\n/**\n * Utility type for inferring and extracting an instance type from an initialization configuration.\n */\ntype ExtractInstance<Config> =\n Config extends InitializationConfiguration<infer Instance, unknown>\n ? Instance\n : never;\n\n/**\n * Utility type for inferring and extracting an instance messenger type from an initialization configuration.\n */\ntype ExtractInstanceMessenger<Config> =\n Config extends InitializationConfiguration<unknown, infer InferredMessenger>\n ? InferredMessenger\n : never;\n\n/**\n * Utility type for inferring and extracting the name of an instance from an initialization configuration.\n */\ntype ExtractName<Config> =\n ExtractInstance<Config> extends { name: infer Name extends string }\n ? Name\n : never;\n\ntype DefaultConfigs = typeof defaultConfigurations;\n\ntype AllDefaultMessengers = ExtractInstanceMessenger<\n DefaultConfigs[keyof DefaultConfigs]\n>;\n\nexport type DefaultInstances = {\n [Key in keyof DefaultConfigs as ExtractName<\n DefaultConfigs[Key]\n >]: ExtractInstance<DefaultConfigs[Key]>;\n};\n\nexport type DefaultActions = MessengerActions<AllDefaultMessengers>;\n\nexport type DefaultEvents = MessengerEvents<AllDefaultMessengers>;\n\nexport type RootMessenger<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n> = Messenger<'Root', AllowedActions, AllowedEvents>;\n\nexport type DefaultState = {\n [Key in keyof DefaultInstances]: InstanceState<DefaultInstances[Key]>;\n};\n"]}
1
+ {"version":3,"file":"defaults.cjs","sourceRoot":"","sources":["../../src/initialization/defaults.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,6EAAqD;AAG5C,sDAAqB","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n Messenger,\n MessengerActions,\n MessengerEvents,\n} from '@metamask/messenger';\n\nimport * as defaultConfigurations from './instances';\nimport type { InitializationConfiguration, InstanceState } from './types';\n\nexport { defaultConfigurations };\n\n/**\n * Utility type for inferring and extracting an instance type from an initialization configuration.\n */\ntype ExtractInstance<Config> =\n Config extends InitializationConfiguration<\n infer Instance,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n infer _Messenger\n >\n ? Instance\n : never;\n\n/**\n * Utility type for inferring and extracting an instance messenger type from an initialization configuration.\n */\ntype ExtractInstanceMessenger<Config> =\n Config extends InitializationConfiguration<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n infer _Instance,\n infer InferredMessenger\n >\n ? InferredMessenger\n : never;\n\n/**\n * Utility type for inferring and extracting the name of an instance from an initialization configuration.\n */\ntype ExtractName<Config> =\n ExtractInstance<Config> extends { name: infer Name extends string }\n ? Name\n : never;\n\ntype DefaultConfigs = typeof defaultConfigurations;\n\ntype AllDefaultMessengers = ExtractInstanceMessenger<\n DefaultConfigs[keyof DefaultConfigs]\n>;\n\nexport type DefaultInstances = {\n [Key in keyof DefaultConfigs as ExtractName<\n DefaultConfigs[Key]\n >]: ExtractInstance<DefaultConfigs[Key]>;\n};\n\nexport type DefaultActions = MessengerActions<AllDefaultMessengers>;\n\nexport type DefaultEvents = MessengerEvents<AllDefaultMessengers>;\n\nexport type RootMessenger<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n> = Messenger<'Root', AllowedActions, AllowedEvents>;\n\nexport type DefaultState = {\n [Key in keyof DefaultInstances]: InstanceState<DefaultInstances[Key]>;\n};\n"]}
@@ -5,11 +5,11 @@ export { defaultConfigurations };
5
5
  /**
6
6
  * Utility type for inferring and extracting an instance type from an initialization configuration.
7
7
  */
8
- type ExtractInstance<Config> = Config extends InitializationConfiguration<infer Instance, unknown> ? Instance : never;
8
+ type ExtractInstance<Config> = Config extends InitializationConfiguration<infer Instance, infer _Messenger> ? Instance : never;
9
9
  /**
10
10
  * Utility type for inferring and extracting an instance messenger type from an initialization configuration.
11
11
  */
12
- type ExtractInstanceMessenger<Config> = Config extends InitializationConfiguration<unknown, infer InferredMessenger> ? InferredMessenger : never;
12
+ type ExtractInstanceMessenger<Config> = Config extends InitializationConfiguration<infer _Instance, infer InferredMessenger> ? InferredMessenger : never;
13
13
  /**
14
14
  * Utility type for inferring and extracting the name of an instance from an initialization configuration.
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.cts","sourceRoot":"","sources":["../../src/initialization/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,4BAA4B;AAE7B,OAAO,KAAK,qBAAqB,8BAAoB;AACrD,OAAO,KAAK,EAAE,2BAA2B,EAAE,aAAa,EAAE,oBAAgB;AAE1E,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC;;GAEG;AACH,KAAK,eAAe,CAAC,MAAM,IACzB,MAAM,SAAS,2BAA2B,CAAC,MAAM,QAAQ,EAAE,OAAO,CAAC,GAC/D,QAAQ,GACR,KAAK,CAAC;AAEZ;;GAEG;AACH,KAAK,wBAAwB,CAAC,MAAM,IAClC,MAAM,SAAS,2BAA2B,CAAC,OAAO,EAAE,MAAM,iBAAiB,CAAC,GACxE,iBAAiB,GACjB,KAAK,CAAC;AAEZ;;GAEG;AACH,KAAK,WAAW,CAAC,MAAM,IACrB,eAAe,CAAC,MAAM,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,IAAI,SAAS,MAAM,CAAA;CAAE,GAC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BAA2B,CAExC,MAAM,SAAS,EACf,MAAM,iBAAiB,CACxB,GACG,iBAAiB,GACjB,KAAK,CAAC;AAEZ;;GAEG;AACH,KAAK,WAAW,CAAC,MAAM,IACrB,eAAe,CAAC,MAAM,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,IAAI,SAAS,MAAM,CAAA;CAAE,GAC/D,IAAI,GACJ,KAAK,CAAC;AAEZ,KAAK,cAAc,GAAG,OAAO,qBAAqB,CAAC;AAEnD,KAAK,oBAAoB,GAAG,wBAAwB,CAClD,cAAc,CAAC,MAAM,cAAc,CAAC,CACrC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;KAC5B,GAAG,IAAI,MAAM,cAAc,IAAI,WAAW,CACzC,cAAc,CAAC,GAAG,CAAC,CACpB,GAAG,eAAe,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AAEpE,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,aAAa,CACvB,cAAc,SAAS,gBAAgB,EACvC,aAAa,SAAS,eAAe,IACnC,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG;KACxB,GAAG,IAAI,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;CACtE,CAAC"}
@@ -5,11 +5,11 @@ export { defaultConfigurations };
5
5
  /**
6
6
  * Utility type for inferring and extracting an instance type from an initialization configuration.
7
7
  */
8
- type ExtractInstance<Config> = Config extends InitializationConfiguration<infer Instance, unknown> ? Instance : never;
8
+ type ExtractInstance<Config> = Config extends InitializationConfiguration<infer Instance, infer _Messenger> ? Instance : never;
9
9
  /**
10
10
  * Utility type for inferring and extracting an instance messenger type from an initialization configuration.
11
11
  */
12
- type ExtractInstanceMessenger<Config> = Config extends InitializationConfiguration<unknown, infer InferredMessenger> ? InferredMessenger : never;
12
+ type ExtractInstanceMessenger<Config> = Config extends InitializationConfiguration<infer _Instance, infer InferredMessenger> ? InferredMessenger : never;
13
13
  /**
14
14
  * Utility type for inferring and extracting the name of an instance from an initialization configuration.
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.mts","sourceRoot":"","sources":["../../src/initialization/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,eAAe,EAChB,4BAA4B;AAE7B,OAAO,KAAK,qBAAqB,8BAAoB;AACrD,OAAO,KAAK,EAAE,2BAA2B,EAAE,aAAa,EAAE,oBAAgB;AAE1E,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC;;GAEG;AACH,KAAK,eAAe,CAAC,MAAM,IACzB,MAAM,SAAS,2BAA2B,CAAC,MAAM,QAAQ,EAAE,OAAO,CAAC,GAC/D,QAAQ,GACR,KAAK,CAAC;AAEZ;;GAEG;AACH,KAAK,wBAAwB,CAAC,MAAM,IAClC,MAAM,SAAS,2BAA2B,CAAC,OAAO,EAAE,MAAM,iBAAiB,CAAC,GACxE,iBAAiB,GACjB,KAAK,CAAC;AAEZ;;GAEG;AACH,KAAK,WAAW,CAAC,MAAM,IACrB,eAAe,CAAC,MAAM,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,IAAI,SAAS,MAAM,CAAA;CAAE,GAC/D,IAAI,GACJ,KAAK,CAAC;AAEZ,KAAK,cAAc,GAAG,OAAO,qBAAqB,CAAC;AAEnD,KAAK,oBAAoB,GAAG,wBAAwB,CAClD,cAAc,CAAC,MAAM,cAAc,CAAC,CACrC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;KAC5B,GAAG,IAAI,MAAM,cAAc,IAAI,WAAW,CACzC,cAAc,CAAC,GAAG,CAAC,CACpB,GAAG,eAAe,CAAC,cAAc,CAAC,G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AAK,oBAAoB,GAAG,wBAAwB,CAClD,cAAc,CAAC,MAAM,cAAc,CAAC,CACrC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;KAC5B,GAAG,IAAI,MAAM,cAAc,IAAI,WAAW,CACzC,cAAc,CAAC,GAAG,CAAC,CACpB,GAAG,eAAe,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AAEpE,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,aAAa,CACvB,cAAc,SAAS,gBAAgB,EACvC,aAAa,SAAS,eAAe,IACnC,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG;KACxB,GAAG,IAAI,MAAM,gBAAgB,GAAG,aAAa,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;CACtE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.mjs","sourceRoot":"","sources":["../../src/initialization/defaults.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,qBAAqB,8BAAoB;AAGrD,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n Messenger,\n MessengerActions,\n MessengerEvents,\n} from '@metamask/messenger';\n\nimport * as defaultConfigurations from './instances';\nimport type { InitializationConfiguration, InstanceState } from './types';\n\nexport { defaultConfigurations };\n\n/**\n * Utility type for inferring and extracting an instance type from an initialization configuration.\n */\ntype ExtractInstance<Config> =\n Config extends InitializationConfiguration<infer Instance, unknown>\n ? Instance\n : never;\n\n/**\n * Utility type for inferring and extracting an instance messenger type from an initialization configuration.\n */\ntype ExtractInstanceMessenger<Config> =\n Config extends InitializationConfiguration<unknown, infer InferredMessenger>\n ? InferredMessenger\n : never;\n\n/**\n * Utility type for inferring and extracting the name of an instance from an initialization configuration.\n */\ntype ExtractName<Config> =\n ExtractInstance<Config> extends { name: infer Name extends string }\n ? Name\n : never;\n\ntype DefaultConfigs = typeof defaultConfigurations;\n\ntype AllDefaultMessengers = ExtractInstanceMessenger<\n DefaultConfigs[keyof DefaultConfigs]\n>;\n\nexport type DefaultInstances = {\n [Key in keyof DefaultConfigs as ExtractName<\n DefaultConfigs[Key]\n >]: ExtractInstance<DefaultConfigs[Key]>;\n};\n\nexport type DefaultActions = MessengerActions<AllDefaultMessengers>;\n\nexport type DefaultEvents = MessengerEvents<AllDefaultMessengers>;\n\nexport type RootMessenger<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n> = Messenger<'Root', AllowedActions, AllowedEvents>;\n\nexport type DefaultState = {\n [Key in keyof DefaultInstances]: InstanceState<DefaultInstances[Key]>;\n};\n"]}
1
+ {"version":3,"file":"defaults.mjs","sourceRoot":"","sources":["../../src/initialization/defaults.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,qBAAqB,8BAAoB;AAGrD,OAAO,EAAE,qBAAqB,EAAE,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n Messenger,\n MessengerActions,\n MessengerEvents,\n} from '@metamask/messenger';\n\nimport * as defaultConfigurations from './instances';\nimport type { InitializationConfiguration, InstanceState } from './types';\n\nexport { defaultConfigurations };\n\n/**\n * Utility type for inferring and extracting an instance type from an initialization configuration.\n */\ntype ExtractInstance<Config> =\n Config extends InitializationConfiguration<\n infer Instance,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n infer _Messenger\n >\n ? Instance\n : never;\n\n/**\n * Utility type for inferring and extracting an instance messenger type from an initialization configuration.\n */\ntype ExtractInstanceMessenger<Config> =\n Config extends InitializationConfiguration<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n infer _Instance,\n infer InferredMessenger\n >\n ? InferredMessenger\n : never;\n\n/**\n * Utility type for inferring and extracting the name of an instance from an initialization configuration.\n */\ntype ExtractName<Config> =\n ExtractInstance<Config> extends { name: infer Name extends string }\n ? Name\n : never;\n\ntype DefaultConfigs = typeof defaultConfigurations;\n\ntype AllDefaultMessengers = ExtractInstanceMessenger<\n DefaultConfigs[keyof DefaultConfigs]\n>;\n\nexport type DefaultInstances = {\n [Key in keyof DefaultConfigs as ExtractName<\n DefaultConfigs[Key]\n >]: ExtractInstance<DefaultConfigs[Key]>;\n};\n\nexport type DefaultActions = MessengerActions<AllDefaultMessengers>;\n\nexport type DefaultEvents = MessengerEvents<AllDefaultMessengers>;\n\nexport type RootMessenger<\n AllowedActions extends ActionConstraint,\n AllowedEvents extends EventConstraint,\n> = Messenger<'Root', AllowedActions, AllowedEvents>;\n\nexport type DefaultState = {\n [Key in keyof DefaultInstances]: InstanceState<DefaultInstances[Key]>;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initialization.cjs","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":";;;AAMA,6CAAkE;AAMlE;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAA0B;IACnD,MAAM,EACJ,SAAS,EACT,KAAK,GAAG,EAAE,EACV,4BAA4B,GAAG,EAAE,EACjC,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,uBAAuB,GAAG,4BAA4B,CAAC,GAAG,CAC9D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CACxB,CAAC;IAEF,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,MAAM,CAC9D,MAAM,CAAC,MAAM,CAAC,gCAAqB,CAAC,CAAC,MAAM,CACzC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAC3D,CACF,CAAC;IAEF,MAAM,SAAS,GAA4B,EAAE,CAAC;IAE9C,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QAExB,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEzD,MAAM,aAAa,GACjB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAmC,CAAC;QAErF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC3B,8CAA8C;YAC9C,KAAK,EAAE,aAAsB;YAC7B,SAAS,EAAE,iBAAiB;YAC5B,OAAO,EAAE,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE;SAChD,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,GAAG,QAAmC,CAAC;IACxD,CAAC;IAED,OAAO,SAA6B,CAAC;AACvC,CAAC;AAzCD,gCAyCC","sourcesContent":["import type { InstanceSpecificOptions, WalletOptions } from '../types';\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n} from './defaults';\nimport { defaultConfigurations, RootMessenger } from './defaults';\n\ntype InitializeOptions = WalletOptions & {\n messenger: RootMessenger<DefaultActions, DefaultEvents>;\n};\n\n/**\n * Initialize all instances based on th default configurations and any additional configurations specified in `options`.\n *\n * @param options - The wallet options.\n * @returns A map containing the instances.\n */\nexport function initialize(options: InitializeOptions): DefaultInstances {\n const {\n messenger,\n state = {},\n initializationConfigurations = [],\n instanceOptions,\n } = options;\n\n const overriddenConfiguration = initializationConfigurations.map(\n (config) => config.name,\n );\n\n const configurationEntries = initializationConfigurations.concat(\n Object.values(defaultConfigurations).filter(\n (config) => !overriddenConfiguration.includes(config.name),\n ),\n );\n\n const instances: Record<string, unknown> = {};\n\n for (const config of configurationEntries) {\n const { name } = config;\n\n const instanceState = state[name];\n\n const instanceMessenger = config.getMessenger(messenger);\n\n const camelCaseName =\n `${name.charAt(0).toLowerCase()}${name.slice(1)}` as keyof InstanceSpecificOptions;\n\n const instance = config.init({\n // TODO: Consider whether this can be improved\n state: instanceState as never,\n messenger: instanceMessenger,\n options: instanceOptions?.[camelCaseName] ?? {},\n });\n\n instances[name] = instance as Record<string, unknown>;\n }\n\n return instances as DefaultInstances;\n}\n"]}
1
+ {"version":3,"file":"initialization.cjs","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":";;;AAMA,6CAAkE;AAOlE;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAA0B;IACnD,MAAM,EACJ,SAAS,EACT,KAAK,GAAG,EAAE,EACV,4BAA4B,GAAG,EAAE,EACjC,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,uBAAuB,GAAG,4BAA4B,CAAC,GAAG,CAC9D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CACxB,CAAC;IAEF,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,MAAM,CAC9D,MAAM,CAAC,MAAM,CAAC,gCAAqB,CAAC,CAAC,MAAM,CACzC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CACR,CACrD,CAAC;IAEF,MAAM,SAAS,GAA4B,EAAE,CAAC;IAE9C,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QAExB,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEzD,MAAM,aAAa,GACjB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAmC,CAAC;QAErF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC3B,8CAA8C;YAC9C,KAAK,EAAE,aAAsB;YAC7B,SAAS,EAAE,iBAAiB;YAC5B,OAAO,EAAE,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE;SAChD,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,OAAO,SAA6B,CAAC;AACvC,CAAC;AAzCD,gCAyCC","sourcesContent":["import type { InstanceSpecificOptions, WalletOptions } from '../types';\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n} from './defaults';\nimport { defaultConfigurations, RootMessenger } from './defaults';\nimport { InitializationConfiguration } from './types';\n\ntype InitializeOptions = WalletOptions & {\n messenger: RootMessenger<DefaultActions, DefaultEvents>;\n};\n\n/**\n * Initialize all instances based on th default configurations and any additional configurations specified in `options`.\n *\n * @param options - The wallet options.\n * @returns A map containing the instances.\n */\nexport function initialize(options: InitializeOptions): DefaultInstances {\n const {\n messenger,\n state = {},\n initializationConfigurations = [],\n instanceOptions,\n } = options;\n\n const overriddenConfiguration = initializationConfigurations.map(\n (config) => config.name,\n );\n\n const configurationEntries = initializationConfigurations.concat(\n Object.values(defaultConfigurations).filter(\n (config) => !overriddenConfiguration.includes(config.name),\n ) as InitializationConfiguration<unknown, unknown>[],\n );\n\n const instances: Record<string, unknown> = {};\n\n for (const config of configurationEntries) {\n const { name } = config;\n\n const instanceState = state[name];\n\n const instanceMessenger = config.getMessenger(messenger);\n\n const camelCaseName =\n `${name.charAt(0).toLowerCase()}${name.slice(1)}` as keyof InstanceSpecificOptions;\n\n const instance = config.init({\n // TODO: Consider whether this can be improved\n state: instanceState as never,\n messenger: instanceMessenger,\n options: instanceOptions?.[camelCaseName] ?? {},\n });\n\n instances[name] = instance;\n }\n\n return instances as DefaultInstances;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initialization.d.cts","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,aAAa,EAAE,qBAAiB;AACvE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,uBAAmB;AACpB,OAAO,EAAyB,aAAa,EAAE,uBAAmB;AAElE,KAAK,iBAAiB,GAAG,aAAa,GAAG;IACvC,SAAS,EAAE,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyCvE"}
1
+ {"version":3,"file":"initialization.d.cts","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,aAAa,EAAE,qBAAiB;AACvE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,uBAAmB;AACpB,OAAO,EAAyB,aAAa,EAAE,uBAAmB;AAGlE,KAAK,iBAAiB,GAAG,aAAa,GAAG;IACvC,SAAS,EAAE,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyCvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"initialization.d.mts","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,aAAa,EAAE,qBAAiB;AACvE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,uBAAmB;AACpB,OAAO,EAAyB,aAAa,EAAE,uBAAmB;AAElE,KAAK,iBAAiB,GAAG,aAAa,GAAG;IACvC,SAAS,EAAE,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyCvE"}
1
+ {"version":3,"file":"initialization.d.mts","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,aAAa,EAAE,qBAAiB;AACvE,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,uBAAmB;AACpB,OAAO,EAAyB,aAAa,EAAE,uBAAmB;AAGlE,KAAK,iBAAiB,GAAG,aAAa,GAAG;IACvC,SAAS,EAAE,aAAa,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyCvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"initialization.mjs","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAiB,uBAAmB;AAMlE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,MAAM,EACJ,SAAS,EACT,KAAK,GAAG,EAAE,EACV,4BAA4B,GAAG,EAAE,EACjC,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,uBAAuB,GAAG,4BAA4B,CAAC,GAAG,CAC9D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CACxB,CAAC;IAEF,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,MAAM,CAC9D,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,MAAM,CACzC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAC3D,CACF,CAAC;IAEF,MAAM,SAAS,GAA4B,EAAE,CAAC;IAE9C,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QAExB,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEzD,MAAM,aAAa,GACjB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAmC,CAAC;QAErF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC3B,8CAA8C;YAC9C,KAAK,EAAE,aAAsB;YAC7B,SAAS,EAAE,iBAAiB;YAC5B,OAAO,EAAE,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE;SAChD,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,GAAG,QAAmC,CAAC;IACxD,CAAC;IAED,OAAO,SAA6B,CAAC;AACvC,CAAC","sourcesContent":["import type { InstanceSpecificOptions, WalletOptions } from '../types';\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n} from './defaults';\nimport { defaultConfigurations, RootMessenger } from './defaults';\n\ntype InitializeOptions = WalletOptions & {\n messenger: RootMessenger<DefaultActions, DefaultEvents>;\n};\n\n/**\n * Initialize all instances based on th default configurations and any additional configurations specified in `options`.\n *\n * @param options - The wallet options.\n * @returns A map containing the instances.\n */\nexport function initialize(options: InitializeOptions): DefaultInstances {\n const {\n messenger,\n state = {},\n initializationConfigurations = [],\n instanceOptions,\n } = options;\n\n const overriddenConfiguration = initializationConfigurations.map(\n (config) => config.name,\n );\n\n const configurationEntries = initializationConfigurations.concat(\n Object.values(defaultConfigurations).filter(\n (config) => !overriddenConfiguration.includes(config.name),\n ),\n );\n\n const instances: Record<string, unknown> = {};\n\n for (const config of configurationEntries) {\n const { name } = config;\n\n const instanceState = state[name];\n\n const instanceMessenger = config.getMessenger(messenger);\n\n const camelCaseName =\n `${name.charAt(0).toLowerCase()}${name.slice(1)}` as keyof InstanceSpecificOptions;\n\n const instance = config.init({\n // TODO: Consider whether this can be improved\n state: instanceState as never,\n messenger: instanceMessenger,\n options: instanceOptions?.[camelCaseName] ?? {},\n });\n\n instances[name] = instance as Record<string, unknown>;\n }\n\n return instances as DefaultInstances;\n}\n"]}
1
+ {"version":3,"file":"initialization.mjs","sourceRoot":"","sources":["../../src/initialization/initialization.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAiB,uBAAmB;AAOlE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,MAAM,EACJ,SAAS,EACT,KAAK,GAAG,EAAE,EACV,4BAA4B,GAAG,EAAE,EACjC,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,uBAAuB,GAAG,4BAA4B,CAAC,GAAG,CAC9D,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CACxB,CAAC;IAEF,MAAM,oBAAoB,GAAG,4BAA4B,CAAC,MAAM,CAC9D,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,MAAM,CACzC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CACR,CACrD,CAAC;IAEF,MAAM,SAAS,GAA4B,EAAE,CAAC;IAE9C,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QAExB,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEzD,MAAM,aAAa,GACjB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAmC,CAAC;QAErF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC3B,8CAA8C;YAC9C,KAAK,EAAE,aAAsB;YAC7B,SAAS,EAAE,iBAAiB;YAC5B,OAAO,EAAE,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE;SAChD,CAAC,CAAC;QAEH,SAAS,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,OAAO,SAA6B,CAAC;AACvC,CAAC","sourcesContent":["import type { InstanceSpecificOptions, WalletOptions } from '../types';\nimport type {\n DefaultActions,\n DefaultEvents,\n DefaultInstances,\n} from './defaults';\nimport { defaultConfigurations, RootMessenger } from './defaults';\nimport { InitializationConfiguration } from './types';\n\ntype InitializeOptions = WalletOptions & {\n messenger: RootMessenger<DefaultActions, DefaultEvents>;\n};\n\n/**\n * Initialize all instances based on th default configurations and any additional configurations specified in `options`.\n *\n * @param options - The wallet options.\n * @returns A map containing the instances.\n */\nexport function initialize(options: InitializeOptions): DefaultInstances {\n const {\n messenger,\n state = {},\n initializationConfigurations = [],\n instanceOptions,\n } = options;\n\n const overriddenConfiguration = initializationConfigurations.map(\n (config) => config.name,\n );\n\n const configurationEntries = initializationConfigurations.concat(\n Object.values(defaultConfigurations).filter(\n (config) => !overriddenConfiguration.includes(config.name),\n ) as InitializationConfiguration<unknown, unknown>[],\n );\n\n const instances: Record<string, unknown> = {};\n\n for (const config of configurationEntries) {\n const { name } = config;\n\n const instanceState = state[name];\n\n const instanceMessenger = config.getMessenger(messenger);\n\n const camelCaseName =\n `${name.charAt(0).toLowerCase()}${name.slice(1)}` as keyof InstanceSpecificOptions;\n\n const instance = config.init({\n // TODO: Consider whether this can be improved\n state: instanceState as never,\n messenger: instanceMessenger,\n options: instanceOptions?.[camelCaseName] ?? {},\n });\n\n instances[name] = instance;\n }\n\n return instances as DefaultInstances;\n}\n"]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.approvalController = void 0;
4
+ const approval_controller_1 = require("@metamask/approval-controller");
5
+ const controller_utils_1 = require("@metamask/controller-utils");
6
+ const messenger_1 = require("@metamask/messenger");
7
+ /**
8
+ * Approval types that are exempt from per-origin rate limiting, so more than one
9
+ * request of the same type can be pending at once. These are the common EVM
10
+ * types: signing, transactions, watch-asset, and encryption.
11
+ *
12
+ * Clients can replace this list via
13
+ * `instanceOptions.approvalController.typesExcludedFromRateLimiting` — the
14
+ * extension and mobile pass their own. `snap_dialog` will be added here once the
15
+ * wallet wires `SnapController`.
16
+ */
17
+ const DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING = [
18
+ controller_utils_1.ApprovalType.PersonalSign,
19
+ controller_utils_1.ApprovalType.EthSignTypedData,
20
+ controller_utils_1.ApprovalType.Transaction,
21
+ controller_utils_1.ApprovalType.WatchAsset,
22
+ controller_utils_1.ApprovalType.EthGetEncryptionPublicKey,
23
+ controller_utils_1.ApprovalType.EthDecrypt,
24
+ ];
25
+ exports.approvalController = {
26
+ name: 'ApprovalController',
27
+ init: ({ state, messenger, options }) => new approval_controller_1.ApprovalController({
28
+ state,
29
+ messenger,
30
+ showApprovalRequest: options.showApprovalRequest ?? (() => undefined),
31
+ typesExcludedFromRateLimiting: options.typesExcludedFromRateLimiting ??
32
+ DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING,
33
+ }),
34
+ getMessenger: (parent) => new messenger_1.Messenger({
35
+ namespace: 'ApprovalController',
36
+ parent,
37
+ }),
38
+ };
39
+ //# sourceMappingURL=approval-controller.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-controller.cjs","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/approval-controller.ts"],"names":[],"mappings":";;;AAAA,uEAGuC;AACvC,iEAA0D;AAC1D,mDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAM,yCAAyC,GAAG;IAChD,+BAAY,CAAC,YAAY;IACzB,+BAAY,CAAC,gBAAgB;IAC7B,+BAAY,CAAC,WAAW;IACxB,+BAAY,CAAC,UAAU;IACvB,+BAAY,CAAC,yBAAyB;IACtC,+BAAY,CAAC,UAAU;CACxB,CAAC;AAEW,QAAA,kBAAkB,GAG3B;IACF,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CACtC,IAAI,wCAAkB,CAAC;QACrB,KAAK;QACL,SAAS;QACT,mBAAmB,EACjB,OAAO,CAAC,mBAAmB,IAAI,CAAC,GAAS,EAAE,CAAC,SAAS,CAAC;QACxD,6BAA6B,EAC3B,OAAO,CAAC,6BAA6B;YACrC,yCAAyC;KAC5C,CAAC;IACJ,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CACvB,IAAI,qBAAS,CAAC;QACZ,SAAS,EAAE,oBAAoB;QAC/B,MAAM;KACP,CAAC;CACL,CAAC","sourcesContent":["import {\n ApprovalController,\n ApprovalControllerMessenger,\n} from '@metamask/approval-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\nimport { Messenger } from '@metamask/messenger';\n\nimport { InitializationConfiguration } from '../../types';\n\n/**\n * Approval types that are exempt from per-origin rate limiting, so more than one\n * request of the same type can be pending at once. These are the common EVM\n * types: signing, transactions, watch-asset, and encryption.\n *\n * Clients can replace this list via\n * `instanceOptions.approvalController.typesExcludedFromRateLimiting` — the\n * extension and mobile pass their own. `snap_dialog` will be added here once the\n * wallet wires `SnapController`.\n */\nconst DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING = [\n ApprovalType.PersonalSign,\n ApprovalType.EthSignTypedData,\n ApprovalType.Transaction,\n ApprovalType.WatchAsset,\n ApprovalType.EthGetEncryptionPublicKey,\n ApprovalType.EthDecrypt,\n];\n\nexport const approvalController: InitializationConfiguration<\n ApprovalController,\n ApprovalControllerMessenger\n> = {\n name: 'ApprovalController',\n init: ({ state, messenger, options }) =>\n new ApprovalController({\n state,\n messenger,\n showApprovalRequest:\n options.showApprovalRequest ?? ((): void => undefined),\n typesExcludedFromRateLimiting:\n options.typesExcludedFromRateLimiting ??\n DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING,\n }),\n getMessenger: (parent) =>\n new Messenger({\n namespace: 'ApprovalController',\n parent,\n }),\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import { ApprovalController, ApprovalControllerMessenger } from "@metamask/approval-controller";
2
+ import { InitializationConfiguration } from "../../types.cjs";
3
+ export declare const approvalController: InitializationConfiguration<ApprovalController, ApprovalControllerMessenger>;
4
+ //# sourceMappingURL=approval-controller.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-controller.d.cts","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/approval-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC5B,sCAAsC;AAIvC,OAAO,EAAE,2BAA2B,EAAE,wBAAoB;AAqB1D,eAAO,MAAM,kBAAkB,EAAE,2BAA2B,CAC1D,kBAAkB,EAClB,2BAA2B,CAkB5B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ApprovalController, ApprovalControllerMessenger } from "@metamask/approval-controller";
2
+ import { InitializationConfiguration } from "../../types.mjs";
3
+ export declare const approvalController: InitializationConfiguration<ApprovalController, ApprovalControllerMessenger>;
4
+ //# sourceMappingURL=approval-controller.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-controller.d.mts","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/approval-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC5B,sCAAsC;AAIvC,OAAO,EAAE,2BAA2B,EAAE,wBAAoB;AAqB1D,eAAO,MAAM,kBAAkB,EAAE,2BAA2B,CAC1D,kBAAkB,EAClB,2BAA2B,CAkB5B,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { ApprovalController } from "@metamask/approval-controller";
2
+ import { ApprovalType } from "@metamask/controller-utils";
3
+ import { Messenger } from "@metamask/messenger";
4
+ /**
5
+ * Approval types that are exempt from per-origin rate limiting, so more than one
6
+ * request of the same type can be pending at once. These are the common EVM
7
+ * types: signing, transactions, watch-asset, and encryption.
8
+ *
9
+ * Clients can replace this list via
10
+ * `instanceOptions.approvalController.typesExcludedFromRateLimiting` — the
11
+ * extension and mobile pass their own. `snap_dialog` will be added here once the
12
+ * wallet wires `SnapController`.
13
+ */
14
+ const DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING = [
15
+ ApprovalType.PersonalSign,
16
+ ApprovalType.EthSignTypedData,
17
+ ApprovalType.Transaction,
18
+ ApprovalType.WatchAsset,
19
+ ApprovalType.EthGetEncryptionPublicKey,
20
+ ApprovalType.EthDecrypt,
21
+ ];
22
+ export const approvalController = {
23
+ name: 'ApprovalController',
24
+ init: ({ state, messenger, options }) => new ApprovalController({
25
+ state,
26
+ messenger,
27
+ showApprovalRequest: options.showApprovalRequest ?? (() => undefined),
28
+ typesExcludedFromRateLimiting: options.typesExcludedFromRateLimiting ??
29
+ DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING,
30
+ }),
31
+ getMessenger: (parent) => new Messenger({
32
+ namespace: 'ApprovalController',
33
+ parent,
34
+ }),
35
+ };
36
+ //# sourceMappingURL=approval-controller.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-controller.mjs","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/approval-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAEnB,sCAAsC;AACvC,OAAO,EAAE,YAAY,EAAE,mCAAmC;AAC1D,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAIhD;;;;;;;;;GASG;AACH,MAAM,yCAAyC,GAAG;IAChD,YAAY,CAAC,YAAY;IACzB,YAAY,CAAC,gBAAgB;IAC7B,YAAY,CAAC,WAAW;IACxB,YAAY,CAAC,UAAU;IACvB,YAAY,CAAC,yBAAyB;IACtC,YAAY,CAAC,UAAU;CACxB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAG3B;IACF,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CACtC,IAAI,kBAAkB,CAAC;QACrB,KAAK;QACL,SAAS;QACT,mBAAmB,EACjB,OAAO,CAAC,mBAAmB,IAAI,CAAC,GAAS,EAAE,CAAC,SAAS,CAAC;QACxD,6BAA6B,EAC3B,OAAO,CAAC,6BAA6B;YACrC,yCAAyC;KAC5C,CAAC;IACJ,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CACvB,IAAI,SAAS,CAAC;QACZ,SAAS,EAAE,oBAAoB;QAC/B,MAAM;KACP,CAAC;CACL,CAAC","sourcesContent":["import {\n ApprovalController,\n ApprovalControllerMessenger,\n} from '@metamask/approval-controller';\nimport { ApprovalType } from '@metamask/controller-utils';\nimport { Messenger } from '@metamask/messenger';\n\nimport { InitializationConfiguration } from '../../types';\n\n/**\n * Approval types that are exempt from per-origin rate limiting, so more than one\n * request of the same type can be pending at once. These are the common EVM\n * types: signing, transactions, watch-asset, and encryption.\n *\n * Clients can replace this list via\n * `instanceOptions.approvalController.typesExcludedFromRateLimiting` — the\n * extension and mobile pass their own. `snap_dialog` will be added here once the\n * wallet wires `SnapController`.\n */\nconst DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING = [\n ApprovalType.PersonalSign,\n ApprovalType.EthSignTypedData,\n ApprovalType.Transaction,\n ApprovalType.WatchAsset,\n ApprovalType.EthGetEncryptionPublicKey,\n ApprovalType.EthDecrypt,\n];\n\nexport const approvalController: InitializationConfiguration<\n ApprovalController,\n ApprovalControllerMessenger\n> = {\n name: 'ApprovalController',\n init: ({ state, messenger, options }) =>\n new ApprovalController({\n state,\n messenger,\n showApprovalRequest:\n options.showApprovalRequest ?? ((): void => undefined),\n typesExcludedFromRateLimiting:\n options.typesExcludedFromRateLimiting ??\n DEFAULT_TYPES_EXCLUDED_FROM_RATE_LIMITING,\n }),\n getMessenger: (parent) =>\n new Messenger({\n namespace: 'ApprovalController',\n parent,\n }),\n};\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ApprovalControllerOptions,\n ShowApprovalRequest,\n} from '@metamask/approval-controller';\n\n/**\n * Per-instance options for the wallet's `ApprovalController`. Both fields are\n * optional; see the controller's `init` for the defaults applied when omitted.\n */\nexport type ApprovalControllerInstanceOptions = {\n /**\n * Callback that surfaces a pending approval request to the user. Defaults to\n * a no-op so the controller works headlessly.\n */\n showApprovalRequest?: ShowApprovalRequest;\n /**\n * Approval types exempt from per-origin rate limiting. Defaults to a baseline\n * of EVM approval types.\n */\n typesExcludedFromRateLimiting?: NonNullable<\n ApprovalControllerOptions['typesExcludedFromRateLimiting']\n >;\n};\n"]}
@@ -0,0 +1,18 @@
1
+ import type { ApprovalControllerOptions, ShowApprovalRequest } from "@metamask/approval-controller";
2
+ /**
3
+ * Per-instance options for the wallet's `ApprovalController`. Both fields are
4
+ * optional; see the controller's `init` for the defaults applied when omitted.
5
+ */
6
+ export type ApprovalControllerInstanceOptions = {
7
+ /**
8
+ * Callback that surfaces a pending approval request to the user. Defaults to
9
+ * a no-op so the controller works headlessly.
10
+ */
11
+ showApprovalRequest?: ShowApprovalRequest;
12
+ /**
13
+ * Approval types exempt from per-origin rate limiting. Defaults to a baseline
14
+ * of EVM approval types.
15
+ */
16
+ typesExcludedFromRateLimiting?: NonNullable<ApprovalControllerOptions['typesExcludedFromRateLimiting']>;
17
+ };
18
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACpB,sCAAsC;AAEvC;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,6BAA6B,CAAC,EAAE,WAAW,CACzC,yBAAyB,CAAC,+BAA+B,CAAC,CAC3D,CAAC;CACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ApprovalControllerOptions, ShowApprovalRequest } from "@metamask/approval-controller";
2
+ /**
3
+ * Per-instance options for the wallet's `ApprovalController`. Both fields are
4
+ * optional; see the controller's `init` for the defaults applied when omitted.
5
+ */
6
+ export type ApprovalControllerInstanceOptions = {
7
+ /**
8
+ * Callback that surfaces a pending approval request to the user. Defaults to
9
+ * a no-op so the controller works headlessly.
10
+ */
11
+ showApprovalRequest?: ShowApprovalRequest;
12
+ /**
13
+ * Approval types exempt from per-origin rate limiting. Defaults to a baseline
14
+ * of EVM approval types.
15
+ */
16
+ typesExcludedFromRateLimiting?: NonNullable<ApprovalControllerOptions['typesExcludedFromRateLimiting']>;
17
+ };
18
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACpB,sCAAsC;AAEvC;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,6BAA6B,CAAC,EAAE,WAAW,CACzC,yBAAyB,CAAC,+BAA+B,CAAC,CAC3D,CAAC;CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/initialization/instances/approval-controller/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ApprovalControllerOptions,\n ShowApprovalRequest,\n} from '@metamask/approval-controller';\n\n/**\n * Per-instance options for the wallet's `ApprovalController`. Both fields are\n * optional; see the controller's `init` for the defaults applied when omitted.\n */\nexport type ApprovalControllerInstanceOptions = {\n /**\n * Callback that surfaces a pending approval request to the user. Defaults to\n * a no-op so the controller works headlessly.\n */\n showApprovalRequest?: ShowApprovalRequest;\n /**\n * Approval types exempt from per-origin rate limiting. Defaults to a baseline\n * of EVM approval types.\n */\n typesExcludedFromRateLimiting?: NonNullable<\n ApprovalControllerOptions['typesExcludedFromRateLimiting']\n >;\n};\n"]}
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keyringController = void 0;
4
- var keyring_controller_1 = require("./keyring-controller.cjs");
3
+ exports.storageService = exports.keyringController = exports.approvalController = void 0;
4
+ var approval_controller_1 = require("./approval-controller/approval-controller.cjs");
5
+ Object.defineProperty(exports, "approvalController", { enumerable: true, get: function () { return approval_controller_1.approvalController; } });
6
+ var keyring_controller_1 = require("./keyring-controller/keyring-controller.cjs");
5
7
  Object.defineProperty(exports, "keyringController", { enumerable: true, get: function () { return keyring_controller_1.keyringController; } });
8
+ var storage_service_1 = require("./storage-service/storage-service.cjs");
9
+ Object.defineProperty(exports, "storageService", { enumerable: true, get: function () { return storage_service_1.storageService; } });
6
10
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":";;;AAAA,+DAAyD;AAAhD,uHAAA,iBAAiB,OAAA","sourcesContent":["export { keyringController } from './keyring-controller';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":";;;AAAA,qFAA+E;AAAtE,yHAAA,kBAAkB,OAAA;AAC3B,kFAA4E;AAAnE,uHAAA,iBAAiB,OAAA;AAC1B,yEAAmE;AAA1D,iHAAA,cAAc,OAAA","sourcesContent":["export { approvalController } from './approval-controller/approval-controller';\nexport { keyringController } from './keyring-controller/keyring-controller';\nexport { storageService } from './storage-service/storage-service';\n"]}
@@ -1,2 +1,4 @@
1
- export { keyringController } from "./keyring-controller.cjs";
1
+ export { approvalController } from "./approval-controller/approval-controller.cjs";
2
+ export { keyringController } from "./keyring-controller/keyring-controller.cjs";
3
+ export { storageService } from "./storage-service/storage-service.cjs";
2
4
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iCAA6B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sDAAkD;AAC/E,OAAO,EAAE,iBAAiB,EAAE,oDAAgD;AAC5E,OAAO,EAAE,cAAc,EAAE,8CAA0C"}
@@ -1,2 +1,4 @@
1
- export { keyringController } from "./keyring-controller.mjs";
1
+ export { approvalController } from "./approval-controller/approval-controller.mjs";
2
+ export { keyringController } from "./keyring-controller/keyring-controller.mjs";
3
+ export { storageService } from "./storage-service/storage-service.mjs";
2
4
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iCAA6B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sDAAkD;AAC/E,OAAO,EAAE,iBAAiB,EAAE,oDAAgD;AAC5E,OAAO,EAAE,cAAc,EAAE,8CAA0C"}
@@ -1,2 +1,4 @@
1
- export { keyringController } from "./keyring-controller.mjs";
1
+ export { approvalController } from "./approval-controller/approval-controller.mjs";
2
+ export { keyringController } from "./keyring-controller/keyring-controller.mjs";
3
+ export { storageService } from "./storage-service/storage-service.mjs";
2
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iCAA6B","sourcesContent":["export { keyringController } from './keyring-controller';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/initialization/instances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sDAAkD;AAC/E,OAAO,EAAE,iBAAiB,EAAE,oDAAgD;AAC5E,OAAO,EAAE,cAAc,EAAE,8CAA0C","sourcesContent":["export { approvalController } from './approval-controller/approval-controller';\nexport { keyringController } from './keyring-controller/keyring-controller';\nexport { storageService } from './storage-service/storage-service';\n"]}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keyringController = exports.encryptorFactory = void 0;
3
+ exports.encryptorFactory = void 0;
4
4
  const browser_passworder_1 = require("@metamask/browser-passworder");
5
- const keyring_controller_1 = require("@metamask/keyring-controller");
6
- const messenger_1 = require("@metamask/messenger");
7
5
  /**
8
6
  * A factory function for the encrypt method of the browser-passworder library,
9
7
  * that encrypts with a given number of iterations.
@@ -82,17 +80,4 @@ const encryptorFactory = (iterations) => ({
82
80
  generateSalt: browser_passworder_1.generateSalt,
83
81
  });
84
82
  exports.encryptorFactory = encryptorFactory;
85
- exports.keyringController = {
86
- name: 'KeyringController',
87
- init: ({ state, messenger, options }) => new keyring_controller_1.KeyringController({
88
- state,
89
- messenger,
90
- keyringBuilders: options.keyringBuilders,
91
- encryptor: (options.encryptor ?? (0, exports.encryptorFactory)(600000)),
92
- }),
93
- getMessenger: (parent) => new messenger_1.Messenger({
94
- namespace: 'KeyringController',
95
- parent,
96
- }),
97
- };
98
- //# sourceMappingURL=keyring-controller.cjs.map
83
+ //# sourceMappingURL=encryptor.cjs.map