@metamask-previews/keyring-api 8.1.0-preview-46bb5ff → 8.1.3-d5a036e
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 +26 -1
- package/dist/JsonRpcRequest.d.ts +2 -2
- package/dist/JsonRpcRequest.js +3 -3
- package/dist/JsonRpcRequest.js.map +1 -1
- package/dist/KeyringClient.d.ts +1 -1
- package/dist/KeyringClient.js +10 -10
- package/dist/KeyringClient.js.map +1 -1
- package/dist/KeyringSnapRpcClient.js.map +1 -1
- package/dist/api/account.d.ts +3 -3
- package/dist/api/account.js +6 -5
- package/dist/api/account.js.map +1 -1
- package/dist/api/balance.d.ts +1 -1
- package/dist/api/balance.js +4 -3
- package/dist/api/balance.js.map +1 -1
- package/dist/api/caip.d.ts +2 -2
- package/dist/api/caip.js +3 -3
- package/dist/api/caip.js.map +1 -1
- package/dist/api/export.d.ts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +0 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/keyring.d.ts +1 -1
- package/dist/api/request.d.ts +2 -2
- package/dist/api/request.js +7 -6
- package/dist/api/request.js.map +1 -1
- package/dist/api/response.d.ts +1 -1
- package/dist/api/response.js +6 -6
- package/dist/api/response.js.map +1 -1
- package/dist/btc/types.d.ts +2 -2
- package/dist/btc/types.js +3 -3
- package/dist/btc/types.js.map +1 -1
- package/dist/contexts.d.ts +1 -1
- package/dist/eth/erc4337/types.d.ts +10 -9
- package/dist/eth/erc4337/types.js +12 -10
- package/dist/eth/erc4337/types.js.map +1 -1
- package/dist/eth/types.d.ts +4 -4
- package/dist/eth/types.js +7 -7
- package/dist/eth/types.js.map +1 -1
- package/dist/events.js +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/api.d.ts +36 -36
- package/dist/internal/api.js +34 -33
- package/dist/internal/api.js.map +1 -1
- package/dist/internal/eth/EthKeyring.d.ts +1 -1
- package/dist/internal/eth/index.d.ts +1 -1
- package/dist/internal/eth/index.js +0 -15
- package/dist/internal/eth/index.js.map +1 -1
- package/dist/internal/events.d.ts +8 -8
- package/dist/internal/events.js +17 -16
- package/dist/internal/events.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +0 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/rpc.js +1 -1
- package/dist/internal/rpc.js.map +1 -1
- package/dist/internal/types.d.ts +58 -61
- package/dist/internal/types.js +20 -23
- package/dist/internal/types.js.map +1 -1
- package/dist/rpc-handler.js +13 -13
- package/dist/rpc-handler.js.map +1 -1
- package/dist/superstruct.d.ts +83 -0
- package/dist/superstruct.js +81 -0
- package/dist/superstruct.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/types.d.ts +17 -0
- package/dist/utils/types.js +29 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/typing.d.ts +32 -0
- package/dist/utils/typing.js +21 -0
- package/dist/utils/typing.js.map +1 -0
- package/package.json +16 -14
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [8.1.3]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump `sinon` and `@types/sinon` to latest versions ([#51](https://github.com/MetaMask/accounts/pull/51))
|
|
15
|
+
- Add `syncpack` and sync dependencies ([#53](https://github.com/metamask/accounts/pull/53))
|
|
16
|
+
|
|
17
|
+
## [8.1.2]
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Bump `@metamask/*` and `@lavamoat/*` dependencies ([#46](https://github.com/MetaMask/accounts/pull/46))
|
|
22
|
+
- Move `deepmerge` to `devDependencies` ([#44](https://github.com/MetaMask/accounts/pull/44))
|
|
23
|
+
|
|
24
|
+
## [8.1.1]
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Convert to monorepo
|
|
29
|
+
- Package name does not change (`@metamask/keyring-api`) and sources have been moved to: `packages/keyring-api`.
|
|
30
|
+
- You can find all the changes [here](https://github.com/MetaMask/accounts/compare/6da58b4...38794aa).
|
|
31
|
+
|
|
10
32
|
## [8.1.0]
|
|
11
33
|
|
|
12
34
|
### Added
|
|
@@ -390,7 +412,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
390
412
|
- SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
|
|
391
413
|
- Helper functions to create keyring handler in the snap.
|
|
392
414
|
|
|
393
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.1.
|
|
415
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.1.3...HEAD
|
|
416
|
+
[8.1.3]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.1.2...@metamask/keyring-api@8.1.3
|
|
417
|
+
[8.1.2]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.1.1...@metamask/keyring-api@8.1.2
|
|
418
|
+
[8.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.1.0...@metamask/keyring-api@8.1.1
|
|
394
419
|
[8.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.0.2...@metamask/keyring-api@8.1.0
|
|
395
420
|
[8.0.2]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.0.1...@metamask/keyring-api@8.0.2
|
|
396
421
|
[8.0.1]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@8.0.0...@metamask/keyring-api@8.0.1
|
package/dist/JsonRpcRequest.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export declare const JsonRpcRequestStruct: import("@metamask/superstruct").Struc
|
|
|
8
8
|
jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
|
|
9
9
|
id: import("@metamask/superstruct").Struct<string | number | null, null>;
|
|
10
10
|
method: import("@metamask/superstruct").Struct<string, null>;
|
|
11
|
-
params: import("@metamask/superstruct").Struct<import("
|
|
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.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type JsonRpcRequest = Infer<typeof JsonRpcRequestStruct>;
|
package/dist/JsonRpcRequest.js
CHANGED
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JsonRpcRequestStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
7
|
-
exports.JsonRpcRequestStruct = (0,
|
|
6
|
+
const superstruct_2 = require("./superstruct");
|
|
7
|
+
exports.JsonRpcRequestStruct = (0, superstruct_2.object)({
|
|
8
8
|
jsonrpc: (0, superstruct_1.literal)('2.0'),
|
|
9
9
|
id: (0, superstruct_1.union)([(0, superstruct_1.string)(), (0, superstruct_1.number)(), (0, superstruct_1.literal)(null)]),
|
|
10
10
|
method: (0, superstruct_1.string)(),
|
|
11
|
-
params: (0,
|
|
11
|
+
params: (0, superstruct_2.exactOptional)((0, superstruct_1.union)([(0, superstruct_1.array)(utils_1.JsonStruct), (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct)])),
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=JsonRpcRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonRpcRequest.js","sourceRoot":"","sources":["../src/JsonRpcRequest.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAE/B,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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Json } from '@metamask/utils';
|
|
2
2
|
import type { Keyring, KeyringAccount, KeyringRequest, KeyringAccountData, KeyringResponse, CaipAssetType, Balance } from './api';
|
|
3
3
|
import type { JsonRpcRequest } from './JsonRpcRequest';
|
|
4
|
-
export
|
|
4
|
+
export type Sender = {
|
|
5
5
|
send(request: JsonRpcRequest): Promise<Json>;
|
|
6
6
|
};
|
|
7
7
|
export declare class KeyringClient implements Keyring {
|
package/dist/KeyringClient.js
CHANGED
|
@@ -17,7 +17,7 @@ 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");
|
|
20
|
-
const
|
|
20
|
+
const superstruct_2 = require("./superstruct");
|
|
21
21
|
class KeyringClient {
|
|
22
22
|
/**
|
|
23
23
|
* Create a new instance of `KeyringClient`.
|
|
@@ -30,30 +30,30 @@ class KeyringClient {
|
|
|
30
30
|
__classPrivateFieldSet(this, _KeyringClient_sender, sender, "f");
|
|
31
31
|
}
|
|
32
32
|
async listAccounts() {
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
34
34
|
method: rpc_1.KeyringRpcMethod.ListAccounts,
|
|
35
35
|
}), api_1.ListAccountsResponseStruct);
|
|
36
36
|
}
|
|
37
37
|
async getAccount(id) {
|
|
38
|
-
return (0,
|
|
38
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
39
39
|
method: rpc_1.KeyringRpcMethod.GetAccount,
|
|
40
40
|
params: { id },
|
|
41
41
|
}), api_1.GetAccountResponseStruct);
|
|
42
42
|
}
|
|
43
43
|
async getAccountBalances(id, assets) {
|
|
44
|
-
return (0,
|
|
44
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
45
45
|
method: rpc_1.KeyringRpcMethod.GetAccountBalances,
|
|
46
46
|
params: { id, assets },
|
|
47
47
|
}), api_1.GetAccountBalancesResponseStruct);
|
|
48
48
|
}
|
|
49
49
|
async createAccount(options = {}) {
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
51
51
|
method: rpc_1.KeyringRpcMethod.CreateAccount,
|
|
52
52
|
params: { options },
|
|
53
53
|
}), api_1.CreateAccountResponseStruct);
|
|
54
54
|
}
|
|
55
55
|
async filterAccountChains(id, chains) {
|
|
56
|
-
return (0,
|
|
56
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
57
57
|
method: rpc_1.KeyringRpcMethod.FilterAccountChains,
|
|
58
58
|
params: { id, chains },
|
|
59
59
|
}), api_1.FilterAccountChainsResponseStruct);
|
|
@@ -71,24 +71,24 @@ class KeyringClient {
|
|
|
71
71
|
}), api_1.DeleteAccountResponseStruct);
|
|
72
72
|
}
|
|
73
73
|
async exportAccount(id) {
|
|
74
|
-
return (0,
|
|
74
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
75
75
|
method: rpc_1.KeyringRpcMethod.ExportAccount,
|
|
76
76
|
params: { id },
|
|
77
77
|
}), api_1.ExportAccountResponseStruct);
|
|
78
78
|
}
|
|
79
79
|
async listRequests() {
|
|
80
|
-
return (0,
|
|
80
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
81
81
|
method: rpc_1.KeyringRpcMethod.ListRequests,
|
|
82
82
|
}), api_1.ListRequestsResponseStruct);
|
|
83
83
|
}
|
|
84
84
|
async getRequest(id) {
|
|
85
|
-
return (0,
|
|
85
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
86
86
|
method: rpc_1.KeyringRpcMethod.GetRequest,
|
|
87
87
|
params: { id },
|
|
88
88
|
}), api_1.GetRequestResponseStruct);
|
|
89
89
|
}
|
|
90
90
|
async submitRequest(request) {
|
|
91
|
-
return (0,
|
|
91
|
+
return (0, superstruct_2.strictMask)(await __classPrivateFieldGet(this, _KeyringClient_instances, "m", _KeyringClient_send).call(this, {
|
|
92
92
|
method: rpc_1.KeyringRpcMethod.SubmitRequest,
|
|
93
93
|
params: request,
|
|
94
94
|
}), api_1.SubmitRequestResponseStruct);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyringClient.js","sourceRoot":"","sources":["../src/KeyringClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,+BAAkC;AAWlC,wCAcwB;AACxB,wCAAkD;AAElD
|
|
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 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 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyringSnapRpcClient.js","sourceRoot":"","sources":["../src/KeyringSnapRpcClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,mDAAgD;AAEhD;;;GAGG;AACH,MAAa,aAAa;IAKxB;;;;;OAKG;IACH,YAAY,MAAc,EAAE,QAAgC;
|
|
1
|
+
{"version":3,"file":"KeyringSnapRpcClient.js","sourceRoot":"","sources":["../src/KeyringSnapRpcClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,mDAAgD;AAEhD;;;GAGG;AACH,MAAa,aAAa;IAKxB;;;;;OAKG;IACH,YAAY,MAAc,EAAE,QAAgC;QAVnD,wCAAgB;QAEhB,0CAAkC;QASzC,uBAAA,IAAI,yBAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,2BAAa,QAAQ,MAAA,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,OAAO,uBAAA,IAAI,+BAAU,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,sBAAsB;YAC9B,MAAM,EAAE;gBACN,MAAM,EAAE,uBAAA,IAAI,6BAAQ;gBACpB,OAAO;aACR;SACF,CAAkB,CAAC;IACtB,CAAC;CACF;AA/BD,sCA+BC;;AAED;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,6BAAa;IACrD;;;;;OAKG;IACH,YAAY,MAAc,EAAE,QAAgC;QAC1D,KAAK,CAAC,IAAI,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF;AAVD,oDAUC","sourcesContent":["import type { MetaMaskInpageProvider } from '@metamask/providers';\nimport type { Json } from '@metamask/utils';\n\nimport type { JsonRpcRequest } from './JsonRpcRequest';\nimport type { Sender } from './KeyringClient';\nimport { KeyringClient } from './KeyringClient';\n\n/**\n * Implementation of the `Sender` interface that can be used to send requests\n * to a snap through the snap JSON-RPC API.\n */\nexport class SnapRpcSender implements Sender {\n readonly #origin: string;\n\n readonly #provider: MetaMaskInpageProvider;\n\n /**\n * Create a new instance of `SnapRpcSender`.\n *\n * @param origin - The caller's origin.\n * @param provider - The `MetaMaskInpageProvider` instance to use.\n */\n constructor(origin: string, provider: MetaMaskInpageProvider) {\n this.#origin = origin;\n this.#provider = provider;\n }\n\n /**\n * Send a request to the snap and return the response.\n *\n * @param request - The JSON-RPC request to send to the snap.\n * @returns A promise that resolves to the response of the request.\n */\n async send(request: JsonRpcRequest): Promise<Json> {\n return this.#provider.request({\n method: 'wallet_invokeKeyring',\n params: {\n snapId: this.#origin,\n request,\n },\n }) as Promise<Json>;\n }\n}\n\n/**\n * A `KeyringClient` that allows the communication with a snap through the snap\n * JSON-RPC API.\n */\nexport class KeyringSnapRpcClient extends KeyringClient {\n /**\n * Create a new instance of `KeyringSnapRpcClient`.\n *\n * @param origin - Caller's origin.\n * @param provider - The `MetaMaskInpageProvider` instance to use.\n */\n constructor(origin: string, provider: MetaMaskInpageProvider) {\n super(new SnapRpcSender(origin, provider));\n }\n}\n"]}
|
package/dist/api/account.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare enum BtcAccountType {
|
|
|
15
15
|
/**
|
|
16
16
|
* Supported account types.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccountType.Erc4337}` | `${BtcAccountType.P2wpkh}`;
|
|
19
19
|
/**
|
|
20
20
|
* A struct which represents a Keyring account object. It is abstract enough to
|
|
21
21
|
* be used with any blockchain. Specific blockchain account types should extend
|
|
@@ -24,8 +24,8 @@ export declare type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccount
|
|
|
24
24
|
* See {@link KeyringAccount}.
|
|
25
25
|
*/
|
|
26
26
|
export declare const KeyringAccountStruct: import("@metamask/superstruct").Struct<{
|
|
27
|
-
id: string;
|
|
28
27
|
type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh";
|
|
28
|
+
id: string;
|
|
29
29
|
address: string;
|
|
30
30
|
options: Record<string, import("@metamask/utils").Json>;
|
|
31
31
|
methods: string[];
|
|
@@ -59,4 +59,4 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
|
59
59
|
* Keyring Account type represents an account and its properties from the
|
|
60
60
|
* point of view of the keyring.
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
62
|
+
export type KeyringAccount = Infer<typeof KeyringAccountStruct>;
|
package/dist/api/account.js
CHANGED
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KeyringAccountStruct = exports.BtcAccountType = exports.EthAccountType = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
6
|
+
const superstruct_2 = require("../superstruct");
|
|
7
|
+
const utils_2 = require("../utils");
|
|
7
8
|
/**
|
|
8
9
|
* Supported Ethereum account types.
|
|
9
10
|
*/
|
|
@@ -11,14 +12,14 @@ var EthAccountType;
|
|
|
11
12
|
(function (EthAccountType) {
|
|
12
13
|
EthAccountType["Eoa"] = "eip155:eoa";
|
|
13
14
|
EthAccountType["Erc4337"] = "eip155:erc4337";
|
|
14
|
-
})(EthAccountType
|
|
15
|
+
})(EthAccountType || (exports.EthAccountType = EthAccountType = {}));
|
|
15
16
|
/**
|
|
16
17
|
* Supported Bitcoin account types.
|
|
17
18
|
*/
|
|
18
19
|
var BtcAccountType;
|
|
19
20
|
(function (BtcAccountType) {
|
|
20
21
|
BtcAccountType["P2wpkh"] = "bip122:p2wpkh";
|
|
21
|
-
})(BtcAccountType
|
|
22
|
+
})(BtcAccountType || (exports.BtcAccountType = BtcAccountType = {}));
|
|
22
23
|
/**
|
|
23
24
|
* A struct which represents a Keyring account object. It is abstract enough to
|
|
24
25
|
* be used with any blockchain. Specific blockchain account types should extend
|
|
@@ -26,11 +27,11 @@ var BtcAccountType;
|
|
|
26
27
|
*
|
|
27
28
|
* See {@link KeyringAccount}.
|
|
28
29
|
*/
|
|
29
|
-
exports.KeyringAccountStruct = (0,
|
|
30
|
+
exports.KeyringAccountStruct = (0, superstruct_2.object)({
|
|
30
31
|
/**
|
|
31
32
|
* Account ID (UUIDv4).
|
|
32
33
|
*/
|
|
33
|
-
id:
|
|
34
|
+
id: utils_2.UuidStruct,
|
|
34
35
|
/**
|
|
35
36
|
* Account type.
|
|
36
37
|
*/
|
package/dist/api/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,
|
|
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,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,8BAAd,cAAc,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
|
@@ -6,4 +6,4 @@ export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
|
|
|
6
6
|
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
7
7
|
unit: import("@metamask/superstruct").Struct<string, null>;
|
|
8
8
|
}>;
|
|
9
|
-
export
|
|
9
|
+
export type Balance = Infer<typeof BalanceStruct>;
|
package/dist/api/balance.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BalanceStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const superstruct_2 = require("../superstruct");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
exports.BalanceStruct = (0, superstruct_2.object)({
|
|
8
|
+
amount: utils_1.StringNumberStruct,
|
|
8
9
|
unit: (0, superstruct_1.string)(),
|
|
9
10
|
});
|
|
10
11
|
//# sourceMappingURL=balance.js.map
|
package/dist/api/balance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,
|
|
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
|
@@ -3,12 +3,12 @@ import { type Infer } from '@metamask/superstruct';
|
|
|
3
3
|
* A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
|
|
4
4
|
*/
|
|
5
5
|
export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
6
|
-
export
|
|
6
|
+
export 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
10
|
export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
11
|
-
export
|
|
11
|
+
export type CaipAssetId = Infer<typeof CaipAssetIdStruct>;
|
|
12
12
|
/**
|
|
13
13
|
* Check if the given value is a {@link CaipAssetType}.
|
|
14
14
|
*
|
package/dist/api/caip.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isCaipAssetId = exports.isCaipAssetType = exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
-
const
|
|
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;
|
|
8
8
|
/**
|
|
9
9
|
* A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
|
|
10
10
|
*/
|
|
11
|
-
exports.CaipAssetTypeStruct = (0,
|
|
11
|
+
exports.CaipAssetTypeStruct = (0, superstruct_2.definePattern)('CaipAssetType', CAIP_ASSET_TYPE_REGEX);
|
|
12
12
|
/**
|
|
13
13
|
* A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
|
|
14
14
|
*/
|
|
15
|
-
exports.CaipAssetIdStruct = (0,
|
|
15
|
+
exports.CaipAssetIdStruct = (0, superstruct_2.definePattern)('CaipAssetId', CAIP_ASSET_ID_REGEX);
|
|
16
16
|
/**
|
|
17
17
|
* Check if the given value is a {@link CaipAssetType}.
|
|
18
18
|
*
|
package/dist/api/caip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caip.js","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD,
|
|
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
|
@@ -5,4 +5,4 @@ export declare const KeyringAccountDataStruct: import("@metamask/superstruct").S
|
|
|
5
5
|
*
|
|
6
6
|
* The exact response depends on the keyring implementation.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type KeyringAccountData = Infer<typeof KeyringAccountDataStruct>;
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -18,7 +18,6 @@ __exportStar(require("./account"), exports);
|
|
|
18
18
|
__exportStar(require("./balance"), exports);
|
|
19
19
|
__exportStar(require("./caip"), exports);
|
|
20
20
|
__exportStar(require("./export"), exports);
|
|
21
|
-
__exportStar(require("./keyring"), exports);
|
|
22
21
|
__exportStar(require("./request"), exports);
|
|
23
22
|
__exportStar(require("./response"), exports);
|
|
24
23
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB;AACvB,2CAAyB;AAEzB,4CAA0B;AAC1B,6CAA2B","sourcesContent":["export * from './account';\nexport * from './balance';\nexport * from './caip';\nexport * from './export';\nexport type * from './keyring';\nexport * from './request';\nexport * from './response';\n"]}
|
package/dist/api/keyring.d.ts
CHANGED
package/dist/api/request.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const KeyringRequestStruct: import("@metamask/superstruct").Struc
|
|
|
28
28
|
params?: import("@metamask/utils").Json[] | Record<string, import("@metamask/utils").Json>;
|
|
29
29
|
}, {
|
|
30
30
|
method: import("@metamask/superstruct").Struct<string, null>;
|
|
31
|
-
params: import("@metamask/superstruct").Struct<import("
|
|
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
|
/**
|
|
@@ -36,4 +36,4 @@ export declare const KeyringRequestStruct: import("@metamask/superstruct").Struc
|
|
|
36
36
|
*
|
|
37
37
|
* Represents a request made to the keyring for account-related operations.
|
|
38
38
|
*/
|
|
39
|
-
export
|
|
39
|
+
export type KeyringRequest = Infer<typeof KeyringRequestStruct>;
|
package/dist/api/request.js
CHANGED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KeyringRequestStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const superstruct_2 = require("../superstruct");
|
|
7
|
+
const utils_2 = require("../utils");
|
|
8
|
+
exports.KeyringRequestStruct = (0, superstruct_2.object)({
|
|
8
9
|
/**
|
|
9
10
|
* Keyring request ID (UUIDv4).
|
|
10
11
|
*/
|
|
11
|
-
id:
|
|
12
|
+
id: utils_2.UuidStruct,
|
|
12
13
|
/**
|
|
13
14
|
* Request's scope (CAIP-2 chain ID).
|
|
14
15
|
*/
|
|
@@ -16,13 +17,13 @@ exports.KeyringRequestStruct = (0, keyring_utils_1.object)({
|
|
|
16
17
|
/**
|
|
17
18
|
* Account ID (UUIDv4).
|
|
18
19
|
*/
|
|
19
|
-
account:
|
|
20
|
+
account: utils_2.UuidStruct,
|
|
20
21
|
/**
|
|
21
22
|
* Inner request sent by the client application.
|
|
22
23
|
*/
|
|
23
|
-
request: (0,
|
|
24
|
+
request: (0, superstruct_2.object)({
|
|
24
25
|
method: (0, superstruct_1.string)(),
|
|
25
|
-
params: (0,
|
|
26
|
+
params: (0, superstruct_2.exactOptional)((0, superstruct_1.union)([(0, superstruct_1.array)(utils_1.JsonStruct), (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct)])),
|
|
26
27
|
}),
|
|
27
28
|
});
|
|
28
29
|
//# sourceMappingURL=request.js.map
|
package/dist/api/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/api/request.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,
|
|
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
|
@@ -21,4 +21,4 @@ export declare const KeyringResponseStruct: import("@metamask/superstruct").Stru
|
|
|
21
21
|
* the request. The main use case for this is to redirect the user to the snap
|
|
22
22
|
* dapp to review the request.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export type KeyringResponse = Infer<typeof KeyringResponseStruct>;
|
package/dist/api/response.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KeyringResponseStruct = void 0;
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const utils_1 = require("@metamask/utils");
|
|
6
|
-
const
|
|
6
|
+
const superstruct_2 = require("../superstruct");
|
|
7
7
|
exports.KeyringResponseStruct = (0, superstruct_1.union)([
|
|
8
|
-
(0,
|
|
8
|
+
(0, superstruct_2.object)({
|
|
9
9
|
/**
|
|
10
10
|
* Pending flag.
|
|
11
11
|
*
|
|
@@ -21,12 +21,12 @@ exports.KeyringResponseStruct = (0, superstruct_1.union)([
|
|
|
21
21
|
* with a link to the redirect URL. The user can choose to follow the link
|
|
22
22
|
* or cancel the request.
|
|
23
23
|
*/
|
|
24
|
-
redirect: (0,
|
|
25
|
-
message: (0,
|
|
26
|
-
url: (0,
|
|
24
|
+
redirect: (0, superstruct_2.exactOptional)((0, superstruct_2.object)({
|
|
25
|
+
message: (0, superstruct_2.exactOptional)((0, superstruct_1.string)()),
|
|
26
|
+
url: (0, superstruct_2.exactOptional)((0, superstruct_1.string)()),
|
|
27
27
|
})),
|
|
28
28
|
}),
|
|
29
|
-
(0,
|
|
29
|
+
(0, superstruct_2.object)({
|
|
30
30
|
/**
|
|
31
31
|
* Pending flag.
|
|
32
32
|
*
|
package/dist/api/response.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AACA,uDAA+D;AAC/D,2CAA6C;AAE7C,
|
|
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
|
@@ -7,8 +7,8 @@ export declare enum BtcMethod {
|
|
|
7
7
|
SendMany = "btc_sendmany"
|
|
8
8
|
}
|
|
9
9
|
export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
|
|
10
|
-
id: string;
|
|
11
10
|
type: "bip122:p2wpkh";
|
|
11
|
+
id: string;
|
|
12
12
|
address: string;
|
|
13
13
|
options: Record<string, import("@metamask/utils").Json>;
|
|
14
14
|
methods: "btc_sendmany"[];
|
|
@@ -30,4 +30,4 @@ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Str
|
|
|
30
30
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
31
31
|
options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
|
|
32
32
|
}>;
|
|
33
|
-
export
|
|
33
|
+
export type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;
|
package/dist/btc/types.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.BtcP2wpkhAccountStruct = exports.BtcMethod = exports.BtcP2wpkhAddressStr
|
|
|
4
4
|
const superstruct_1 = require("@metamask/superstruct");
|
|
5
5
|
const bech32_1 = require("bech32");
|
|
6
6
|
const api_1 = require("../api");
|
|
7
|
-
const
|
|
7
|
+
const superstruct_2 = require("../superstruct");
|
|
8
8
|
exports.BtcP2wpkhAddressStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'BtcP2wpkhAddressStruct', (address) => {
|
|
9
9
|
try {
|
|
10
10
|
bech32_1.bech32.decode(address);
|
|
@@ -21,8 +21,8 @@ var BtcMethod;
|
|
|
21
21
|
(function (BtcMethod) {
|
|
22
22
|
// General transaction methods
|
|
23
23
|
BtcMethod["SendMany"] = "btc_sendmany";
|
|
24
|
-
})(BtcMethod
|
|
25
|
-
exports.BtcP2wpkhAccountStruct = (0,
|
|
24
|
+
})(BtcMethod || (exports.BtcMethod = BtcMethod = {}));
|
|
25
|
+
exports.BtcP2wpkhAccountStruct = (0, superstruct_2.object)({
|
|
26
26
|
...api_1.KeyringAccountStruct.schema,
|
|
27
27
|
/**
|
|
28
28
|
* Account address.
|
package/dist/btc/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":";;;AACA,uDAA8E;AAC9E,mCAAgC;AAEhC,gCAA8D;AAC9D,
|
|
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,CAAC;QACH,eAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;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,yBAAT,SAAS,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"]}
|