@metamask/keyring-api 7.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -2
- package/dist/JsonRpcRequest.d.ts +6 -6
- package/dist/JsonRpcRequest.js +1 -1
- package/dist/JsonRpcRequest.js.map +1 -1
- package/dist/KeyringClient.js +1 -1
- package/dist/KeyringClient.js.map +1 -1
- package/dist/api/account.d.ts +9 -35
- package/dist/api/account.js +3 -29
- package/dist/api/account.js.map +1 -1
- package/dist/api/balance.d.ts +4 -4
- package/dist/api/balance.js +1 -1
- package/dist/api/balance.js.map +1 -1
- package/dist/api/caip.d.ts +3 -3
- package/dist/api/caip.js +1 -1
- package/dist/api/caip.js.map +1 -1
- package/dist/api/export.d.ts +2 -2
- package/dist/api/export.js +1 -1
- package/dist/api/export.js.map +1 -1
- package/dist/api/keyring.d.ts +1 -6
- package/dist/api/keyring.js.map +1 -1
- package/dist/api/request.d.ts +8 -8
- package/dist/api/request.js +1 -1
- package/dist/api/request.js.map +1 -1
- package/dist/api/response.d.ts +2 -2
- package/dist/api/response.js +1 -1
- package/dist/api/response.js.map +1 -1
- package/dist/btc/types.d.ts +8 -8
- package/dist/btc/types.js +1 -1
- package/dist/btc/types.js.map +1 -1
- package/dist/eth/erc4337/types.d.ts +33 -33
- package/dist/eth/erc4337/types.js.map +1 -1
- package/dist/eth/types.d.ts +16 -16
- package/dist/eth/types.js +1 -1
- package/dist/eth/types.js.map +1 -1
- package/dist/internal/api.d.ts +137 -137
- package/dist/internal/api.js +1 -1
- package/dist/internal/api.js.map +1 -1
- package/dist/internal/events.d.ts +39 -39
- package/dist/internal/events.js +1 -1
- package/dist/internal/events.js.map +1 -1
- package/dist/internal/types.d.ts +3 -3
- package/dist/internal/types.js +1 -1
- package/dist/internal/types.js.map +1 -1
- package/dist/rpc-handler.js +1 -4
- package/dist/rpc-handler.js.map +1 -1
- package/dist/superstruct.d.ts +2 -3
- package/dist/superstruct.js +1 -1
- package/dist/superstruct.js.map +1 -1
- package/dist/utils/types.d.ts +4 -4
- package/dist/utils/types.js +1 -1
- package/dist/utils/types.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -7,12 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [8.0.1]
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Migrate to @metamask/superstruct and update required dependencies ([#355](https://github.com/MetaMask/keyring-api/pull/355)).
|
15
|
+
- Bump @metamask/providers from 17.1.0 to 17.1.1 ([#354](https://github.com/MetaMask/keyring-api/pull/354)).
|
16
|
+
- Bump @metamask/key-tree from 9.1.1 to 9.1.2 ([#351](https://github.com/MetaMask/keyring-api/pull/351)).
|
17
|
+
- Bump @metamask/rpc-errors from 6.3.0 to 6.3.1 ([#350](https://github.com/MetaMask/keyring-api/pull/350)).
|
18
|
+
- Bump @metamask/providers from 17.0.0 to 17.1.0 ([#348](https://github.com/MetaMask/keyring-api/pull/348)).
|
19
|
+
- Bump @metamask/snaps-sdk from 4.4.2 to 6.0.0 ([#347](https://github.com/MetaMask/keyring-api/pull/347)).
|
20
|
+
- Bump braces from 3.0.2 to 3.0.3 ([#345](https://github.com/MetaMask/keyring-api/pull/345)).
|
21
|
+
|
22
|
+
## [8.0.0]
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- **BREAKING:** Revert "feat: allow multiple address per account (#315)" ([#342](https://github.com/MetaMask/keyring-api/pull/342)).
|
27
|
+
|
10
28
|
## [7.0.0]
|
11
29
|
|
12
30
|
### Added
|
13
31
|
|
14
32
|
- Add `getAccountBalances` to `KeyringClient` ([#340](https://github.com/MetaMask/keyring-api/pull/340)).
|
15
|
-
- Allow multiple address per account ([#315](https://github.com/MetaMask/keyring-api/pull/315)).
|
33
|
+
- **BREAKING:** Allow multiple address per account ([#315](https://github.com/MetaMask/keyring-api/pull/315)).
|
16
34
|
|
17
35
|
### Changed
|
18
36
|
|
@@ -355,7 +373,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
355
373
|
- SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
|
356
374
|
- Helper functions to create keyring handler in the snap.
|
357
375
|
|
358
|
-
[Unreleased]: https://github.com/MetaMask/keyring-api/compare/
|
376
|
+
[Unreleased]: https://github.com/MetaMask/keyring-api/compare/v8.0.1...HEAD
|
377
|
+
[8.0.1]: https://github.com/MetaMask/keyring-api/compare/v8.0.0...v8.0.1
|
378
|
+
[8.0.0]: https://github.com/MetaMask/keyring-api/compare/v7.0.0...v8.0.0
|
359
379
|
[7.0.0]: https://github.com/MetaMask/keyring-api/compare/v6.4.0...v7.0.0
|
360
380
|
[6.4.0]: https://github.com/MetaMask/keyring-api/compare/v6.3.1...v6.4.0
|
361
381
|
[6.3.1]: https://github.com/MetaMask/keyring-api/compare/v6.3.0...v6.3.1
|
package/dist/JsonRpcRequest.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
2
|
-
export declare const JsonRpcRequestStruct: import("superstruct").Struct<{
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
|
+
export declare const JsonRpcRequestStruct: import("@metamask/superstruct").Struct<{
|
3
3
|
jsonrpc: "2.0";
|
4
4
|
id: string | number | null;
|
5
5
|
method: string;
|
6
6
|
params?: import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>;
|
7
7
|
}, {
|
8
|
-
jsonrpc: import("superstruct").Struct<"2.0", "2.0">;
|
9
|
-
id: import("superstruct").Struct<string | number | null, null>;
|
10
|
-
method: import("superstruct").Struct<string, null>;
|
11
|
-
params: import("superstruct").Struct<import("./superstruct").ExactOptionalTag | import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>, null>;
|
8
|
+
jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
|
9
|
+
id: import("@metamask/superstruct").Struct<string | number | null, null>;
|
10
|
+
method: import("@metamask/superstruct").Struct<string, null>;
|
11
|
+
params: import("@metamask/superstruct").Struct<import("./superstruct").ExactOptionalTag | import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>, null>;
|
12
12
|
}>;
|
13
13
|
/**
|
14
14
|
* JSON-RPC request type.
|
package/dist/JsonRpcRequest.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.JsonRpcRequestStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
4
5
|
const utils_1 = require("@metamask/utils");
|
5
|
-
const superstruct_1 = require("superstruct");
|
6
6
|
const superstruct_2 = require("./superstruct");
|
7
7
|
exports.JsonRpcRequestStruct = (0, superstruct_2.object)({
|
8
8
|
jsonrpc: (0, superstruct_1.literal)('2.0'),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"JsonRpcRequest.js","sourceRoot":"","sources":["../src/JsonRpcRequest.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C
|
1
|
+
{"version":3,"file":"JsonRpcRequest.js","sourceRoot":"","sources":["../src/JsonRpcRequest.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAE/B,2CAA6C;AAE7C,+CAAsD;AAEzC,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACvB,EAAE,EAAE,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,MAAM,EAAE,IAAA,oBAAM,GAAE;IAChB,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,mBAAK,EAAC,CAAC,IAAA,mBAAK,EAAC,kBAAU,CAAC,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC,CAAC,CACzD;CACF,CAAC,CAAC","sourcesContent":["import {\n array,\n literal,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from './superstruct';\n\nexport const JsonRpcRequestStruct = object({\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n method: string(),\n params: exactOptional(\n union([array(JsonStruct), record(string(), JsonStruct)]),\n ),\n});\n\n/**\n * JSON-RPC request type.\n */\nexport type JsonRpcRequest = Infer<typeof JsonRpcRequestStruct>;\n"]}
|
package/dist/KeyringClient.js
CHANGED
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
13
13
|
var _KeyringClient_instances, _KeyringClient_sender, _KeyringClient_send;
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.KeyringClient = void 0;
|
16
|
-
const superstruct_1 = require("superstruct");
|
16
|
+
const superstruct_1 = require("@metamask/superstruct");
|
17
17
|
const uuid_1 = require("uuid");
|
18
18
|
const api_1 = require("./internal/api");
|
19
19
|
const rpc_1 = require("./internal/rpc");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KeyringClient.js","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"KeyringClient.js","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":"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","sourcesContent":["import { assert } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { v4 as uuid } from 'uuid';\n\nimport type {\n Keyring,\n KeyringAccount,\n KeyringRequest,\n KeyringAccountData,\n KeyringResponse,\n CaipAssetType,\n Balance,\n} from './api';\nimport {\n ApproveRequestResponseStruct,\n CreateAccountResponseStruct,\n DeleteAccountResponseStruct,\n ExportAccountResponseStruct,\n FilterAccountChainsResponseStruct,\n GetAccountBalancesResponseStruct,\n GetAccountResponseStruct,\n GetRequestResponseStruct,\n ListAccountsResponseStruct,\n ListRequestsResponseStruct,\n RejectRequestResponseStruct,\n SubmitRequestResponseStruct,\n UpdateAccountResponseStruct,\n} from './internal/api';\nimport { KeyringRpcMethod } from './internal/rpc';\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport { strictMask } from './superstruct';\n\nexport type Sender = {\n send(request: JsonRpcRequest): Promise<Json>;\n};\n\nexport class KeyringClient implements Keyring {\n #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 partial - A partial JSON-RPC request (method and params).\n * @returns A promise that resolves to the response to the request.\n */\n async #send(partial: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>): Promise<Json> {\n return this.#sender.send({\n jsonrpc: '2.0',\n id: uuid(),\n ...partial,\n });\n }\n\n async listAccounts(): Promise<KeyringAccount[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListAccounts,\n }),\n ListAccountsResponseStruct,\n );\n }\n\n async getAccount(id: string): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccount,\n params: { id },\n }),\n GetAccountResponseStruct,\n );\n }\n\n async getAccountBalances(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetAccountBalances,\n params: { id, assets },\n }),\n GetAccountBalancesResponseStruct,\n );\n }\n\n async createAccount(\n options: Record<string, Json> = {},\n ): Promise<KeyringAccount> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.CreateAccount,\n params: { options },\n }),\n CreateAccountResponseStruct,\n );\n }\n\n async filterAccountChains(id: string, chains: string[]): Promise<string[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.FilterAccountChains,\n params: { id, chains },\n }),\n FilterAccountChainsResponseStruct,\n );\n }\n\n async updateAccount(account: KeyringAccount): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.UpdateAccount,\n params: { account },\n }),\n UpdateAccountResponseStruct,\n );\n }\n\n async deleteAccount(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.DeleteAccount,\n params: { id },\n }),\n DeleteAccountResponseStruct,\n );\n }\n\n async exportAccount(id: string): Promise<KeyringAccountData> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ExportAccount,\n params: { id },\n }),\n ExportAccountResponseStruct,\n );\n }\n\n async listRequests(): Promise<KeyringRequest[]> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.ListRequests,\n }),\n ListRequestsResponseStruct,\n );\n }\n\n async getRequest(id: string): Promise<KeyringRequest> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.GetRequest,\n params: { id },\n }),\n GetRequestResponseStruct,\n );\n }\n\n async submitRequest(request: KeyringRequest): Promise<KeyringResponse> {\n return strictMask(\n await this.#send({\n method: KeyringRpcMethod.SubmitRequest,\n params: request,\n }),\n SubmitRequestResponseStruct,\n );\n }\n\n async approveRequest(\n id: string,\n data: Record<string, Json> = {},\n ): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.ApproveRequest,\n params: { id, data },\n }),\n ApproveRequestResponseStruct,\n );\n }\n\n async rejectRequest(id: string): Promise<void> {\n assert(\n await this.#send({\n method: KeyringRpcMethod.RejectRequest,\n params: { id },\n }),\n RejectRequestResponseStruct,\n );\n }\n}\n"]}
|
package/dist/api/account.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
2
|
/**
|
3
3
|
* Supported Ethereum account types.
|
4
4
|
*/
|
@@ -23,63 +23,37 @@ export declare type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccount
|
|
23
23
|
*
|
24
24
|
* See {@link KeyringAccount}.
|
25
25
|
*/
|
26
|
-
export declare const KeyringAccountStruct: import("superstruct").Struct<{
|
26
|
+
export declare const KeyringAccountStruct: import("@metamask/superstruct").Struct<{
|
27
27
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh";
|
28
28
|
id: string;
|
29
|
-
address: string
|
29
|
+
address: string;
|
30
30
|
options: Record<string, import("@metamask/utils").Json>;
|
31
31
|
methods: string[];
|
32
32
|
}, {
|
33
33
|
/**
|
34
34
|
* Account ID (UUIDv4).
|
35
35
|
*/
|
36
|
-
id: import("superstruct").Struct<string, null>;
|
36
|
+
id: import("@metamask/superstruct").Struct<string, null>;
|
37
37
|
/**
|
38
38
|
* Account type.
|
39
39
|
*/
|
40
|
-
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh", {
|
40
|
+
type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh", {
|
41
41
|
"eip155:eoa": "eip155:eoa";
|
42
42
|
"eip155:erc4337": "eip155:erc4337";
|
43
43
|
"bip122:p2wpkh": "bip122:p2wpkh";
|
44
44
|
}>;
|
45
45
|
/**
|
46
|
-
* Account
|
47
|
-
* chain.
|
48
|
-
*
|
49
|
-
* If the address is a string, it's assumed to be under the 'eip155'
|
50
|
-
* namespace. Otherwise, it must be a map of addresses per chain, where the
|
51
|
-
* key is the chain ID (CAIP-2) and the value is an array of addresses.
|
52
|
-
*
|
53
|
-
* @example
|
54
|
-
* ```ts
|
55
|
-
* address: {
|
56
|
-
* // Different addresses per chain.
|
57
|
-
* 'eip155:1': ['0x1234...'],
|
58
|
-
* 'eip155:137': ['0x5678...'],
|
59
|
-
* }
|
60
|
-
* ```
|
61
|
-
* @example
|
62
|
-
* ```ts
|
63
|
-
* address: {
|
64
|
-
* // The address is the same across all 'eip155' chains.
|
65
|
-
* 'eip155': ['0x1234...'],
|
66
|
-
* }
|
67
|
-
* ```
|
68
|
-
* @example
|
69
|
-
* ```ts
|
70
|
-
* // Assumed to be under the 'eip155' namespace.
|
71
|
-
* address: '0x1234...',
|
72
|
-
* ```
|
46
|
+
* Account main address.
|
73
47
|
*/
|
74
|
-
address: import("superstruct").Struct<string
|
48
|
+
address: import("@metamask/superstruct").Struct<string, null>;
|
75
49
|
/**
|
76
50
|
* Account options.
|
77
51
|
*/
|
78
|
-
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
52
|
+
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
79
53
|
/**
|
80
54
|
* Account supported methods.
|
81
55
|
*/
|
82
|
-
methods: import("superstruct").Struct<string[], import("superstruct").Struct<string, null>>;
|
56
|
+
methods: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
|
83
57
|
}>;
|
84
58
|
/**
|
85
59
|
* Keyring Account type represents an account and its properties from the
|
package/dist/api/account.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.KeyringAccountStruct = exports.BtcAccountType = exports.EthAccountType = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
4
5
|
const utils_1 = require("@metamask/utils");
|
5
|
-
const superstruct_1 = require("superstruct");
|
6
6
|
const superstruct_2 = require("../superstruct");
|
7
7
|
const utils_2 = require("../utils");
|
8
8
|
/**
|
@@ -41,35 +41,9 @@ exports.KeyringAccountStruct = (0, superstruct_2.object)({
|
|
41
41
|
`${BtcAccountType.P2wpkh}`,
|
42
42
|
]),
|
43
43
|
/**
|
44
|
-
* Account
|
45
|
-
* chain.
|
46
|
-
*
|
47
|
-
* If the address is a string, it's assumed to be under the 'eip155'
|
48
|
-
* namespace. Otherwise, it must be a map of addresses per chain, where the
|
49
|
-
* key is the chain ID (CAIP-2) and the value is an array of addresses.
|
50
|
-
*
|
51
|
-
* @example
|
52
|
-
* ```ts
|
53
|
-
* address: {
|
54
|
-
* // Different addresses per chain.
|
55
|
-
* 'eip155:1': ['0x1234...'],
|
56
|
-
* 'eip155:137': ['0x5678...'],
|
57
|
-
* }
|
58
|
-
* ```
|
59
|
-
* @example
|
60
|
-
* ```ts
|
61
|
-
* address: {
|
62
|
-
* // The address is the same across all 'eip155' chains.
|
63
|
-
* 'eip155': ['0x1234...'],
|
64
|
-
* }
|
65
|
-
* ```
|
66
|
-
* @example
|
67
|
-
* ```ts
|
68
|
-
* // Assumed to be under the 'eip155' namespace.
|
69
|
-
* address: '0x1234...',
|
70
|
-
* ```
|
44
|
+
* Account main address.
|
71
45
|
*/
|
72
|
-
address: (0, superstruct_1.
|
46
|
+
address: (0, superstruct_1.string)(),
|
73
47
|
/**
|
74
48
|
* Account options.
|
75
49
|
*/
|
package/dist/api/account.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,gDAAwC;AACxC,oCAAsC;AAEtC;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAEzB;AAUD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,kBAAU;IAEd;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;KAC3B,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
|
package/dist/api/balance.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
2
|
-
export declare const BalanceStruct: import("superstruct").Struct<{
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
|
+
export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
|
3
3
|
amount: string;
|
4
4
|
unit: string;
|
5
5
|
}, {
|
6
|
-
amount: import("superstruct").Struct<string, null>;
|
7
|
-
unit: import("superstruct").Struct<string, null>;
|
6
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
7
|
+
unit: import("@metamask/superstruct").Struct<string, null>;
|
8
8
|
}>;
|
9
9
|
export declare type Balance = Infer<typeof BalanceStruct>;
|
package/dist/api/balance.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.BalanceStruct = void 0;
|
4
|
-
const superstruct_1 = require("superstruct");
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
5
5
|
const superstruct_2 = require("../superstruct");
|
6
6
|
const utils_1 = require("../utils");
|
7
7
|
exports.BalanceStruct = (0, superstruct_2.object)({
|
package/dist/api/balance.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,gDAAwC;AACxC,oCAA8C;AAEjC,QAAA,aAAa,GAAG,IAAA,oBAAM,EAAC;IAClC,MAAM,EAAE,0BAAkB;IAC1B,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nimport { object } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
|
package/dist/api/caip.d.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
import { type Infer } from 'superstruct';
|
1
|
+
import { type Infer } from '@metamask/superstruct';
|
2
2
|
/**
|
3
3
|
* A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
|
4
4
|
*/
|
5
|
-
export declare const CaipAssetTypeStruct: import("superstruct").Struct<string, null>;
|
5
|
+
export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<string, null>;
|
6
6
|
export declare type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;
|
7
7
|
/**
|
8
8
|
* A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
|
9
9
|
*/
|
10
|
-
export declare const CaipAssetIdStruct: import("superstruct").Struct<string, null>;
|
10
|
+
export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<string, null>;
|
11
11
|
export declare type CaipAssetId = Infer<typeof CaipAssetIdStruct>;
|
12
12
|
/**
|
13
13
|
* Check if the given value is a {@link CaipAssetType}.
|
package/dist/api/caip.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isCaipAssetId = exports.isCaipAssetType = exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = void 0;
|
4
|
-
const superstruct_1 = require("superstruct");
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
5
5
|
const superstruct_2 = require("../superstruct");
|
6
6
|
const CAIP_ASSET_TYPE_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;
|
7
7
|
const CAIP_ASSET_ID_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;
|
package/dist/api/caip.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD,gDAA+C;AAE/C,MAAM,qBAAqB,GACzB,2JAA2J,CAAC;AAE9J,MAAM,mBAAmB,GACvB,6LAA6L,CAAC;AAEhM;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,2BAAa,EAC9C,eAAe,EACf,qBAAqB,CACtB,CAAC;AAGF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,2BAAa,EAC5C,aAAa,EACb,mBAAmB,CACpB,CAAC;AAGF;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,2BAAmB,CAAC,CAAC;AACxC,CAAC;AAFD,0CAEC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,yBAAiB,CAAC,CAAC;AACtC,CAAC;AAFD,sCAEC","sourcesContent":["import { is, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\nconst CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nconst CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct = definePattern(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n);\nexport type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = definePattern(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n);\nexport type CaipAssetId = Infer<typeof CaipAssetIdStruct>;\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // true\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false\n * ```\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // false\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true\n * ```\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n"]}
|
package/dist/api/export.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
2
|
-
export declare const KeyringAccountDataStruct: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
|
+
export declare const KeyringAccountDataStruct: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
3
3
|
/**
|
4
4
|
* Response to a call to `exportAccount`.
|
5
5
|
*
|
package/dist/api/export.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.KeyringAccountDataStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
4
5
|
const utils_1 = require("@metamask/utils");
|
5
|
-
const superstruct_1 = require("superstruct");
|
6
6
|
exports.KeyringAccountDataStruct = (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct);
|
7
7
|
//# sourceMappingURL=export.js.map
|
package/dist/api/export.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/api/export.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/api/export.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AACvD,2CAA6C;AAEhC,QAAA,wBAAwB,GAAG,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nexport const KeyringAccountDataStruct = record(string(), JsonStruct);\n\n/**\n * Response to a call to `exportAccount`.\n *\n * The exact response depends on the keyring implementation.\n */\nexport type KeyringAccountData = Infer<typeof KeyringAccountDataStruct>;\n"]}
|
package/dist/api/keyring.d.ts
CHANGED
@@ -72,17 +72,12 @@ export declare type Keyring = {
|
|
72
72
|
/**
|
73
73
|
* Filter supported chains for a given account.
|
74
74
|
*
|
75
|
-
* See {@link KeyringAccount}.
|
76
|
-
*
|
77
|
-
* @deprecated Use the keys of the `address` map of the account object to
|
78
|
-
* indicate the supported chains. This method will be removed in a future
|
79
|
-
* version of the Keyring API.
|
80
75
|
* @param id - ID of the account to be checked.
|
81
76
|
* @param chains - List of chains (CAIP-2) to be checked.
|
82
77
|
* @returns A Promise that resolves to a filtered list of CAIP-2 IDs
|
83
78
|
* representing the supported chains.
|
84
79
|
*/
|
85
|
-
filterAccountChains
|
80
|
+
filterAccountChains(id: string, chains: string[]): Promise<string[]>;
|
86
81
|
/**
|
87
82
|
* Update an account.
|
88
83
|
*
|
package/dist/api/keyring.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"keyring.js","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { Balance } from './balance';\nimport type { CaipAssetType } from './caip';\nimport type { KeyringAccountData } from './export';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional).\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(options?: Record<string, Json>): Promise<KeyringAccount>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Filter supported chains for a given account.\n *\n *
|
1
|
+
{"version":3,"file":"keyring.js","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { Balance } from './balance';\nimport type { CaipAssetType } from './caip';\nimport type { KeyringAccountData } from './export';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional).\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(options?: Record<string, Json>): Promise<KeyringAccount>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
|
package/dist/api/request.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
2
|
-
export declare const KeyringRequestStruct: import("superstruct").Struct<{
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
|
+
export declare const KeyringRequestStruct: import("@metamask/superstruct").Struct<{
|
3
3
|
id: string;
|
4
4
|
scope: string;
|
5
5
|
account: string;
|
@@ -11,24 +11,24 @@ export declare const KeyringRequestStruct: import("superstruct").Struct<{
|
|
11
11
|
/**
|
12
12
|
* Keyring request ID (UUIDv4).
|
13
13
|
*/
|
14
|
-
id: import("superstruct").Struct<string, null>;
|
14
|
+
id: import("@metamask/superstruct").Struct<string, null>;
|
15
15
|
/**
|
16
16
|
* Request's scope (CAIP-2 chain ID).
|
17
17
|
*/
|
18
|
-
scope: import("superstruct").Struct<string, null>;
|
18
|
+
scope: import("@metamask/superstruct").Struct<string, null>;
|
19
19
|
/**
|
20
20
|
* Account ID (UUIDv4).
|
21
21
|
*/
|
22
|
-
account: import("superstruct").Struct<string, null>;
|
22
|
+
account: import("@metamask/superstruct").Struct<string, null>;
|
23
23
|
/**
|
24
24
|
* Inner request sent by the client application.
|
25
25
|
*/
|
26
|
-
request: import("superstruct").Struct<{
|
26
|
+
request: import("@metamask/superstruct").Struct<{
|
27
27
|
method: string;
|
28
28
|
params?: import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>;
|
29
29
|
}, {
|
30
|
-
method: import("superstruct").Struct<string, null>;
|
31
|
-
params: import("superstruct").Struct<import("../superstruct").ExactOptionalTag | import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>, null>;
|
30
|
+
method: import("@metamask/superstruct").Struct<string, null>;
|
31
|
+
params: import("@metamask/superstruct").Struct<import("../superstruct").ExactOptionalTag | import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>, null>;
|
32
32
|
}>;
|
33
33
|
}>;
|
34
34
|
/**
|
package/dist/api/request.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.KeyringRequestStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
4
5
|
const utils_1 = require("@metamask/utils");
|
5
|
-
const superstruct_1 = require("superstruct");
|
6
6
|
const superstruct_2 = require("../superstruct");
|
7
7
|
const utils_2 = require("../utils");
|
8
8
|
exports.KeyringRequestStruct = (0, superstruct_2.object)({
|
package/dist/api/request.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,gDAAuD;AACvD,oCAAsC;AAEzB,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,kBAAU;IAEd;;OAEG;IACH,KAAK,EAAE,IAAA,oBAAM,GAAE;IAEf;;OAEG;IACH,OAAO,EAAE,kBAAU;IAEnB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC;QACd,MAAM,EAAE,IAAA,oBAAM,GAAE;QAChB,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,mBAAK,EAAC,CAAC,IAAA,mBAAK,EAAC,kBAAU,CAAC,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC,CAAC,CAAC,CACzD;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, record, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\nexport const KeyringRequestStruct = object({\n /**\n * Keyring request ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Request's scope (CAIP-2 chain ID).\n */\n scope: string(),\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Inner request sent by the client application.\n */\n request: object({\n method: string(),\n params: exactOptional(\n union([array(JsonStruct), record(string(), JsonStruct)]),\n ),\n }),\n});\n\n/**\n * Keyring request.\n *\n * Represents a request made to the keyring for account-related operations.\n */\nexport type KeyringRequest = Infer<typeof KeyringRequestStruct>;\n"]}
|
package/dist/api/response.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
2
|
-
export declare const KeyringResponseStruct: import("superstruct").Struct<{
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
|
+
export declare const KeyringResponseStruct: import("@metamask/superstruct").Struct<{
|
3
3
|
pending: true;
|
4
4
|
redirect?: {
|
5
5
|
message?: string;
|
package/dist/api/response.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.KeyringResponseStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
4
5
|
const utils_1 = require("@metamask/utils");
|
5
|
-
const superstruct_1 = require("superstruct");
|
6
6
|
const superstruct_2 = require("../superstruct");
|
7
7
|
exports.KeyringResponseStruct = (0, superstruct_1.union)([
|
8
8
|
(0, superstruct_2.object)({
|
package/dist/api/response.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAC/D,2CAA6C;AAE7C,gDAAuD;AAE1C,QAAA,qBAAqB,GAAG,IAAA,mBAAK,EAAC;IACzC,IAAA,oBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;QAEtB;;;;;;WAMG;QACH,QAAQ,EAAE,IAAA,2BAAa,EACrB,IAAA,oBAAM,EAAC;YACL,OAAO,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;YAChC,GAAG,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;SAC7B,CAAC,CACH;KACF,CAAC;IACF,IAAA,oBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;QAEvB;;WAEG;QACH,MAAM,EAAE,kBAAU;KACnB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { literal, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { exactOptional, object } from '../superstruct';\n\nexport const KeyringResponseStruct = union([\n object({\n /**\n * Pending flag.\n *\n * Setting the pending flag to true indicates that the request will be\n * handled asynchronously. The keyring must be called with `approveRequest`\n * or `rejectRequest` to resolve the request.\n */\n pending: literal(true),\n\n /**\n * Redirect URL.\n *\n * If present in the response, MetaMask will display a confirmation dialog\n * with a link to the redirect URL. The user can choose to follow the link\n * or cancel the request.\n */\n redirect: exactOptional(\n object({\n message: exactOptional(string()),\n url: exactOptional(string()),\n }),\n ),\n }),\n object({\n /**\n * Pending flag.\n *\n * Setting the pending flag to false indicates that the request will be\n * handled synchronously. The keyring must return the result of the\n * request execution.\n */\n pending: literal(false),\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n]);\n\n/**\n * Response to a call to `submitRequest`.\n *\n * Keyring implementations must return a response with `pending: true` if the\n * request will be handled asynchronously. Otherwise, the response must contain\n * the result of the request and `pending: false`.\n *\n * In the asynchronous case, the keyring can return a redirect URL and message\n * to be shown to the user. The user can choose to follow the link or cancel\n * the request. The main use case for this is to redirect the user to the snap\n * dapp to review the request.\n */\nexport type KeyringResponse = Infer<typeof KeyringResponseStruct>;\n"]}
|
package/dist/btc/types.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import type { Infer } from 'superstruct';
|
2
|
-
export declare const BtcP2wpkhAddressStruct: import("superstruct").Struct<string, null>;
|
1
|
+
import type { Infer } from '@metamask/superstruct';
|
2
|
+
export declare const BtcP2wpkhAddressStruct: import("@metamask/superstruct").Struct<string, null>;
|
3
3
|
/**
|
4
4
|
* Supported Bitcoin methods.
|
5
5
|
*/
|
6
6
|
export declare enum BtcMethod {
|
7
7
|
SendMany = "btc_sendmany"
|
8
8
|
}
|
9
|
-
export declare const BtcP2wpkhAccountStruct: import("superstruct").Struct<{
|
9
|
+
export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
|
10
10
|
type: "bip122:p2wpkh";
|
11
11
|
id: string;
|
12
12
|
address: string;
|
@@ -16,18 +16,18 @@ export declare const BtcP2wpkhAccountStruct: import("superstruct").Struct<{
|
|
16
16
|
/**
|
17
17
|
* Account address.
|
18
18
|
*/
|
19
|
-
address: import("superstruct").Struct<string, null>;
|
19
|
+
address: import("@metamask/superstruct").Struct<string, null>;
|
20
20
|
/**
|
21
21
|
* Account type.
|
22
22
|
*/
|
23
|
-
type: import("superstruct").Struct<"bip122:p2wpkh", "bip122:p2wpkh">;
|
23
|
+
type: import("@metamask/superstruct").Struct<"bip122:p2wpkh", "bip122:p2wpkh">;
|
24
24
|
/**
|
25
25
|
* Account supported methods.
|
26
26
|
*/
|
27
|
-
methods: import("superstruct").Struct<"btc_sendmany"[], import("superstruct").Struct<"btc_sendmany", {
|
27
|
+
methods: import("@metamask/superstruct").Struct<"btc_sendmany"[], import("@metamask/superstruct").Struct<"btc_sendmany", {
|
28
28
|
btc_sendmany: "btc_sendmany";
|
29
29
|
}>>;
|
30
|
-
id: import("superstruct").Struct<string, null>;
|
31
|
-
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
30
|
+
id: import("@metamask/superstruct").Struct<string, null>;
|
31
|
+
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
32
32
|
}>;
|
33
33
|
export declare type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;
|
package/dist/btc/types.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.BtcP2wpkhAccountStruct = exports.BtcMethod = exports.BtcP2wpkhAddressStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
4
5
|
const bech32_1 = require("bech32");
|
5
|
-
const superstruct_1 = require("superstruct");
|
6
6
|
const api_1 = require("../api");
|
7
7
|
const superstruct_2 = require("../superstruct");
|
8
8
|
exports.BtcP2wpkhAddressStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'BtcP2wpkhAddressStruct', (address) => {
|
package/dist/btc/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AACA,uDAA8E;AAC9E,mCAAgC;AAEhC,gCAA8D;AAC9D,gDAAwC;AAE3B,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAC1C,IAAA,oBAAM,GAAE,EACR,wBAAwB,EACxB,CAAC,OAAe,EAAE,EAAE;IAClB,IAAI;QACF,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KACxB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,sCAAyB,CAAA;AAC3B,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAEY,QAAA,sBAAsB,GAAG,IAAA,oBAAM,EAAC;IAC3C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,8BAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC;IAEzC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;CACjD,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string, array, enums, refine, literal } from '@metamask/superstruct';\nimport { bech32 } from 'bech32';\n\nimport { KeyringAccountStruct, BtcAccountType } from '../api';\nimport { object } from '../superstruct';\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n try {\n bech32.decode(address);\n } catch (error) {\n return new Error(\n `Could not decode P2WPKH address: ${(error as Error).message}`,\n );\n }\n return true;\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n // General transaction methods\n SendMany = 'btc_sendmany',\n}\n\nexport const BtcP2wpkhAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${BtcMethod.SendMany}`])),\n});\n\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\n"]}
|