@metamask-previews/multichain-api-middleware 4.0.3-preview-8bfa290fb → 5.0.0-preview-97d6b86c0
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 +15 -1
- package/dist/handlers/index.d.ts +25 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/{index.mjs → index.js} +5 -5
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/{types.d.cts → types.d.ts} +5 -5
- package/dist/handlers/types.d.ts.map +1 -0
- package/dist/handlers/{types.mjs → types.js} +1 -2
- package/dist/handlers/types.js.map +1 -0
- package/dist/handlers/{wallet-createSession.d.cts → wallet-createSession.d.ts} +9 -9
- package/dist/handlers/wallet-createSession.d.ts.map +1 -0
- package/dist/handlers/{wallet-createSession.mjs → wallet-createSession.js} +6 -6
- package/dist/handlers/wallet-createSession.js.map +1 -0
- package/dist/handlers/{wallet-getSession.d.mts → wallet-getSession.d.ts} +5 -5
- package/dist/handlers/wallet-getSession.d.ts.map +1 -0
- package/dist/handlers/{wallet-getSession.mjs → wallet-getSession.js} +2 -2
- package/dist/handlers/wallet-getSession.js.map +1 -0
- package/dist/handlers/{wallet-invokeMethod.d.mts → wallet-invokeMethod.d.ts} +7 -7
- package/dist/handlers/wallet-invokeMethod.d.ts.map +1 -0
- package/dist/handlers/{wallet-invokeMethod.mjs → wallet-invokeMethod.js} +4 -4
- package/dist/handlers/wallet-invokeMethod.js.map +1 -0
- package/dist/handlers/{wallet-revokeSession.d.mts → wallet-revokeSession.d.ts} +6 -6
- package/dist/handlers/wallet-revokeSession.d.ts.map +1 -0
- package/dist/handlers/{wallet-revokeSession.mjs → wallet-revokeSession.js} +5 -5
- package/dist/handlers/wallet-revokeSession.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/{MultichainMiddlewareManager.d.cts → MultichainMiddlewareManager.d.ts} +4 -4
- package/dist/middlewares/MultichainMiddlewareManager.d.ts.map +1 -0
- package/dist/middlewares/MultichainMiddlewareManager.js +93 -0
- package/dist/middlewares/MultichainMiddlewareManager.js.map +1 -0
- package/dist/middlewares/{MultichainSubscriptionManager.d.cts → MultichainSubscriptionManager.d.ts} +6 -6
- package/dist/middlewares/MultichainSubscriptionManager.d.ts.map +1 -0
- package/dist/middlewares/MultichainSubscriptionManager.js +100 -0
- package/dist/middlewares/MultichainSubscriptionManager.js.map +1 -0
- package/dist/middlewares/{multichainMethodCallValidatorMiddleware.d.cts → multichainMethodCallValidatorMiddleware.d.ts} +2 -2
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.d.ts.map +1 -0
- package/dist/middlewares/{multichainMethodCallValidatorMiddleware.mjs → multichainMethodCallValidatorMiddleware.js} +8 -15
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.js.map +1 -0
- package/package.json +20 -24
- package/dist/handlers/index.cjs +0 -20
- package/dist/handlers/index.cjs.map +0 -1
- package/dist/handlers/index.d.cts +0 -25
- package/dist/handlers/index.d.cts.map +0 -1
- package/dist/handlers/index.d.mts +0 -25
- package/dist/handlers/index.d.mts.map +0 -1
- package/dist/handlers/index.mjs.map +0 -1
- package/dist/handlers/types.cjs +0 -13
- package/dist/handlers/types.cjs.map +0 -1
- package/dist/handlers/types.d.cts.map +0 -1
- package/dist/handlers/types.d.mts +0 -27
- package/dist/handlers/types.d.mts.map +0 -1
- package/dist/handlers/types.mjs.map +0 -1
- package/dist/handlers/wallet-createSession.cjs +0 -179
- package/dist/handlers/wallet-createSession.cjs.map +0 -1
- package/dist/handlers/wallet-createSession.d.cts.map +0 -1
- package/dist/handlers/wallet-createSession.d.mts +0 -70
- package/dist/handlers/wallet-createSession.d.mts.map +0 -1
- package/dist/handlers/wallet-createSession.mjs.map +0 -1
- package/dist/handlers/wallet-getSession.cjs +0 -54
- package/dist/handlers/wallet-getSession.cjs.map +0 -1
- package/dist/handlers/wallet-getSession.d.cts +0 -43
- package/dist/handlers/wallet-getSession.d.cts.map +0 -1
- package/dist/handlers/wallet-getSession.d.mts.map +0 -1
- package/dist/handlers/wallet-getSession.mjs.map +0 -1
- package/dist/handlers/wallet-invokeMethod.cjs +0 -103
- package/dist/handlers/wallet-invokeMethod.cjs.map +0 -1
- package/dist/handlers/wallet-invokeMethod.d.cts +0 -57
- package/dist/handlers/wallet-invokeMethod.d.cts.map +0 -1
- package/dist/handlers/wallet-invokeMethod.d.mts.map +0 -1
- package/dist/handlers/wallet-invokeMethod.mjs.map +0 -1
- package/dist/handlers/wallet-revokeSession.cjs +0 -106
- package/dist/handlers/wallet-revokeSession.cjs.map +0 -1
- package/dist/handlers/wallet-revokeSession.d.cts +0 -45
- package/dist/handlers/wallet-revokeSession.d.cts.map +0 -1
- package/dist/handlers/wallet-revokeSession.d.mts.map +0 -1
- package/dist/handlers/wallet-revokeSession.mjs.map +0 -1
- package/dist/index.cjs +0 -14
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -7
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -7
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -6
- package/dist/index.mjs.map +0 -1
- package/dist/middlewares/MultichainMiddlewareManager.cjs +0 -110
- package/dist/middlewares/MultichainMiddlewareManager.cjs.map +0 -1
- package/dist/middlewares/MultichainMiddlewareManager.d.cts.map +0 -1
- package/dist/middlewares/MultichainMiddlewareManager.d.mts +0 -35
- package/dist/middlewares/MultichainMiddlewareManager.d.mts.map +0 -1
- package/dist/middlewares/MultichainMiddlewareManager.mjs +0 -106
- package/dist/middlewares/MultichainMiddlewareManager.mjs.map +0 -1
- package/dist/middlewares/MultichainSubscriptionManager.cjs +0 -118
- package/dist/middlewares/MultichainSubscriptionManager.cjs.map +0 -1
- package/dist/middlewares/MultichainSubscriptionManager.d.cts.map +0 -1
- package/dist/middlewares/MultichainSubscriptionManager.d.mts +0 -49
- package/dist/middlewares/MultichainSubscriptionManager.d.mts.map +0 -1
- package/dist/middlewares/MultichainSubscriptionManager.mjs +0 -118
- package/dist/middlewares/MultichainSubscriptionManager.mjs.map +0 -1
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.cjs +0 -74
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.cjs.map +0 -1
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.d.cts.map +0 -1
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.d.mts +0 -7
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.d.mts.map +0 -1
- package/dist/middlewares/multichainMethodCallValidatorMiddleware.mjs.map +0 -1
package/dist/middlewares/{MultichainSubscriptionManager.d.cts → MultichainSubscriptionManager.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ExternalScopeString } from
|
|
2
|
-
import type { NetworkController } from
|
|
3
|
-
import SafeEventEmitter from
|
|
4
|
-
import type { Hex } from
|
|
5
|
-
import type { ExtendedJsonRpcMiddleware } from
|
|
1
|
+
import type { ExternalScopeString } from '@metamask/chain-agnostic-permission';
|
|
2
|
+
import type { NetworkController } from '@metamask/network-controller';
|
|
3
|
+
import SafeEventEmitter from '@metamask/safe-event-emitter';
|
|
4
|
+
import type { Hex } from '@metamask/utils';
|
|
5
|
+
import type { ExtendedJsonRpcMiddleware } from './MultichainMiddlewareManager.js';
|
|
6
6
|
export type SubscriptionManager = {
|
|
7
7
|
events: SafeEventEmitter;
|
|
8
8
|
destroy?: () => void;
|
|
@@ -46,4 +46,4 @@ export declare class MultichainSubscriptionManager extends SafeEventEmitter {
|
|
|
46
46
|
unsubscribeByOriginAndTabId(origin: string, tabId?: number): void;
|
|
47
47
|
}
|
|
48
48
|
export {};
|
|
49
|
-
//# sourceMappingURL=MultichainSubscriptionManager.d.
|
|
49
|
+
//# sourceMappingURL=MultichainSubscriptionManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultichainSubscriptionMan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e,EAAE,eAAe,OAmCzC;IAQD,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,QAM5C;IAED,2BAA2B,CAAC,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,QASrE;IAED,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QASzD;CACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { toHex } from '@metamask/controller-utils';
|
|
2
|
+
import createSubscriptionManager from '@metamask/eth-json-rpc-filters/subscriptionManager';
|
|
3
|
+
import SafeEventEmitter from '@metamask/safe-event-emitter';
|
|
4
|
+
import { parseCaipChainId } from '@metamask/utils';
|
|
5
|
+
import { MultichainApiNotifications } from '../handlers/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* A helper that facilates the lifecycle of a SubscriptionManager instance that
|
|
8
|
+
* is meant to handle subscriptons for only one specific scope, origin, and tabId combination.
|
|
9
|
+
*/
|
|
10
|
+
export class MultichainSubscriptionManager extends SafeEventEmitter {
|
|
11
|
+
#findNetworkClientIdByChainId;
|
|
12
|
+
#getNetworkClientById;
|
|
13
|
+
#subscriptions = [];
|
|
14
|
+
/**
|
|
15
|
+
* Construct a MultichainSubscriptionManager.
|
|
16
|
+
*
|
|
17
|
+
* @param options - The controller options.
|
|
18
|
+
* @param options.findNetworkClientIdByChainId - The hook to get the networkClientId from a chainId.
|
|
19
|
+
* @param options.getNetworkClientById - The hook to get the network client instance by its networkClientId.
|
|
20
|
+
*/
|
|
21
|
+
constructor(options) {
|
|
22
|
+
super();
|
|
23
|
+
this.#findNetworkClientIdByChainId = options.findNetworkClientIdByChainId;
|
|
24
|
+
this.#getNetworkClientById = options.getNetworkClientById;
|
|
25
|
+
}
|
|
26
|
+
notify({ scope, origin, tabId }, { method, params }) {
|
|
27
|
+
this.emit('notification', origin, tabId, {
|
|
28
|
+
method: MultichainApiNotifications.walletNotify,
|
|
29
|
+
params: {
|
|
30
|
+
scope,
|
|
31
|
+
notification: { method, params },
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
#getSubscriptionEntry({ scope, origin, tabId, }) {
|
|
36
|
+
return this.#subscriptions.find((subscriptionEntry) => {
|
|
37
|
+
return (subscriptionEntry.scope === scope &&
|
|
38
|
+
subscriptionEntry.origin === origin &&
|
|
39
|
+
subscriptionEntry.tabId === tabId);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
#removeSubscriptionEntry({ scope, origin, tabId }) {
|
|
43
|
+
this.#subscriptions = this.#subscriptions.filter((subscriptionEntry) => {
|
|
44
|
+
return (subscriptionEntry.scope !== scope ||
|
|
45
|
+
subscriptionEntry.origin !== origin ||
|
|
46
|
+
subscriptionEntry.tabId !== tabId);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
subscribe(subscriptionKey) {
|
|
50
|
+
const subscriptionEntry = this.#getSubscriptionEntry(subscriptionKey);
|
|
51
|
+
if (subscriptionEntry) {
|
|
52
|
+
return subscriptionEntry.subscriptionManager;
|
|
53
|
+
}
|
|
54
|
+
const networkClientId = this.#findNetworkClientIdByChainId(toHex(parseCaipChainId(subscriptionKey.scope).reference));
|
|
55
|
+
const networkClient = this.#getNetworkClientById(networkClientId);
|
|
56
|
+
const subscriptionManager = createSubscriptionManager({
|
|
57
|
+
blockTracker: networkClient.blockTracker,
|
|
58
|
+
provider: networkClient.provider,
|
|
59
|
+
});
|
|
60
|
+
subscriptionManager.events.on('notification', (message) => {
|
|
61
|
+
this.notify(subscriptionKey, message);
|
|
62
|
+
});
|
|
63
|
+
const newSubscriptionManagerEntry = {
|
|
64
|
+
...subscriptionKey,
|
|
65
|
+
subscriptionManager,
|
|
66
|
+
};
|
|
67
|
+
subscriptionManager.destroy = subscriptionManager.middleware.destroy;
|
|
68
|
+
subscriptionManager.middleware.destroy = this.#unsubscribe.bind(this, newSubscriptionManagerEntry);
|
|
69
|
+
this.#subscriptions.push(newSubscriptionManagerEntry);
|
|
70
|
+
return subscriptionManager;
|
|
71
|
+
}
|
|
72
|
+
#unsubscribe(subscriptionEntry) {
|
|
73
|
+
subscriptionEntry.subscriptionManager.destroy?.();
|
|
74
|
+
this.#removeSubscriptionEntry(subscriptionEntry);
|
|
75
|
+
}
|
|
76
|
+
unsubscribeByScope(scope) {
|
|
77
|
+
this.#subscriptions.forEach((subscriptionEntry) => {
|
|
78
|
+
if (subscriptionEntry.scope === scope) {
|
|
79
|
+
this.#unsubscribe(subscriptionEntry);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
unsubscribeByScopeAndOrigin(scope, origin) {
|
|
84
|
+
this.#subscriptions.forEach((subscriptionEntry) => {
|
|
85
|
+
if (subscriptionEntry.scope === scope &&
|
|
86
|
+
subscriptionEntry.origin === origin) {
|
|
87
|
+
this.#unsubscribe(subscriptionEntry);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
unsubscribeByOriginAndTabId(origin, tabId) {
|
|
92
|
+
this.#subscriptions.forEach((subscriptionEntry) => {
|
|
93
|
+
if (subscriptionEntry.origin === origin &&
|
|
94
|
+
subscriptionEntry.tabId === tabId) {
|
|
95
|
+
this.#unsubscribe(subscriptionEntry);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=MultichainSubscriptionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultichainSubscriptionManager.js","sourceRoot":"","sources":["../../src/middlewares/MultichainSubscriptionManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,yBAAyB,MAAM,oDAAoD,CAAC;AAE3F,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,C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ACnD,CAAC;IAED,kBAAkB,CAAC,KAA0B;QAC3C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAE;YAChD,IAAI,iBAAiB,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBACtC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2BAA2B,CAAC,KAA0B,EAAE,MAAc;QACpE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAE;YAChD,IACE,iBAAiB,CAAC,KAAK,KAAK,KAAK;gBACjC,iBAAiB,CAAC,MAAM,KAAK,MAAM,EACnC,CAAC;gBACD,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2BAA2B,CAAC,MAAc,EAAE,KAAc;QACxD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,iBAAiB,EAAE,EAAE;YAChD,IACE,iBAAiB,CAAC,MAAM,KAAK,MAAM;gBACnC,iBAAiB,CAAC,KAAK,KAAK,KAAK,EACjC,CAAC;gBACD,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { ExternalScopeString } from '@metamask/chain-agnostic-permission';\nimport { toHex } from '@metamask/controller-utils';\nimport createSubscriptionManager from '@metamask/eth-json-rpc-filters/subscriptionManager';\nimport type { NetworkController } from '@metamask/network-controller';\nimport SafeEventEmitter from '@metamask/safe-event-emitter';\nimport type { CaipChainId, Hex } from '@metamask/utils';\nimport { parseCaipChainId } from '@metamask/utils';\n\nimport { MultichainApiNotifications } from '../handlers/types.js';\nimport type { ExtendedJsonRpcMiddleware } from './MultichainMiddlewareManager.js';\n\nexport type SubscriptionManager = {\n events: SafeEventEmitter;\n destroy?: () => void;\n middleware: ExtendedJsonRpcMiddleware;\n};\n\ntype SubscriptionNotificationEvent = {\n jsonrpc: '2.0';\n method: 'eth_subscription';\n params: {\n subscription: Hex;\n result: unknown;\n };\n};\n\ntype SubscriptionKey = {\n scope: ExternalScopeString;\n origin: string;\n tabId?: number;\n};\ntype SubscriptionEntry = SubscriptionKey & {\n subscriptionManager: SubscriptionManager;\n};\n\ntype MultichainSubscriptionManagerOptions = {\n findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId'];\n getNetworkClientById: NetworkController['getNetworkClientById'];\n};\n\n/**\n * A helper that facilates the lifecycle of a SubscriptionManager instance that\n * is meant to handle subscriptons for only one specific scope, origin, and tabId combination.\n */\nexport class MultichainSubscriptionManager extends SafeEventEmitter {\n readonly #findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId'];\n\n readonly #getNetworkClientById: NetworkController['getNetworkClientById'];\n\n #subscriptions: SubscriptionEntry[] = [];\n\n /**\n * Construct a MultichainSubscriptionManager.\n *\n * @param options - The controller options.\n * @param options.findNetworkClientIdByChainId - The hook to get the networkClientId from a chainId.\n * @param options.getNetworkClientById - The hook to get the network client instance by its networkClientId.\n */\n constructor(options: MultichainSubscriptionManagerOptions) {\n super();\n this.#findNetworkClientIdByChainId = options.findNetworkClientIdByChainId;\n this.#getNetworkClientById = options.getNetworkClientById;\n }\n\n notify(\n { scope, origin, tabId }: SubscriptionKey,\n { method, params }: SubscriptionNotificationEvent,\n ) {\n this.emit('notification', origin, tabId, {\n method: MultichainApiNotifications.walletNotify,\n params: {\n scope,\n notification: { method, params },\n },\n });\n }\n\n #getSubscriptionEntry({\n scope,\n origin,\n tabId,\n }: SubscriptionKey): SubscriptionEntry | undefined {\n return this.#subscriptions.find((subscriptionEntry) => {\n return (\n subscriptionEntry.scope === scope &&\n subscriptionEntry.origin === origin &&\n subscriptionEntry.tabId === tabId\n );\n });\n }\n\n #removeSubscriptionEntry({ scope, origin, tabId }: SubscriptionEntry) {\n this.#subscriptions = this.#subscriptions.filter((subscriptionEntry) => {\n return (\n subscriptionEntry.scope !== scope ||\n subscriptionEntry.origin !== origin ||\n subscriptionEntry.tabId !== tabId\n );\n });\n }\n\n subscribe(subscriptionKey: SubscriptionKey) {\n const subscriptionEntry = this.#getSubscriptionEntry(subscriptionKey);\n if (subscriptionEntry) {\n return subscriptionEntry.subscriptionManager;\n }\n\n const networkClientId = this.#findNetworkClientIdByChainId(\n toHex(parseCaipChainId(subscriptionKey.scope as CaipChainId).reference),\n );\n const networkClient = this.#getNetworkClientById(networkClientId);\n const subscriptionManager = createSubscriptionManager({\n blockTracker: networkClient.blockTracker,\n provider: networkClient.provider,\n });\n\n subscriptionManager.events.on(\n 'notification',\n (message: SubscriptionNotificationEvent) => {\n this.notify(subscriptionKey, message);\n },\n );\n\n const newSubscriptionManagerEntry = {\n ...subscriptionKey,\n subscriptionManager,\n };\n subscriptionManager.destroy = subscriptionManager.middleware.destroy;\n subscriptionManager.middleware.destroy = this.#unsubscribe.bind(\n this,\n newSubscriptionManagerEntry,\n );\n\n this.#subscriptions.push(newSubscriptionManagerEntry);\n\n return subscriptionManager;\n }\n\n #unsubscribe(subscriptionEntry: SubscriptionEntry) {\n subscriptionEntry.subscriptionManager.destroy?.();\n\n this.#removeSubscriptionEntry(subscriptionEntry);\n }\n\n unsubscribeByScope(scope: ExternalScopeString) {\n this.#subscriptions.forEach((subscriptionEntry) => {\n if (subscriptionEntry.scope === scope) {\n this.#unsubscribe(subscriptionEntry);\n }\n });\n }\n\n unsubscribeByScopeAndOrigin(scope: ExternalScopeString, origin: string) {\n this.#subscriptions.forEach((subscriptionEntry) => {\n if (\n subscriptionEntry.scope === scope &&\n subscriptionEntry.origin === origin\n ) {\n this.#unsubscribe(subscriptionEntry);\n }\n });\n }\n\n unsubscribeByOriginAndTabId(origin: string, tabId?: number) {\n this.#subscriptions.forEach((subscriptionEntry) => {\n if (\n subscriptionEntry.origin === origin &&\n subscriptionEntry.tabId === tabId\n ) {\n this.#unsubscribe(subscriptionEntry);\n }\n });\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { JsonRpcParams } from
|
|
1
|
+
import type { JsonRpcParams } from '@metamask/utils';
|
|
2
2
|
/**
|
|
3
3
|
* Middleware that validates the params of a Multichain method request
|
|
4
4
|
* using the specifications from `@metamask/api-specs`.
|
|
5
5
|
*/
|
|
6
6
|
export declare const multichainMethodCallValidatorMiddleware: import("@metamask/json-rpc-engine").JsonRpcMiddleware<JsonRpcParams, import("@metamask/utils").Json>;
|
|
7
|
-
//# sourceMappingURL=multichainMethodCallValidatorMiddleware.d.
|
|
7
|
+
//# sourceMappingURL=multichainMethodCallValidatorMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multichainMethodCallValidatorMiddleware.d.ts","sourceRoot":"","sources":["../../src/middlewares/multichainMethodCallValidatorMiddleware.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAwFnE;;;GAGG;AACH,eAAO,MAAM,uCAAuC,sGAWnD,CAAC"}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
import {
|
|
8
|
-
import { createAsyncMiddleware } from "@metamask/json-rpc-engine";
|
|
9
|
-
import { rpcErrors } from "@metamask/rpc-errors";
|
|
10
|
-
import { isObject } from "@metamask/utils";
|
|
11
|
-
import $dereferenceDocument from "@open-rpc/schema-utils-js/build/dereference-document.js";
|
|
12
|
-
const dereferenceDocument = $importDefault($dereferenceDocument);
|
|
13
|
-
import { makeCustomResolver } from "@open-rpc/schema-utils-js/build/parse-open-rpc-document.js";
|
|
14
|
-
import { Validator } from "jsonschema";
|
|
1
|
+
import { MultiChainOpenRPCDocument } from '@metamask/api-specs';
|
|
2
|
+
import { createAsyncMiddleware } from '@metamask/json-rpc-engine';
|
|
3
|
+
import { rpcErrors } from '@metamask/rpc-errors';
|
|
4
|
+
import { isObject } from '@metamask/utils';
|
|
5
|
+
import { dereferenceDocument } from '@open-rpc/schema-utils-js';
|
|
6
|
+
import { makeCustomResolver } from '@open-rpc/schema-utils-js/build/parse-open-rpc-document.js';
|
|
7
|
+
import { Validator } from 'jsonschema';
|
|
15
8
|
const transformError = (error, param, got) => {
|
|
16
9
|
// if there is a path, add it to the message
|
|
17
10
|
const message = `${param.name}${error.path.length > 0 ? `.${error.path.join('.')}` : ''} ${error.message}`;
|
|
@@ -72,4 +65,4 @@ export const multichainMethodCallValidatorMiddleware = createAsyncMiddleware(asy
|
|
|
72
65
|
}
|
|
73
66
|
return await next();
|
|
74
67
|
});
|
|
75
|
-
//# sourceMappingURL=multichainMethodCallValidatorMiddleware.
|
|
68
|
+
//# sourceMappingURL=multichainMethodCallValidatorMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multichainMethodCallValidatorMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/multichainMethodCallValidatorMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAQ3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,cAAc,GAAG,CACrB,KAAsB,EACtB,KAA8B,EAC9B,GAAY,EACZ,EAAE;IACF,4CAA4C;IAC5C,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,GAC3B,KAAK,CAAC,IAAI,CA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C;QACvD,CAAC;QACD,MAAM,CAAC,GAAG,KAAgC,CAAC;QAC3C,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAEpC,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,MAA2B,EAAE;YACrE,QAAQ,EAAE,CAAC,CAAC,QAAQ;SACrB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,CACT,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACzB,OAAO,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,YAAY,CAAiB,CAAC;YAC5D,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,qBAAqB,CAC1E,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;IACjC,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAChD,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,MAAM,CACf,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,SAAS,CAAC,aAAa,CAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC,CACF,CAAC","sourcesContent":["import { MultiChainOpenRPCDocument } from '@metamask/api-specs';\nimport { createAsyncMiddleware } from '@metamask/json-rpc-engine';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { isObject } from '@metamask/utils';\nimport type { JsonRpcError, JsonRpcParams } from '@metamask/utils';\nimport type {\n ContentDescriptorObject,\n MethodObject,\n OpenrpcDocument,\n ReferenceObject,\n} from '@open-rpc/meta-schema';\nimport { dereferenceDocument } from '@open-rpc/schema-utils-js';\nimport { makeCustomResolver } from '@open-rpc/schema-utils-js/build/parse-open-rpc-document.js';\nimport type { Schema, ValidationError } from 'jsonschema';\nimport { Validator } from 'jsonschema';\n\nconst transformError = (\n error: ValidationError,\n param: ContentDescriptorObject,\n got: unknown,\n) => {\n // if there is a path, add it to the message\n const message = `${param.name}${\n error.path.length > 0 ? `.${error.path.join('.')}` : ''\n } ${error.message}`;\n\n return rpcErrors.invalidParams({\n message,\n data: {\n param: param.name,\n path: error.path,\n schema: error.schema,\n got,\n },\n });\n};\n\nconst v = new Validator();\n\nconst dereffedPromise = dereferenceDocument(\n MultiChainOpenRPCDocument as unknown as OpenrpcDocument,\n makeCustomResolver({}),\n);\n\n/**\n * Helper that utilizes the Multichain method specifications from `@metamask/api-specs`\n * to validate the params of a Multichain request.\n *\n * @param method - The request's method.\n * @param params - The request's optional JsonRpcParams object.\n * @returns an array of error objects for each validation error or an empty array if no errors.\n */\nconst multichainMethodCallValidator = async (\n method: string,\n params: JsonRpcParams | undefined,\n) => {\n const dereffed = await dereffedPromise;\n\n const methodToCheck = dereffed.methods.find(\n (m: MethodObject | ReferenceObject) => (m as MethodObject).name === method,\n ) as MethodObject | undefined;\n\n if (\n !methodToCheck ||\n !isObject(methodToCheck) ||\n !('params' in methodToCheck)\n ) {\n return [rpcErrors.methodNotFound({ data: { method } })] as JsonRpcError[];\n }\n\n const errors: JsonRpcError[] = [];\n for (const param of methodToCheck.params) {\n if (!isObject(params)) {\n return [rpcErrors.invalidParams()] as JsonRpcError[];\n }\n const p = param as ContentDescriptorObject;\n const paramToCheck = params[p.name];\n\n const result = v.validate(paramToCheck, p.schema as unknown as Schema, {\n required: p.required,\n });\n if (result.errors) {\n errors.push(\n ...result.errors.map((e) => {\n return transformError(e, p, paramToCheck) as JsonRpcError;\n }),\n );\n }\n }\n return errors;\n};\n\n/**\n * Middleware that validates the params of a Multichain method request\n * using the specifications from `@metamask/api-specs`.\n */\nexport const multichainMethodCallValidatorMiddleware = createAsyncMiddleware(\n async (request, _response, next) => {\n const errors = await multichainMethodCallValidator(\n request.method,\n request.params,\n );\n if (errors.length > 0) {\n throw rpcErrors.invalidParams<JsonRpcError[]>({ data: errors });\n }\n return await next();\n },\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/multichain-api-middleware",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-preview-97d6b86c0",
|
|
4
4
|
"description": "JSON-RPC methods and middleware to support the MetaMask Multichain API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -18,19 +18,12 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
|
+
"type": "module",
|
|
21
22
|
"sideEffects": false,
|
|
22
|
-
"main": "./dist/index.cjs",
|
|
23
|
-
"types": "./dist/index.d.cts",
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"default": "./dist/index.mjs"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/index.d.cts",
|
|
32
|
-
"default": "./dist/index.cjs"
|
|
33
|
-
}
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
34
27
|
},
|
|
35
28
|
"./package.json": "./package.json"
|
|
36
29
|
},
|
|
@@ -39,9 +32,11 @@
|
|
|
39
32
|
"registry": "https://registry.npmjs.org/"
|
|
40
33
|
},
|
|
41
34
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"build:all": "
|
|
35
|
+
"build": "tsc --project tsconfig.build.json",
|
|
36
|
+
"build:all": "tsc --build tsconfig.build.json --verbose",
|
|
37
|
+
"build:clean": "yarn build:only-clean && yarn build",
|
|
44
38
|
"build:docs": "typedoc",
|
|
39
|
+
"build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
|
|
45
40
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/multichain-api-middleware",
|
|
46
41
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/multichain-api-middleware",
|
|
47
42
|
"lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
|
|
@@ -53,13 +48,13 @@
|
|
|
53
48
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
54
49
|
},
|
|
55
50
|
"dependencies": {
|
|
56
|
-
"@metamask/accounts-controller": "^
|
|
51
|
+
"@metamask/accounts-controller": "^40.0.0",
|
|
57
52
|
"@metamask/api-specs": "^0.15.0",
|
|
58
|
-
"@metamask/chain-agnostic-permission": "^
|
|
59
|
-
"@metamask/controller-utils": "^
|
|
60
|
-
"@metamask/json-rpc-engine": "^
|
|
61
|
-
"@metamask/network-controller": "^
|
|
62
|
-
"@metamask/permission-controller": "^
|
|
53
|
+
"@metamask/chain-agnostic-permission": "^2.0.0",
|
|
54
|
+
"@metamask/controller-utils": "^13.0.0",
|
|
55
|
+
"@metamask/json-rpc-engine": "^11.0.0",
|
|
56
|
+
"@metamask/network-controller": "^37.0.0",
|
|
57
|
+
"@metamask/permission-controller": "^14.0.0",
|
|
63
58
|
"@metamask/rpc-errors": "^7.0.2",
|
|
64
59
|
"@metamask/snaps-controllers": "^19.0.0",
|
|
65
60
|
"@metamask/utils": "^11.12.0",
|
|
@@ -70,19 +65,20 @@
|
|
|
70
65
|
"devDependencies": {
|
|
71
66
|
"@metamask/auto-changelog": "^6.1.0",
|
|
72
67
|
"@metamask/eth-json-rpc-filters": "^9.0.0",
|
|
73
|
-
"@metamask/multichain-transactions-controller": "^
|
|
74
|
-
"@metamask/safe-event-emitter": "^3.
|
|
75
|
-
"@ts-bridge/cli": "^0.6.4",
|
|
68
|
+
"@metamask/multichain-transactions-controller": "^8.0.0",
|
|
69
|
+
"@metamask/safe-event-emitter": "^3.1.3",
|
|
76
70
|
"@types/jest": "^30.0.0",
|
|
71
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
77
72
|
"deepmerge": "^4.2.2",
|
|
78
73
|
"jest": "^30.4.2",
|
|
74
|
+
"rimraf": "^5.0.5",
|
|
79
75
|
"ts-jest": "^29.4.11",
|
|
80
76
|
"tsx": "^4.20.5",
|
|
81
77
|
"typedoc": "^0.25.13",
|
|
82
78
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
83
|
-
"typescript": "
|
|
79
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
84
80
|
},
|
|
85
81
|
"engines": {
|
|
86
|
-
"node": "^
|
|
82
|
+
"node": "^22.14.0 || ^24"
|
|
87
83
|
}
|
|
88
84
|
}
|
package/dist/handlers/index.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.methodHandlers = void 0;
|
|
4
|
-
const wallet_createSession_js_1 = require("./wallet-createSession.cjs");
|
|
5
|
-
const wallet_getSession_js_1 = require("./wallet-getSession.cjs");
|
|
6
|
-
const wallet_invokeMethod_js_1 = require("./wallet-invokeMethod.cjs");
|
|
7
|
-
const wallet_revokeSession_js_1 = require("./wallet-revokeSession.cjs");
|
|
8
|
-
const MethodNames = {
|
|
9
|
-
WalletCreateSession: 'wallet_createSession',
|
|
10
|
-
WalletGetSession: 'wallet_getSession',
|
|
11
|
-
WalletInvokeMethod: 'wallet_invokeMethod',
|
|
12
|
-
WalletRevokeSession: 'wallet_revokeSession',
|
|
13
|
-
};
|
|
14
|
-
exports.methodHandlers = {
|
|
15
|
-
[MethodNames.WalletCreateSession]: wallet_createSession_js_1.walletCreateSessionHandler,
|
|
16
|
-
[MethodNames.WalletGetSession]: wallet_getSession_js_1.walletGetSessionHandler,
|
|
17
|
-
[MethodNames.WalletInvokeMethod]: wallet_invokeMethod_js_1.walletInvokeMethodHandler,
|
|
18
|
-
[MethodNames.WalletRevokeSession]: wallet_revokeSession_js_1.walletRevokeSessionHandler,
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";;;AAGA,wEAAuE;AAEvE,kEAAiE;AAEjE,sEAAqE;AAErE,wEAAuE;AASvE,MAAM,WAAW,GAAG;IAClB,mBAAmB,EAAE,sBAAsB;IAC3C,gBAAgB,EAAE,mBAAmB;IACrC,kBAAkB,EAAE,qBAAqB;IACzC,mBAAmB,EAAE,sBAAsB;CACnC,CAAC;AASE,QAAA,cAAc,GAA6B;IACtD,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,oDAA0B;IAC7D,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,8CAAuB;IACvD,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,kDAAyB;IAC3D,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,oDAA0B;CAC9D,CAAC","sourcesContent":["import type { UnionToIntersection } from '@metamask/json-rpc-engine/v2';\n\nimport type { WalletCreateSessionHooks } from './wallet-createSession.js';\nimport { walletCreateSessionHandler } from './wallet-createSession.js';\nimport type { WalletGetSessionHooks } from './wallet-getSession.js';\nimport { walletGetSessionHandler } from './wallet-getSession.js';\nimport type { WalletInvokeMethodHooks } from './wallet-invokeMethod.js';\nimport { walletInvokeMethodHandler } from './wallet-invokeMethod.js';\nimport type { WalletRevokeSessionHooks } from './wallet-revokeSession.js';\nimport { walletRevokeSessionHandler } from './wallet-revokeSession.js';\n\nexport type MethodHandlerHooks = UnionToIntersection<\n | WalletCreateSessionHooks\n | WalletGetSessionHooks\n | WalletInvokeMethodHooks\n | WalletRevokeSessionHooks\n>;\n\nconst MethodNames = {\n WalletCreateSession: 'wallet_createSession',\n WalletGetSession: 'wallet_getSession',\n WalletInvokeMethod: 'wallet_invokeMethod',\n WalletRevokeSession: 'wallet_revokeSession',\n} as const;\n\ntype MethodHandlers = {\n [MethodNames.WalletCreateSession]: typeof walletCreateSessionHandler;\n [MethodNames.WalletGetSession]: typeof walletGetSessionHandler;\n [MethodNames.WalletInvokeMethod]: typeof walletInvokeMethodHandler;\n [MethodNames.WalletRevokeSession]: typeof walletRevokeSessionHandler;\n};\n\nexport const methodHandlers: Readonly<MethodHandlers> = {\n [MethodNames.WalletCreateSession]: walletCreateSessionHandler,\n [MethodNames.WalletGetSession]: walletGetSessionHandler,\n [MethodNames.WalletInvokeMethod]: walletInvokeMethodHandler,\n [MethodNames.WalletRevokeSession]: walletRevokeSessionHandler,\n};\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { UnionToIntersection } from "@metamask/json-rpc-engine/v2";
|
|
2
|
-
import type { WalletCreateSessionHooks } from "./wallet-createSession.cjs";
|
|
3
|
-
import { walletCreateSessionHandler } from "./wallet-createSession.cjs";
|
|
4
|
-
import type { WalletGetSessionHooks } from "./wallet-getSession.cjs";
|
|
5
|
-
import { walletGetSessionHandler } from "./wallet-getSession.cjs";
|
|
6
|
-
import type { WalletInvokeMethodHooks } from "./wallet-invokeMethod.cjs";
|
|
7
|
-
import { walletInvokeMethodHandler } from "./wallet-invokeMethod.cjs";
|
|
8
|
-
import type { WalletRevokeSessionHooks } from "./wallet-revokeSession.cjs";
|
|
9
|
-
import { walletRevokeSessionHandler } from "./wallet-revokeSession.cjs";
|
|
10
|
-
export type MethodHandlerHooks = UnionToIntersection<WalletCreateSessionHooks | WalletGetSessionHooks | WalletInvokeMethodHooks | WalletRevokeSessionHooks>;
|
|
11
|
-
declare const MethodNames: {
|
|
12
|
-
readonly WalletCreateSession: "wallet_createSession";
|
|
13
|
-
readonly WalletGetSession: "wallet_getSession";
|
|
14
|
-
readonly WalletInvokeMethod: "wallet_invokeMethod";
|
|
15
|
-
readonly WalletRevokeSession: "wallet_revokeSession";
|
|
16
|
-
};
|
|
17
|
-
type MethodHandlers = {
|
|
18
|
-
[MethodNames.WalletCreateSession]: typeof walletCreateSessionHandler;
|
|
19
|
-
[MethodNames.WalletGetSession]: typeof walletGetSessionHandler;
|
|
20
|
-
[MethodNames.WalletInvokeMethod]: typeof walletInvokeMethodHandler;
|
|
21
|
-
[MethodNames.WalletRevokeSession]: typeof walletRevokeSessionHandler;
|
|
22
|
-
};
|
|
23
|
-
export declare const methodHandlers: Readonly<MethodHandlers>;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qCAAqC;AAExE,OAAO,KAAK,EAAE,wBAAwB,EAAE,mCAAkC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,mCAAkC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gCAA+B;AACpE,OAAO,EAAE,uBAAuB,EAAE,gCAA+B;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,kCAAiC;AACxE,OAAO,EAAE,yBAAyB,EAAE,kCAAiC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,mCAAkC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,mCAAkC;AAEvE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAChD,wBAAwB,GACxB,qBAAqB,GACrB,uBAAuB,GACvB,wBAAwB,CAC3B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;CAKP,CAAC;AAEX,KAAK,cAAc,GAAG;IACpB,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,OAAO,0BAA0B,CAAC;IACrE,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,OAAO,uBAAuB,CAAC;IAC/D,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,OAAO,yBAAyB,CAAC;IACnE,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,OAAO,0BAA0B,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,cAAc,CAKnD,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { UnionToIntersection } from "@metamask/json-rpc-engine/v2";
|
|
2
|
-
import type { WalletCreateSessionHooks } from "./wallet-createSession.mjs";
|
|
3
|
-
import { walletCreateSessionHandler } from "./wallet-createSession.mjs";
|
|
4
|
-
import type { WalletGetSessionHooks } from "./wallet-getSession.mjs";
|
|
5
|
-
import { walletGetSessionHandler } from "./wallet-getSession.mjs";
|
|
6
|
-
import type { WalletInvokeMethodHooks } from "./wallet-invokeMethod.mjs";
|
|
7
|
-
import { walletInvokeMethodHandler } from "./wallet-invokeMethod.mjs";
|
|
8
|
-
import type { WalletRevokeSessionHooks } from "./wallet-revokeSession.mjs";
|
|
9
|
-
import { walletRevokeSessionHandler } from "./wallet-revokeSession.mjs";
|
|
10
|
-
export type MethodHandlerHooks = UnionToIntersection<WalletCreateSessionHooks | WalletGetSessionHooks | WalletInvokeMethodHooks | WalletRevokeSessionHooks>;
|
|
11
|
-
declare const MethodNames: {
|
|
12
|
-
readonly WalletCreateSession: "wallet_createSession";
|
|
13
|
-
readonly WalletGetSession: "wallet_getSession";
|
|
14
|
-
readonly WalletInvokeMethod: "wallet_invokeMethod";
|
|
15
|
-
readonly WalletRevokeSession: "wallet_revokeSession";
|
|
16
|
-
};
|
|
17
|
-
type MethodHandlers = {
|
|
18
|
-
[MethodNames.WalletCreateSession]: typeof walletCreateSessionHandler;
|
|
19
|
-
[MethodNames.WalletGetSession]: typeof walletGetSessionHandler;
|
|
20
|
-
[MethodNames.WalletInvokeMethod]: typeof walletInvokeMethodHandler;
|
|
21
|
-
[MethodNames.WalletRevokeSession]: typeof walletRevokeSessionHandler;
|
|
22
|
-
};
|
|
23
|
-
export declare const methodHandlers: Readonly<MethodHandlers>;
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qCAAqC;AAExE,OAAO,KAAK,EAAE,wBAAwB,EAAE,mCAAkC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,mCAAkC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gCAA+B;AACpE,OAAO,EAAE,uBAAuB,EAAE,gCAA+B;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,kCAAiC;AACxE,OAAO,EAAE,yBAAyB,EAAE,kCAAiC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,mCAAkC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,mCAAkC;AAEvE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAChD,wBAAwB,GACxB,qBAAqB,GACrB,uBAAuB,GACvB,wBAAwB,CAC3B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;CAKP,CAAC;AAEX,KAAK,cAAc,GAAG;IACpB,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,OAAO,0BAA0B,CAAC;IACrE,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,OAAO,uBAAuB,CAAC;IAC/D,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,OAAO,yBAAyB,CAAC;IACnE,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,OAAO,0BAA0B,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,cAAc,CAKnD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,mCAAkC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,gCAA+B;AAEjE,OAAO,EAAE,yBAAyB,EAAE,kCAAiC;AAErE,OAAO,EAAE,0BAA0B,EAAE,mCAAkC;AASvE,MAAM,WAAW,GAAG;IAClB,mBAAmB,EAAE,sBAAsB;IAC3C,gBAAgB,EAAE,mBAAmB;IACrC,kBAAkB,EAAE,qBAAqB;IACzC,mBAAmB,EAAE,sBAAsB;CACnC,CAAC;AASX,MAAM,CAAC,MAAM,cAAc,GAA6B;IACtD,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,0BAA0B;IAC7D,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,uBAAuB;IACvD,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,yBAAyB;IAC3D,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,0BAA0B;CAC9D,CAAC","sourcesContent":["import type { UnionToIntersection } from '@metamask/json-rpc-engine/v2';\n\nimport type { WalletCreateSessionHooks } from './wallet-createSession.js';\nimport { walletCreateSessionHandler } from './wallet-createSession.js';\nimport type { WalletGetSessionHooks } from './wallet-getSession.js';\nimport { walletGetSessionHandler } from './wallet-getSession.js';\nimport type { WalletInvokeMethodHooks } from './wallet-invokeMethod.js';\nimport { walletInvokeMethodHandler } from './wallet-invokeMethod.js';\nimport type { WalletRevokeSessionHooks } from './wallet-revokeSession.js';\nimport { walletRevokeSessionHandler } from './wallet-revokeSession.js';\n\nexport type MethodHandlerHooks = UnionToIntersection<\n | WalletCreateSessionHooks\n | WalletGetSessionHooks\n | WalletInvokeMethodHooks\n | WalletRevokeSessionHooks\n>;\n\nconst MethodNames = {\n WalletCreateSession: 'wallet_createSession',\n WalletGetSession: 'wallet_getSession',\n WalletInvokeMethod: 'wallet_invokeMethod',\n WalletRevokeSession: 'wallet_revokeSession',\n} as const;\n\ntype MethodHandlers = {\n [MethodNames.WalletCreateSession]: typeof walletCreateSessionHandler;\n [MethodNames.WalletGetSession]: typeof walletGetSessionHandler;\n [MethodNames.WalletInvokeMethod]: typeof walletInvokeMethodHandler;\n [MethodNames.WalletRevokeSession]: typeof walletRevokeSessionHandler;\n};\n\nexport const methodHandlers: Readonly<MethodHandlers> = {\n [MethodNames.WalletCreateSession]: walletCreateSessionHandler,\n [MethodNames.WalletGetSession]: walletGetSessionHandler,\n [MethodNames.WalletInvokeMethod]: walletInvokeMethodHandler,\n [MethodNames.WalletRevokeSession]: walletRevokeSessionHandler,\n};\n"]}
|
package/dist/handlers/types.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MultichainApiNotifications = void 0;
|
|
4
|
-
const chain_agnostic_permission_1 = require("@metamask/chain-agnostic-permission");
|
|
5
|
-
/**
|
|
6
|
-
* Multichain API notifications currently supported by/known to the wallet.
|
|
7
|
-
*/
|
|
8
|
-
var MultichainApiNotifications;
|
|
9
|
-
(function (MultichainApiNotifications) {
|
|
10
|
-
MultichainApiNotifications["sessionChanged"] = "wallet_sessionChanged";
|
|
11
|
-
MultichainApiNotifications["walletNotify"] = "wallet_notify";
|
|
12
|
-
})(MultichainApiNotifications || (exports.MultichainApiNotifications = MultichainApiNotifications = {}));
|
|
13
|
-
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":";;;AAAA,mFAG6C;AAQ7C;;GAEG;AACH,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,sEAAwC,CAAA;IACxC,4DAA8B,CAAA;AAChC,CAAC,EAHW,0BAA0B,0CAA1B,0BAA0B,QAGrC","sourcesContent":["import {\n Caip25CaveatType,\n Caip25CaveatValue,\n} from '@metamask/chain-agnostic-permission';\nimport type {\n GenericPermissionController,\n Caveat,\n} from '@metamask/permission-controller';\nimport type { MultichainRoutingService } from '@metamask/snaps-controllers';\nimport type { CaipAccountId, Hex, Json } from '@metamask/utils';\n\n/**\n * Multichain API notifications currently supported by/known to the wallet.\n */\nexport enum MultichainApiNotifications {\n sessionChanged = 'wallet_sessionChanged',\n walletNotify = 'wallet_notify',\n}\n\nexport type Caip25Caveat = Caveat<typeof Caip25CaveatType, Caip25CaveatValue>;\n\nexport type GetCaveatForOriginHook = {\n getCaveatForOrigin: (\n endowmentPermissionName: string,\n caveatType: string,\n ) => ReturnType<GenericPermissionController['getCaveat']>;\n};\n\nexport type GetNonEvmSupportedMethodsHook = {\n getNonEvmSupportedMethods: MultichainRoutingService['getSupportedMethods'];\n};\n\nexport type SortAccountIdsByLastSelectedHook = {\n sortAccountIdsByLastSelected: (accounts: CaipAccountId[]) => CaipAccountId[];\n};\n\nexport type GetCapabilitiesHook = {\n getCapabilities: (params: {\n address: string;\n }) => Promise<Record<Hex, Record<string, Json>>>;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAClB,4CAA4C;AAC7C,OAAO,KAAK,EACV,2BAA2B,EAC3B,MAAM,EACP,wCAAwC;AACzC,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAEhE;;GAEG;AACH,oBAAY,0BAA0B;IACpC,cAAc,0BAA0B;IACxC,YAAY,kBAAkB;CAC/B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAE9E,MAAM,MAAM,sBAAsB,GAAG;IACnC,kBAAkB,EAAE,CAClB,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,KACf,UAAU,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,yBAAyB,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,4BAA4B,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,CAAC;CAC9E,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CAClD,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Caip25CaveatType, Caip25CaveatValue } from "@metamask/chain-agnostic-permission";
|
|
2
|
-
import type { GenericPermissionController, Caveat } from "@metamask/permission-controller";
|
|
3
|
-
import type { MultichainRoutingService } from "@metamask/snaps-controllers";
|
|
4
|
-
import type { CaipAccountId, Hex, Json } from "@metamask/utils";
|
|
5
|
-
/**
|
|
6
|
-
* Multichain API notifications currently supported by/known to the wallet.
|
|
7
|
-
*/
|
|
8
|
-
export declare enum MultichainApiNotifications {
|
|
9
|
-
sessionChanged = "wallet_sessionChanged",
|
|
10
|
-
walletNotify = "wallet_notify"
|
|
11
|
-
}
|
|
12
|
-
export type Caip25Caveat = Caveat<typeof Caip25CaveatType, Caip25CaveatValue>;
|
|
13
|
-
export type GetCaveatForOriginHook = {
|
|
14
|
-
getCaveatForOrigin: (endowmentPermissionName: string, caveatType: string) => ReturnType<GenericPermissionController['getCaveat']>;
|
|
15
|
-
};
|
|
16
|
-
export type GetNonEvmSupportedMethodsHook = {
|
|
17
|
-
getNonEvmSupportedMethods: MultichainRoutingService['getSupportedMethods'];
|
|
18
|
-
};
|
|
19
|
-
export type SortAccountIdsByLastSelectedHook = {
|
|
20
|
-
sortAccountIdsByLastSelected: (accounts: CaipAccountId[]) => CaipAccountId[];
|
|
21
|
-
};
|
|
22
|
-
export type GetCapabilitiesHook = {
|
|
23
|
-
getCapabilities: (params: {
|
|
24
|
-
address: string;
|
|
25
|
-
}) => Promise<Record<Hex, Record<string, Json>>>;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAClB,4CAA4C;AAC7C,OAAO,KAAK,EACV,2BAA2B,EAC3B,MAAM,EACP,wCAAwC;AACzC,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAEhE;;GAEG;AACH,oBAAY,0BAA0B;IACpC,cAAc,0BAA0B;IACxC,YAAY,kBAAkB;CAC/B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAE9E,MAAM,MAAM,sBAAsB,GAAG;IACnC,kBAAkB,EAAE,CAClB,uBAAuB,EAAE,MAAM,EAC/B,UAAU,EAAE,MAAM,KACf,UAAU,CAAC,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,yBAAyB,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,4BAA4B,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,CAAC;CAC9E,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CAClD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEjB,4CAA4C;AAQ7C;;GAEG;AACH,MAAM,CAAN,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,sEAAwC,CAAA;IACxC,4DAA8B,CAAA;AAChC,CAAC,EAHW,0BAA0B,KAA1B,0BAA0B,QAGrC","sourcesContent":["import {\n Caip25CaveatType,\n Caip25CaveatValue,\n} from '@metamask/chain-agnostic-permission';\nimport type {\n GenericPermissionController,\n Caveat,\n} from '@metamask/permission-controller';\nimport type { MultichainRoutingService } from '@metamask/snaps-controllers';\nimport type { CaipAccountId, Hex, Json } from '@metamask/utils';\n\n/**\n * Multichain API notifications currently supported by/known to the wallet.\n */\nexport enum MultichainApiNotifications {\n sessionChanged = 'wallet_sessionChanged',\n walletNotify = 'wallet_notify',\n}\n\nexport type Caip25Caveat = Caveat<typeof Caip25CaveatType, Caip25CaveatValue>;\n\nexport type GetCaveatForOriginHook = {\n getCaveatForOrigin: (\n endowmentPermissionName: string,\n caveatType: string,\n ) => ReturnType<GenericPermissionController['getCaveat']>;\n};\n\nexport type GetNonEvmSupportedMethodsHook = {\n getNonEvmSupportedMethods: MultichainRoutingService['getSupportedMethods'];\n};\n\nexport type SortAccountIdsByLastSelectedHook = {\n sortAccountIdsByLastSelected: (accounts: CaipAccountId[]) => CaipAccountId[];\n};\n\nexport type GetCapabilitiesHook = {\n getCapabilities: (params: {\n address: string;\n }) => Promise<Record<Hex, Record<string, Json>>>;\n};\n"]}
|