@metamask/snaps-controllers 18.0.4 → 19.0.1
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 +108 -1
- package/dist/cronjob/CronjobController-method-action-types.cjs +7 -0
- package/dist/cronjob/CronjobController-method-action-types.cjs.map +1 -0
- package/dist/cronjob/CronjobController-method-action-types.d.cts +51 -0
- package/dist/cronjob/CronjobController-method-action-types.d.cts.map +1 -0
- package/dist/cronjob/CronjobController-method-action-types.d.mts +51 -0
- package/dist/cronjob/CronjobController-method-action-types.d.mts.map +1 -0
- package/dist/cronjob/CronjobController-method-action-types.mjs +6 -0
- package/dist/cronjob/CronjobController-method-action-types.mjs.map +1 -0
- package/dist/cronjob/CronjobController.cjs +7 -4
- package/dist/cronjob/CronjobController.cjs.map +1 -1
- package/dist/cronjob/CronjobController.d.cts +8 -25
- package/dist/cronjob/CronjobController.d.cts.map +1 -1
- package/dist/cronjob/CronjobController.d.mts +8 -25
- package/dist/cronjob/CronjobController.d.mts.map +1 -1
- package/dist/cronjob/CronjobController.mjs +7 -4
- package/dist/cronjob/CronjobController.mjs.map +1 -1
- package/dist/cronjob/index.cjs +3 -15
- package/dist/cronjob/index.cjs.map +1 -1
- package/dist/cronjob/index.d.cts +3 -1
- package/dist/cronjob/index.d.cts.map +1 -1
- package/dist/cronjob/index.d.mts +3 -1
- package/dist/cronjob/index.d.mts.map +1 -1
- package/dist/cronjob/index.mjs +1 -1
- package/dist/cronjob/index.mjs.map +1 -1
- package/dist/insights/SnapInsightsController.cjs +1 -3
- package/dist/insights/SnapInsightsController.cjs.map +1 -1
- package/dist/insights/SnapInsightsController.d.cts +9 -9
- package/dist/insights/SnapInsightsController.d.cts.map +1 -1
- package/dist/insights/SnapInsightsController.d.mts +9 -9
- package/dist/insights/SnapInsightsController.d.mts.map +1 -1
- package/dist/insights/SnapInsightsController.mjs +1 -3
- package/dist/insights/SnapInsightsController.mjs.map +1 -1
- package/dist/insights/index.cjs +3 -15
- package/dist/insights/index.cjs.map +1 -1
- package/dist/insights/index.d.cts +2 -1
- package/dist/insights/index.d.cts.map +1 -1
- package/dist/insights/index.d.mts +2 -1
- package/dist/insights/index.d.mts.map +1 -1
- package/dist/insights/index.mjs +1 -1
- package/dist/insights/index.mjs.map +1 -1
- package/dist/interface/SnapInterfaceController-method-action-types.cjs +7 -0
- package/dist/interface/SnapInterfaceController-method-action-types.cjs.map +1 -0
- package/dist/interface/SnapInterfaceController-method-action-types.d.cts +99 -0
- package/dist/interface/SnapInterfaceController-method-action-types.d.cts.map +1 -0
- package/dist/interface/SnapInterfaceController-method-action-types.d.mts +99 -0
- package/dist/interface/SnapInterfaceController-method-action-types.d.mts.map +1 -0
- package/dist/interface/SnapInterfaceController-method-action-types.mjs +6 -0
- package/dist/interface/SnapInterfaceController-method-action-types.mjs.map +1 -0
- package/dist/interface/SnapInterfaceController.cjs +12 -16
- package/dist/interface/SnapInterfaceController.cjs.map +1 -1
- package/dist/interface/SnapInterfaceController.d.cts +10 -40
- package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
- package/dist/interface/SnapInterfaceController.d.mts +10 -40
- package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
- package/dist/interface/SnapInterfaceController.mjs +12 -16
- package/dist/interface/SnapInterfaceController.mjs.map +1 -1
- package/dist/interface/index.cjs +3 -15
- package/dist/interface/index.cjs.map +1 -1
- package/dist/interface/index.d.cts +3 -1
- package/dist/interface/index.d.cts.map +1 -1
- package/dist/interface/index.d.mts +3 -1
- package/dist/interface/index.d.mts.map +1 -1
- package/dist/interface/index.mjs +1 -1
- package/dist/interface/index.mjs.map +1 -1
- package/dist/multichain/MultichainRoutingService-method-action-types.cjs +7 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.cjs.map +1 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.d.cts +61 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.d.cts.map +1 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.d.mts +61 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.d.mts.map +1 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.mjs +6 -0
- package/dist/multichain/MultichainRoutingService-method-action-types.mjs.map +1 -0
- package/dist/multichain/{MultichainRouter.cjs → MultichainRoutingService.cjs} +14 -13
- package/dist/multichain/MultichainRoutingService.cjs.map +1 -0
- package/dist/multichain/{MultichainRouter.d.mts → MultichainRoutingService.d.cts} +14 -29
- package/dist/multichain/MultichainRoutingService.d.cts.map +1 -0
- package/dist/multichain/{MultichainRouter.d.cts → MultichainRoutingService.d.mts} +14 -29
- package/dist/multichain/MultichainRoutingService.d.mts.map +1 -0
- package/dist/multichain/{MultichainRouter.mjs → MultichainRoutingService.mjs} +12 -11
- package/dist/multichain/MultichainRoutingService.mjs.map +1 -0
- package/dist/multichain/index.cjs +3 -15
- package/dist/multichain/index.cjs.map +1 -1
- package/dist/multichain/index.d.cts +3 -1
- package/dist/multichain/index.d.cts.map +1 -1
- package/dist/multichain/index.d.mts +3 -1
- package/dist/multichain/index.d.mts.map +1 -1
- package/dist/multichain/index.mjs +1 -1
- package/dist/multichain/index.mjs.map +1 -1
- package/dist/services/ExecutionService-method-action-types.cjs +7 -0
- package/dist/services/ExecutionService-method-action-types.cjs.map +1 -0
- package/dist/services/ExecutionService-method-action-types.d.cts +50 -0
- package/dist/services/ExecutionService-method-action-types.d.cts.map +1 -0
- package/dist/services/ExecutionService-method-action-types.d.mts +50 -0
- package/dist/services/ExecutionService-method-action-types.d.mts.map +1 -0
- package/dist/services/ExecutionService-method-action-types.mjs +6 -0
- package/dist/services/ExecutionService-method-action-types.mjs.map +1 -0
- package/dist/services/ExecutionService.cjs +287 -0
- package/dist/services/ExecutionService.cjs.map +1 -1
- package/dist/services/ExecutionService.d.cts +100 -46
- package/dist/services/ExecutionService.d.cts.map +1 -1
- package/dist/services/ExecutionService.d.mts +100 -46
- package/dist/services/ExecutionService.d.mts.map +1 -1
- package/dist/services/ExecutionService.mjs +285 -1
- package/dist/services/ExecutionService.mjs.map +1 -1
- package/dist/services/browser.cjs +5 -2
- package/dist/services/browser.cjs.map +1 -1
- package/dist/services/browser.d.cts +4 -2
- package/dist/services/browser.d.cts.map +1 -1
- package/dist/services/browser.d.mts +4 -2
- package/dist/services/browser.d.mts.map +1 -1
- package/dist/services/browser.mjs +2 -2
- package/dist/services/browser.mjs.map +1 -1
- package/dist/services/iframe/IframeExecutionService.cjs +2 -2
- package/dist/services/iframe/IframeExecutionService.cjs.map +1 -1
- package/dist/services/iframe/IframeExecutionService.d.cts +3 -3
- package/dist/services/iframe/IframeExecutionService.d.cts.map +1 -1
- package/dist/services/iframe/IframeExecutionService.d.mts +3 -3
- package/dist/services/iframe/IframeExecutionService.d.mts.map +1 -1
- package/dist/services/iframe/IframeExecutionService.mjs +2 -2
- package/dist/services/iframe/IframeExecutionService.mjs.map +1 -1
- package/dist/services/index.cjs +5 -1
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +4 -2
- package/dist/services/index.d.cts.map +1 -1
- package/dist/services/index.d.mts +4 -2
- package/dist/services/index.d.mts.map +1 -1
- package/dist/services/index.mjs +2 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/services/multiplex.cjs +27 -0
- package/dist/services/multiplex.cjs.map +1 -0
- package/dist/services/multiplex.d.cts +11 -0
- package/dist/services/multiplex.d.cts.map +1 -0
- package/dist/services/multiplex.d.mts +11 -0
- package/dist/services/multiplex.d.mts.map +1 -0
- package/dist/services/multiplex.mjs +27 -0
- package/dist/services/multiplex.mjs.map +1 -0
- package/dist/services/node-js/NodeProcessExecutionService.cjs +2 -2
- package/dist/services/node-js/NodeProcessExecutionService.cjs.map +1 -1
- package/dist/services/node-js/NodeProcessExecutionService.d.cts +3 -3
- package/dist/services/node-js/NodeProcessExecutionService.d.cts.map +1 -1
- package/dist/services/node-js/NodeProcessExecutionService.d.mts +3 -3
- package/dist/services/node-js/NodeProcessExecutionService.d.mts.map +1 -1
- package/dist/services/node-js/NodeProcessExecutionService.mjs +2 -2
- package/dist/services/node-js/NodeProcessExecutionService.mjs.map +1 -1
- package/dist/services/node-js/NodeThreadExecutionService.cjs +2 -5
- package/dist/services/node-js/NodeThreadExecutionService.cjs.map +1 -1
- package/dist/services/node-js/NodeThreadExecutionService.d.cts +3 -3
- package/dist/services/node-js/NodeThreadExecutionService.d.cts.map +1 -1
- package/dist/services/node-js/NodeThreadExecutionService.d.mts +3 -3
- package/dist/services/node-js/NodeThreadExecutionService.d.mts.map +1 -1
- package/dist/services/node-js/NodeThreadExecutionService.mjs +2 -5
- package/dist/services/node-js/NodeThreadExecutionService.mjs.map +1 -1
- package/dist/services/offscreen/OffscreenExecutionService.cjs.map +1 -1
- package/dist/services/offscreen/OffscreenExecutionService.d.cts +1 -1
- package/dist/services/offscreen/OffscreenExecutionService.d.cts.map +1 -1
- package/dist/services/offscreen/OffscreenExecutionService.d.mts +1 -1
- package/dist/services/offscreen/OffscreenExecutionService.d.mts.map +1 -1
- package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -1
- package/dist/services/proxy/ProxyExecutionService.cjs +2 -5
- package/dist/services/proxy/ProxyExecutionService.cjs.map +1 -1
- package/dist/services/proxy/ProxyExecutionService.d.cts +3 -3
- package/dist/services/proxy/ProxyExecutionService.d.cts.map +1 -1
- package/dist/services/proxy/ProxyExecutionService.d.mts +3 -3
- package/dist/services/proxy/ProxyExecutionService.d.mts.map +1 -1
- package/dist/services/proxy/ProxyExecutionService.mjs +2 -5
- package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -1
- package/dist/services/webview/WebViewExecutionService.cjs +2 -2
- package/dist/services/webview/WebViewExecutionService.cjs.map +1 -1
- package/dist/services/webview/WebViewExecutionService.d.cts +3 -3
- package/dist/services/webview/WebViewExecutionService.d.cts.map +1 -1
- package/dist/services/webview/WebViewExecutionService.d.mts +3 -3
- package/dist/services/webview/WebViewExecutionService.d.mts.map +1 -1
- package/dist/services/webview/WebViewExecutionService.mjs +2 -2
- package/dist/services/webview/WebViewExecutionService.mjs.map +1 -1
- package/dist/snaps/SnapController-method-action-types.cjs +7 -0
- package/dist/snaps/SnapController-method-action-types.cjs.map +1 -0
- package/dist/snaps/SnapController-method-action-types.d.cts +284 -0
- package/dist/snaps/SnapController-method-action-types.d.cts.map +1 -0
- package/dist/snaps/SnapController-method-action-types.d.mts +284 -0
- package/dist/snaps/SnapController-method-action-types.d.mts.map +1 -0
- package/dist/snaps/SnapController-method-action-types.mjs +6 -0
- package/dist/snaps/SnapController-method-action-types.mjs.map +1 -0
- package/dist/snaps/SnapController.cjs +118 -113
- package/dist/snaps/SnapController.cjs.map +1 -1
- package/dist/snaps/SnapController.d.cts +33 -190
- package/dist/snaps/SnapController.d.cts.map +1 -1
- package/dist/snaps/SnapController.d.mts +33 -190
- package/dist/snaps/SnapController.d.mts.map +1 -1
- package/dist/snaps/SnapController.mjs +119 -114
- package/dist/snaps/SnapController.mjs.map +1 -1
- package/dist/snaps/index.cjs +3 -1
- package/dist/snaps/index.cjs.map +1 -1
- package/dist/snaps/index.d.cts +3 -1
- package/dist/snaps/index.d.cts.map +1 -1
- package/dist/snaps/index.d.mts +3 -1
- package/dist/snaps/index.d.mts.map +1 -1
- package/dist/snaps/index.mjs +1 -1
- package/dist/snaps/index.mjs.map +1 -1
- package/dist/snaps/registry/SnapRegistryController-method-action-types.cjs +7 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.cjs.map +1 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.d.cts +46 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.d.cts.map +1 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.d.mts +46 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.d.mts.map +1 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.mjs +6 -0
- package/dist/snaps/registry/SnapRegistryController-method-action-types.mjs.map +1 -0
- package/dist/snaps/registry/{json.cjs → SnapRegistryController.cjs} +27 -24
- package/dist/snaps/registry/SnapRegistryController.cjs.map +1 -0
- package/dist/snaps/registry/SnapRegistryController.d.cts +67 -0
- package/dist/snaps/registry/SnapRegistryController.d.cts.map +1 -0
- package/dist/snaps/registry/SnapRegistryController.d.mts +67 -0
- package/dist/snaps/registry/SnapRegistryController.d.mts.map +1 -0
- package/dist/snaps/registry/{json.mjs → SnapRegistryController.mjs} +25 -22
- package/dist/snaps/registry/SnapRegistryController.mjs.map +1 -0
- package/dist/snaps/registry/index.cjs +5 -16
- package/dist/snaps/registry/index.cjs.map +1 -1
- package/dist/snaps/registry/index.d.cts +5 -2
- package/dist/snaps/registry/index.d.cts.map +1 -1
- package/dist/snaps/registry/index.d.mts +5 -2
- package/dist/snaps/registry/index.d.mts.map +1 -1
- package/dist/snaps/registry/index.mjs +2 -2
- package/dist/snaps/registry/index.mjs.map +1 -1
- package/dist/snaps/registry/types.cjs +11 -0
- package/dist/snaps/registry/types.cjs.map +1 -0
- package/dist/snaps/registry/types.d.cts +20 -0
- package/dist/snaps/registry/types.d.cts.map +1 -0
- package/dist/snaps/registry/types.d.mts +20 -0
- package/dist/snaps/registry/types.d.mts.map +1 -0
- package/dist/snaps/registry/types.mjs +8 -0
- package/dist/snaps/registry/types.mjs.map +1 -0
- package/dist/types/controllers.cjs.map +1 -1
- package/dist/types/controllers.d.cts +1 -1
- package/dist/types/controllers.d.cts.map +1 -1
- package/dist/types/controllers.d.mts +1 -1
- package/dist/types/controllers.d.mts.map +1 -1
- package/dist/types/controllers.mjs.map +1 -1
- package/dist/websocket/WebSocketService-method-action-types.cjs +7 -0
- package/dist/websocket/WebSocketService-method-action-types.cjs.map +1 -0
- package/dist/websocket/WebSocketService-method-action-types.d.cts +54 -0
- package/dist/websocket/WebSocketService-method-action-types.d.cts.map +1 -0
- package/dist/websocket/WebSocketService-method-action-types.d.mts +54 -0
- package/dist/websocket/WebSocketService-method-action-types.d.mts.map +1 -0
- package/dist/websocket/WebSocketService-method-action-types.mjs +6 -0
- package/dist/websocket/WebSocketService-method-action-types.mjs.map +1 -0
- package/dist/websocket/WebSocketService.cjs +14 -11
- package/dist/websocket/WebSocketService.cjs.map +1 -1
- package/dist/websocket/WebSocketService.d.cts +43 -22
- package/dist/websocket/WebSocketService.d.cts.map +1 -1
- package/dist/websocket/WebSocketService.d.mts +43 -22
- package/dist/websocket/WebSocketService.d.mts.map +1 -1
- package/dist/websocket/WebSocketService.mjs +14 -11
- package/dist/websocket/WebSocketService.mjs.map +1 -1
- package/dist/websocket/index.cjs +3 -15
- package/dist/websocket/index.cjs.map +1 -1
- package/dist/websocket/index.d.cts +3 -1
- package/dist/websocket/index.d.cts.map +1 -1
- package/dist/websocket/index.d.mts +3 -1
- package/dist/websocket/index.d.mts.map +1 -1
- package/dist/websocket/index.mjs +1 -1
- package/dist/websocket/index.mjs.map +1 -1
- package/package.json +12 -11
- package/dist/multichain/MultichainRouter.cjs.map +0 -1
- package/dist/multichain/MultichainRouter.d.cts.map +0 -1
- package/dist/multichain/MultichainRouter.d.mts.map +0 -1
- package/dist/multichain/MultichainRouter.mjs.map +0 -1
- package/dist/services/AbstractExecutionService.cjs +0 -314
- package/dist/services/AbstractExecutionService.cjs.map +0 -1
- package/dist/services/AbstractExecutionService.d.cts +0 -107
- package/dist/services/AbstractExecutionService.d.cts.map +0 -1
- package/dist/services/AbstractExecutionService.d.mts +0 -107
- package/dist/services/AbstractExecutionService.d.mts.map +0 -1
- package/dist/services/AbstractExecutionService.mjs +0 -313
- package/dist/services/AbstractExecutionService.mjs.map +0 -1
- package/dist/snaps/registry/json.cjs.map +0 -1
- package/dist/snaps/registry/json.d.cts +0 -58
- package/dist/snaps/registry/json.d.cts.map +0 -1
- package/dist/snaps/registry/json.d.mts +0 -58
- package/dist/snaps/registry/json.d.mts.map +0 -1
- package/dist/snaps/registry/json.mjs.map +0 -1
- package/dist/snaps/registry/registry.cjs +0 -11
- package/dist/snaps/registry/registry.cjs.map +0 -1
- package/dist/snaps/registry/registry.d.cts +0 -41
- package/dist/snaps/registry/registry.d.cts.map +0 -1
- package/dist/snaps/registry/registry.d.mts +0 -41
- package/dist/snaps/registry/registry.d.mts.map +0 -1
- package/dist/snaps/registry/registry.mjs +0 -8
- package/dist/snaps/registry/registry.mjs.map +0 -1
|
@@ -2,18 +2,24 @@ import { BaseController } from "@metamask/base-controller";
|
|
|
2
2
|
import { verify } from "@metamask/snaps-registry";
|
|
3
3
|
import { getTargetVersion } from "@metamask/snaps-utils";
|
|
4
4
|
import { assert, assertIsSemVerRange, Duration, inMilliseconds, satisfiesVersionRange } from "@metamask/utils";
|
|
5
|
-
import {
|
|
5
|
+
import { SnapRegistryStatus } from "./types.mjs";
|
|
6
6
|
const SNAP_REGISTRY_URL = 'https://acl.execution.metamask.io/latest/registry.json';
|
|
7
7
|
const SNAP_REGISTRY_SIGNATURE_URL = 'https://acl.execution.metamask.io/latest/signature.json';
|
|
8
8
|
const DEFAULT_PUBLIC_KEY = '0x025b65308f0f0fb8bc7f7ff87bfc296e0330eee5d3c1d1ee4a048b2fd6a86fa0a6';
|
|
9
|
-
const controllerName = '
|
|
9
|
+
const controllerName = 'SnapRegistryController';
|
|
10
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
11
|
+
'get',
|
|
12
|
+
'getMetadata',
|
|
13
|
+
'resolveVersion',
|
|
14
|
+
'requestUpdate',
|
|
15
|
+
];
|
|
10
16
|
const defaultState = {
|
|
11
17
|
database: null,
|
|
12
18
|
signature: null,
|
|
13
19
|
lastUpdated: null,
|
|
14
20
|
databaseUnavailable: false,
|
|
15
21
|
};
|
|
16
|
-
export class
|
|
22
|
+
export class SnapRegistryController extends BaseController {
|
|
17
23
|
#url;
|
|
18
24
|
#publicKey;
|
|
19
25
|
#clientConfig;
|
|
@@ -66,10 +72,7 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
66
72
|
this.#recentFetchThreshold = recentFetchThreshold;
|
|
67
73
|
this.#refetchOnAllowlistMiss = refetchOnAllowlistMiss;
|
|
68
74
|
this.#currentUpdate = null;
|
|
69
|
-
this.messenger.
|
|
70
|
-
this.messenger.registerActionHandler('SnapsRegistry:getMetadata', (...args) => this.#getMetadata(...args));
|
|
71
|
-
this.messenger.registerActionHandler('SnapsRegistry:resolveVersion', async (...args) => this.#resolveVersion(...args));
|
|
72
|
-
this.messenger.registerActionHandler('SnapsRegistry:update', async () => this.#triggerUpdate());
|
|
75
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
73
76
|
}
|
|
74
77
|
#wasRecentlyFetched() {
|
|
75
78
|
return (this.state.lastUpdated &&
|
|
@@ -80,7 +83,7 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
80
83
|
*
|
|
81
84
|
* If an existing update is in progress this function will await that update.
|
|
82
85
|
*/
|
|
83
|
-
async
|
|
86
|
+
async requestUpdate() {
|
|
84
87
|
// If an update is ongoing, wait for that.
|
|
85
88
|
if (this.#currentUpdate) {
|
|
86
89
|
await this.#currentUpdate;
|
|
@@ -134,7 +137,7 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
134
137
|
}
|
|
135
138
|
async #getDatabase() {
|
|
136
139
|
if (this.state.database === null) {
|
|
137
|
-
await this
|
|
140
|
+
await this.requestUpdate();
|
|
138
141
|
}
|
|
139
142
|
return this.state.database;
|
|
140
143
|
}
|
|
@@ -149,7 +152,7 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
149
152
|
});
|
|
150
153
|
if (blockedEntry) {
|
|
151
154
|
return {
|
|
152
|
-
status:
|
|
155
|
+
status: SnapRegistryStatus.Blocked,
|
|
153
156
|
reason: blockedEntry.reason,
|
|
154
157
|
};
|
|
155
158
|
}
|
|
@@ -159,20 +162,20 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
159
162
|
const isCompatible = !clientRange ||
|
|
160
163
|
satisfiesVersionRange(this.#clientConfig.version, clientRange);
|
|
161
164
|
if (version && version.checksum === snapInfo.checksum && isCompatible) {
|
|
162
|
-
return { status:
|
|
165
|
+
return { status: SnapRegistryStatus.Verified };
|
|
163
166
|
}
|
|
164
167
|
// For now, if we have an allowlist miss, we can refetch once and try again.
|
|
165
168
|
if (this.#refetchOnAllowlistMiss && !refetch) {
|
|
166
|
-
await this
|
|
169
|
+
await this.requestUpdate();
|
|
167
170
|
return this.#getSingle(snapId, snapInfo, true);
|
|
168
171
|
}
|
|
169
172
|
return {
|
|
170
173
|
status: this.state.databaseUnavailable
|
|
171
|
-
?
|
|
172
|
-
:
|
|
174
|
+
? SnapRegistryStatus.Unavailable
|
|
175
|
+
: SnapRegistryStatus.Unverified,
|
|
173
176
|
};
|
|
174
177
|
}
|
|
175
|
-
async
|
|
178
|
+
async get(snaps) {
|
|
176
179
|
return Object.entries(snaps).reduce(async (previousPromise, [snapId, snapInfo]) => {
|
|
177
180
|
const result = await this.#getSingle(snapId, snapInfo);
|
|
178
181
|
const acc = await previousPromise;
|
|
@@ -188,12 +191,12 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
188
191
|
* @param refetch - An optional flag used to determine if we are refetching the registry.
|
|
189
192
|
* @returns An allowlisted version within the specified version range if available otherwise returns the input version range.
|
|
190
193
|
*/
|
|
191
|
-
async
|
|
194
|
+
async resolveVersion(snapId, versionRange, refetch = false) {
|
|
192
195
|
const database = await this.#getDatabase();
|
|
193
196
|
const versions = database?.verifiedSnaps[snapId]?.versions ?? null;
|
|
194
197
|
if (!versions && this.#refetchOnAllowlistMiss && !refetch) {
|
|
195
|
-
await this
|
|
196
|
-
return this
|
|
198
|
+
await this.requestUpdate();
|
|
199
|
+
return this.resolveVersion(snapId, versionRange, true);
|
|
197
200
|
}
|
|
198
201
|
// If we cannot narrow down the version range we return the unaltered version range.
|
|
199
202
|
if (!versions) {
|
|
@@ -209,8 +212,8 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
209
212
|
}, []);
|
|
210
213
|
const targetVersion = getTargetVersion(compatibleVersions, versionRange);
|
|
211
214
|
if (!targetVersion && this.#refetchOnAllowlistMiss && !refetch) {
|
|
212
|
-
await this
|
|
213
|
-
return this
|
|
215
|
+
await this.requestUpdate();
|
|
216
|
+
return this.resolveVersion(snapId, versionRange, true);
|
|
214
217
|
}
|
|
215
218
|
// If we cannot narrow down the version range we return the unaltered version range.
|
|
216
219
|
if (!targetVersion) {
|
|
@@ -227,7 +230,7 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
227
230
|
* @returns The metadata for the given snap ID, or `null` if the snap is not
|
|
228
231
|
* verified.
|
|
229
232
|
*/
|
|
230
|
-
|
|
233
|
+
getMetadata(snapId) {
|
|
231
234
|
return this.state?.database?.verifiedSnaps[snapId]?.metadata ?? null;
|
|
232
235
|
}
|
|
233
236
|
/**
|
|
@@ -261,4 +264,4 @@ export class JsonSnapsRegistry extends BaseController {
|
|
|
261
264
|
return await response.text();
|
|
262
265
|
}
|
|
263
266
|
}
|
|
264
|
-
//# sourceMappingURL=
|
|
267
|
+
//# sourceMappingURL=SnapRegistryController.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapRegistryController.mjs","sourceRoot":"","sources":["../../../src/snaps/registry/SnapRegistryController.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAM3D,OAAO,EAAE,MAAM,EAAE,iCAAiC;AAClD,OAAO,EAAE,gBAAgB,EAAE,8BAA8B;AAGzD,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,QAAQ,EACR,cAAc,EACd,qBAAqB,EACtB,wBAAwB;AASzB,OAAO,EAAE,kBAAkB,EAAE,oBAAgB;AAE7C,MAAM,iBAAiB,GACrB,wDAAwD,CAAC;AAE3D,MAAM,2BAA2B,GAC/B,yDAAyD,CAAC;AAE5D,MAAM,kBAAkB,GACtB,sEAAsE,CAAC;AAqDzE,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEhD,MAAM,yBAAyB,GAAG;IAChC,KAAK;IACL,aAAa;IACb,gBAAgB;IAChB,eAAe;CACP,CAAC;AAEX,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IAAI,IAAI,CAAC;IACvE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CACpB,QAAgB,EAChB,SAAwC;QAExC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC;QAEnD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC;YACzB,QAAQ,EAAE,QAAQ;YAClB,SAAS;YACT,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,GAAW;QAC1B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,GAAG,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n SnapsRegistryDatabase,\n SignatureStruct,\n} from '@metamask/snaps-registry';\nimport { verify } from '@metamask/snaps-registry';\nimport { getTargetVersion } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Hex, SemVerRange, SemVerVersion } from '@metamask/utils';\nimport {\n assert,\n assertIsSemVerRange,\n Duration,\n inMilliseconds,\n satisfiesVersionRange,\n} from '@metamask/utils';\n\nimport type { SnapRegistryControllerMethodActions } from './SnapRegistryController-method-action-types';\nimport type {\n SnapRegistryInfo,\n SnapRegistryMetadata,\n SnapRegistryRequest,\n SnapRegistryResult,\n} from './types';\nimport { SnapRegistryStatus } from './types';\n\nconst SNAP_REGISTRY_URL =\n 'https://acl.execution.metamask.io/latest/registry.json';\n\nconst SNAP_REGISTRY_SIGNATURE_URL =\n 'https://acl.execution.metamask.io/latest/signature.json';\n\nconst DEFAULT_PUBLIC_KEY =\n '0x025b65308f0f0fb8bc7f7ff87bfc296e0330eee5d3c1d1ee4a048b2fd6a86fa0a6';\n\ntype JsonSnapsRegistryUrl = {\n registry: string;\n signature: string;\n};\n\nexport type ClientConfig = {\n type: 'extension' | 'mobile';\n version: SemVerVersion;\n};\n\nexport type SnapRegistryControllerArgs = {\n messenger: SnapRegistryControllerMessenger;\n state?: SnapRegistryControllerState;\n fetchFunction?: typeof fetch;\n url?: JsonSnapsRegistryUrl;\n recentFetchThreshold?: number;\n refetchOnAllowlistMiss?: boolean;\n publicKey?: Hex;\n clientConfig: ClientConfig;\n};\n\nexport type SnapRegistryControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n SnapRegistryControllerState\n>;\n\nexport type SnapRegistryControllerActions =\n | SnapRegistryControllerGetStateAction\n | SnapRegistryControllerMethodActions;\n\nexport type SnapRegistryControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n SnapRegistryControllerState\n>;\n\nexport type SnapRegistryControllerEvents =\n SnapRegistryControllerStateChangeEvent;\n\nexport type SnapRegistryControllerMessenger = Messenger<\n typeof controllerName,\n SnapRegistryControllerActions,\n SnapRegistryControllerEvents\n>;\n\nexport type SnapRegistryControllerState = {\n database: SnapsRegistryDatabase | null;\n signature: string | null;\n lastUpdated: number | null;\n databaseUnavailable: boolean;\n};\n\nconst controllerName = 'SnapRegistryController';\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'get',\n 'getMetadata',\n 'resolveVersion',\n 'requestUpdate',\n] as const;\n\nconst defaultState = {\n database: null,\n signature: null,\n lastUpdated: null,\n databaseUnavailable: false,\n};\n\nexport class SnapRegistryController extends BaseController<\n typeof controllerName,\n SnapRegistryControllerState,\n SnapRegistryControllerMessenger\n> {\n readonly #url: JsonSnapsRegistryUrl;\n\n readonly #publicKey: Hex;\n\n readonly #clientConfig: ClientConfig;\n\n readonly #fetchFunction: typeof fetch;\n\n readonly #recentFetchThreshold: number;\n\n readonly #refetchOnAllowlistMiss: boolean;\n\n #currentUpdate: Promise<void> | null;\n\n constructor({\n messenger,\n state,\n url = {\n registry: SNAP_REGISTRY_URL,\n signature: SNAP_REGISTRY_SIGNATURE_URL,\n },\n publicKey = DEFAULT_PUBLIC_KEY,\n clientConfig,\n fetchFunction = globalThis.fetch.bind(undefined),\n recentFetchThreshold = inMilliseconds(5, Duration.Minute),\n refetchOnAllowlistMiss = true,\n }: SnapRegistryControllerArgs) {\n super({\n messenger,\n metadata: {\n database: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n signature: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n lastUpdated: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n databaseUnavailable: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n },\n name: controllerName,\n state: {\n ...defaultState,\n ...state,\n },\n });\n this.#url = url;\n this.#publicKey = publicKey;\n this.#clientConfig = clientConfig;\n this.#fetchFunction = fetchFunction;\n this.#recentFetchThreshold = recentFetchThreshold;\n this.#refetchOnAllowlistMiss = refetchOnAllowlistMiss;\n this.#currentUpdate = null;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n #wasRecentlyFetched() {\n return (\n this.state.lastUpdated &&\n Date.now() - this.state.lastUpdated < this.#recentFetchThreshold\n );\n }\n\n /**\n * Triggers an update of the registry database.\n *\n * If an existing update is in progress this function will await that update.\n */\n async requestUpdate() {\n // If an update is ongoing, wait for that.\n if (this.#currentUpdate) {\n await this.#currentUpdate;\n return;\n }\n // If no update exists, create promise and store globally.\n if (this.#currentUpdate === null) {\n this.#currentUpdate = this.#update();\n }\n await this.#currentUpdate;\n this.#currentUpdate = null;\n }\n\n /**\n * Updates the registry database if the registry hasn't been updated recently.\n *\n * NOTE: SHOULD NOT be called directly, instead `triggerUpdate` should be used.\n */\n async #update() {\n // No-op if we recently fetched the registry.\n if (this.#wasRecentlyFetched()) {\n return;\n }\n\n try {\n const [database, signature] = await Promise.all([\n this.#safeFetch(this.#url.registry),\n this.#safeFetch(this.#url.signature),\n ]);\n\n const signatureJson = JSON.parse(signature);\n\n // If the signature matches the existing state, we can skip verification and don't need to update the database.\n if (signatureJson.signature === this.state.signature) {\n this.update((state) => {\n state.lastUpdated = Date.now();\n state.databaseUnavailable = false;\n });\n return;\n }\n\n await this.#verifySignature(database, signatureJson);\n\n this.update((state) => {\n state.database = JSON.parse(database);\n state.lastUpdated = Date.now();\n state.databaseUnavailable = false;\n state.signature = signatureJson.signature;\n });\n } catch {\n // Ignore\n this.update((state) => {\n state.databaseUnavailable = true;\n });\n }\n }\n\n async #getDatabase(): Promise<SnapsRegistryDatabase | null> {\n if (this.state.database === null) {\n await this.requestUpdate();\n }\n\n return this.state.database;\n }\n\n async #getSingle(\n snapId: string,\n snapInfo: SnapRegistryInfo,\n refetch = false,\n ): Promise<SnapRegistryResult> {\n const database = await this.#getDatabase();\n\n const blockedEntry = database?.blockedSnaps.find((blocked) => {\n if ('id' in blocked) {\n return (\n blocked.id === snapId &&\n satisfiesVersionRange(snapInfo.version, blocked.versionRange)\n );\n }\n\n return blocked.checksum === snapInfo.checksum;\n });\n\n if (blockedEntry) {\n return {\n status: SnapRegistryStatus.Blocked,\n reason: blockedEntry.reason,\n };\n }\n\n const verified = database?.verifiedSnaps[snapId];\n const version = verified?.versions?.[snapInfo.version];\n const clientRange = version?.clientVersions?.[this.#clientConfig.type];\n const isCompatible =\n !clientRange ||\n satisfiesVersionRange(this.#clientConfig.version, clientRange);\n if (version && version.checksum === snapInfo.checksum && isCompatible) {\n return { status: SnapRegistryStatus.Verified };\n }\n // For now, if we have an allowlist miss, we can refetch once and try again.\n if (this.#refetchOnAllowlistMiss && !refetch) {\n await this.requestUpdate();\n return this.#getSingle(snapId, snapInfo, true);\n }\n return {\n status: this.state.databaseUnavailable\n ? SnapRegistryStatus.Unavailable\n : SnapRegistryStatus.Unverified,\n };\n }\n\n async get(\n snaps: SnapRegistryRequest,\n ): Promise<Record<string, SnapRegistryResult>> {\n return Object.entries(snaps).reduce<\n Promise<Record<string, SnapRegistryResult>>\n >(async (previousPromise, [snapId, snapInfo]) => {\n const result = await this.#getSingle(snapId, snapInfo);\n const acc = await previousPromise;\n acc[snapId] = result;\n return acc;\n }, Promise.resolve({}));\n }\n\n /**\n * Find an allowlisted version within a specified version range. Otherwise return the version range itself.\n *\n * @param snapId - The ID of the snap we are trying to resolve a version for.\n * @param versionRange - The version range.\n * @param refetch - An optional flag used to determine if we are refetching the registry.\n * @returns An allowlisted version within the specified version range if available otherwise returns the input version range.\n */\n async resolveVersion(\n snapId: string,\n versionRange: SemVerRange,\n refetch = false,\n ): Promise<SemVerRange> {\n const database = await this.#getDatabase();\n const versions = database?.verifiedSnaps[snapId]?.versions ?? null;\n\n if (!versions && this.#refetchOnAllowlistMiss && !refetch) {\n await this.requestUpdate();\n return this.resolveVersion(snapId, versionRange, true);\n }\n\n // If we cannot narrow down the version range we return the unaltered version range.\n if (!versions) {\n return versionRange;\n }\n\n const compatibleVersions = Object.entries(versions).reduce<SemVerVersion[]>(\n (accumulator, [version, metadata]) => {\n const clientRange = metadata.clientVersions?.[this.#clientConfig.type];\n if (\n !clientRange ||\n satisfiesVersionRange(this.#clientConfig.version, clientRange)\n ) {\n accumulator.push(version as SemVerVersion);\n }\n\n return accumulator;\n },\n [],\n );\n\n const targetVersion = getTargetVersion(compatibleVersions, versionRange);\n\n if (!targetVersion && this.#refetchOnAllowlistMiss && !refetch) {\n await this.requestUpdate();\n return this.resolveVersion(snapId, versionRange, true);\n }\n\n // If we cannot narrow down the version range we return the unaltered version range.\n if (!targetVersion) {\n return versionRange;\n }\n\n // A semver version is technically also a valid semver range.\n assertIsSemVerRange(targetVersion);\n return targetVersion;\n }\n\n /**\n * Get metadata for the given snap ID, if available, without updating registry.\n *\n * @param snapId - The ID of the snap to get metadata for.\n * @returns The metadata for the given snap ID, or `null` if the snap is not\n * verified.\n */\n getMetadata(snapId: string): SnapRegistryMetadata | null {\n return this.state?.database?.verifiedSnaps[snapId]?.metadata ?? null;\n }\n\n /**\n * Verify the signature of the registry.\n *\n * @param database - The registry database.\n * @param signature - The signature of the registry.\n * @throws If the signature is invalid.\n */\n async #verifySignature(\n database: string,\n signature: Infer<typeof SignatureStruct>,\n ) {\n assert(this.#publicKey, 'No public key provided.');\n\n const valid = await verify({\n registry: database,\n signature,\n publicKey: this.#publicKey,\n });\n\n assert(valid, 'Invalid registry signature.');\n }\n\n /**\n * Fetch the given URL, throwing if the response is not OK.\n *\n * @param url - The URL to fetch.\n * @returns The response body.\n * @private\n */\n async #safeFetch(url: string) {\n const response = await this.#fetchFunction(url, { cache: 'no-cache' });\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}.`);\n }\n\n return await response.text();\n }\n}\n"]}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.SnapRegistryStatus = exports.SnapRegistryController = void 0;
|
|
4
|
+
var SnapRegistryController_1 = require("./SnapRegistryController.cjs");
|
|
5
|
+
Object.defineProperty(exports, "SnapRegistryController", { enumerable: true, get: function () { return SnapRegistryController_1.SnapRegistryController; } });
|
|
6
|
+
var types_1 = require("./types.cjs");
|
|
7
|
+
Object.defineProperty(exports, "SnapRegistryStatus", { enumerable: true, get: function () { return types_1.SnapRegistryStatus; } });
|
|
19
8
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":";;;AASA,uEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAa/B,qCAA6C;AAApC,2GAAA,kBAAkB,OAAA","sourcesContent":["export type {\n SnapRegistryControllerActions,\n SnapRegistryControllerEvents,\n SnapRegistryControllerArgs,\n SnapRegistryControllerGetStateAction,\n SnapRegistryControllerMessenger,\n SnapRegistryControllerState,\n SnapRegistryControllerStateChangeEvent,\n} from './SnapRegistryController';\nexport { SnapRegistryController } from './SnapRegistryController';\nexport type {\n SnapRegistryControllerGetAction,\n SnapRegistryControllerGetMetadataAction,\n SnapRegistryControllerRequestUpdateAction,\n SnapRegistryControllerResolveVersionAction,\n} from './SnapRegistryController-method-action-types';\nexport type {\n SnapRegistryInfo,\n SnapRegistryMetadata,\n SnapRegistryRequest,\n SnapRegistryResult,\n} from './types';\nexport { SnapRegistryStatus } from './types';\n"]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type { SnapRegistryControllerActions, SnapRegistryControllerEvents, SnapRegistryControllerArgs, SnapRegistryControllerGetStateAction, SnapRegistryControllerMessenger, SnapRegistryControllerState, SnapRegistryControllerStateChangeEvent, } from "./SnapRegistryController.cjs";
|
|
2
|
+
export { SnapRegistryController } from "./SnapRegistryController.cjs";
|
|
3
|
+
export type { SnapRegistryControllerGetAction, SnapRegistryControllerGetMetadataAction, SnapRegistryControllerRequestUpdateAction, SnapRegistryControllerResolveVersionAction, } from "./SnapRegistryController-method-action-types.cjs";
|
|
4
|
+
export type { SnapRegistryInfo, SnapRegistryMetadata, SnapRegistryRequest, SnapRegistryResult, } from "./types.cjs";
|
|
5
|
+
export { SnapRegistryStatus } from "./types.cjs";
|
|
3
6
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"AAAA,+
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,sCAAsC,GACvC,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,YAAY,EACV,+BAA+B,EAC/B,uCAAuC,EACvC,yCAAyC,EACzC,0CAA0C,GAC3C,yDAAqD;AACtD,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,oBAAgB;AACjB,OAAO,EAAE,kBAAkB,EAAE,oBAAgB"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type { SnapRegistryControllerActions, SnapRegistryControllerEvents, SnapRegistryControllerArgs, SnapRegistryControllerGetStateAction, SnapRegistryControllerMessenger, SnapRegistryControllerState, SnapRegistryControllerStateChangeEvent, } from "./SnapRegistryController.mjs";
|
|
2
|
+
export { SnapRegistryController } from "./SnapRegistryController.mjs";
|
|
3
|
+
export type { SnapRegistryControllerGetAction, SnapRegistryControllerGetMetadataAction, SnapRegistryControllerRequestUpdateAction, SnapRegistryControllerResolveVersionAction, } from "./SnapRegistryController-method-action-types.mjs";
|
|
4
|
+
export type { SnapRegistryInfo, SnapRegistryMetadata, SnapRegistryRequest, SnapRegistryResult, } from "./types.mjs";
|
|
5
|
+
export { SnapRegistryStatus } from "./types.mjs";
|
|
3
6
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"AAAA,+
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,sCAAsC,GACvC,qCAAiC;AAClC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAClE,YAAY,EACV,+BAA+B,EAC/B,uCAAuC,EACvC,yCAAyC,EACzC,0CAA0C,GAC3C,yDAAqD;AACtD,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,oBAAgB;AACjB,OAAO,EAAE,kBAAkB,EAAE,oBAAgB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { SnapRegistryController } from "./SnapRegistryController.mjs";
|
|
2
|
+
export { SnapRegistryStatus } from "./types.mjs";
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/snaps/registry/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAalE,OAAO,EAAE,kBAAkB,EAAE,oBAAgB","sourcesContent":["export type {\n SnapRegistryControllerActions,\n SnapRegistryControllerEvents,\n SnapRegistryControllerArgs,\n SnapRegistryControllerGetStateAction,\n SnapRegistryControllerMessenger,\n SnapRegistryControllerState,\n SnapRegistryControllerStateChangeEvent,\n} from './SnapRegistryController';\nexport { SnapRegistryController } from './SnapRegistryController';\nexport type {\n SnapRegistryControllerGetAction,\n SnapRegistryControllerGetMetadataAction,\n SnapRegistryControllerRequestUpdateAction,\n SnapRegistryControllerResolveVersionAction,\n} from './SnapRegistryController-method-action-types';\nexport type {\n SnapRegistryInfo,\n SnapRegistryMetadata,\n SnapRegistryRequest,\n SnapRegistryResult,\n} from './types';\nexport { SnapRegistryStatus } from './types';\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnapRegistryStatus = void 0;
|
|
4
|
+
var SnapRegistryStatus;
|
|
5
|
+
(function (SnapRegistryStatus) {
|
|
6
|
+
SnapRegistryStatus[SnapRegistryStatus["Unverified"] = 0] = "Unverified";
|
|
7
|
+
SnapRegistryStatus[SnapRegistryStatus["Blocked"] = 1] = "Blocked";
|
|
8
|
+
SnapRegistryStatus[SnapRegistryStatus["Verified"] = 2] = "Verified";
|
|
9
|
+
SnapRegistryStatus[SnapRegistryStatus["Unavailable"] = 3] = "Unavailable";
|
|
10
|
+
})(SnapRegistryStatus || (exports.SnapRegistryStatus = SnapRegistryStatus = {}));
|
|
11
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/snaps/registry/types.ts"],"names":[],"mappings":";;;AAYA,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,uEAAc,CAAA;IACd,iEAAW,CAAA;IACX,mEAAY,CAAA;IACZ,yEAAe,CAAA;AACjB,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B","sourcesContent":["import type {\n BlockReason,\n SnapsRegistryDatabase,\n} from '@metamask/snaps-registry';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SemVerVersion } from '@metamask/utils';\n\nexport type SnapRegistryInfo = { version: SemVerVersion; checksum: string };\nexport type SnapRegistryRequest = Record<SnapId, SnapRegistryInfo>;\nexport type SnapRegistryMetadata =\n SnapsRegistryDatabase['verifiedSnaps'][SnapId]['metadata'];\n\nexport enum SnapRegistryStatus {\n Unverified = 0,\n Blocked = 1,\n Verified = 2,\n Unavailable = 3,\n}\n\nexport type SnapRegistryResult = {\n status: SnapRegistryStatus;\n reason?: BlockReason;\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BlockReason, SnapsRegistryDatabase } from "@metamask/snaps-registry";
|
|
2
|
+
import type { SnapId } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { SemVerVersion } from "@metamask/utils";
|
|
4
|
+
export type SnapRegistryInfo = {
|
|
5
|
+
version: SemVerVersion;
|
|
6
|
+
checksum: string;
|
|
7
|
+
};
|
|
8
|
+
export type SnapRegistryRequest = Record<SnapId, SnapRegistryInfo>;
|
|
9
|
+
export type SnapRegistryMetadata = SnapsRegistryDatabase['verifiedSnaps'][SnapId]['metadata'];
|
|
10
|
+
export declare enum SnapRegistryStatus {
|
|
11
|
+
Unverified = 0,
|
|
12
|
+
Blocked = 1,
|
|
13
|
+
Verified = 2,
|
|
14
|
+
Unavailable = 3
|
|
15
|
+
}
|
|
16
|
+
export type SnapRegistryResult = {
|
|
17
|
+
status: SnapRegistryStatus;
|
|
18
|
+
reason?: BlockReason;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/snaps/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACtB,iCAAiC;AAClC,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACnE,MAAM,MAAM,oBAAoB,GAC9B,qBAAqB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;AAE7D,oBAAY,kBAAkB;IAC5B,UAAU,IAAI;IACd,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,WAAW,IAAI;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BlockReason, SnapsRegistryDatabase } from "@metamask/snaps-registry";
|
|
2
|
+
import type { SnapId } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { SemVerVersion } from "@metamask/utils";
|
|
4
|
+
export type SnapRegistryInfo = {
|
|
5
|
+
version: SemVerVersion;
|
|
6
|
+
checksum: string;
|
|
7
|
+
};
|
|
8
|
+
export type SnapRegistryRequest = Record<SnapId, SnapRegistryInfo>;
|
|
9
|
+
export type SnapRegistryMetadata = SnapsRegistryDatabase['verifiedSnaps'][SnapId]['metadata'];
|
|
10
|
+
export declare enum SnapRegistryStatus {
|
|
11
|
+
Unverified = 0,
|
|
12
|
+
Blocked = 1,
|
|
13
|
+
Verified = 2,
|
|
14
|
+
Unavailable = 3
|
|
15
|
+
}
|
|
16
|
+
export type SnapRegistryResult = {
|
|
17
|
+
status: SnapRegistryStatus;
|
|
18
|
+
reason?: BlockReason;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/snaps/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACtB,iCAAiC;AAClC,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACnE,MAAM,MAAM,oBAAoB,GAC9B,qBAAqB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;AAE7D,oBAAY,kBAAkB;IAC5B,UAAU,IAAI;IACd,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,WAAW,IAAI;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var SnapRegistryStatus;
|
|
2
|
+
(function (SnapRegistryStatus) {
|
|
3
|
+
SnapRegistryStatus[SnapRegistryStatus["Unverified"] = 0] = "Unverified";
|
|
4
|
+
SnapRegistryStatus[SnapRegistryStatus["Blocked"] = 1] = "Blocked";
|
|
5
|
+
SnapRegistryStatus[SnapRegistryStatus["Verified"] = 2] = "Verified";
|
|
6
|
+
SnapRegistryStatus[SnapRegistryStatus["Unavailable"] = 3] = "Unavailable";
|
|
7
|
+
})(SnapRegistryStatus || (SnapRegistryStatus = {}));
|
|
8
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/snaps/registry/types.ts"],"names":[],"mappings":"AAYA,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,uEAAc,CAAA;IACd,iEAAW,CAAA;IACX,mEAAY,CAAA;IACZ,yEAAe,CAAA;AACjB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B","sourcesContent":["import type {\n BlockReason,\n SnapsRegistryDatabase,\n} from '@metamask/snaps-registry';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport type { SemVerVersion } from '@metamask/utils';\n\nexport type SnapRegistryInfo = { version: SemVerVersion; checksum: string };\nexport type SnapRegistryRequest = Record<SnapId, SnapRegistryInfo>;\nexport type SnapRegistryMetadata =\n SnapsRegistryDatabase['verifiedSnaps'][SnapId]['metadata'];\n\nexport enum SnapRegistryStatus {\n Unverified = 0,\n Blocked = 1,\n Verified = 2,\n Unavailable = 3,\n}\n\nexport type SnapRegistryResult = {\n status: SnapRegistryStatus;\n reason?: BlockReason;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.cjs","sourceRoot":"","sources":["../../src/types/controllers.ts"],"names":[],"mappings":"","sourcesContent":["import type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { Hex, Json } from '@metamask/utils';\n\n// Partial types that should overlap with types from controllers.\nexport type TransactionMeta = {\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * The status of the transaction.\n */\n status: string;\n};\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport type TransactionParams = {\n /**\n * Chain ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maximum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n};\n\nexport type TransactionControllerUnapprovedTransactionAddedEvent = {\n type: `TransactionController:unapprovedTransactionAdded`;\n payload: [transactionMeta: TransactionMeta];\n};\n\nexport type TransactionControllerTransactionStatusUpdatedEvent = {\n type: `TransactionController:transactionStatusUpdated`;\n payload: [\n {\n transactionMeta: TransactionMeta;\n },\n ];\n};\n\nexport type StateSignatureParams = {\n from: string;\n origin?: string;\n deferSetAsSigned?: boolean;\n data: string | Record<string, Json>;\n signatureMethod: string;\n};\n\nexport type StateSignature = {\n id: string;\n msgParams: StateSignatureParams;\n};\n\nexport type SignatureControllerState = {\n unapprovedPersonalMsgs: Record<string, StateSignature>;\n unapprovedTypedMessages: Record<string, StateSignature>;\n unapprovedPersonalMsgCount: number;\n unapprovedTypedMessagesCount: number;\n};\n\nexport type
|
|
1
|
+
{"version":3,"file":"controllers.cjs","sourceRoot":"","sources":["../../src/types/controllers.ts"],"names":[],"mappings":"","sourcesContent":["import type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { Hex, Json } from '@metamask/utils';\n\n// Partial types that should overlap with types from controllers.\nexport type TransactionMeta = {\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * The status of the transaction.\n */\n status: string;\n};\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport type TransactionParams = {\n /**\n * Chain ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maximum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n};\n\nexport type TransactionControllerUnapprovedTransactionAddedEvent = {\n type: `TransactionController:unapprovedTransactionAdded`;\n payload: [transactionMeta: TransactionMeta];\n};\n\nexport type TransactionControllerTransactionStatusUpdatedEvent = {\n type: `TransactionController:transactionStatusUpdated`;\n payload: [\n {\n transactionMeta: TransactionMeta;\n },\n ];\n};\n\nexport type StateSignatureParams = {\n from: string;\n origin?: string;\n deferSetAsSigned?: boolean;\n data: string | Record<string, Json>;\n signatureMethod: string;\n};\n\nexport type StateSignature = {\n id: string;\n msgParams: StateSignatureParams;\n};\n\nexport type SignatureControllerState = {\n unapprovedPersonalMsgs: Record<string, StateSignature>;\n unapprovedTypedMessages: Record<string, StateSignature>;\n unapprovedPersonalMsgCount: number;\n unapprovedTypedMessagesCount: number;\n};\n\nexport type SignatureControllerStateChangeEvent = ControllerStateChangeEvent<\n 'SignatureController',\n SignatureControllerState\n>;\n"]}
|
|
@@ -126,5 +126,5 @@ export type SignatureControllerState = {
|
|
|
126
126
|
unapprovedPersonalMsgCount: number;
|
|
127
127
|
unapprovedTypedMessagesCount: number;
|
|
128
128
|
};
|
|
129
|
-
export type
|
|
129
|
+
export type SignatureControllerStateChangeEvent = ControllerStateChangeEvent<'SignatureController', SignatureControllerState>;
|
|
130
130
|
//# sourceMappingURL=controllers.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.d.cts","sourceRoot":"","sources":["../../src/types/controllers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAGjD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE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EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvD,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxD,0BAA0B,EAAE,MAAM,CAAC;IACnC,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,0BAA0B,CAC1E,qBAAqB,EACrB,wBAAwB,CACzB,CAAC"}
|
|
@@ -126,5 +126,5 @@ export type SignatureControllerState = {
|
|
|
126
126
|
unapprovedPersonalMsgCount: number;
|
|
127
127
|
unapprovedTypedMessagesCount: number;
|
|
128
128
|
};
|
|
129
|
-
export type
|
|
129
|
+
export type SignatureControllerStateChangeEvent = ControllerStateChangeEvent<'SignatureController', SignatureControllerState>;
|
|
130
130
|
//# sourceMappingURL=controllers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.d.mts","sourceRoot":"","sources":["../../src/types/controllers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,kCAAkC;AAC5E,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAGjD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,iBAAiB,CAAC;IAE5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;O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jC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvD,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxD,0BAA0B,EAAE,MAAM,CAAC;IACnC,4BAA4B,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,0BAA0B,CAC1E,qBAAqB,EACrB,wBAAwB,CACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllers.mjs","sourceRoot":"","sources":["../../src/types/controllers.ts"],"names":[],"mappings":"","sourcesContent":["import type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { Hex, Json } from '@metamask/utils';\n\n// Partial types that should overlap with types from controllers.\nexport type TransactionMeta = {\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * The status of the transaction.\n */\n status: string;\n};\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport type TransactionParams = {\n /**\n * Chain ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maximum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n};\n\nexport type TransactionControllerUnapprovedTransactionAddedEvent = {\n type: `TransactionController:unapprovedTransactionAdded`;\n payload: [transactionMeta: TransactionMeta];\n};\n\nexport type TransactionControllerTransactionStatusUpdatedEvent = {\n type: `TransactionController:transactionStatusUpdated`;\n payload: [\n {\n transactionMeta: TransactionMeta;\n },\n ];\n};\n\nexport type StateSignatureParams = {\n from: string;\n origin?: string;\n deferSetAsSigned?: boolean;\n data: string | Record<string, Json>;\n signatureMethod: string;\n};\n\nexport type StateSignature = {\n id: string;\n msgParams: StateSignatureParams;\n};\n\nexport type SignatureControllerState = {\n unapprovedPersonalMsgs: Record<string, StateSignature>;\n unapprovedTypedMessages: Record<string, StateSignature>;\n unapprovedPersonalMsgCount: number;\n unapprovedTypedMessagesCount: number;\n};\n\nexport type
|
|
1
|
+
{"version":3,"file":"controllers.mjs","sourceRoot":"","sources":["../../src/types/controllers.ts"],"names":[],"mappings":"","sourcesContent":["import type { ControllerStateChangeEvent } from '@metamask/base-controller';\nimport type { Hex, Json } from '@metamask/utils';\n\n// Partial types that should overlap with types from controllers.\nexport type TransactionMeta = {\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * The status of the transaction.\n */\n status: string;\n};\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport type TransactionParams = {\n /**\n * Chain ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maximum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n};\n\nexport type TransactionControllerUnapprovedTransactionAddedEvent = {\n type: `TransactionController:unapprovedTransactionAdded`;\n payload: [transactionMeta: TransactionMeta];\n};\n\nexport type TransactionControllerTransactionStatusUpdatedEvent = {\n type: `TransactionController:transactionStatusUpdated`;\n payload: [\n {\n transactionMeta: TransactionMeta;\n },\n ];\n};\n\nexport type StateSignatureParams = {\n from: string;\n origin?: string;\n deferSetAsSigned?: boolean;\n data: string | Record<string, Json>;\n signatureMethod: string;\n};\n\nexport type StateSignature = {\n id: string;\n msgParams: StateSignatureParams;\n};\n\nexport type SignatureControllerState = {\n unapprovedPersonalMsgs: Record<string, StateSignature>;\n unapprovedTypedMessages: Record<string, StateSignature>;\n unapprovedPersonalMsgCount: number;\n unapprovedTypedMessagesCount: number;\n};\n\nexport type SignatureControllerStateChangeEvent = ControllerStateChangeEvent<\n 'SignatureController',\n SignatureControllerState\n>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketService-method-action-types.cjs","sourceRoot":"","sources":["../../src/websocket/WebSocketService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { WebSocketService } from './WebSocketService';\n\n/**\n * Open a WebSocket connection.\n *\n * @param snapId - The Snap ID.\n * @param url - The URL for the WebSocket connection.\n * @param protocols - An optional parameter for protocols.\n * @returns The identifier for the opened connection.\n * @throws If the connection fails.\n */\nexport type WebSocketServiceOpenAction = {\n type: `WebSocketService:open`;\n handler: WebSocketService['open'];\n};\n\n/**\n * Close a given WebSocket connection.\n *\n * @param snapId - The Snap ID.\n * @param id - The identifier for the WebSocket connection.\n */\nexport type WebSocketServiceCloseAction = {\n type: `WebSocketService:close`;\n handler: WebSocketService['close'];\n};\n\n/**\n * Send a message from a given Snap ID to a WebSocket connection.\n *\n * @param snapId - The Snap ID.\n * @param id - The identifier for the WebSocket connection.\n * @param data - The message to send.\n */\nexport type WebSocketServiceSendMessageAction = {\n type: `WebSocketService:sendMessage`;\n handler: WebSocketService['sendMessage'];\n};\n\n/**\n * Get a list of all open WebSocket connections for a Snap ID.\n *\n * @param snapId - The Snap ID.\n * @returns A list of WebSocket connections.\n */\nexport type WebSocketServiceGetAllAction = {\n type: `WebSocketService:getAll`;\n handler: WebSocketService['getAll'];\n};\n\n/**\n * Union of all WebSocketService action types.\n */\nexport type WebSocketServiceMethodActions =\n | WebSocketServiceOpenAction\n | WebSocketServiceCloseAction\n | WebSocketServiceSendMessageAction\n | WebSocketServiceGetAllAction;\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { WebSocketService } from "./WebSocketService.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Open a WebSocket connection.
|
|
8
|
+
*
|
|
9
|
+
* @param snapId - The Snap ID.
|
|
10
|
+
* @param url - The URL for the WebSocket connection.
|
|
11
|
+
* @param protocols - An optional parameter for protocols.
|
|
12
|
+
* @returns The identifier for the opened connection.
|
|
13
|
+
* @throws If the connection fails.
|
|
14
|
+
*/
|
|
15
|
+
export type WebSocketServiceOpenAction = {
|
|
16
|
+
type: `WebSocketService:open`;
|
|
17
|
+
handler: WebSocketService['open'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Close a given WebSocket connection.
|
|
21
|
+
*
|
|
22
|
+
* @param snapId - The Snap ID.
|
|
23
|
+
* @param id - The identifier for the WebSocket connection.
|
|
24
|
+
*/
|
|
25
|
+
export type WebSocketServiceCloseAction = {
|
|
26
|
+
type: `WebSocketService:close`;
|
|
27
|
+
handler: WebSocketService['close'];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Send a message from a given Snap ID to a WebSocket connection.
|
|
31
|
+
*
|
|
32
|
+
* @param snapId - The Snap ID.
|
|
33
|
+
* @param id - The identifier for the WebSocket connection.
|
|
34
|
+
* @param data - The message to send.
|
|
35
|
+
*/
|
|
36
|
+
export type WebSocketServiceSendMessageAction = {
|
|
37
|
+
type: `WebSocketService:sendMessage`;
|
|
38
|
+
handler: WebSocketService['sendMessage'];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get a list of all open WebSocket connections for a Snap ID.
|
|
42
|
+
*
|
|
43
|
+
* @param snapId - The Snap ID.
|
|
44
|
+
* @returns A list of WebSocket connections.
|
|
45
|
+
*/
|
|
46
|
+
export type WebSocketServiceGetAllAction = {
|
|
47
|
+
type: `WebSocketService:getAll`;
|
|
48
|
+
handler: WebSocketService['getAll'];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Union of all WebSocketService action types.
|
|
52
|
+
*/
|
|
53
|
+
export type WebSocketServiceMethodActions = WebSocketServiceOpenAction | WebSocketServiceCloseAction | WebSocketServiceSendMessageAction | WebSocketServiceGetAllAction;
|
|
54
|
+
//# sourceMappingURL=WebSocketService-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketService-method-action-types.d.cts","sourceRoot":"","sources":["../../src/websocket/WebSocketService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,0BAA0B,GAC1B,2BAA2B,GAC3B,iCAAiC,GACjC,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { WebSocketService } from "./WebSocketService.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Open a WebSocket connection.
|
|
8
|
+
*
|
|
9
|
+
* @param snapId - The Snap ID.
|
|
10
|
+
* @param url - The URL for the WebSocket connection.
|
|
11
|
+
* @param protocols - An optional parameter for protocols.
|
|
12
|
+
* @returns The identifier for the opened connection.
|
|
13
|
+
* @throws If the connection fails.
|
|
14
|
+
*/
|
|
15
|
+
export type WebSocketServiceOpenAction = {
|
|
16
|
+
type: `WebSocketService:open`;
|
|
17
|
+
handler: WebSocketService['open'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Close a given WebSocket connection.
|
|
21
|
+
*
|
|
22
|
+
* @param snapId - The Snap ID.
|
|
23
|
+
* @param id - The identifier for the WebSocket connection.
|
|
24
|
+
*/
|
|
25
|
+
export type WebSocketServiceCloseAction = {
|
|
26
|
+
type: `WebSocketService:close`;
|
|
27
|
+
handler: WebSocketService['close'];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Send a message from a given Snap ID to a WebSocket connection.
|
|
31
|
+
*
|
|
32
|
+
* @param snapId - The Snap ID.
|
|
33
|
+
* @param id - The identifier for the WebSocket connection.
|
|
34
|
+
* @param data - The message to send.
|
|
35
|
+
*/
|
|
36
|
+
export type WebSocketServiceSendMessageAction = {
|
|
37
|
+
type: `WebSocketService:sendMessage`;
|
|
38
|
+
handler: WebSocketService['sendMessage'];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get a list of all open WebSocket connections for a Snap ID.
|
|
42
|
+
*
|
|
43
|
+
* @param snapId - The Snap ID.
|
|
44
|
+
* @returns A list of WebSocket connections.
|
|
45
|
+
*/
|
|
46
|
+
export type WebSocketServiceGetAllAction = {
|
|
47
|
+
type: `WebSocketService:getAll`;
|
|
48
|
+
handler: WebSocketService['getAll'];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Union of all WebSocketService action types.
|
|
52
|
+
*/
|
|
53
|
+
export type WebSocketServiceMethodActions = WebSocketServiceOpenAction | WebSocketServiceCloseAction | WebSocketServiceSendMessageAction | WebSocketServiceGetAllAction;
|
|
54
|
+
//# sourceMappingURL=WebSocketService-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketService-method-action-types.d.mts","sourceRoot":"","sources":["../../src/websocket/WebSocketService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,0BAA0B,GAC1B,2BAA2B,GAC3B,iCAAiC,GACjC,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketService-method-action-types.mjs","sourceRoot":"","sources":["../../src/websocket/WebSocketService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { WebSocketService } from './WebSocketService';\n\n/**\n * Open a WebSocket connection.\n *\n * @param snapId - The Snap ID.\n * @param url - The URL for the WebSocket connection.\n * @param protocols - An optional parameter for protocols.\n * @returns The identifier for the opened connection.\n * @throws If the connection fails.\n */\nexport type WebSocketServiceOpenAction = {\n type: `WebSocketService:open`;\n handler: WebSocketService['open'];\n};\n\n/**\n * Close a given WebSocket connection.\n *\n * @param snapId - The Snap ID.\n * @param id - The identifier for the WebSocket connection.\n */\nexport type WebSocketServiceCloseAction = {\n type: `WebSocketService:close`;\n handler: WebSocketService['close'];\n};\n\n/**\n * Send a message from a given Snap ID to a WebSocket connection.\n *\n * @param snapId - The Snap ID.\n * @param id - The identifier for the WebSocket connection.\n * @param data - The message to send.\n */\nexport type WebSocketServiceSendMessageAction = {\n type: `WebSocketService:sendMessage`;\n handler: WebSocketService['sendMessage'];\n};\n\n/**\n * Get a list of all open WebSocket connections for a Snap ID.\n *\n * @param snapId - The Snap ID.\n * @returns A list of WebSocket connections.\n */\nexport type WebSocketServiceGetAllAction = {\n type: `WebSocketService:getAll`;\n handler: WebSocketService['getAll'];\n};\n\n/**\n * Union of all WebSocketService action types.\n */\nexport type WebSocketServiceMethodActions =\n | WebSocketServiceOpenAction\n | WebSocketServiceCloseAction\n | WebSocketServiceSendMessageAction\n | WebSocketServiceGetAllAction;\n"]}
|