@metamask/keyring-api 1.0.0 → 2.0.0

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +43 -1
  2. package/README.md +38 -34
  3. package/dist/KeyringClient.js +13 -13
  4. package/dist/KeyringClient.js.map +1 -1
  5. package/dist/KeyringSnapControllerClient.d.ts +3 -2
  6. package/dist/KeyringSnapControllerClient.js.map +1 -1
  7. package/dist/api.d.ts +13 -7
  8. package/dist/api.js +10 -2
  9. package/dist/api.js.map +1 -1
  10. package/dist/eth/erc4337/index.d.ts +1 -0
  11. package/dist/eth/erc4337/index.js +18 -0
  12. package/dist/eth/erc4337/index.js.map +1 -0
  13. package/dist/eth/erc4337/types.d.ts +90 -0
  14. package/dist/eth/erc4337/types.js +58 -0
  15. package/dist/eth/erc4337/types.js.map +1 -0
  16. package/dist/eth/index.d.ts +2 -0
  17. package/dist/eth/index.js +19 -0
  18. package/dist/eth/index.js.map +1 -0
  19. package/dist/eth/types.d.ts +3 -0
  20. package/dist/eth/types.js +8 -0
  21. package/dist/eth/types.js.map +1 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/internal/api.d.ts +62 -50
  26. package/dist/internal/api.js +8 -8
  27. package/dist/internal/api.js.map +1 -1
  28. package/dist/internal/eth/EthKeyring.d.ts +29 -0
  29. package/dist/internal/eth/EthKeyring.js +3 -0
  30. package/dist/internal/eth/EthKeyring.js.map +1 -0
  31. package/dist/internal/eth/index.d.ts +1 -0
  32. package/dist/internal/eth/index.js +18 -0
  33. package/dist/internal/eth/index.js.map +1 -0
  34. package/dist/internal/events.d.ts +30 -20
  35. package/dist/internal/index.d.ts +2 -0
  36. package/dist/internal/index.js +2 -0
  37. package/dist/internal/index.js.map +1 -1
  38. package/dist/internal/rpc.d.ts +24 -0
  39. package/dist/internal/rpc.js +32 -0
  40. package/dist/internal/rpc.js.map +1 -0
  41. package/dist/internal/types.d.ts +8 -5
  42. package/dist/rpc-handler.d.ts +0 -21
  43. package/dist/rpc-handler.js +14 -38
  44. package/dist/rpc-handler.js.map +1 -1
  45. package/dist/snap-utils.d.ts +2 -2
  46. package/dist/snap-utils.js.map +1 -1
  47. package/dist/superstruct.d.ts +14 -0
  48. package/dist/superstruct.js +18 -1
  49. package/dist/superstruct.js.map +1 -1
  50. package/dist/utils.js +2 -1
  51. package/dist/utils.js.map +1 -1
  52. package/package.json +7 -7
  53. package/dist/superstruct.test-d.d.ts +0 -1
  54. package/dist/superstruct.test-d.js +0 -17
  55. package/dist/superstruct.test-d.js.map +0 -1
@@ -7,7 +7,7 @@ const api_1 = require("../api");
7
7
  const utils_2 = require("../utils");
8
8
  const CommonHeader = {
9
9
  jsonrpc: (0, superstruct_1.literal)('2.0'),
10
- id: utils_2.UuidStruct,
10
+ id: (0, superstruct_1.union)([(0, superstruct_1.string)(), (0, superstruct_1.number)(), (0, superstruct_1.literal)(null)]),
11
11
  };
12
12
  // ----------------------------------------------------------------------------
13
13
  // List accounts
@@ -22,7 +22,7 @@ exports.GetAccountRequestStruct = (0, superstruct_1.object)({
22
22
  ...CommonHeader,
23
23
  method: (0, superstruct_1.literal)('keyring_getAccount'),
24
24
  params: (0, superstruct_1.object)({
25
- id: (0, superstruct_1.string)(),
25
+ id: utils_2.UuidStruct,
26
26
  }),
27
27
  });
28
28
  exports.GetAccountResponseStruct = api_1.KeyringAccountStruct;
@@ -42,7 +42,7 @@ exports.FilterAccountChainsStruct = (0, superstruct_1.object)({
42
42
  ...CommonHeader,
43
43
  method: (0, superstruct_1.literal)('keyring_filterAccountChains'),
44
44
  params: (0, superstruct_1.object)({
45
- id: (0, superstruct_1.string)(),
45
+ id: utils_2.UuidStruct,
46
46
  chains: (0, superstruct_1.array)((0, superstruct_1.string)()),
47
47
  }),
48
48
  });
@@ -63,7 +63,7 @@ exports.DeleteAccountRequestStruct = (0, superstruct_1.object)({
63
63
  ...CommonHeader,
64
64
  method: (0, superstruct_1.literal)('keyring_deleteAccount'),
65
65
  params: (0, superstruct_1.object)({
66
- id: (0, superstruct_1.string)(),
66
+ id: utils_2.UuidStruct,
67
67
  }),
68
68
  });
69
69
  exports.DeleteAccountResponseStruct = (0, superstruct_1.literal)(null);
@@ -73,7 +73,7 @@ exports.ExportAccountRequestStruct = (0, superstruct_1.object)({
73
73
  ...CommonHeader,
74
74
  method: (0, superstruct_1.literal)('keyring_exportAccount'),
75
75
  params: (0, superstruct_1.object)({
76
- id: (0, superstruct_1.string)(),
76
+ id: utils_2.UuidStruct,
77
77
  }),
78
78
  });
79
79
  exports.ExportAccountResponseStruct = api_1.KeyringAccountDataStruct;
@@ -90,7 +90,7 @@ exports.GetRequestRequestStruct = (0, superstruct_1.object)({
90
90
  ...CommonHeader,
91
91
  method: (0, superstruct_1.literal)('keyring_getRequest'),
92
92
  params: (0, superstruct_1.object)({
93
- id: (0, superstruct_1.string)(),
93
+ id: utils_2.UuidStruct,
94
94
  }),
95
95
  });
96
96
  exports.GetRequestResponseStruct = api_1.KeyringRequestStruct;
@@ -108,7 +108,7 @@ exports.ApproveRequestRequestStruct = (0, superstruct_1.object)({
108
108
  ...CommonHeader,
109
109
  method: (0, superstruct_1.literal)('keyring_approveRequest'),
110
110
  params: (0, superstruct_1.object)({
111
- id: (0, superstruct_1.string)(),
111
+ id: utils_2.UuidStruct,
112
112
  data: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
113
113
  }),
114
114
  });
@@ -119,7 +119,7 @@ exports.RejectRequestRequestStruct = (0, superstruct_1.object)({
119
119
  ...CommonHeader,
120
120
  method: (0, superstruct_1.literal)('keyring_rejectRequest'),
121
121
  params: (0, superstruct_1.object)({
122
- id: (0, superstruct_1.string)(),
122
+ id: utils_2.UuidStruct,
123
123
  }),
124
124
  });
125
125
  exports.RejectRequestResponseStruct = (0, superstruct_1.literal)(null);
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sour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AA,oBAAM,GAAE;KACb,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import { JsonStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport { array, literal, object, record, string } from 'superstruct';\n\nimport {\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n} from '../api';\nimport { UuidStruct } from '../utils';\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: UuidStruct,\n};\n\n// ----------------------------------------------------------------------------\n// List accounts\n\nexport const ListAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccounts'),\n});\n\nexport type ListAccountsRequest = Infer<typeof ListAccountsRequestStruct>;\n\nexport const ListAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type ListAccountsResponse = Infer<typeof ListAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account\n\nexport const GetAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getAccount'),\n params: object({\n id: string(),\n }),\n});\n\nexport type GetAccountRequest = Infer<typeof GetAccountRequestStruct>;\n\nexport const GetAccountResponseStruct = KeyringAccountStruct;\n\nexport type GetAccountResponse = Infer<typeof GetAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create account\n\nexport const CreateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccount'),\n params: object({\n options: record(string(), JsonStruct),\n }),\n});\n\nexport type CreateAccountRequest = Infer<typeof CreateAccountRequestStruct>;\n\nexport const CreateAccountResponseStruct = KeyringAccountStruct;\n\nexport type CreateAccountResponse = Infer<typeof CreateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Filter account chains\n\nexport const FilterAccountChainsStruct = object({\n ...CommonHeader,\n method: literal('keyring_filterAccountChains'),\n params: object({\n id: string(),\n chains: array(string()),\n }),\n});\n\nexport type FilterAccountChainsRequest = Infer<\n typeof FilterAccountChainsStruct\n>;\n\nexport const FilterAccountChainsResponseStruct = array(string());\n\nexport type FilterAccountChainsResponse = Infer<\n typeof FilterAccountChainsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Update account\n\nexport const UpdateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_updateAccount'),\n params: object({\n account: KeyringAccountStruct,\n }),\n});\n\nexport type UpdateAccountRequest = Infer<typeof UpdateAccountRequestStruct>;\n\nexport const UpdateAccountResponseStruct = literal(null);\n\nexport type UpdateAccountResponse = Infer<typeof UpdateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Delete account\n\nexport const DeleteAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_deleteAccount'),\n params: object({\n id: string(),\n }),\n});\n\nexport type DeleteAccountRequest = Infer<typeof DeleteAccountRequestStruct>;\n\nexport const DeleteAccountResponseStruct = literal(null);\n\nexport type DeleteAccountResponse = Infer<typeof DeleteAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Export account\n\nexport const ExportAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_exportAccount'),\n params: object({\n id: string(),\n }),\n});\n\nexport type ExportAccountRequest = Infer<typeof ExportAccountRequestStruct>;\n\nexport const ExportAccountResponseStruct = KeyringAccountDataStruct;\n\nexport type ExportAccountResponse = Infer<typeof ExportAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// List requests\n\nexport const ListRequestsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listRequests'),\n});\n\nexport type ListRequestsRequest = Infer<typeof ListRequestsRequestStruct>;\n\nexport const ListRequestsResponseStruct = array(KeyringRequestStruct);\n\nexport type ListRequestsResponse = Infer<typeof ListRequestsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get request\n\nexport const GetRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getRequest'),\n params: object({\n id: string(),\n }),\n});\n\nexport type GetRequestRequest = Infer<typeof GetRequestRequestStruct>;\n\nexport const GetRequestResponseStruct = KeyringRequestStruct;\n\nexport type GetRequestResponse = Infer<typeof GetRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Submit request\n\nexport const SubmitRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_submitRequest'),\n params: KeyringRequestStruct,\n});\n\nexport type SubmitRequestRequest = Infer<typeof SubmitRequestRequestStruct>;\n\nexport const SubmitRequestResponseStruct = KeyringResponseStruct;\n\nexport type SubmitRequestResponse = Infer<typeof SubmitRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Approve request\n\nexport const ApproveRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_approveRequest'),\n params: object({\n id: string(),\n data: record(string(), JsonStruct),\n }),\n});\n\nexport type ApproveRequestRequest = Infer<typeof ApproveRequestRequestStruct>;\n\nexport const ApproveRequestResponseStruct = literal(null);\n\nexport type ApproveRequestResponse = Infer<typeof ApproveRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Reject request\n\nexport const RejectRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_rejectRequest'),\n params: object({\n id: string(),\n }),\n});\n\nexport type RejectRequestRequest = Infer<typeof RejectRequestRequestStruct>;\n\nexport const RejectRequestResponseStruct = literal(null);\n\nexport type RejectRequestResponse = Infer<typeof RejectRequestResponseStruct>;\n"]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/internal/api.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,6CAQqB;AAErB,gCAKgB;AAChB,oCAAsC;AAEtC,MAAM,YAAY,GAAG;IACnB,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;CAC/C,CAAC;AAEF,+EAA+E;AAC/E,gBAAgB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M,EAAC;QACb,EAAE,EAAE,kBAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,wBAAwB,GAAG,0BAAoB,CAAC;AAI7D,+EAA+E;AAC/E,iBAAiB;AAEJ,QAAA,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,0BAAoB;CAC7B,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,2BAAqB,CAAC;AAIjE,+EAA+E;AAC/E,kBAAkB;AAEL,QAAA,2BAA2B,GAAG,IAAA,oBAAM,EAAC;IAChD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,wBAAwB,CAAC;IACzC,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,kBAAU;QACd,IAAI,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;KACnC,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,4BAA4B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC;AAI1D,+EAA+E;AAC/E,iBAAiB;AAEJ,QAAA,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,IAAA,oBAAM,EAAC;QACb,EAAE,EAAE,kBAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import { JsonStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport {\n array,\n literal,\n number,\n object,\n record,\n string,\n union,\n} from 'superstruct';\n\nimport {\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n} from '../api';\nimport { UuidStruct } from '../utils';\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n};\n\n// ----------------------------------------------------------------------------\n// List accounts\n\nexport const ListAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccounts'),\n});\n\nexport type ListAccountsRequest = Infer<typeof ListAccountsRequestStruct>;\n\nexport const ListAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type ListAccountsResponse = Infer<typeof ListAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account\n\nexport const GetAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetAccountRequest = Infer<typeof GetAccountRequestStruct>;\n\nexport const GetAccountResponseStruct = KeyringAccountStruct;\n\nexport type GetAccountResponse = Infer<typeof GetAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create account\n\nexport const CreateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccount'),\n params: object({\n options: record(string(), JsonStruct),\n }),\n});\n\nexport type CreateAccountRequest = Infer<typeof CreateAccountRequestStruct>;\n\nexport const CreateAccountResponseStruct = KeyringAccountStruct;\n\nexport type CreateAccountResponse = Infer<typeof CreateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Filter account chains\n\nexport const FilterAccountChainsStruct = object({\n ...CommonHeader,\n method: literal('keyring_filterAccountChains'),\n params: object({\n id: UuidStruct,\n chains: array(string()),\n }),\n});\n\nexport type FilterAccountChainsRequest = Infer<\n typeof FilterAccountChainsStruct\n>;\n\nexport const FilterAccountChainsResponseStruct = array(string());\n\nexport type FilterAccountChainsResponse = Infer<\n typeof FilterAccountChainsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Update account\n\nexport const UpdateAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_updateAccount'),\n params: object({\n account: KeyringAccountStruct,\n }),\n});\n\nexport type UpdateAccountRequest = Infer<typeof UpdateAccountRequestStruct>;\n\nexport const UpdateAccountResponseStruct = literal(null);\n\nexport type UpdateAccountResponse = Infer<typeof UpdateAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Delete account\n\nexport const DeleteAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_deleteAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type DeleteAccountRequest = Infer<typeof DeleteAccountRequestStruct>;\n\nexport const DeleteAccountResponseStruct = literal(null);\n\nexport type DeleteAccountResponse = Infer<typeof DeleteAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Export account\n\nexport const ExportAccountRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_exportAccount'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ExportAccountRequest = Infer<typeof ExportAccountRequestStruct>;\n\nexport const ExportAccountResponseStruct = KeyringAccountDataStruct;\n\nexport type ExportAccountResponse = Infer<typeof ExportAccountResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// List requests\n\nexport const ListRequestsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listRequests'),\n});\n\nexport type ListRequestsRequest = Infer<typeof ListRequestsRequestStruct>;\n\nexport const ListRequestsResponseStruct = array(KeyringRequestStruct);\n\nexport type ListRequestsResponse = Infer<typeof ListRequestsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get request\n\nexport const GetRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_getRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetRequestRequest = Infer<typeof GetRequestRequestStruct>;\n\nexport const GetRequestResponseStruct = KeyringRequestStruct;\n\nexport type GetRequestResponse = Infer<typeof GetRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Submit request\n\nexport const SubmitRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_submitRequest'),\n params: KeyringRequestStruct,\n});\n\nexport type SubmitRequestRequest = Infer<typeof SubmitRequestRequestStruct>;\n\nexport const SubmitRequestResponseStruct = KeyringResponseStruct;\n\nexport type SubmitRequestResponse = Infer<typeof SubmitRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Approve request\n\nexport const ApproveRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_approveRequest'),\n params: object({\n id: UuidStruct,\n data: record(string(), JsonStruct),\n }),\n});\n\nexport type ApproveRequestRequest = Infer<typeof ApproveRequestRequestStruct>;\n\nexport const ApproveRequestResponseStruct = literal(null);\n\nexport type ApproveRequestResponse = Infer<typeof ApproveRequestResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Reject request\n\nexport const RejectRequestRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_rejectRequest'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type RejectRequestRequest = Infer<typeof RejectRequestRequestStruct>;\n\nexport const RejectRequestResponseStruct = literal(null);\n\nexport type RejectRequestResponse = Infer<typeof RejectRequestResponseStruct>;\n"]}
@@ -0,0 +1,29 @@
1
+ import type { Json, Keyring } from '@metamask/utils';
2
+ import type { EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch } from '../../eth';
3
+ export declare type EthKeyring<State extends Json> = Keyring<State> & {
4
+ /**
5
+ * Convert a base transaction to a base UserOperation.
6
+ *
7
+ * @param address - Address of the sender.
8
+ * @param transactions - Base transactions to include in the UserOperation.
9
+ * @returns A pseudo-UserOperation that can be used to construct a real.
10
+ */
11
+ prepareUserOperation?(address: string, transactions: EthBaseTransaction[]): Promise<EthBaseUserOperation>;
12
+ /**
13
+ * Patches properties of a UserOperation. Currently, only the
14
+ * `paymasterAndData` can be patched.
15
+ *
16
+ * @param address - Address of the sender.
17
+ * @param userOp - UserOperation to patch.
18
+ * @returns A patch to apply to the UserOperation.
19
+ */
20
+ patchUserOperation?(address: string, userOp: EthUserOperation): Promise<EthUserOperationPatch>;
21
+ /**
22
+ * Signs an UserOperation.
23
+ *
24
+ * @param address - Address of the sender.
25
+ * @param userOp - UserOperation to sign.
26
+ * @returns The signature of the UserOperation.
27
+ */
28
+ signUserOperation?(address: string, userOp: EthUserOperation): Promise<string>;
29
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=EthKeyring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthKeyring.js","sourceRoot":"","sources":["../../../src/internal/eth/EthKeyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { Json, Keyring } from '@metamask/utils';\n\nimport type {\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n} from '../../eth';\n\nexport type EthKeyring<State extends Json> = Keyring<State> & {\n /**\n * Convert a base transaction to a base UserOperation.\n *\n * @param address - Address of the sender.\n * @param transactions - Base transactions to include in the UserOperation.\n * @returns A pseudo-UserOperation that can be used to construct a real.\n */\n prepareUserOperation?(\n address: string,\n transactions: EthBaseTransaction[],\n ): Promise<EthBaseUserOperation>;\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to patch.\n * @returns A patch to apply to the UserOperation.\n */\n patchUserOperation?(\n address: string,\n userOp: EthUserOperation,\n ): Promise<EthUserOperationPatch>;\n\n /**\n * Signs an UserOperation.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to sign.\n * @returns The signature of the UserOperation.\n */\n signUserOperation?(\n address: string,\n userOp: EthUserOperation,\n ): Promise<string>;\n};\n"]}
@@ -0,0 +1 @@
1
+ export * from './EthKeyring';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./EthKeyring"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B","sourcesContent":["export * from './EthKeyring';\n"]}
@@ -2,48 +2,53 @@ export declare const AccountCreatedEventStruct: import("superstruct").Struct<{
2
2
  method: "notify:accountCreated";
3
3
  params: {
4
4
  account: {
5
- type: "eip155:eoa" | "eip155:eip4337";
5
+ type: "eip155:eoa" | "eip155:erc4337";
6
6
  id: string;
7
7
  address: string;
8
8
  options: Record<string, import("@metamask/utils").Json>;
9
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
9
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
10
10
  };
11
11
  };
12
12
  }, {
13
13
  method: import("superstruct").Struct<"notify:accountCreated", "notify:accountCreated">;
14
14
  params: import("superstruct").Struct<{
15
15
  account: {
16
- type: "eip155:eoa" | "eip155:eip4337";
16
+ type: "eip155:eoa" | "eip155:erc4337";
17
17
  id: string;
18
18
  address: string;
19
19
  options: Record<string, import("@metamask/utils").Json>;
20
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
20
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
21
21
  };
22
22
  }, {
23
23
  /**
24
24
  * New account object.
25
25
  */
26
26
  account: import("superstruct").Struct<{
27
- type: "eip155:eoa" | "eip155:eip4337";
27
+ type: "eip155:eoa" | "eip155:erc4337";
28
28
  id: string;
29
29
  address: string;
30
30
  options: Record<string, import("@metamask/utils").Json>;
31
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
31
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
32
32
  }, {
33
- id: import("superstruct").Struct<string, null>;
33
+ id: import("superstruct").Struct<string, null>; /**
34
+ * Request result.
35
+ */
34
36
  address: import("superstruct").Struct<string, null>;
35
37
  options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
36
- methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4", {
38
+ methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", {
37
39
  personal_sign: "personal_sign";
38
40
  eth_sign: "eth_sign";
39
41
  eth_signTransaction: "eth_signTransaction";
40
42
  eth_signTypedData_v1: "eth_signTypedData_v1";
41
43
  eth_signTypedData_v3: "eth_signTypedData_v3";
42
44
  eth_signTypedData_v4: "eth_signTypedData_v4";
45
+ eth_prepareUserOperation: "eth_prepareUserOperation";
46
+ eth_patchUserOperation: "eth_patchUserOperation";
47
+ eth_signUserOperation: "eth_signUserOperation";
43
48
  }>>;
44
- type: import("superstruct").Struct<"eip155:eoa" | "eip155:eip4337", {
49
+ type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", {
45
50
  "eip155:eoa": "eip155:eoa";
46
- "eip155:eip4337": "eip155:eip4337";
51
+ "eip155:erc4337": "eip155:erc4337";
47
52
  }>;
48
53
  }>;
49
54
  }>;
@@ -52,48 +57,53 @@ export declare const AccountUpdatedEventStruct: import("superstruct").Struct<{
52
57
  method: "notify:accountUpdated";
53
58
  params: {
54
59
  account: {
55
- type: "eip155:eoa" | "eip155:eip4337";
60
+ type: "eip155:eoa" | "eip155:erc4337";
56
61
  id: string;
57
62
  address: string;
58
63
  options: Record<string, import("@metamask/utils").Json>;
59
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
64
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
60
65
  };
61
66
  };
62
67
  }, {
63
68
  method: import("superstruct").Struct<"notify:accountUpdated", "notify:accountUpdated">;
64
69
  params: import("superstruct").Struct<{
65
70
  account: {
66
- type: "eip155:eoa" | "eip155:eip4337";
71
+ type: "eip155:eoa" | "eip155:erc4337";
67
72
  id: string;
68
73
  address: string;
69
74
  options: Record<string, import("@metamask/utils").Json>;
70
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
75
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
71
76
  };
72
77
  }, {
73
78
  /**
74
79
  * Updated account object.
75
80
  */
76
81
  account: import("superstruct").Struct<{
77
- type: "eip155:eoa" | "eip155:eip4337";
82
+ type: "eip155:eoa" | "eip155:erc4337";
78
83
  id: string;
79
84
  address: string;
80
85
  options: Record<string, import("@metamask/utils").Json>;
81
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
86
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
82
87
  }, {
83
- id: import("superstruct").Struct<string, null>;
88
+ id: import("superstruct").Struct<string, null>; /**
89
+ * Request result.
90
+ */
84
91
  address: import("superstruct").Struct<string, null>;
85
92
  options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
86
- methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4", {
93
+ methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", {
87
94
  personal_sign: "personal_sign";
88
95
  eth_sign: "eth_sign";
89
96
  eth_signTransaction: "eth_signTransaction";
90
97
  eth_signTypedData_v1: "eth_signTypedData_v1";
91
98
  eth_signTypedData_v3: "eth_signTypedData_v3";
92
99
  eth_signTypedData_v4: "eth_signTypedData_v4";
100
+ eth_prepareUserOperation: "eth_prepareUserOperation";
101
+ eth_patchUserOperation: "eth_patchUserOperation";
102
+ eth_signUserOperation: "eth_signUserOperation";
93
103
  }>>;
94
- type: import("superstruct").Struct<"eip155:eoa" | "eip155:eip4337", {
104
+ type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", {
95
105
  "eip155:eoa": "eip155:eoa";
96
- "eip155:eip4337": "eip155:eip4337";
106
+ "eip155:erc4337": "eip155:erc4337";
97
107
  }>;
98
108
  }>;
99
109
  }>;
@@ -1,3 +1,5 @@
1
1
  export * from './api';
2
+ export * from './eth';
2
3
  export * from './events';
4
+ export * from './rpc';
3
5
  export * from './types';
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api"), exports);
18
+ __exportStar(require("./eth"), exports);
18
19
  __exportStar(require("./events"), exports);
20
+ __exportStar(require("./rpc"), exports);
19
21
  __exportStar(require("./types"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB","sourcesContent":["export * from './api';\nexport * from './events';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,wCAAsB;AACtB,2CAAyB;AACzB,wCAAsB;AACtB,0CAAwB","sourcesContent":["export * from './api';\nexport * from './eth';\nexport * from './events';\nexport * from './rpc';\nexport * from './types';\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Keyring RPC methods used by the API.
3
+ */
4
+ export declare enum KeyringRpcMethod {
5
+ ListAccounts = "keyring_listAccounts",
6
+ GetAccount = "keyring_getAccount",
7
+ CreateAccount = "keyring_createAccount",
8
+ FilterAccountChains = "keyring_filterAccountChains",
9
+ UpdateAccount = "keyring_updateAccount",
10
+ DeleteAccount = "keyring_deleteAccount",
11
+ ExportAccount = "keyring_exportAccount",
12
+ ListRequests = "keyring_listRequests",
13
+ GetRequest = "keyring_getRequest",
14
+ SubmitRequest = "keyring_submitRequest",
15
+ ApproveRequest = "keyring_approveRequest",
16
+ RejectRequest = "keyring_rejectRequest"
17
+ }
18
+ /**
19
+ * Check if a method is a keyring RPC method.
20
+ *
21
+ * @param method - Method to check.
22
+ * @returns Whether the method is a keyring RPC method.
23
+ */
24
+ export declare function isKeyringRpcMethod(method: string): boolean;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isKeyringRpcMethod = exports.KeyringRpcMethod = void 0;
4
+ /**
5
+ * Keyring RPC methods used by the API.
6
+ */
7
+ var KeyringRpcMethod;
8
+ (function (KeyringRpcMethod) {
9
+ KeyringRpcMethod["ListAccounts"] = "keyring_listAccounts";
10
+ KeyringRpcMethod["GetAccount"] = "keyring_getAccount";
11
+ KeyringRpcMethod["CreateAccount"] = "keyring_createAccount";
12
+ KeyringRpcMethod["FilterAccountChains"] = "keyring_filterAccountChains";
13
+ KeyringRpcMethod["UpdateAccount"] = "keyring_updateAccount";
14
+ KeyringRpcMethod["DeleteAccount"] = "keyring_deleteAccount";
15
+ KeyringRpcMethod["ExportAccount"] = "keyring_exportAccount";
16
+ KeyringRpcMethod["ListRequests"] = "keyring_listRequests";
17
+ KeyringRpcMethod["GetRequest"] = "keyring_getRequest";
18
+ KeyringRpcMethod["SubmitRequest"] = "keyring_submitRequest";
19
+ KeyringRpcMethod["ApproveRequest"] = "keyring_approveRequest";
20
+ KeyringRpcMethod["RejectRequest"] = "keyring_rejectRequest";
21
+ })(KeyringRpcMethod = exports.KeyringRpcMethod || (exports.KeyringRpcMethod = {}));
22
+ /**
23
+ * Check if a method is a keyring RPC method.
24
+ *
25
+ * @param method - Method to check.
26
+ * @returns Whether the method is a keyring RPC method.
27
+ */
28
+ function isKeyringRpcMethod(method) {
29
+ return Object.values(KeyringRpcMethod).includes(method);
30
+ }
31
+ exports.isKeyringRpcMethod = isKeyringRpcMethod;
32
+ //# sourceMappingURL=rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../src/internal/rpc.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBAaX;AAbD,WAAY,gBAAgB;IAC1B,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,2DAAuC,CAAA;IACvC,uEAAmD,CAAA;IACnD,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IACvC,2DAAuC,CAAA;IACvC,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,2DAAuC,CAAA;IACvC,6DAAyC,CAAA;IACzC,2DAAuC,CAAA;AACzC,CAAC,EAbW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAa3B;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,MAA0B,CAAC,CAAC;AAC9E,CAAC;AAFD,gDAEC","sourcesContent":["/**\n * Keyring RPC methods used by the API.\n */\nexport enum KeyringRpcMethod {\n ListAccounts = 'keyring_listAccounts',\n GetAccount = 'keyring_getAccount',\n CreateAccount = 'keyring_createAccount',\n FilterAccountChains = 'keyring_filterAccountChains',\n UpdateAccount = 'keyring_updateAccount',\n DeleteAccount = 'keyring_deleteAccount',\n ExportAccount = 'keyring_exportAccount',\n ListRequests = 'keyring_listRequests',\n GetRequest = 'keyring_getRequest',\n SubmitRequest = 'keyring_submitRequest',\n ApproveRequest = 'keyring_approveRequest',\n RejectRequest = 'keyring_rejectRequest',\n}\n\n/**\n * Check if a method is a keyring RPC method.\n *\n * @param method - Method to check.\n * @returns Whether the method is a keyring RPC method.\n */\nexport function isKeyringRpcMethod(method: string): boolean {\n return Object.values(KeyringRpcMethod).includes(method as KeyringRpcMethod);\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import type { Infer } from 'superstruct';
2
2
  export declare const InternalAccountStruct: import("superstruct").Struct<{
3
- type: "eip155:eoa" | "eip155:eip4337";
3
+ type: "eip155:eoa" | "eip155:erc4337";
4
4
  id: string;
5
5
  address: string;
6
6
  options: Record<string, import("@metamask/utils").Json>;
7
- methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
7
+ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
8
8
  metadata: {
9
9
  name: string;
10
10
  keyring: {
@@ -50,17 +50,20 @@ export declare const InternalAccountStruct: import("superstruct").Struct<{
50
50
  id: import("superstruct").Struct<string, null>;
51
51
  address: import("superstruct").Struct<string, null>;
52
52
  options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
53
- methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4", {
53
+ methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", {
54
54
  personal_sign: "personal_sign";
55
55
  eth_sign: "eth_sign";
56
56
  eth_signTransaction: "eth_signTransaction";
57
57
  eth_signTypedData_v1: "eth_signTypedData_v1";
58
58
  eth_signTypedData_v3: "eth_signTypedData_v3";
59
59
  eth_signTypedData_v4: "eth_signTypedData_v4";
60
+ eth_prepareUserOperation: "eth_prepareUserOperation";
61
+ eth_patchUserOperation: "eth_patchUserOperation";
62
+ eth_signUserOperation: "eth_signUserOperation";
60
63
  }>>;
61
- type: import("superstruct").Struct<"eip155:eoa" | "eip155:eip4337", {
64
+ type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", {
62
65
  "eip155:eoa": "eip155:eoa";
63
- "eip155:eip4337": "eip155:eip4337";
66
+ "eip155:erc4337": "eip155:erc4337";
64
67
  }>;
65
68
  }>;
66
69
  /**
@@ -7,20 +7,6 @@ import type { JsonRpcRequest } from './JsonRpcRequest';
7
7
  export declare class MethodNotSupportedError extends Error {
8
8
  constructor(method: string);
9
9
  }
10
- export declare enum KeyringRpcMethod {
11
- ListAccounts = "keyring_listAccounts",
12
- GetAccount = "keyring_getAccount",
13
- CreateAccount = "keyring_createAccount",
14
- FilterAccountChains = "keyring_filterAccountChains",
15
- UpdateAccount = "keyring_updateAccount",
16
- DeleteAccount = "keyring_deleteAccount",
17
- ExportAccount = "keyring_exportAccount",
18
- ListRequests = "keyring_listRequests",
19
- GetRequest = "keyring_getRequest",
20
- SubmitRequest = "keyring_submitRequest",
21
- ApproveRequest = "keyring_approveRequest",
22
- RejectRequest = "keyring_rejectRequest"
23
- }
24
10
  /**
25
11
  * Handles a keyring JSON-RPC request.
26
12
  *
@@ -29,10 +15,3 @@ export declare enum KeyringRpcMethod {
29
15
  * @returns A promise that resolves to the keyring response.
30
16
  */
31
17
  export declare function handleKeyringRequest(keyring: Keyring, request: JsonRpcRequest): Promise<Json | void>;
32
- /**
33
- * Check if a method is a keyring RPC method.
34
- *
35
- * @param method - Method to check.
36
- * @returns Whether the method is a keyring RPC method.
37
- */
38
- export declare function isKeyringRpcMethod(method: string): boolean;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isKeyringRpcMethod = exports.handleKeyringRequest = exports.KeyringRpcMethod = exports.MethodNotSupportedError = void 0;
3
+ exports.handleKeyringRequest = exports.MethodNotSupportedError = void 0;
4
4
  const superstruct_1 = require("superstruct");
5
5
  const api_1 = require("./internal/api");
6
+ const rpc_1 = require("./internal/rpc");
6
7
  const JsonRpcRequest_1 = require("./JsonRpcRequest");
7
8
  /**
8
9
  * Error thrown when a keyring JSON-RPC method is not supported.
@@ -13,21 +14,6 @@ class MethodNotSupportedError extends Error {
13
14
  }
14
15
  }
15
16
  exports.MethodNotSupportedError = MethodNotSupportedError;
16
- var KeyringRpcMethod;
17
- (function (KeyringRpcMethod) {
18
- KeyringRpcMethod["ListAccounts"] = "keyring_listAccounts";
19
- KeyringRpcMethod["GetAccount"] = "keyring_getAccount";
20
- KeyringRpcMethod["CreateAccount"] = "keyring_createAccount";
21
- KeyringRpcMethod["FilterAccountChains"] = "keyring_filterAccountChains";
22
- KeyringRpcMethod["UpdateAccount"] = "keyring_updateAccount";
23
- KeyringRpcMethod["DeleteAccount"] = "keyring_deleteAccount";
24
- KeyringRpcMethod["ExportAccount"] = "keyring_exportAccount";
25
- KeyringRpcMethod["ListRequests"] = "keyring_listRequests";
26
- KeyringRpcMethod["GetRequest"] = "keyring_getRequest";
27
- KeyringRpcMethod["SubmitRequest"] = "keyring_submitRequest";
28
- KeyringRpcMethod["ApproveRequest"] = "keyring_approveRequest";
29
- KeyringRpcMethod["RejectRequest"] = "keyring_rejectRequest";
30
- })(KeyringRpcMethod = exports.KeyringRpcMethod || (exports.KeyringRpcMethod = {}));
31
17
  /**
32
18
  * Handles a keyring JSON-RPC request.
33
19
  *
@@ -40,63 +26,63 @@ async function handleKeyringRequest(keyring, request) {
40
26
  // we can check its method name.
41
27
  (0, superstruct_1.assert)(request, JsonRpcRequest_1.JsonRpcRequestStruct);
42
28
  switch (request.method) {
43
- case KeyringRpcMethod.ListAccounts: {
29
+ case rpc_1.KeyringRpcMethod.ListAccounts: {
44
30
  (0, superstruct_1.assert)(request, api_1.ListAccountsRequestStruct);
45
31
  return keyring.listAccounts();
46
32
  }
47
- case KeyringRpcMethod.GetAccount: {
33
+ case rpc_1.KeyringRpcMethod.GetAccount: {
48
34
  (0, superstruct_1.assert)(request, api_1.GetAccountRequestStruct);
49
35
  return keyring.getAccount(request.params.id);
50
36
  }
51
- case KeyringRpcMethod.CreateAccount: {
37
+ case rpc_1.KeyringRpcMethod.CreateAccount: {
52
38
  (0, superstruct_1.assert)(request, api_1.CreateAccountRequestStruct);
53
39
  return keyring.createAccount(request.params.options);
54
40
  }
55
- case KeyringRpcMethod.FilterAccountChains: {
41
+ case rpc_1.KeyringRpcMethod.FilterAccountChains: {
56
42
  (0, superstruct_1.assert)(request, api_1.FilterAccountChainsStruct);
57
43
  return keyring.filterAccountChains(request.params.id, request.params.chains);
58
44
  }
59
- case KeyringRpcMethod.UpdateAccount: {
45
+ case rpc_1.KeyringRpcMethod.UpdateAccount: {
60
46
  (0, superstruct_1.assert)(request, api_1.UpdateAccountRequestStruct);
61
47
  return keyring.updateAccount(request.params.account);
62
48
  }
63
- case KeyringRpcMethod.DeleteAccount: {
49
+ case rpc_1.KeyringRpcMethod.DeleteAccount: {
64
50
  (0, superstruct_1.assert)(request, api_1.DeleteAccountRequestStruct);
65
51
  return keyring.deleteAccount(request.params.id);
66
52
  }
67
- case KeyringRpcMethod.ExportAccount: {
53
+ case rpc_1.KeyringRpcMethod.ExportAccount: {
68
54
  if (keyring.exportAccount === undefined) {
69
55
  throw new MethodNotSupportedError(request.method);
70
56
  }
71
57
  (0, superstruct_1.assert)(request, api_1.ExportAccountRequestStruct);
72
58
  return keyring.exportAccount(request.params.id);
73
59
  }
74
- case KeyringRpcMethod.ListRequests: {
60
+ case rpc_1.KeyringRpcMethod.ListRequests: {
75
61
  if (keyring.listRequests === undefined) {
76
62
  throw new MethodNotSupportedError(request.method);
77
63
  }
78
64
  (0, superstruct_1.assert)(request, api_1.ListRequestsRequestStruct);
79
65
  return keyring.listRequests();
80
66
  }
81
- case KeyringRpcMethod.GetRequest: {
67
+ case rpc_1.KeyringRpcMethod.GetRequest: {
82
68
  if (keyring.getRequest === undefined) {
83
69
  throw new MethodNotSupportedError(request.method);
84
70
  }
85
71
  (0, superstruct_1.assert)(request, api_1.GetRequestRequestStruct);
86
72
  return keyring.getRequest(request.params.id);
87
73
  }
88
- case KeyringRpcMethod.SubmitRequest: {
74
+ case rpc_1.KeyringRpcMethod.SubmitRequest: {
89
75
  (0, superstruct_1.assert)(request, api_1.SubmitRequestRequestStruct);
90
76
  return keyring.submitRequest(request.params);
91
77
  }
92
- case KeyringRpcMethod.ApproveRequest: {
78
+ case rpc_1.KeyringRpcMethod.ApproveRequest: {
93
79
  if (keyring.approveRequest === undefined) {
94
80
  throw new MethodNotSupportedError(request.method);
95
81
  }
96
82
  (0, superstruct_1.assert)(request, api_1.ApproveRequestRequestStruct);
97
83
  return keyring.approveRequest(request.params.id, request.params.data);
98
84
  }
99
- case KeyringRpcMethod.RejectRequest: {
85
+ case rpc_1.KeyringRpcMethod.RejectRequest: {
100
86
  if (keyring.rejectRequest === undefined) {
101
87
  throw new MethodNotSupportedError(request.method);
102
88
  }
@@ -109,14 +95,4 @@ async function handleKeyringRequest(keyring, request) {
109
95
  }
110
96
  }
111
97
  exports.handleKeyringRequest = handleKeyringRequest;
112
- /**
113
- * Check if a method is a keyring RPC method.
114
- *
115
- * @param method - Method to check.
116
- * @returns Whether the method is a keyring RPC method.
117
- */
118
- function isKeyringRpcMethod(method) {
119
- return Object.values(KeyringRpcMethod).includes(method);
120
- }
121
- exports.isKeyringRpcMethod = isKeyringRpcMethod;
122
98
  //# sourceMappingURL=rpc-handler.js.map