@metamask-previews/keyring-snap-client 8.2.0-fd40efd → 8.2.1-5c366be
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 +12 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/v2/KeyringClientV2.cjs +91 -0
- package/dist/v2/KeyringClientV2.cjs.map +1 -0
- package/dist/v2/KeyringClientV2.d.cts +28 -0
- package/dist/v2/KeyringClientV2.d.cts.map +1 -0
- package/dist/v2/KeyringClientV2.d.mts +28 -0
- package/dist/v2/KeyringClientV2.d.mts.map +1 -0
- package/dist/v2/KeyringClientV2.mjs +87 -0
- package/dist/v2/KeyringClientV2.mjs.map +1 -0
- package/dist/v2/index.cjs +18 -0
- package/dist/v2/index.cjs.map +1 -0
- package/dist/v2/index.d.cts +2 -0
- package/dist/v2/index.d.cts.map +1 -0
- package/dist/v2/index.d.mts +2 -0
- package/dist/v2/index.d.mts.map +1 -0
- package/dist/v2/index.mjs +2 -0
- package/dist/v2/index.mjs.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `KeyringClientV2` class implementing the keyring v2 RPC client ([#408](https://github.com/MetaMask/accounts/pull/408))
|
|
13
|
+
|
|
14
|
+
## [8.2.1]
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Bump `@metamask/keyring-api` from `^21.6.0` to `^22.0.0` ([#482](https://github.com/MetaMask/accounts/pull/482))
|
|
19
|
+
|
|
10
20
|
## [8.2.0]
|
|
11
21
|
|
|
12
22
|
### Added
|
|
@@ -148,7 +158,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
148
158
|
- This new version fixes a bug with CJS re-exports.
|
|
149
159
|
- Initial release ([#24](https://github.com/MetaMask/accounts/pull/24))
|
|
150
160
|
|
|
151
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-snap-client@8.2.
|
|
161
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-snap-client@8.2.1...HEAD
|
|
162
|
+
[8.2.1]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-snap-client@8.2.0...@metamask/keyring-snap-client@8.2.1
|
|
152
163
|
[8.2.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-snap-client@8.1.1...@metamask/keyring-snap-client@8.2.0
|
|
153
164
|
[8.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-snap-client@8.1.0...@metamask/keyring-snap-client@8.1.1
|
|
154
165
|
[8.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-snap-client@8.0.0...@metamask/keyring-snap-client@8.1.0
|
package/dist/index.cjs
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./KeyringClient.cjs"), exports);
|
|
18
18
|
__exportStar(require("./KeyringSnapRpcClient.cjs"), exports);
|
|
19
19
|
__exportStar(require("./KeyringPublicClient.cjs"), exports);
|
|
20
|
+
__exportStar(require("./v2/index.cjs"), exports);
|
|
20
21
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAgC;AAChC,6DAAuC;AACvC,4DAAsC","sourcesContent":["export * from './KeyringClient';\nexport * from './KeyringSnapRpcClient';\nexport * from './KeyringPublicClient';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAgC;AAChC,6DAAuC;AACvC,4DAAsC;AACtC,iDAAqB","sourcesContent":["export * from './KeyringClient';\nexport * from './KeyringSnapRpcClient';\nexport * from './KeyringPublicClient';\nexport * from './v2';\n"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,2CAAuC;AACvC,0CAAsC"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,2CAAuC;AACvC,0CAAsC;AACtC,+BAAqB"}
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,2CAAuC;AACvC,0CAAsC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,2CAAuC;AACvC,0CAAsC;AACtC,+BAAqB"}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,2CAAuC;AACvC,0CAAsC","sourcesContent":["export * from './KeyringClient';\nexport * from './KeyringSnapRpcClient';\nexport * from './KeyringPublicClient';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAgC;AAChC,2CAAuC;AACvC,0CAAsC;AACtC,+BAAqB","sourcesContent":["export * from './KeyringClient';\nexport * from './KeyringSnapRpcClient';\nexport * from './KeyringPublicClient';\nexport * from './v2';\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 _KeyringClientV2_sender;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.KeyringClientV2 = void 0;
|
|
16
|
+
const keyring_api_1 = require("@metamask/keyring-api");
|
|
17
|
+
const keyring_utils_1 = require("@metamask/keyring-utils");
|
|
18
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
19
|
+
const uuid_1 = require("uuid");
|
|
20
|
+
class KeyringClientV2 {
|
|
21
|
+
/**
|
|
22
|
+
* Create a new instance of `KeyringClient`.
|
|
23
|
+
*
|
|
24
|
+
* @param sender - The `Sender` instance to use to send requests to the snap.
|
|
25
|
+
*/
|
|
26
|
+
constructor(sender) {
|
|
27
|
+
_KeyringClientV2_sender.set(this, void 0);
|
|
28
|
+
__classPrivateFieldSet(this, _KeyringClientV2_sender, sender, "f");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Send a request to the Snap and return the response.
|
|
32
|
+
*
|
|
33
|
+
* @param request - A partial JSON-RPC request (method and params).
|
|
34
|
+
* @returns A promise that resolves to the response to the request.
|
|
35
|
+
*/
|
|
36
|
+
async send(request) {
|
|
37
|
+
return __classPrivateFieldGet(this, _KeyringClientV2_sender, "f").send({
|
|
38
|
+
...request,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async getAccounts() {
|
|
42
|
+
return (0, keyring_utils_1.strictMask)(await this.send({
|
|
43
|
+
jsonrpc: '2.0',
|
|
44
|
+
id: (0, uuid_1.v4)(),
|
|
45
|
+
method: keyring_api_1.KeyringRpcV2Method.GetAccounts,
|
|
46
|
+
}), keyring_api_1.GetAccountsV2ResponseStruct);
|
|
47
|
+
}
|
|
48
|
+
async getAccount(id) {
|
|
49
|
+
return (0, keyring_utils_1.strictMask)(await this.send({
|
|
50
|
+
jsonrpc: '2.0',
|
|
51
|
+
id: (0, uuid_1.v4)(),
|
|
52
|
+
method: keyring_api_1.KeyringRpcV2Method.GetAccount,
|
|
53
|
+
params: { id },
|
|
54
|
+
}), keyring_api_1.GetAccountV2ResponseStruct);
|
|
55
|
+
}
|
|
56
|
+
async createAccounts(params) {
|
|
57
|
+
return (0, keyring_utils_1.strictMask)(await this.send({
|
|
58
|
+
jsonrpc: '2.0',
|
|
59
|
+
id: (0, uuid_1.v4)(),
|
|
60
|
+
method: keyring_api_1.KeyringRpcV2Method.CreateAccounts,
|
|
61
|
+
params,
|
|
62
|
+
}), keyring_api_1.CreateAccountsV2ResponseStruct);
|
|
63
|
+
}
|
|
64
|
+
async exportAccount(id, options) {
|
|
65
|
+
return (0, keyring_utils_1.strictMask)(await this.send({
|
|
66
|
+
jsonrpc: '2.0',
|
|
67
|
+
id: (0, uuid_1.v4)(),
|
|
68
|
+
method: keyring_api_1.KeyringRpcV2Method.ExportAccount,
|
|
69
|
+
params: { id, ...(options && { options }) },
|
|
70
|
+
}), keyring_api_1.ExportAccountV2ResponseStruct);
|
|
71
|
+
}
|
|
72
|
+
async deleteAccount(id) {
|
|
73
|
+
(0, superstruct_1.assert)(await this.send({
|
|
74
|
+
jsonrpc: '2.0',
|
|
75
|
+
id: (0, uuid_1.v4)(),
|
|
76
|
+
method: keyring_api_1.KeyringRpcV2Method.DeleteAccount,
|
|
77
|
+
params: { id },
|
|
78
|
+
}), keyring_api_1.DeleteAccountV2ResponseStruct);
|
|
79
|
+
}
|
|
80
|
+
async submitRequest(request) {
|
|
81
|
+
return (0, keyring_utils_1.strictMask)(await this.send({
|
|
82
|
+
jsonrpc: '2.0',
|
|
83
|
+
id: (0, uuid_1.v4)(),
|
|
84
|
+
method: keyring_api_1.KeyringRpcV2Method.SubmitRequest,
|
|
85
|
+
params: request,
|
|
86
|
+
}), keyring_api_1.SubmitRequestV2ResponseStruct);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.KeyringClientV2 = KeyringClientV2;
|
|
90
|
+
_KeyringClientV2_sender = new WeakMap();
|
|
91
|
+
//# sourceMappingURL=KeyringClientV2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyringClientV2.cjs","sourceRoot":"","sources":["../../src/v2/KeyringClientV2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAQ+B;AAW/B,2DAAqD;AACrD,uDAA+C;AAE/C,+BAAkC;AAIlC,MAAa,eAAe;IAG1B;;;;OAIG;IACH,YAAY,MAAc;QAPjB,0CAAgB;QAQvB,uBAAA,IAAI,2BAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,IAAI,CAClB,OAA2C;QAE3C,OAAO,uBAAA,IAAI,+BAAQ,CAAC,IAAI,CAAC;YACvB,GA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ACd,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,IAAA,SAAI,GAAE;YACV,MAAM,EAAE,gCAAkB,CAAC,aAAa;YACxC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,2CAA6B,CAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAuB;QACzC,OAAO,IAAA,0BAAU,EACf,MAAM,IAAI,CAAC,IAAI,CAAC;YACd,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,IAAA,SAAI,GAAE;YACV,MAAM,EAAE,gCAAkB,CAAC,aAAa;YACxC,MAAM,EAAE,OAAO;SAChB,CAAC,EACF,2CAA6B,CAC9B,CAAC;IACJ,CAAC;CACF;AArGD,0CAqGC","sourcesContent":["import {\n CreateAccountsV2ResponseStruct,\n DeleteAccountV2ResponseStruct,\n GetAccountV2ResponseStruct,\n GetAccountsV2ResponseStruct,\n SubmitRequestV2ResponseStruct,\n KeyringRpcV2Method,\n ExportAccountV2ResponseStruct,\n} from '@metamask/keyring-api';\nimport type {\n CreateAccountOptions,\n ExportAccountOptions,\n ExportedAccount,\n KeyringAccount,\n KeyringRequest,\n KeyringRpcV2,\n KeyringRpcV2Request,\n} from '@metamask/keyring-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport { strictMask } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type { Sender } from '../KeyringClient';\n\nexport class KeyringClientV2 implements KeyringRpcV2 {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the Snap and return the response.\n *\n * @param request - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n protected async send<RequestMethod extends KeyringRpcV2Method>(\n request: KeyringRpcV2Request<RequestMethod>,\n ): Promise<Json> {\n return this.#sender.send({\n ...request,\n });\n }\n\n async getAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.GetAccounts,\n }),\n GetAccountsV2ResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.GetAccount,\n params: { id },\n }),\n GetAccountV2ResponseStruct,\n );\n }\n\n async createAccounts(\n params: CreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.CreateAccounts,\n params,\n }),\n CreateAccountsV2ResponseStruct,\n );\n }\n\n async exportAccount(\n id: AccountId,\n options?: ExportAccountOptions,\n ): Promise<ExportedAccount> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.ExportAccount,\n params: { id, ...(options && { options }) },\n }),\n ExportAccountV2ResponseStruct,\n );\n }\n\n async deleteAccount(id: AccountId): Promise<void> {\n assert(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.DeleteAccount,\n params: { id },\n }),\n DeleteAccountV2ResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<Json> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.SubmitRequest,\n params: request,\n }),\n SubmitRequestV2ResponseStruct,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { KeyringRpcV2Method } from "@metamask/keyring-api";
|
|
2
|
+
import type { CreateAccountOptions, ExportAccountOptions, ExportedAccount, KeyringAccount, KeyringRequest, KeyringRpcV2, KeyringRpcV2Request } from "@metamask/keyring-api";
|
|
3
|
+
import type { AccountId } from "@metamask/keyring-utils";
|
|
4
|
+
import type { Json } from "@metamask/utils";
|
|
5
|
+
import type { Sender } from "../KeyringClient.cjs";
|
|
6
|
+
export declare class KeyringClientV2 implements KeyringRpcV2 {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of `KeyringClient`.
|
|
10
|
+
*
|
|
11
|
+
* @param sender - The `Sender` instance to use to send requests to the snap.
|
|
12
|
+
*/
|
|
13
|
+
constructor(sender: Sender);
|
|
14
|
+
/**
|
|
15
|
+
* Send a request to the Snap and return the response.
|
|
16
|
+
*
|
|
17
|
+
* @param request - A partial JSON-RPC request (method and params).
|
|
18
|
+
* @returns A promise that resolves to the response to the request.
|
|
19
|
+
*/
|
|
20
|
+
protected send<RequestMethod extends KeyringRpcV2Method>(request: KeyringRpcV2Request<RequestMethod>): Promise<Json>;
|
|
21
|
+
getAccounts(): Promise<KeyringAccount[]>;
|
|
22
|
+
getAccount(id: string): Promise<KeyringAccount>;
|
|
23
|
+
createAccounts(params: CreateAccountOptions): Promise<KeyringAccount[]>;
|
|
24
|
+
exportAccount(id: AccountId, options?: ExportAccountOptions): Promise<ExportedAccount>;
|
|
25
|
+
deleteAccount(id: AccountId): Promise<void>;
|
|
26
|
+
submitRequest(request: KeyringRequest): Promise<Json>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=KeyringClientV2.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyringClientV2.d.cts","sourceRoot":"","sources":["../../src/v2/KeyringClientV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,kBAAkB,EAEnB,8BAA8B;AAC/B,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,mBAAmB,EACpB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAGzD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,MAAM,EAAE,6BAAyB;AAE/C,qBAAa,eAAgB,YAAW,YAAY;;IAGlD;;;;OAIG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;OAKG;cACa,IAAI,CAAC,aAAa,SAAS,kBAAkB,EAC3D,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC;IAMV,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAWxC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAY/C,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC;IAYtB,aAAa,CACjB,EAAE,EAAE,SAAS,EACb,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,eAAe,CAAC;IAYrB,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAW5D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { KeyringRpcV2Method } from "@metamask/keyring-api";
|
|
2
|
+
import type { CreateAccountOptions, ExportAccountOptions, ExportedAccount, KeyringAccount, KeyringRequest, KeyringRpcV2, KeyringRpcV2Request } from "@metamask/keyring-api";
|
|
3
|
+
import type { AccountId } from "@metamask/keyring-utils";
|
|
4
|
+
import type { Json } from "@metamask/utils";
|
|
5
|
+
import type { Sender } from "../KeyringClient.mjs";
|
|
6
|
+
export declare class KeyringClientV2 implements KeyringRpcV2 {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of `KeyringClient`.
|
|
10
|
+
*
|
|
11
|
+
* @param sender - The `Sender` instance to use to send requests to the snap.
|
|
12
|
+
*/
|
|
13
|
+
constructor(sender: Sender);
|
|
14
|
+
/**
|
|
15
|
+
* Send a request to the Snap and return the response.
|
|
16
|
+
*
|
|
17
|
+
* @param request - A partial JSON-RPC request (method and params).
|
|
18
|
+
* @returns A promise that resolves to the response to the request.
|
|
19
|
+
*/
|
|
20
|
+
protected send<RequestMethod extends KeyringRpcV2Method>(request: KeyringRpcV2Request<RequestMethod>): Promise<Json>;
|
|
21
|
+
getAccounts(): Promise<KeyringAccount[]>;
|
|
22
|
+
getAccount(id: string): Promise<KeyringAccount>;
|
|
23
|
+
createAccounts(params: CreateAccountOptions): Promise<KeyringAccount[]>;
|
|
24
|
+
exportAccount(id: AccountId, options?: ExportAccountOptions): Promise<ExportedAccount>;
|
|
25
|
+
deleteAccount(id: AccountId): Promise<void>;
|
|
26
|
+
submitRequest(request: KeyringRequest): Promise<Json>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=KeyringClientV2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyringClientV2.d.mts","sourceRoot":"","sources":["../../src/v2/KeyringClientV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,kBAAkB,EAEnB,8BAA8B;AAC/B,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,mBAAmB,EACpB,8BAA8B;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAGzD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,MAAM,EAAE,6BAAyB;AAE/C,qBAAa,eAAgB,YAAW,YAAY;;IAGlD;;;;OAIG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;OAKG;cACa,IAAI,CAAC,aAAa,SAAS,kBAAkB,EAC3D,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC;IAMV,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAWxC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAY/C,cAAc,CAClB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC;IAYtB,aAAa,CACjB,EAAE,EAAE,SAAS,EACb,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,eAAe,CAAC;IAYrB,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAW5D"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 _KeyringClientV2_sender;
|
|
13
|
+
import { CreateAccountsV2ResponseStruct, DeleteAccountV2ResponseStruct, GetAccountV2ResponseStruct, GetAccountsV2ResponseStruct, SubmitRequestV2ResponseStruct, KeyringRpcV2Method, ExportAccountV2ResponseStruct } from "@metamask/keyring-api";
|
|
14
|
+
import { strictMask } from "@metamask/keyring-utils";
|
|
15
|
+
import { assert } from "@metamask/superstruct";
|
|
16
|
+
import { v4 as uuid } from "uuid";
|
|
17
|
+
export class KeyringClientV2 {
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `KeyringClient`.
|
|
20
|
+
*
|
|
21
|
+
* @param sender - The `Sender` instance to use to send requests to the snap.
|
|
22
|
+
*/
|
|
23
|
+
constructor(sender) {
|
|
24
|
+
_KeyringClientV2_sender.set(this, void 0);
|
|
25
|
+
__classPrivateFieldSet(this, _KeyringClientV2_sender, sender, "f");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Send a request to the Snap and return the response.
|
|
29
|
+
*
|
|
30
|
+
* @param request - A partial JSON-RPC request (method and params).
|
|
31
|
+
* @returns A promise that resolves to the response to the request.
|
|
32
|
+
*/
|
|
33
|
+
async send(request) {
|
|
34
|
+
return __classPrivateFieldGet(this, _KeyringClientV2_sender, "f").send({
|
|
35
|
+
...request,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async getAccounts() {
|
|
39
|
+
return strictMask(await this.send({
|
|
40
|
+
jsonrpc: '2.0',
|
|
41
|
+
id: uuid(),
|
|
42
|
+
method: KeyringRpcV2Method.GetAccounts,
|
|
43
|
+
}), GetAccountsV2ResponseStruct);
|
|
44
|
+
}
|
|
45
|
+
async getAccount(id) {
|
|
46
|
+
return strictMask(await this.send({
|
|
47
|
+
jsonrpc: '2.0',
|
|
48
|
+
id: uuid(),
|
|
49
|
+
method: KeyringRpcV2Method.GetAccount,
|
|
50
|
+
params: { id },
|
|
51
|
+
}), GetAccountV2ResponseStruct);
|
|
52
|
+
}
|
|
53
|
+
async createAccounts(params) {
|
|
54
|
+
return strictMask(await this.send({
|
|
55
|
+
jsonrpc: '2.0',
|
|
56
|
+
id: uuid(),
|
|
57
|
+
method: KeyringRpcV2Method.CreateAccounts,
|
|
58
|
+
params,
|
|
59
|
+
}), CreateAccountsV2ResponseStruct);
|
|
60
|
+
}
|
|
61
|
+
async exportAccount(id, options) {
|
|
62
|
+
return strictMask(await this.send({
|
|
63
|
+
jsonrpc: '2.0',
|
|
64
|
+
id: uuid(),
|
|
65
|
+
method: KeyringRpcV2Method.ExportAccount,
|
|
66
|
+
params: { id, ...(options && { options }) },
|
|
67
|
+
}), ExportAccountV2ResponseStruct);
|
|
68
|
+
}
|
|
69
|
+
async deleteAccount(id) {
|
|
70
|
+
assert(await this.send({
|
|
71
|
+
jsonrpc: '2.0',
|
|
72
|
+
id: uuid(),
|
|
73
|
+
method: KeyringRpcV2Method.DeleteAccount,
|
|
74
|
+
params: { id },
|
|
75
|
+
}), DeleteAccountV2ResponseStruct);
|
|
76
|
+
}
|
|
77
|
+
async submitRequest(request) {
|
|
78
|
+
return strictMask(await this.send({
|
|
79
|
+
jsonrpc: '2.0',
|
|
80
|
+
id: uuid(),
|
|
81
|
+
method: KeyringRpcV2Method.SubmitRequest,
|
|
82
|
+
params: request,
|
|
83
|
+
}), SubmitRequestV2ResponseStruct);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_KeyringClientV2_sender = new WeakMap();
|
|
87
|
+
//# sourceMappingURL=KeyringClientV2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyringClientV2.mjs","sourceRoot":"","sources":["../../src/v2/KeyringClientV2.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,6BAA6B,EAC7B,kBAAkB,EAClB,6BAA6B,EAC9B,8BAA8B;AAW/B,OAAO,EAAE,UAAU,EAAE,gCAAgC;AACrD,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,aAAa;AAIlC,MAAM,OAAO,eAAe;IAG1B;;;;OAIG;IACH,YAAY,MAAc;QAPjB,0CAAgB;QAQvB,uBAAA,IAAI,2BAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,IAAI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C,IAAI,CAAC;YACd,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,IAAI,EAAE;YACV,MAAM,EAAE,kBAAkB,CAAC,aAAa;YACxC,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,EACF,6BAA6B,CAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAuB;QACzC,OAAO,UAAU,CACf,MAAM,IAAI,CAAC,IAAI,CAAC;YACd,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,IAAI,EAAE;YACV,MAAM,EAAE,kBAAkB,CAAC,aAAa;YACxC,MAAM,EAAE,OAAO;SAChB,CAAC,EACF,6BAA6B,CAC9B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n CreateAccountsV2ResponseStruct,\n DeleteAccountV2ResponseStruct,\n GetAccountV2ResponseStruct,\n GetAccountsV2ResponseStruct,\n SubmitRequestV2ResponseStruct,\n KeyringRpcV2Method,\n ExportAccountV2ResponseStruct,\n} from '@metamask/keyring-api';\nimport type {\n CreateAccountOptions,\n ExportAccountOptions,\n ExportedAccount,\n KeyringAccount,\n KeyringRequest,\n KeyringRpcV2,\n KeyringRpcV2Request,\n} from '@metamask/keyring-api';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport { strictMask } from '@metamask/keyring-utils';\nimport { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type { Sender } from '../KeyringClient';\n\nexport class KeyringClientV2 implements KeyringRpcV2 {\n readonly #sender: Sender;\n\n /**\n * Create a new instance of `KeyringClient`.\n *\n * @param sender - The `Sender` instance to use to send requests to the snap.\n */\n constructor(sender: Sender) {\n this.#sender = sender;\n }\n\n /**\n * Send a request to the Snap and return the response.\n *\n * @param request - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n protected async send<RequestMethod extends KeyringRpcV2Method>(\n request: KeyringRpcV2Request<RequestMethod>,\n ): Promise<Json> {\n return this.#sender.send({\n ...request,\n });\n }\n\n async getAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.GetAccounts,\n }),\n GetAccountsV2ResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.GetAccount,\n params: { id },\n }),\n GetAccountV2ResponseStruct,\n );\n }\n\n async createAccounts(\n params: CreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.CreateAccounts,\n params,\n }),\n CreateAccountsV2ResponseStruct,\n );\n }\n\n async exportAccount(\n id: AccountId,\n options?: ExportAccountOptions,\n ): Promise<ExportedAccount> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.ExportAccount,\n params: { id, ...(options && { options }) },\n }),\n ExportAccountV2ResponseStruct,\n );\n }\n\n async deleteAccount(id: AccountId): Promise<void> {\n assert(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.DeleteAccount,\n params: { id },\n }),\n DeleteAccountV2ResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<Json> {\n return strictMask(\n await this.send({\n jsonrpc: '2.0',\n id: uuid(),\n method: KeyringRpcV2Method.SubmitRequest,\n params: request,\n }),\n SubmitRequestV2ResponseStruct,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./KeyringClientV2.cjs"), exports);
|
|
18
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC","sourcesContent":["export * from './KeyringClientV2';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,sCAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,sCAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,sCAAkC","sourcesContent":["export * from './KeyringClientV2';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/keyring-snap-client",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.1-5c366be",
|
|
4
4
|
"description": "MetaMask Keyring Snap clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"metamask",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"test:watch": "jest --watch"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@metamask/keyring-api": "
|
|
48
|
+
"@metamask/keyring-api": "22.0.0",
|
|
49
49
|
"@metamask/keyring-utils": "3.2.0",
|
|
50
50
|
"@metamask/superstruct": "^3.1.0",
|
|
51
51
|
"@types/uuid": "^9.0.8",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
58
58
|
"@metamask/auto-changelog": "^3.4.4",
|
|
59
59
|
"@metamask/providers": "^19.0.0",
|
|
60
|
-
"@metamask/utils": "^11.
|
|
60
|
+
"@metamask/utils": "^11.10.0",
|
|
61
61
|
"@ts-bridge/cli": "^0.6.3",
|
|
62
62
|
"@types/jest": "^29.5.12",
|
|
63
63
|
"@types/node": "^20.12.12",
|