@metamask/snaps-simulation 4.1.2 → 4.1.4
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.
- package/CHANGELOG.md +21 -2
- package/dist/controllers.cjs.map +1 -1
- package/dist/controllers.d.cts +2 -2
- package/dist/controllers.d.cts.map +1 -1
- package/dist/controllers.d.mts +2 -2
- package/dist/controllers.d.mts.map +1 -1
- package/dist/controllers.mjs.map +1 -1
- package/dist/methods/hooks/index.cjs +0 -2
- package/dist/methods/hooks/index.cjs.map +1 -1
- package/dist/methods/hooks/index.d.cts +0 -2
- package/dist/methods/hooks/index.d.cts.map +1 -1
- package/dist/methods/hooks/index.d.mts +0 -2
- package/dist/methods/hooks/index.d.mts.map +1 -1
- package/dist/methods/hooks/index.mjs +0 -2
- package/dist/methods/hooks/index.mjs.map +1 -1
- package/dist/methods/hooks/state.cjs +1 -1
- package/dist/methods/hooks/state.cjs.map +1 -1
- package/dist/methods/hooks/state.d.cts +1 -1
- package/dist/methods/hooks/state.d.cts.map +1 -1
- package/dist/methods/hooks/state.d.mts +1 -1
- package/dist/methods/hooks/state.d.mts.map +1 -1
- package/dist/methods/hooks/state.mjs +1 -1
- package/dist/methods/hooks/state.mjs.map +1 -1
- package/dist/methods/specifications.cjs +5 -14
- package/dist/methods/specifications.cjs.map +1 -1
- package/dist/methods/specifications.d.cts +7 -17
- package/dist/methods/specifications.d.cts.map +1 -1
- package/dist/methods/specifications.d.mts +7 -17
- package/dist/methods/specifications.d.mts.map +1 -1
- package/dist/methods/specifications.mjs +6 -15
- package/dist/methods/specifications.mjs.map +1 -1
- package/dist/middleware/engine.cjs +8 -4
- package/dist/middleware/engine.cjs.map +1 -1
- package/dist/middleware/engine.d.cts +7 -6
- package/dist/middleware/engine.d.cts.map +1 -1
- package/dist/middleware/engine.d.mts +7 -6
- package/dist/middleware/engine.d.mts.map +1 -1
- package/dist/middleware/engine.mjs +9 -5
- package/dist/middleware/engine.mjs.map +1 -1
- package/dist/simulation.cjs +82 -27
- package/dist/simulation.cjs.map +1 -1
- package/dist/simulation.d.cts +18 -114
- package/dist/simulation.d.cts.map +1 -1
- package/dist/simulation.d.mts +18 -114
- package/dist/simulation.d.mts.map +1 -1
- package/dist/simulation.mjs +83 -28
- package/dist/simulation.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/methods/hooks/get-entropy-sources.cjs +0 -30
- package/dist/methods/hooks/get-entropy-sources.cjs.map +0 -1
- package/dist/methods/hooks/get-entropy-sources.d.cts +0 -14
- package/dist/methods/hooks/get-entropy-sources.d.cts.map +0 -1
- package/dist/methods/hooks/get-entropy-sources.d.mts +0 -14
- package/dist/methods/hooks/get-entropy-sources.d.mts.map +0 -1
- package/dist/methods/hooks/get-entropy-sources.mjs +0 -26
- package/dist/methods/hooks/get-entropy-sources.mjs.map +0 -1
- package/dist/methods/hooks/get-mnemonic-seed.cjs +0 -29
- package/dist/methods/hooks/get-mnemonic-seed.cjs.map +0 -1
- package/dist/methods/hooks/get-mnemonic-seed.d.cts +0 -9
- package/dist/methods/hooks/get-mnemonic-seed.d.cts.map +0 -1
- package/dist/methods/hooks/get-mnemonic-seed.d.mts +0 -9
- package/dist/methods/hooks/get-mnemonic-seed.d.mts.map +0 -1
- package/dist/methods/hooks/get-mnemonic-seed.mjs +0 -25
- package/dist/methods/hooks/get-mnemonic-seed.mjs.map +0 -1
- package/dist/methods/hooks/interface.cjs +0 -34
- package/dist/methods/hooks/interface.cjs.map +0 -1
- package/dist/methods/hooks/interface.d.cts +0 -24
- package/dist/methods/hooks/interface.d.cts.map +0 -1
- package/dist/methods/hooks/interface.d.mts +0 -24
- package/dist/methods/hooks/interface.d.mts.map +0 -1
- package/dist/methods/hooks/interface.mjs +0 -28
- package/dist/methods/hooks/interface.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.1.4]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump `@metamask/snaps-rpc-methods` from `^15.1.1` to `16.0.0` and handle breaking changes ([#3968](https://github.com/MetaMask/snaps/pull/3968), [#3987](https://github.com/MetaMask/snaps/pull/3987), [#3993](https://github.com/MetaMask/snaps/pull/3993))
|
|
15
|
+
- Bump `@metamask/permission-controller` `12.3.0` to `^13.1.0` ([#3984](https://github.com/MetaMask/snaps/pull/3984), [#3989](https://github.com/MetaMask/snaps/pull/3989))
|
|
16
|
+
- Bump `@metamask/json-rpc-engine` from `^10.2.4` to `^10.5.0` ([#3982](https://github.com/MetaMask/snaps/pull/3982),[#3992](https://github.com/MetaMask/snaps/pull/3992), [#3998](https://github.com/MetaMask/snaps/pull/3998))
|
|
17
|
+
- Bump `@metamask/messenger` from `^1.1.1` to `^1.2.0` ([#3981](https://github.com/MetaMask/snaps/pull/3981))
|
|
18
|
+
- Bump `@metamask/chain-agnostic-permission` from `^1.5.0` to `^1.6.0` ([#3997](https://github.com/MetaMask/snaps/pull/3997))
|
|
19
|
+
|
|
20
|
+
## [4.1.3]
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Bump `@metamask/messenger` from `^0.3.0` to `^1.1.0` ([#3930](https://github.com/MetaMask/snaps/pull/3930), [#3934](https://github.com/MetaMask/snaps/pull/3934))
|
|
25
|
+
- Bump `@metamask/permission-controller` from `^12.2.1` to `^12.3.0` ([#3930](https://github.com/MetaMask/snaps/pull/3930))
|
|
26
|
+
|
|
10
27
|
## [4.1.2]
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -64,7 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
64
81
|
|
|
65
82
|
## Changed
|
|
66
83
|
|
|
67
|
-
- Bump `@metamask/permission-controller` from `12.0.0` to `12.1.1
|
|
84
|
+
- Bump `@metamask/permission-controller` from `12.0.0` to `12.1.1`, ([#3746](https://github.com/MetaMask/snaps/pull/3746), [#3714](https://github.com/MetaMask/snaps/pull/3714))
|
|
68
85
|
- Bump `@metamask/phishing-controller` from `13.1.0` to `15.0.0` ([#3707](https://github.com/MetaMask/snaps/pull/3707))
|
|
69
86
|
|
|
70
87
|
## [3.5.1]
|
|
@@ -293,7 +310,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
293
310
|
|
|
294
311
|
- Initial release of `@metamask/snaps-simulation` package ([#2727](https://github.com/MetaMask/snaps/pull/2727))
|
|
295
312
|
|
|
296
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.
|
|
313
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.4...HEAD
|
|
314
|
+
[4.1.4]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.3...@metamask/snaps-simulation@4.1.4
|
|
315
|
+
[4.1.3]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.2...@metamask/snaps-simulation@4.1.3
|
|
297
316
|
[4.1.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.1...@metamask/snaps-simulation@4.1.2
|
|
298
317
|
[4.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.1.0...@metamask/snaps-simulation@4.1.1
|
|
299
318
|
[4.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-simulation@4.0.0...@metamask/snaps-simulation@4.1.0
|
package/dist/controllers.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.cjs","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":";;;AAAA,mFAG6C;AAM7C,mDAAgD;
|
|
1
|
+
{"version":3,"file":"controllers.cjs","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":";;;AAAA,mFAG6C;AAM7C,mDAAg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7B,GAAG,iDAAkC;SACtC;QACD,wBAAwB;QACxB,mBAAmB,EAAE,gCAAoB;KAC1C,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,QAAsB,EACtB,EACE,oBAAoB,EACpB,yBAAyB,GACgB;IAE3C,yBAAyB,CAAC,kBAAkB,CAAC;QAC3C,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,mCAAW,CAAC,IAAI;KAC9B,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,IAAA,0CAAsB,EAChD,IAAA,mBAAW,EAAC,QAAQ,CAAC,kBAAkB,CAAC,CACzC,CAAC;IAEF,oBAAoB,CAAC,gBAAgB,CAAC;QACpC,mBAAmB;QACnB,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;QAC3B,2BAA2B,EAAE,KAAK;KACnC,CAAC,CAAC;AACL,CAAC;AAtBD,oCAsBC","sourcesContent":["import {\n caip25CaveatBuilder,\n Caip25CaveatType,\n} from '@metamask/chain-agnostic-permission';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\nimport { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerMessenger } from '@metamask/permission-controller';\nimport {\n PermissionController,\n SubjectMetadataController,\n SubjectType,\n} from '@metamask/permission-controller';\nimport type {\n ExecutionServiceMessenger,\n SnapControllerMessenger,\n SnapInterfaceControllerMessenger,\n SnapRegistryControllerMessenger,\n} from '@metamask/snaps-controllers';\nimport { SnapInterfaceController } from '@metamask/snaps-controllers';\nimport {\n caveatSpecifications as snapsCaveatsSpecifications,\n endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications,\n processSnapPermissions,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SnapManifest } from '@metamask/snaps-utils';\nimport type { Hex } from '@metamask/utils';\nimport { getSafeJson } from '@metamask/utils';\n\nimport { getPermissionSpecifications } from './methods';\nimport { UNRESTRICTED_METHODS } from './methods/constants';\nimport type { SimulationOptions } from './options';\nimport type { RestrictedMiddlewareHooks } from './simulation';\nimport type { RunSagaFunction } from './store';\n\nexport type RootControllerMessenger = Messenger<\n MockAnyNamespace,\n MessengerActions<\n | ExecutionServiceMessenger\n | PermissionControllerMessenger\n | SnapControllerMessenger\n | SnapInterfaceControllerMessenger\n | SnapRegistryControllerMessenger\n >,\n MessengerEvents<\n | ExecutionServiceMessenger\n | PermissionControllerMessenger\n | SnapControllerMessenger\n | SnapInterfaceControllerMessenger\n | SnapRegistryControllerMessenger\n >\n>;\n\nexport type GetControllersOptions = {\n controllerMessenger: Messenger<any, any, any>;\n hooks: RestrictedMiddlewareHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\nexport type Controllers = {\n permissionController: PermissionController;\n subjectMetadataController: SubjectMetadataController;\n interfaceController: SnapInterfaceController;\n};\n\n/**\n * Get the controllers for the Snap.\n *\n * @param options - The options.\n * @returns The controllers for the Snap.\n */\nexport function getControllers(options: GetControllersOptions): Controllers {\n const { controllerMessenger } = options;\n const subjectMetadataController = new SubjectMetadataController({\n messenger: new Messenger({\n namespace: 'SubjectMetadataController',\n parent: controllerMessenger,\n }),\n subjectCacheLimit: 100,\n });\n\n const interfaceControllerMessenger: SnapInterfaceControllerMessenger =\n new Messenger({\n namespace: 'SnapInterfaceController',\n parent: controllerMessenger,\n });\n\n controllerMessenger.delegate({\n messenger: interfaceControllerMessenger,\n actions: [\n 'PhishingController:testOrigin',\n 'ApprovalController:hasRequest',\n 'ApprovalController:acceptRequest',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:getSelectedMultichainAccount',\n 'AccountsController:listMultichainAccounts',\n 'MultichainAssetsController:getState',\n 'PermissionController:hasPermission',\n ],\n events: ['NotificationServicesController:notificationsListUpdated'],\n });\n\n const interfaceController = new SnapInterfaceController({\n messenger: interfaceControllerMessenger,\n });\n\n const permissionController = getPermissionController(options);\n\n return {\n permissionController,\n subjectMetadataController,\n interfaceController,\n };\n}\n\n/**\n * Get the permission controller for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.options - Miscellaneous options.\n * @returns The permission controller for the Snap.\n */\nfunction getPermissionController(options: GetControllersOptions) {\n const { controllerMessenger } = options;\n const permissionSpecifications = getPermissionSpecifications(options);\n const messenger = new Messenger({\n namespace: 'PermissionController',\n parent: controllerMessenger,\n });\n\n controllerMessenger.delegate({\n messenger,\n actions: [\n `ApprovalController:addRequest`,\n `ApprovalController:hasRequest`,\n `ApprovalController:acceptRequest`,\n `ApprovalController:rejectRequest`,\n `SnapController:getPermitted`,\n `SnapController:install`,\n `SubjectMetadataController:getSubjectMetadata`,\n ],\n });\n\n const simulatedAccounts = options.options.accounts;\n const ethereumAccounts = simulatedAccounts\n .filter((account) =>\n account.scopes.some((scope) => scope.startsWith('eip155')),\n )\n .map((account) => ({\n type: 'eip155:eoa',\n address: account.address as Hex,\n }));\n\n return new PermissionController({\n messenger,\n caveatSpecifications: {\n [Caip25CaveatType]: caip25CaveatBuilder({\n findNetworkClientIdByChainId: (chainId) => chainId,\n isNonEvmScopeSupported: (_scope) => true,\n getNonEvmAccountAddresses: (scope) =>\n simulatedAccounts\n .filter((account) => account.scopes.includes(scope))\n .map((account) => `${scope}:${account.address}`),\n listAccounts: () => ethereumAccounts,\n }),\n ...snapsCaveatsSpecifications,\n ...snapsEndowmentCaveatSpecifications,\n },\n permissionSpecifications,\n unrestrictedMethods: UNRESTRICTED_METHODS,\n });\n}\n\n/**\n * Register the Snap. This sets up the Snap's permissions and subject metadata.\n *\n * @param snapId - The ID of the Snap to install.\n * @param manifest - The parsed manifest.\n * @param controllers - The controllers for the Snap.\n * @param controllers.permissionController - The permission controller.\n * @param controllers.subjectMetadataController - The subject metadata controller.\n */\nexport async function registerSnap(\n snapId: SnapId,\n manifest: SnapManifest,\n {\n permissionController,\n subjectMetadataController,\n }: Omit<Controllers, 'interfaceController'>,\n) {\n subjectMetadataController.addSubjectMetadata({\n origin: snapId,\n subjectType: SubjectType.Snap,\n });\n\n const approvedPermissions = processSnapPermissions(\n getSafeJson(manifest.initialPermissions),\n );\n\n permissionController.grantPermissions({\n approvedPermissions,\n subject: { origin: snapId },\n preserveExistingPermissions: false,\n });\n}\n"]}
|
package/dist/controllers.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MessengerActions, MessengerEvents, MockAnyNamespace } from "@metamask/messenger";
|
|
2
2
|
import { Messenger } from "@metamask/messenger";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PermissionControllerMessenger } from "@metamask/permission-controller";
|
|
4
4
|
import { PermissionController, SubjectMetadataController } from "@metamask/permission-controller";
|
|
5
5
|
import type { ExecutionServiceMessenger, SnapControllerMessenger, SnapInterfaceControllerMessenger, SnapRegistryControllerMessenger } from "@metamask/snaps-controllers";
|
|
6
6
|
import { SnapInterfaceController } from "@metamask/snaps-controllers";
|
|
@@ -17,7 +17,7 @@ export type GetControllersOptions = {
|
|
|
17
17
|
options: SimulationOptions;
|
|
18
18
|
};
|
|
19
19
|
export type Controllers = {
|
|
20
|
-
permissionController: PermissionController
|
|
20
|
+
permissionController: PermissionController;
|
|
21
21
|
subjectMetadataController: SubjectMetadataController;
|
|
22
22
|
interfaceController: SnapInterfaceController;
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.d.cts","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAChD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"controllers.d.cts","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,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C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,EACE,oBAAoB,EACpB,yBAAyB,GAC1B,EAAE,IAAI,CAAC,WAAW,EAAE,qBAAqB,CAAC,iBAgB5C"}
|
package/dist/controllers.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MessengerActions, MessengerEvents, MockAnyNamespace } from "@metamask/messenger";
|
|
2
2
|
import { Messenger } from "@metamask/messenger";
|
|
3
|
-
import type {
|
|
3
|
+
import type { PermissionControllerMessenger } from "@metamask/permission-controller";
|
|
4
4
|
import { PermissionController, SubjectMetadataController } from "@metamask/permission-controller";
|
|
5
5
|
import type { ExecutionServiceMessenger, SnapControllerMessenger, SnapInterfaceControllerMessenger, SnapRegistryControllerMessenger } from "@metamask/snaps-controllers";
|
|
6
6
|
import { SnapInterfaceController } from "@metamask/snaps-controllers";
|
|
@@ -17,7 +17,7 @@ export type GetControllersOptions = {
|
|
|
17
17
|
options: SimulationOptions;
|
|
18
18
|
};
|
|
19
19
|
export type Controllers = {
|
|
20
|
-
permissionController: PermissionController
|
|
20
|
+
permissionController: PermissionController;
|
|
21
21
|
subjectMetadataController: SubjectMetadataController;
|
|
22
22
|
interfaceController: SnapInterfaceController;
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.d.mts","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAChD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"controllers.d.mts","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAChD,OAAO,KAAK,EAAE,6BA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,oBAAoB,EACpB,yBAAyB,GAC1B,EAAE,IAAI,CAAC,WAAW,EAAE,qBAAqB,CAAC,iBAgB5C"}
|
package/dist/controllers.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.mjs","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EACjB,4CAA4C;AAM7C,OAAO,EAAE,SAAS,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"controllers.mjs","sourceRoot":"","sources":["../src/controllers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EACjB,4CAA4C;AAM7C,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAEhD,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,WAAW,EACZ,wCAAwC;AAOzC,OAAO,EAAE,uBAAuB,EAAE,oCAAoC;AACtE,OAAO,EACL,oBAAoB,IAAI,0BAA0B,EAClD,6BAA6B,IAAI,kCAAkC,EACnE,sBAAsB,EACvB,oCAAoC;AAIrC,OAAO,EAAE,WAAW,EAAE,wBAAwB;AAE9C,OAAO,EAAE,2BAA2B,EAAE,4BAAkB;AACxD,OAAO,EAAE,oBAAoB,EAAE,gCAA4B;AAoC3D;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC3D,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,yBAAyB,GAAG,IAAI,yBAAyB,CAAC;QAC9D,SAAS,EAAE,IAAI,SAAS,CAAC;YACvB,SAAS,EAAE,2BAA2B;YACtC,MAAM,EAAE,mBAAmB;SAC5B,CAAC;QACF,iBAAiB,EAAE,GAAG;KACvB,CAAC,CAAC;IAEH,MAAM,4BAA4B,GAChC,IAAI,SAAS,CAAC;QACZ,SAAS,EAAE,yBAAyB;QACpC,MAAM,EAAE,mBAAmB;KAC5B,CAAC,CAAC;IAEL,mBA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KACnC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n caip25CaveatBuilder,\n Caip25CaveatType,\n} from '@metamask/chain-agnostic-permission';\nimport type {\n MessengerActions,\n MessengerEvents,\n MockAnyNamespace,\n} from '@metamask/messenger';\nimport { Messenger } from '@metamask/messenger';\nimport type { PermissionControllerMessenger } from '@metamask/permission-controller';\nimport {\n PermissionController,\n SubjectMetadataController,\n SubjectType,\n} from '@metamask/permission-controller';\nimport type {\n ExecutionServiceMessenger,\n SnapControllerMessenger,\n SnapInterfaceControllerMessenger,\n SnapRegistryControllerMessenger,\n} from '@metamask/snaps-controllers';\nimport { SnapInterfaceController } from '@metamask/snaps-controllers';\nimport {\n caveatSpecifications as snapsCaveatsSpecifications,\n endowmentCaveatSpecifications as snapsEndowmentCaveatSpecifications,\n processSnapPermissions,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SnapManifest } from '@metamask/snaps-utils';\nimport type { Hex } from '@metamask/utils';\nimport { getSafeJson } from '@metamask/utils';\n\nimport { getPermissionSpecifications } from './methods';\nimport { UNRESTRICTED_METHODS } from './methods/constants';\nimport type { SimulationOptions } from './options';\nimport type { RestrictedMiddlewareHooks } from './simulation';\nimport type { RunSagaFunction } from './store';\n\nexport type RootControllerMessenger = Messenger<\n MockAnyNamespace,\n MessengerActions<\n | ExecutionServiceMessenger\n | PermissionControllerMessenger\n | SnapControllerMessenger\n | SnapInterfaceControllerMessenger\n | SnapRegistryControllerMessenger\n >,\n MessengerEvents<\n | ExecutionServiceMessenger\n | PermissionControllerMessenger\n | SnapControllerMessenger\n | SnapInterfaceControllerMessenger\n | SnapRegistryControllerMessenger\n >\n>;\n\nexport type GetControllersOptions = {\n controllerMessenger: Messenger<any, any, any>;\n hooks: RestrictedMiddlewareHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\nexport type Controllers = {\n permissionController: PermissionController;\n subjectMetadataController: SubjectMetadataController;\n interfaceController: SnapInterfaceController;\n};\n\n/**\n * Get the controllers for the Snap.\n *\n * @param options - The options.\n * @returns The controllers for the Snap.\n */\nexport function getControllers(options: GetControllersOptions): Controllers {\n const { controllerMessenger } = options;\n const subjectMetadataController = new SubjectMetadataController({\n messenger: new Messenger({\n namespace: 'SubjectMetadataController',\n parent: controllerMessenger,\n }),\n subjectCacheLimit: 100,\n });\n\n const interfaceControllerMessenger: SnapInterfaceControllerMessenger =\n new Messenger({\n namespace: 'SnapInterfaceController',\n parent: controllerMessenger,\n });\n\n controllerMessenger.delegate({\n messenger: interfaceControllerMessenger,\n actions: [\n 'PhishingController:testOrigin',\n 'ApprovalController:hasRequest',\n 'ApprovalController:acceptRequest',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:getSelectedMultichainAccount',\n 'AccountsController:listMultichainAccounts',\n 'MultichainAssetsController:getState',\n 'PermissionController:hasPermission',\n ],\n events: ['NotificationServicesController:notificationsListUpdated'],\n });\n\n const interfaceController = new SnapInterfaceController({\n messenger: interfaceControllerMessenger,\n });\n\n const permissionController = getPermissionController(options);\n\n return {\n permissionController,\n subjectMetadataController,\n interfaceController,\n };\n}\n\n/**\n * Get the permission controller for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.options - Miscellaneous options.\n * @returns The permission controller for the Snap.\n */\nfunction getPermissionController(options: GetControllersOptions) {\n const { controllerMessenger } = options;\n const permissionSpecifications = getPermissionSpecifications(options);\n const messenger = new Messenger({\n namespace: 'PermissionController',\n parent: controllerMessenger,\n });\n\n controllerMessenger.delegate({\n messenger,\n actions: [\n `ApprovalController:addRequest`,\n `ApprovalController:hasRequest`,\n `ApprovalController:acceptRequest`,\n `ApprovalController:rejectRequest`,\n `SnapController:getPermitted`,\n `SnapController:install`,\n `SubjectMetadataController:getSubjectMetadata`,\n ],\n });\n\n const simulatedAccounts = options.options.accounts;\n const ethereumAccounts = simulatedAccounts\n .filter((account) =>\n account.scopes.some((scope) => scope.startsWith('eip155')),\n )\n .map((account) => ({\n type: 'eip155:eoa',\n address: account.address as Hex,\n }));\n\n return new PermissionController({\n messenger,\n caveatSpecifications: {\n [Caip25CaveatType]: caip25CaveatBuilder({\n findNetworkClientIdByChainId: (chainId) => chainId,\n isNonEvmScopeSupported: (_scope) => true,\n getNonEvmAccountAddresses: (scope) =>\n simulatedAccounts\n .filter((account) => account.scopes.includes(scope))\n .map((account) => `${scope}:${account.address}`),\n listAccounts: () => ethereumAccounts,\n }),\n ...snapsCaveatsSpecifications,\n ...snapsEndowmentCaveatSpecifications,\n },\n permissionSpecifications,\n unrestrictedMethods: UNRESTRICTED_METHODS,\n });\n}\n\n/**\n * Register the Snap. This sets up the Snap's permissions and subject metadata.\n *\n * @param snapId - The ID of the Snap to install.\n * @param manifest - The parsed manifest.\n * @param controllers - The controllers for the Snap.\n * @param controllers.permissionController - The permission controller.\n * @param controllers.subjectMetadataController - The subject metadata controller.\n */\nexport async function registerSnap(\n snapId: SnapId,\n manifest: SnapManifest,\n {\n permissionController,\n subjectMetadataController,\n }: Omit<Controllers, 'interfaceController'>,\n) {\n subjectMetadataController.addSubjectMetadata({\n origin: snapId,\n subjectType: SubjectType.Snap,\n });\n\n const approvedPermissions = processSnapPermissions(\n getSafeJson(manifest.initialPermissions),\n );\n\n permissionController.grantPermissions({\n approvedPermissions,\n subject: { origin: snapId },\n preserveExistingPermissions: false,\n });\n}\n"]}
|
|
@@ -16,11 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./chain.cjs"), exports);
|
|
18
18
|
__exportStar(require("./end-trace.cjs"), exports);
|
|
19
|
-
__exportStar(require("./get-entropy-sources.cjs"), exports);
|
|
20
19
|
__exportStar(require("./get-mnemonic.cjs"), exports);
|
|
21
20
|
__exportStar(require("./get-preferences.cjs"), exports);
|
|
22
21
|
__exportStar(require("./get-snap.cjs"), exports);
|
|
23
|
-
__exportStar(require("./interface.cjs"), exports);
|
|
24
22
|
__exportStar(require("./notifications.cjs"), exports);
|
|
25
23
|
__exportStar(require("./permitted/index.cjs"), exports);
|
|
26
24
|
__exportStar(require("./request-user-approval.cjs"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,kDAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,kDAA4B;AAC5B,qDAA+B;AAC/B,wDAAkC;AAClC,iDAA2B;AAC3B,sDAAgC;AAChC,wDAA4B;AAC5B,8DAAwC;AACxC,oDAA8B;AAC9B,8CAAwB;AACxB,oDAA8B;AAC9B,oDAA8B","sourcesContent":["export * from './chain';\nexport * from './end-trace';\nexport * from './get-mnemonic';\nexport * from './get-preferences';\nexport * from './get-snap';\nexport * from './notifications';\nexport * from './permitted';\nexport * from './request-user-approval';\nexport * from './start-trace';\nexport * from './state';\nexport * from './track-error';\nexport * from './track-event';\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export * from "./chain.cjs";
|
|
2
2
|
export * from "./end-trace.cjs";
|
|
3
|
-
export * from "./get-entropy-sources.cjs";
|
|
4
3
|
export * from "./get-mnemonic.cjs";
|
|
5
4
|
export * from "./get-preferences.cjs";
|
|
6
5
|
export * from "./get-snap.cjs";
|
|
7
|
-
export * from "./interface.cjs";
|
|
8
6
|
export * from "./notifications.cjs";
|
|
9
7
|
export * from "./permitted/index.cjs";
|
|
10
8
|
export * from "./request-user-approval.cjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,gCAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,gCAA4B;AAC5B,mCAA+B;AAC/B,sCAAkC;AAClC,+BAA2B;AAC3B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,kCAA8B;AAC9B,4BAAwB;AACxB,kCAA8B;AAC9B,kCAA8B"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export * from "./chain.mjs";
|
|
2
2
|
export * from "./end-trace.mjs";
|
|
3
|
-
export * from "./get-entropy-sources.mjs";
|
|
4
3
|
export * from "./get-mnemonic.mjs";
|
|
5
4
|
export * from "./get-preferences.mjs";
|
|
6
5
|
export * from "./get-snap.mjs";
|
|
7
|
-
export * from "./interface.mjs";
|
|
8
6
|
export * from "./notifications.mjs";
|
|
9
7
|
export * from "./permitted/index.mjs";
|
|
10
8
|
export * from "./request-user-approval.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,gCAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,gCAA4B;AAC5B,mCAA+B;AAC/B,sCAAkC;AAClC,+BAA2B;AAC3B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,kCAA8B;AAC9B,4BAAwB;AACxB,kCAA8B;AAC9B,kCAA8B"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export * from "./chain.mjs";
|
|
2
2
|
export * from "./end-trace.mjs";
|
|
3
|
-
export * from "./get-entropy-sources.mjs";
|
|
4
3
|
export * from "./get-mnemonic.mjs";
|
|
5
4
|
export * from "./get-preferences.mjs";
|
|
6
5
|
export * from "./get-snap.mjs";
|
|
7
|
-
export * from "./interface.mjs";
|
|
8
6
|
export * from "./notifications.mjs";
|
|
9
7
|
export * from "./permitted/index.mjs";
|
|
10
8
|
export * from "./request-user-approval.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,gCAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,4BAAwB;AACxB,gCAA4B;AAC5B,mCAA+B;AAC/B,sCAAkC;AAClC,+BAA2B;AAC3B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,kCAA8B;AAC9B,4BAAwB;AACxB,kCAA8B;AAC9B,kCAA8B","sourcesContent":["export * from './chain';\nexport * from './end-trace';\nexport * from './get-mnemonic';\nexport * from './get-preferences';\nexport * from './get-snap';\nexport * from './notifications';\nexport * from './permitted';\nexport * from './request-user-approval';\nexport * from './start-trace';\nexport * from './state';\nexport * from './track-error';\nexport * from './track-event';\n"]}
|
|
@@ -52,7 +52,7 @@ function* updateSnapStateImplementation(_snapId, newState, encrypted = true) {
|
|
|
52
52
|
* @returns The implementation of the `updateSnapState` hook.
|
|
53
53
|
*/
|
|
54
54
|
function getUpdateSnapStateMethodImplementation(runSaga) {
|
|
55
|
-
return (...args) => {
|
|
55
|
+
return async (...args) => {
|
|
56
56
|
runSaga(updateSnapStateImplementation, ...args).result();
|
|
57
57
|
};
|
|
58
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/state.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAGlD,gDAAiD;AAGjD,iDAA6D;AAE7D;;;;;;;;;GASG;AACH,QAAQ,CAAC,CAAC,0BAA0B,CAClC,OAAe,EACf,SAAS,GAAG,IAAI;IAEhB,MAAM,KAA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E,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAJD,kFAIC;AAED;;;;;;;;;GASG;AACH,QAAQ,CAAC,CAAC,6BAA6B,CACrC,OAAe,EACf,QAA8B,EAC9B,SAAS,GAAG,IAAI;IAEhB,6CAA6C;IAC7C,MAAM,IAAA,aAAG,EAAC,IAAA,gBAAQ,EAAC,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sCAAsC,CACpD,OAAwB;IAExB,OAAO,KAAK,EAAE,GAAG,IAAsD,EAAE,EAAE;QACzE,OAAO,CAAC,6BAA6B,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAND,wFAMC;AAED;;;;;;;;GAQG;AACH,QAAQ,CAAC,CAAC,4BAA4B,CACpC,OAAe,EACf,SAAS,GAAG,IAAI;IAEhB,MAAM,IAAA,aAAG,EAAC,IAAA,kBAAU,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qCAAqC,CACnD,OAAwB;IAExB,OAAO,KAAK,EAAE,GAAG,IAAqD,EAAE,EAAE;QACxE,OAAO,CAAC,4BAA4B,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC;AAND,sFAMC","sourcesContent":["import { parseJson } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, select } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { clearState, getState, setState } from '../../store';\n\n/**\n * Get the Snap state from the store.\n *\n * @param _snapId - The ID of the Snap to get the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @returns The state of the Snap.\n * @yields Selects the state from the store.\n */\nfunction* getSnapStateImplementation(\n _snapId: string,\n encrypted = true,\n): SagaIterator<string> {\n const state = yield select(getState(encrypted));\n // TODO: Use actual decryption implementation\n return parseJson(state);\n}\n\n/**\n * Get the implementation of the `getSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `getSnapState` hook.\n */\nexport function getGetSnapStateMethodImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof getSnapStateImplementation>) => {\n return runSaga(getSnapStateImplementation, ...args).result();\n };\n}\n\n/**\n * Update the Snap state in the store.\n *\n * @param _snapId - The ID of the Snap to update the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @yields Puts the new state in the store.\n */\nfunction* updateSnapStateImplementation(\n _snapId: string,\n newState: Record<string, Json>,\n encrypted = true,\n): SagaIterator<void> {\n // TODO: Use actual encryption implementation\n yield put(setState({ state: JSON.stringify(newState), encrypted }));\n}\n\n/**\n * Get the implementation of the `updateSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `updateSnapState` hook.\n */\nexport function getUpdateSnapStateMethodImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (...args: Parameters<typeof updateSnapStateImplementation>) => {\n runSaga(updateSnapStateImplementation, ...args).result();\n };\n}\n\n/**\n * Clear the Snap state in the store.\n *\n * @param _snapId - The ID of the Snap to clear the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @yields Puts the new state in the store.\n */\nfunction* clearSnapStateImplementation(\n _snapId: string,\n encrypted = true,\n): SagaIterator<void> {\n yield put(clearState({ encrypted }));\n}\n\n/**\n * Get the implementation of the `clearSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `clearSnapState` hook.\n */\nexport function getClearSnapStateMethodImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (...args: Parameters<typeof clearSnapStateImplementation>) => {\n runSaga(clearSnapStateImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export declare function getGetSnapStateMethodImplementation(runSaga: RunSagaFunc
|
|
|
13
13
|
* @param runSaga - The function to run a saga outside the usual Redux flow.
|
|
14
14
|
* @returns The implementation of the `updateSnapState` hook.
|
|
15
15
|
*/
|
|
16
|
-
export declare function getUpdateSnapStateMethodImplementation(runSaga: RunSagaFunction): (_snapId: string, newState: Record<string, Json>, encrypted?: boolean | undefined) => void
|
|
16
|
+
export declare function getUpdateSnapStateMethodImplementation(runSaga: RunSagaFunction): (_snapId: string, newState: Record<string, Json>, encrypted?: boolean | undefined) => Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Get the implementation of the `clearSnapState` hook.
|
|
19
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAsBnD;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,eAAe,6DAI3E;AAqBD;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"state.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAsBnD;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,eAAe,6DAI3E;AAqBD;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,eAAe,uGAKzB;AAkBD;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,eAAe,uEAKzB"}
|
|
@@ -13,7 +13,7 @@ export declare function getGetSnapStateMethodImplementation(runSaga: RunSagaFunc
|
|
|
13
13
|
* @param runSaga - The function to run a saga outside the usual Redux flow.
|
|
14
14
|
* @returns The implementation of the `updateSnapState` hook.
|
|
15
15
|
*/
|
|
16
|
-
export declare function getUpdateSnapStateMethodImplementation(runSaga: RunSagaFunction): (_snapId: string, newState: Record<string, Json>, encrypted?: boolean | undefined) => void
|
|
16
|
+
export declare function getUpdateSnapStateMethodImplementation(runSaga: RunSagaFunction): (_snapId: string, newState: Record<string, Json>, encrypted?: boolean | undefined) => Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Get the implementation of the `clearSnapState` hook.
|
|
19
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAsBnD;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,eAAe,6DAI3E;AAqBD;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"state.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAsBnD;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,eAAe,6DAI3E;AAqBD;;;;;GAKG;AACH,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,eAAe,uGAKzB;AAkBD;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,eAAe,uEAKzB"}
|
|
@@ -48,7 +48,7 @@ function* updateSnapStateImplementation(_snapId, newState, encrypted = true) {
|
|
|
48
48
|
* @returns The implementation of the `updateSnapState` hook.
|
|
49
49
|
*/
|
|
50
50
|
export function getUpdateSnapStateMethodImplementation(runSaga) {
|
|
51
|
-
return (...args) => {
|
|
51
|
+
return async (...args) => {
|
|
52
52
|
runSaga(updateSnapStateImplementation, ...args).result();
|
|
53
53
|
};
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,8BAA8B;AAGlD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,2BAA2B;AAGjD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAAoB;AAE7D;;;;;;;;;GASG;AACH,QAAQ,CAAC,CAAC,0BAA0B,CAClC,OAAe,EACf,SAAS,GAAG,IAAI;IAEhB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IAChD,6CAA6C;IAC7C,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CAAC,OAAwB;IAC1E,OAAO,CAAC,GAAG,IAAmD,EAAE,EAAE;QAChE,OAAO,OAAO,CAAC,0BAA0B,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,QAAQ,CAAC,CAAC,6BAA6B,CACrC,OAAe,EACf,QAA8B,EAC9B,SAAS,GAAG,IAAI;IAEhB,6CAA6C;IAC7C,MAAM,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,C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AC,CAAC,MAAM,EAAE,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,QAAQ,CAAC,CAAC,4BAA4B,CACpC,OAAe,EACf,SAAS,GAAG,IAAI;IAEhB,MAAM,GAAG,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qCAAqC,CACnD,OAAwB;IAExB,OAAO,KAAK,EAAE,GAAG,IAAqD,EAAE,EAAE;QACxE,OAAO,CAAC,4BAA4B,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { parseJson } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport type { SagaIterator } from 'redux-saga';\nimport { put, select } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { clearState, getState, setState } from '../../store';\n\n/**\n * Get the Snap state from the store.\n *\n * @param _snapId - The ID of the Snap to get the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param encrypted - Whether to get the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @returns The state of the Snap.\n * @yields Selects the state from the store.\n */\nfunction* getSnapStateImplementation(\n _snapId: string,\n encrypted = true,\n): SagaIterator<string> {\n const state = yield select(getState(encrypted));\n // TODO: Use actual decryption implementation\n return parseJson(state);\n}\n\n/**\n * Get the implementation of the `getSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `getSnapState` hook.\n */\nexport function getGetSnapStateMethodImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof getSnapStateImplementation>) => {\n return runSaga(getSnapStateImplementation, ...args).result();\n };\n}\n\n/**\n * Update the Snap state in the store.\n *\n * @param _snapId - The ID of the Snap to update the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param newState - The new state.\n * @param encrypted - Whether to update the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @yields Puts the new state in the store.\n */\nfunction* updateSnapStateImplementation(\n _snapId: string,\n newState: Record<string, Json>,\n encrypted = true,\n): SagaIterator<void> {\n // TODO: Use actual encryption implementation\n yield put(setState({ state: JSON.stringify(newState), encrypted }));\n}\n\n/**\n * Get the implementation of the `updateSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `updateSnapState` hook.\n */\nexport function getUpdateSnapStateMethodImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (...args: Parameters<typeof updateSnapStateImplementation>) => {\n runSaga(updateSnapStateImplementation, ...args).result();\n };\n}\n\n/**\n * Clear the Snap state in the store.\n *\n * @param _snapId - The ID of the Snap to clear the state for. This is ignored\n * because the simulator only supports one Snap.\n * @param encrypted - Whether to clear the encrypted or unencrypted state.\n * Defaults to encrypted state.\n * @yields Puts the new state in the store.\n */\nfunction* clearSnapStateImplementation(\n _snapId: string,\n encrypted = true,\n): SagaIterator<void> {\n yield put(clearState({ encrypted }));\n}\n\n/**\n * Get the implementation of the `clearSnapState` hook.\n *\n * @param runSaga - The function to run a saga outside the usual Redux flow.\n * @returns The implementation of the `clearSnapState` hook.\n */\nexport function getClearSnapStateMethodImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (...args: Parameters<typeof clearSnapStateImplementation>) => {\n runSaga(clearSnapStateImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -33,34 +33,25 @@ exports.asyncResolve = asyncResolve;
|
|
|
33
33
|
* @param options - The options.
|
|
34
34
|
* @param options.controllerMessenger - The controller messenger.
|
|
35
35
|
* @param options.hooks - The hooks.
|
|
36
|
-
* @param options.runSaga - The function to run a saga outside the usual Redux
|
|
37
|
-
* flow.
|
|
38
36
|
* @param options.options - The simulation options.
|
|
39
37
|
* @returns The permission specifications for the Snap.
|
|
40
38
|
*/
|
|
41
|
-
function getPermissionSpecifications({ controllerMessenger, hooks,
|
|
39
|
+
function getPermissionSpecifications({ controllerMessenger, hooks, options, }) {
|
|
40
|
+
const { getClientCryptography } = hooks;
|
|
42
41
|
return {
|
|
43
42
|
[chain_agnostic_permission_1.caip25EndowmentBuilder.targetName]: chain_agnostic_permission_1.caip25EndowmentBuilder.specificationBuilder({}),
|
|
44
43
|
...(0, snaps_rpc_methods_1.buildSnapEndowmentSpecifications)(constants_1.EXCLUDED_SNAP_ENDOWMENTS),
|
|
45
44
|
...(0, snaps_rpc_methods_1.buildSnapRestrictedMethodSpecifications)(constants_1.EXCLUDED_SNAP_PERMISSIONS, {
|
|
46
45
|
// Shared hooks.
|
|
47
|
-
|
|
46
|
+
getClientCryptography,
|
|
48
47
|
// Snaps-specific hooks.
|
|
49
|
-
clearSnapState: (0, hooks_1.getClearSnapStateMethodImplementation)(runSaga),
|
|
50
48
|
getPreferences: (0, hooks_1.getGetPreferencesMethodImplementation)(options),
|
|
51
|
-
getSnapState: (0, hooks_1.getGetSnapStateMethodImplementation)(runSaga),
|
|
52
49
|
getUnlockPromise: asyncResolve(true),
|
|
50
|
+
getSnapKeyring: asyncResolve(null),
|
|
53
51
|
// TODO: Allow the user to specify the result of this function.
|
|
54
52
|
isOnPhishingList: resolve(false),
|
|
55
53
|
maybeUpdatePhishingList: asyncResolve(),
|
|
56
|
-
|
|
57
|
-
showInAppNotification: (0, hooks_1.getShowInAppNotificationImplementation)(runSaga),
|
|
58
|
-
showNativeNotification: (0, hooks_1.getShowNativeNotificationImplementation)(runSaga),
|
|
59
|
-
updateSnapState: (0, hooks_1.getUpdateSnapStateMethodImplementation)(runSaga),
|
|
60
|
-
createInterface: (0, hooks_1.getCreateInterfaceImplementation)(controllerMessenger),
|
|
61
|
-
getInterface: (0, hooks_1.getGetInterfaceImplementation)(controllerMessenger),
|
|
62
|
-
setInterfaceDisplayed: (0, hooks_1.getSetInterfaceDisplayedImplementation)(controllerMessenger),
|
|
63
|
-
}),
|
|
54
|
+
}, controllerMessenger),
|
|
64
55
|
};
|
|
65
56
|
}
|
|
66
57
|
exports.getPermissionSpecifications = getPermissionSpecifications;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specifications.cjs","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":";;;AAAA,mFAA6E;
|
|
1
|
+
{"version":3,"file":"specifications.cjs","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":";;;AAAA,mFAA6E;AAQ7E,mEAIqC;AAErC,uDAA2D;AAE3D,+CAGqB;AACrB,6CAAgE;AAoBhE;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,MAAe;IACrC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC;AACtB,CAAC;AAFD,0BAEC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAO,MAAa;IAC9C,OAAO,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC;AAC5B,CAAC;AAFD,oCAEC;AAED;;;;;;;;GAQG;AACH,SAAgB,2BAA2B,CAAC,EAC1C,mBAAmB,EACnB,KAAK,EACL,OAAO,GAC4B;IACnC,MAAM,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IACxC,OAAO;QACL,CAAC,kDAAsB,CAAC,UAAU,CAAC,EACjC,kDAAsB,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACjD,GAAG,IAAA,oDAAgC,EAAC,oCAAwB,CAAC;QAC7D,GAAG,IAAA,2DAAuC,EACxC,qCAAyB,EACzB;YACE,gBAAgB;YAChB,qBAAqB;YAErB,wBAAwB;YACxB,cAAc,EAAE,IAAA,6CAAqC,EAAC,OAAO,CAAC;YAC9D,gBAAgB,EAAE,YAAY,CAAC,IAAI,CAAC;YACpC,cAAc,EAAE,YAAY,CAAC,IAAI,CAAC;YAElC,+DAA+D;YAC/D,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC;YAEhC,uBAAuB,EAAE,YAAY,EAAE;SACxC,EACD,mBAAgD,CACjD;KACF,CAAC;AACJ,CAAC;AA7BD,kEA6BC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CACjC,oBAAiD,EACjD,MAAc;IAEd,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,+CAA2B,CAAC,CAAC,MAAM,CAEzE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;QAClC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC;QAClC,IAAI,oBAAoB,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;YAC/D,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,aAAa,CACzD,MAAM,EACN,cAAc,CACf,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,WAAW,CAAC,MAAM,CAAC,UAAsB,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,gCAAkB,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAvBD,sCAuBC","sourcesContent":["import { caip25EndowmentBuilder } from '@metamask/chain-agnostic-permission';\nimport type { CryptographicFunctions } from '@metamask/key-tree';\nimport type {\n GenericPermissionController,\n PermissionSpecificationConstraint,\n PermissionSpecificationMap,\n} from '@metamask/permission-controller';\nimport type { RestrictedMethodMessenger } from '@metamask/snaps-rpc-methods';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport { getGetPreferencesMethodImplementation } from './hooks';\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * Get the cryptographic functions to use for the client. This may return an\n * empty object to fall back to the default cryptographic functions.\n *\n * @returns The cryptographic functions to use for the client.\n */\n getClientCryptography: () => CryptographicFunctions;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve<Type>(result?: Type) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n options,\n}: GetPermissionSpecificationsOptions): PermissionSpecificationMap<PermissionSpecificationConstraint> {\n const { getClientCryptography } = hooks;\n return {\n [caip25EndowmentBuilder.targetName]:\n caip25EndowmentBuilder.specificationBuilder({}),\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(\n EXCLUDED_SNAP_PERMISSIONS,\n {\n // Shared hooks.\n getClientCryptography,\n\n // Snaps-specific hooks.\n getPreferences: getGetPreferencesMethodImplementation(options),\n getUnlockPromise: asyncResolve(true),\n getSnapKeyring: asyncResolve(null),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n },\n controllerMessenger as RestrictedMethodMessenger,\n ),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"]}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CryptographicFunctions } from "@metamask/key-tree";
|
|
2
|
+
import type { GenericPermissionController, PermissionSpecificationConstraint, PermissionSpecificationMap } from "@metamask/permission-controller";
|
|
2
3
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
3
4
|
import type { RootControllerMessenger } from "../controllers.cjs";
|
|
4
5
|
import type { SimulationOptions } from "../options.cjs";
|
|
5
|
-
import type { RunSagaFunction } from "../store/index.cjs";
|
|
6
6
|
export type PermissionSpecificationsHooks = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Get the cryptographic functions to use for the client. This may return an
|
|
9
|
+
* empty object to fall back to the default cryptographic functions.
|
|
9
10
|
*
|
|
10
|
-
* @returns The
|
|
11
|
+
* @returns The cryptographic functions to use for the client.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
getClientCryptography: () => CryptographicFunctions;
|
|
13
14
|
};
|
|
14
15
|
export type GetPermissionSpecificationsOptions = {
|
|
15
16
|
controllerMessenger: RootControllerMessenger;
|
|
16
17
|
hooks: PermissionSpecificationsHooks;
|
|
17
|
-
runSaga: RunSagaFunction;
|
|
18
18
|
options: SimulationOptions;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
@@ -38,20 +38,10 @@ export declare function asyncResolve<Type>(result?: Type): () => Promise<Type |
|
|
|
38
38
|
* @param options - The options.
|
|
39
39
|
* @param options.controllerMessenger - The controller messenger.
|
|
40
40
|
* @param options.hooks - The hooks.
|
|
41
|
-
* @param options.runSaga - The function to run a saga outside the usual Redux
|
|
42
|
-
* flow.
|
|
43
41
|
* @param options.options - The simulation options.
|
|
44
42
|
* @returns The permission specifications for the Snap.
|
|
45
43
|
*/
|
|
46
|
-
export declare function getPermissionSpecifications({ controllerMessenger, hooks,
|
|
47
|
-
"endowment:caip25": {
|
|
48
|
-
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
49
|
-
targetName: "endowment:caip25";
|
|
50
|
-
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => null;
|
|
51
|
-
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
52
|
-
allowedCaveats: readonly [string, ...string[]] | null;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
44
|
+
export declare function getPermissionSpecifications({ controllerMessenger, hooks, options, }: GetPermissionSpecificationsOptions): PermissionSpecificationMap<PermissionSpecificationConstraint>;
|
|
55
45
|
/**
|
|
56
46
|
* Get the endowments for the Snap.
|
|
57
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specifications.d.cts","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"specifications.d.cts","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC3B,wCAAwC;AAOzC,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAQlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,2BAAuB;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;;;OAKG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,KAAK,EAAE,6BAA6B,CAAC;IACrC,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,iBAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,mCAE/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,mBAAmB,EACnB,KAAK,EACL,OAAO,GACR,EAAE,kCAAkC,GAAG,0BAA0B,CAAC,iCAAiC,CAAC,CAyBpG;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,oBAAoB,EAAE,2BAA2B,EACjD,MAAM,EAAE,MAAM,qBAqBf"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CryptographicFunctions } from "@metamask/key-tree";
|
|
2
|
+
import type { GenericPermissionController, PermissionSpecificationConstraint, PermissionSpecificationMap } from "@metamask/permission-controller";
|
|
2
3
|
import type { SnapId } from "@metamask/snaps-sdk";
|
|
3
4
|
import type { RootControllerMessenger } from "../controllers.mjs";
|
|
4
5
|
import type { SimulationOptions } from "../options.mjs";
|
|
5
|
-
import type { RunSagaFunction } from "../store/index.mjs";
|
|
6
6
|
export type PermissionSpecificationsHooks = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Get the cryptographic functions to use for the client. This may return an
|
|
9
|
+
* empty object to fall back to the default cryptographic functions.
|
|
9
10
|
*
|
|
10
|
-
* @returns The
|
|
11
|
+
* @returns The cryptographic functions to use for the client.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
getClientCryptography: () => CryptographicFunctions;
|
|
13
14
|
};
|
|
14
15
|
export type GetPermissionSpecificationsOptions = {
|
|
15
16
|
controllerMessenger: RootControllerMessenger;
|
|
16
17
|
hooks: PermissionSpecificationsHooks;
|
|
17
|
-
runSaga: RunSagaFunction;
|
|
18
18
|
options: SimulationOptions;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
@@ -38,20 +38,10 @@ export declare function asyncResolve<Type>(result?: Type): () => Promise<Type |
|
|
|
38
38
|
* @param options - The options.
|
|
39
39
|
* @param options.controllerMessenger - The controller messenger.
|
|
40
40
|
* @param options.hooks - The hooks.
|
|
41
|
-
* @param options.runSaga - The function to run a saga outside the usual Redux
|
|
42
|
-
* flow.
|
|
43
41
|
* @param options.options - The simulation options.
|
|
44
42
|
* @returns The permission specifications for the Snap.
|
|
45
43
|
*/
|
|
46
|
-
export declare function getPermissionSpecifications({ controllerMessenger, hooks,
|
|
47
|
-
"endowment:caip25": {
|
|
48
|
-
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
49
|
-
targetName: "endowment:caip25";
|
|
50
|
-
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => null;
|
|
51
|
-
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
52
|
-
allowedCaveats: readonly [string, ...string[]] | null;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
44
|
+
export declare function getPermissionSpecifications({ controllerMessenger, hooks, options, }: GetPermissionSpecificationsOptions): PermissionSpecificationMap<PermissionSpecificationConstraint>;
|
|
55
45
|
/**
|
|
56
46
|
* Get the endowments for the Snap.
|
|
57
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specifications.d.mts","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"specifications.d.mts","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B;AACjE,OAAO,KAAK,EACV,2BAA2B,EAC3B,iCAAiC,EACjC,0BAA0B,EAC3B,wCAAwC;AAOzC,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAQlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,2BAAuB;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;;;;OAKG;IACH,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,KAAK,EAAE,6BAA6B,CAAC;IACrC,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,iBAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,mCAE/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,mBAAmB,EACnB,KAAK,EACL,OAAO,GACR,EAAE,kCAAkC,GAAG,0BAA0B,CAAC,iCAAiC,CAAC,CAyBpG;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,oBAAoB,EAAE,2BAA2B,EACjD,MAAM,EAAE,MAAM,qBAqBf"}
|