@metamask-previews/snap-account-service 0.0.0-preview-1614749c0
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 +14 -0
- package/LICENSE +20 -0
- package/README.md +25 -0
- package/dist/SnapAccountService.cjs +51 -0
- package/dist/SnapAccountService.cjs.map +1 -0
- package/dist/SnapAccountService.d.cts +52 -0
- package/dist/SnapAccountService.d.cts.map +1 -0
- package/dist/SnapAccountService.d.mts +52 -0
- package/dist/SnapAccountService.d.mts.map +1 -0
- package/dist/SnapAccountService.mjs +47 -0
- package/dist/SnapAccountService.mjs.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +73 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `SnapAccountService` ([#8414](https://github.com/MetaMask/core/pull/8414))
|
|
13
|
+
|
|
14
|
+
[Unreleased]: https://github.com/MetaMask/core/
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MetaMask
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# `@metamask/snap-account-service`
|
|
2
|
+
|
|
3
|
+
Service for Account Management Snaps
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`SnapAccountService` centralizes common operations around Snap-based account management, providing a single integration point for:
|
|
8
|
+
|
|
9
|
+
- **Migration** — Migrates accounts from the legacy monolithic v1 Snap keyring to per-Snap v2 keyrings. The migration runs once at initialization and is safe for concurrent callers (subsequent calls await the same promise).
|
|
10
|
+
- **Readiness** — Ensures a Snap is fully ready for account operations before proceeding: migration is complete, a v2 keyring exists for the Snap, and the Snap platform itself is initialized.
|
|
11
|
+
- **Keyring message handling** — Routes messages from Snap keyrings to the appropriate per-Snap keyring instance, including lazy keyring creation for event-driven v1 flows.
|
|
12
|
+
|
|
13
|
+
The service exposes its functionality through the MetaMask messenger pattern and depends on `KeyringController` and `SnapController`.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
`yarn add @metamask/snap-account-service`
|
|
18
|
+
|
|
19
|
+
or
|
|
20
|
+
|
|
21
|
+
`npm install @metamask/snap-account-service`
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _SnapAccountService_messenger;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SnapAccountService = exports.serviceName = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* The name of the {@link SnapAccountService}, used to namespace the service's
|
|
18
|
+
* actions and events.
|
|
19
|
+
*/
|
|
20
|
+
exports.serviceName = 'SnapAccountService';
|
|
21
|
+
/**
|
|
22
|
+
* All of the methods within {@link SnapAccountService} that are exposed via
|
|
23
|
+
* the messenger.
|
|
24
|
+
*/
|
|
25
|
+
const MESSENGER_EXPOSED_METHODS = [];
|
|
26
|
+
/**
|
|
27
|
+
* Service responsible for managing account management snaps.
|
|
28
|
+
*/
|
|
29
|
+
class SnapAccountService {
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a new {@link SnapAccountService}.
|
|
32
|
+
*
|
|
33
|
+
* @param args - The constructor arguments.
|
|
34
|
+
* @param args.messenger - The messenger suited for this service.
|
|
35
|
+
*/
|
|
36
|
+
constructor({ messenger }) {
|
|
37
|
+
_SnapAccountService_messenger.set(this, void 0);
|
|
38
|
+
this.name = exports.serviceName;
|
|
39
|
+
__classPrivateFieldSet(this, _SnapAccountService_messenger, messenger, "f");
|
|
40
|
+
__classPrivateFieldGet(this, _SnapAccountService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Initializes the snap account service.
|
|
44
|
+
*/
|
|
45
|
+
async init() {
|
|
46
|
+
// TODO: Add initialization logic here.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.SnapAccountService = SnapAccountService;
|
|
50
|
+
_SnapAccountService_messenger = new WeakMap();
|
|
51
|
+
//# sourceMappingURL=SnapAccountService.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapAccountService.cjs","sourceRoot":"","sources":["../src/SnapAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA;;;GAGG;AACU,QAAA,WAAW,GAAG,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,MAAM,yBAAyB,GAAG,EAAW,CAAC;AAgC9C;;GAEG;AACH,MAAa,kBAAkB;IAQ7B;;;;;OAKG;IACH,YAAY,EAAE,SAAS,EAA8C;QAR5D,gDAAwC;QAS/C,IAAI,CAAC,IAAI,GAAG,mBAAW,CAAC;QACxB,uBAAA,IAAI,iCAAc,SAAS,MAAA,CAAC;QAE5B,uBAAA,IAAI,qCAAW,CAAC,4BAA4B,CAC1C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,uCAAuC;IACzC,CAAC;CACF;AA9BD,gDA8BC","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\n/**\n * The name of the {@link SnapAccountService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'SnapAccountService';\n\n/**\n * All of the methods within {@link SnapAccountService} that are exposed via\n * the messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = [] as const;\n\n/**\n * Actions that {@link SnapAccountService} exposes to other consumers.\n */\nexport type SnapAccountServiceActions = never;\n\n/**\n * Actions from other messengers that {@link SnapAccountService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link SnapAccountService} exposes to other consumers.\n */\nexport type SnapAccountServiceEvents = never;\n\n/**\n * Events from other messengers that {@link SnapAccountService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link SnapAccountService}.\n */\nexport type SnapAccountServiceMessenger = Messenger<\n typeof serviceName,\n SnapAccountServiceActions | AllowedActions,\n SnapAccountServiceEvents | AllowedEvents\n>;\n\n/**\n * Service responsible for managing account management snaps.\n */\nexport class SnapAccountService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n readonly #messenger: SnapAccountServiceMessenger;\n\n /**\n * Constructs a new {@link SnapAccountService}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n */\n constructor({ messenger }: { messenger: SnapAccountServiceMessenger }) {\n this.name = serviceName;\n this.#messenger = messenger;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Initializes the snap account service.\n */\n async init(): Promise<void> {\n // TODO: Add initialization logic here.\n }\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Messenger } from "@metamask/messenger";
|
|
2
|
+
/**
|
|
3
|
+
* The name of the {@link SnapAccountService}, used to namespace the service's
|
|
4
|
+
* actions and events.
|
|
5
|
+
*/
|
|
6
|
+
export declare const serviceName = "SnapAccountService";
|
|
7
|
+
/**
|
|
8
|
+
* Actions that {@link SnapAccountService} exposes to other consumers.
|
|
9
|
+
*/
|
|
10
|
+
export type SnapAccountServiceActions = never;
|
|
11
|
+
/**
|
|
12
|
+
* Actions from other messengers that {@link SnapAccountService} calls.
|
|
13
|
+
*/
|
|
14
|
+
type AllowedActions = never;
|
|
15
|
+
/**
|
|
16
|
+
* Events that {@link SnapAccountService} exposes to other consumers.
|
|
17
|
+
*/
|
|
18
|
+
export type SnapAccountServiceEvents = never;
|
|
19
|
+
/**
|
|
20
|
+
* Events from other messengers that {@link SnapAccountService} subscribes to.
|
|
21
|
+
*/
|
|
22
|
+
type AllowedEvents = never;
|
|
23
|
+
/**
|
|
24
|
+
* The messenger which is restricted to actions and events accessed by
|
|
25
|
+
* {@link SnapAccountService}.
|
|
26
|
+
*/
|
|
27
|
+
export type SnapAccountServiceMessenger = Messenger<typeof serviceName, SnapAccountServiceActions | AllowedActions, SnapAccountServiceEvents | AllowedEvents>;
|
|
28
|
+
/**
|
|
29
|
+
* Service responsible for managing account management snaps.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SnapAccountService {
|
|
32
|
+
#private;
|
|
33
|
+
/**
|
|
34
|
+
* The name of the service.
|
|
35
|
+
*/
|
|
36
|
+
readonly name: typeof serviceName;
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new {@link SnapAccountService}.
|
|
39
|
+
*
|
|
40
|
+
* @param args - The constructor arguments.
|
|
41
|
+
* @param args.messenger - The messenger suited for this service.
|
|
42
|
+
*/
|
|
43
|
+
constructor({ messenger }: {
|
|
44
|
+
messenger: SnapAccountServiceMessenger;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Initializes the snap account service.
|
|
48
|
+
*/
|
|
49
|
+
init(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=SnapAccountService.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapAccountService.d.cts","sourceRoot":"","sources":["../src/SnapAccountService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;;GAGG;AACH,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAQhD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE9C;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE7C;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,SAAS,CACjD,OAAO,WAAW,EAClB,yBAAyB,GAAG,cAAc,EAC1C,wBAAwB,GAAG,aAAa,CACzC,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;;IAC7B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,WAAW,CAAC;IAIlC;;;;;OAKG;gBACS,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,2BAA2B,CAAA;KAAE;IAUrE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Messenger } from "@metamask/messenger";
|
|
2
|
+
/**
|
|
3
|
+
* The name of the {@link SnapAccountService}, used to namespace the service's
|
|
4
|
+
* actions and events.
|
|
5
|
+
*/
|
|
6
|
+
export declare const serviceName = "SnapAccountService";
|
|
7
|
+
/**
|
|
8
|
+
* Actions that {@link SnapAccountService} exposes to other consumers.
|
|
9
|
+
*/
|
|
10
|
+
export type SnapAccountServiceActions = never;
|
|
11
|
+
/**
|
|
12
|
+
* Actions from other messengers that {@link SnapAccountService} calls.
|
|
13
|
+
*/
|
|
14
|
+
type AllowedActions = never;
|
|
15
|
+
/**
|
|
16
|
+
* Events that {@link SnapAccountService} exposes to other consumers.
|
|
17
|
+
*/
|
|
18
|
+
export type SnapAccountServiceEvents = never;
|
|
19
|
+
/**
|
|
20
|
+
* Events from other messengers that {@link SnapAccountService} subscribes to.
|
|
21
|
+
*/
|
|
22
|
+
type AllowedEvents = never;
|
|
23
|
+
/**
|
|
24
|
+
* The messenger which is restricted to actions and events accessed by
|
|
25
|
+
* {@link SnapAccountService}.
|
|
26
|
+
*/
|
|
27
|
+
export type SnapAccountServiceMessenger = Messenger<typeof serviceName, SnapAccountServiceActions | AllowedActions, SnapAccountServiceEvents | AllowedEvents>;
|
|
28
|
+
/**
|
|
29
|
+
* Service responsible for managing account management snaps.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SnapAccountService {
|
|
32
|
+
#private;
|
|
33
|
+
/**
|
|
34
|
+
* The name of the service.
|
|
35
|
+
*/
|
|
36
|
+
readonly name: typeof serviceName;
|
|
37
|
+
/**
|
|
38
|
+
* Constructs a new {@link SnapAccountService}.
|
|
39
|
+
*
|
|
40
|
+
* @param args - The constructor arguments.
|
|
41
|
+
* @param args.messenger - The messenger suited for this service.
|
|
42
|
+
*/
|
|
43
|
+
constructor({ messenger }: {
|
|
44
|
+
messenger: SnapAccountServiceMessenger;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Initializes the snap account service.
|
|
48
|
+
*/
|
|
49
|
+
init(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=SnapAccountService.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapAccountService.d.mts","sourceRoot":"","sources":["../src/SnapAccountService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD;;;GAGG;AACH,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAQhD;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE9C;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE7C;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,SAAS,CACjD,OAAO,WAAW,EAClB,yBAAyB,GAAG,cAAc,EAC1C,wBAAwB,GAAG,aAAa,CACzC,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;;IAC7B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,WAAW,CAAC;IAIlC;;;;;OAKG;gBACS,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,2BAA2B,CAAA;KAAE;IAUrE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _SnapAccountService_messenger;
|
|
13
|
+
/**
|
|
14
|
+
* The name of the {@link SnapAccountService}, used to namespace the service's
|
|
15
|
+
* actions and events.
|
|
16
|
+
*/
|
|
17
|
+
export const serviceName = 'SnapAccountService';
|
|
18
|
+
/**
|
|
19
|
+
* All of the methods within {@link SnapAccountService} that are exposed via
|
|
20
|
+
* the messenger.
|
|
21
|
+
*/
|
|
22
|
+
const MESSENGER_EXPOSED_METHODS = [];
|
|
23
|
+
/**
|
|
24
|
+
* Service responsible for managing account management snaps.
|
|
25
|
+
*/
|
|
26
|
+
export class SnapAccountService {
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new {@link SnapAccountService}.
|
|
29
|
+
*
|
|
30
|
+
* @param args - The constructor arguments.
|
|
31
|
+
* @param args.messenger - The messenger suited for this service.
|
|
32
|
+
*/
|
|
33
|
+
constructor({ messenger }) {
|
|
34
|
+
_SnapAccountService_messenger.set(this, void 0);
|
|
35
|
+
this.name = serviceName;
|
|
36
|
+
__classPrivateFieldSet(this, _SnapAccountService_messenger, messenger, "f");
|
|
37
|
+
__classPrivateFieldGet(this, _SnapAccountService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Initializes the snap account service.
|
|
41
|
+
*/
|
|
42
|
+
async init() {
|
|
43
|
+
// TODO: Add initialization logic here.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
_SnapAccountService_messenger = new WeakMap();
|
|
47
|
+
//# sourceMappingURL=SnapAccountService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnapAccountService.mjs","sourceRoot":"","sources":["../src/SnapAccountService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,MAAM,yBAAyB,GAAG,EAAW,CAAC;AAgC9C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAQ7B;;;;;OAKG;IACH,YAAY,EAAE,SAAS,EAA8C;QAR5D,gDAAwC;QAS/C,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,uBAAA,IAAI,iCAAc,SAAS,MAAA,CAAC;QAE5B,uBAAA,IAAI,qCAAW,CAAC,4BAA4B,CAC1C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,uCAAuC;IACzC,CAAC;CACF","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\n/**\n * The name of the {@link SnapAccountService}, used to namespace the service's\n * actions and events.\n */\nexport const serviceName = 'SnapAccountService';\n\n/**\n * All of the methods within {@link SnapAccountService} that are exposed via\n * the messenger.\n */\nconst MESSENGER_EXPOSED_METHODS = [] as const;\n\n/**\n * Actions that {@link SnapAccountService} exposes to other consumers.\n */\nexport type SnapAccountServiceActions = never;\n\n/**\n * Actions from other messengers that {@link SnapAccountService} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link SnapAccountService} exposes to other consumers.\n */\nexport type SnapAccountServiceEvents = never;\n\n/**\n * Events from other messengers that {@link SnapAccountService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link SnapAccountService}.\n */\nexport type SnapAccountServiceMessenger = Messenger<\n typeof serviceName,\n SnapAccountServiceActions | AllowedActions,\n SnapAccountServiceEvents | AllowedEvents\n>;\n\n/**\n * Service responsible for managing account management snaps.\n */\nexport class SnapAccountService {\n /**\n * The name of the service.\n */\n readonly name: typeof serviceName;\n\n readonly #messenger: SnapAccountServiceMessenger;\n\n /**\n * Constructs a new {@link SnapAccountService}.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger suited for this service.\n */\n constructor({ messenger }: { messenger: SnapAccountServiceMessenger }) {\n this.name = serviceName;\n this.#messenger = messenger;\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Initializes the snap account service.\n */\n async init(): Promise<void> {\n // TODO: Add initialization logic here.\n }\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SnapAccountService = void 0;
|
|
4
|
+
var SnapAccountService_1 = require("./SnapAccountService.cjs");
|
|
5
|
+
Object.defineProperty(exports, "SnapAccountService", { enumerable: true, get: function () { return SnapAccountService_1.SnapAccountService; } });
|
|
6
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+DAA0D;AAAjD,wHAAA,kBAAkB,OAAA","sourcesContent":["export { SnapAccountService } from './SnapAccountService';\nexport type {\n SnapAccountServiceActions,\n SnapAccountServiceEvents,\n SnapAccountServiceMessenger,\n} from './SnapAccountService';\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iCAA6B;AAC1D,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,GAC5B,iCAA6B"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iCAA6B;AAC1D,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,GAC5B,iCAA6B"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iCAA6B","sourcesContent":["export { SnapAccountService } from './SnapAccountService';\nexport type {\n SnapAccountServiceActions,\n SnapAccountServiceEvents,\n SnapAccountServiceMessenger,\n} from './SnapAccountService';\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metamask-previews/snap-account-service",
|
|
3
|
+
"version": "0.0.0-preview-1614749c0",
|
|
4
|
+
"description": "Service for Account Management Snaps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Ethereum",
|
|
7
|
+
"MetaMask"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/snap-account-service#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/MetaMask/core/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/MetaMask/core.git"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"default": "./dist/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.cts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
43
|
+
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
44
|
+
"build:docs": "typedoc",
|
|
45
|
+
"changelog:update": "../../scripts/update-changelog.sh @metamask/snap-account-service",
|
|
46
|
+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/snap-account-service",
|
|
47
|
+
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --check",
|
|
48
|
+
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --generate",
|
|
49
|
+
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
50
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
51
|
+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
52
|
+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
53
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@metamask/messenger": "^1.1.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@metamask/auto-changelog": "^6.1.0",
|
|
60
|
+
"@ts-bridge/cli": "^0.6.4",
|
|
61
|
+
"@types/jest": "^29.5.14",
|
|
62
|
+
"deepmerge": "^4.2.2",
|
|
63
|
+
"jest": "^29.7.0",
|
|
64
|
+
"ts-jest": "^29.2.5",
|
|
65
|
+
"tsx": "^4.20.5",
|
|
66
|
+
"typedoc": "^0.25.13",
|
|
67
|
+
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
68
|
+
"typescript": "~5.3.3"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": "^18.18 || >=20"
|
|
72
|
+
}
|
|
73
|
+
}
|