@metamask-previews/keyring-api 22.0.0-018fb62 → 22.0.0-5c366be

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,440 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ import type { KeyringV2 } from "./keyring.mjs";
3
+ /**
4
+ * Keyring interface for keyring methods that can be invoked through
5
+ * RPC calls.
6
+ */
7
+ export type KeyringRpcV2 = {
8
+ getAccount: KeyringV2['getAccount'];
9
+ getAccounts: KeyringV2['getAccounts'];
10
+ createAccounts: KeyringV2['createAccounts'];
11
+ deleteAccount: KeyringV2['deleteAccount'];
12
+ submitRequest: KeyringV2['submitRequest'];
13
+ exportAccount?: KeyringV2['exportAccount'];
14
+ };
15
+ /**
16
+ * Keyring RPC methods used by the API.
17
+ */
18
+ export declare const KeyringRpcV2Method: {
19
+ readonly GetAccounts: "keyring_getAccounts";
20
+ readonly CreateAccounts: "keyring_createAccounts";
21
+ readonly GetAccount: "keyring_getAccount";
22
+ readonly DeleteAccount: "keyring_deleteAccount";
23
+ readonly ExportAccount: "keyring_exportAccount";
24
+ readonly SubmitRequest: "keyring_submitRequest";
25
+ };
26
+ /**
27
+ * Keyring RPC methods used by the API.
28
+ */
29
+ export type KeyringRpcV2Method = (typeof KeyringRpcV2Method)[keyof typeof KeyringRpcV2Method];
30
+ /**
31
+ * Check if a method is a keyring RPC method (v2).
32
+ *
33
+ * @param method - Method to check.
34
+ * @returns Whether the method is a keyring RPC method (v2).
35
+ */
36
+ export declare function isKeyringRpcV2Method(method: string): method is KeyringRpcV2Method;
37
+ export declare const GetAccountsV2RequestStruct: import("@metamask/superstruct").Struct<{
38
+ method: "keyring_getAccounts";
39
+ id: string | number | null;
40
+ jsonrpc: "2.0";
41
+ }, {
42
+ method: import("@metamask/superstruct").Struct<"keyring_getAccounts", "keyring_getAccounts">;
43
+ jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
44
+ id: import("@metamask/superstruct").Struct<string | number | null, null>;
45
+ }>;
46
+ export type GetAccountsV2Request = Infer<typeof GetAccountsV2RequestStruct>;
47
+ export declare const GetAccountsV2ResponseStruct: import("@metamask/superstruct").Struct<{
48
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
49
+ id: string;
50
+ options: Record<string, import("@metamask/utils").Json> & {
51
+ entropy?: {
52
+ type: "mnemonic";
53
+ id: string;
54
+ derivationPath: string;
55
+ groupIndex: number;
56
+ } | {
57
+ type: "private-key";
58
+ } | {
59
+ type: "custom";
60
+ };
61
+ exportable?: boolean;
62
+ };
63
+ address: string;
64
+ scopes: `${string}:${string}`[];
65
+ methods: string[];
66
+ }[], import("@metamask/superstruct").Struct<{
67
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
68
+ id: string;
69
+ options: Record<string, import("@metamask/utils").Json> & {
70
+ entropy?: {
71
+ type: "mnemonic";
72
+ id: string;
73
+ derivationPath: string;
74
+ groupIndex: number;
75
+ } | {
76
+ type: "private-key";
77
+ } | {
78
+ type: "custom";
79
+ };
80
+ exportable?: boolean;
81
+ };
82
+ address: string;
83
+ scopes: `${string}:${string}`[];
84
+ methods: string[];
85
+ }, {
86
+ id: import("@metamask/superstruct").Struct<string, null>;
87
+ type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
88
+ "eip155:eoa": "eip155:eoa";
89
+ "eip155:erc4337": "eip155:erc4337";
90
+ "bip122:p2pkh": "bip122:p2pkh";
91
+ "bip122:p2sh": "bip122:p2sh";
92
+ "bip122:p2wpkh": "bip122:p2wpkh";
93
+ "bip122:p2tr": "bip122:p2tr";
94
+ "solana:data-account": "solana:data-account";
95
+ "tron:eoa": "tron:eoa";
96
+ "any:account": "any:account";
97
+ }>;
98
+ address: import("@metamask/superstruct").Struct<string, null>;
99
+ scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
100
+ options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
101
+ entropy?: {
102
+ type: "mnemonic";
103
+ id: string;
104
+ derivationPath: string;
105
+ groupIndex: number;
106
+ } | {
107
+ type: "private-key";
108
+ } | {
109
+ type: "custom";
110
+ };
111
+ exportable?: boolean;
112
+ }, null>;
113
+ methods: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
114
+ }>>;
115
+ export type GetAccountsV2Response = Infer<typeof GetAccountsV2ResponseStruct>;
116
+ export declare const GetAccountV2RequestStruct: import("@metamask/superstruct").Struct<{
117
+ method: "keyring_getAccount";
118
+ id: string | number | null;
119
+ jsonrpc: "2.0";
120
+ params: {
121
+ id: string;
122
+ };
123
+ }, {
124
+ method: import("@metamask/superstruct").Struct<"keyring_getAccount", "keyring_getAccount">;
125
+ params: import("@metamask/superstruct").Struct<{
126
+ id: string;
127
+ }, {
128
+ id: import("@metamask/superstruct").Struct<string, null>;
129
+ }>;
130
+ jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
131
+ id: import("@metamask/superstruct").Struct<string | number | null, null>;
132
+ }>;
133
+ export type GetAccountV2Request = Infer<typeof GetAccountV2RequestStruct>;
134
+ export declare const GetAccountV2ResponseStruct: import("@metamask/superstruct").Struct<{
135
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
136
+ id: string;
137
+ options: Record<string, import("@metamask/utils").Json> & {
138
+ entropy?: {
139
+ type: "mnemonic";
140
+ id: string;
141
+ derivationPath: string;
142
+ groupIndex: number;
143
+ } | {
144
+ type: "private-key";
145
+ } | {
146
+ type: "custom";
147
+ };
148
+ exportable?: boolean;
149
+ };
150
+ address: string;
151
+ scopes: `${string}:${string}`[];
152
+ methods: string[];
153
+ }, {
154
+ id: import("@metamask/superstruct").Struct<string, null>;
155
+ type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
156
+ "eip155:eoa": "eip155:eoa";
157
+ "eip155:erc4337": "eip155:erc4337";
158
+ "bip122:p2pkh": "bip122:p2pkh";
159
+ "bip122:p2sh": "bip122:p2sh";
160
+ "bip122:p2wpkh": "bip122:p2wpkh";
161
+ "bip122:p2tr": "bip122:p2tr";
162
+ "solana:data-account": "solana:data-account";
163
+ "tron:eoa": "tron:eoa";
164
+ "any:account": "any:account";
165
+ }>;
166
+ address: import("@metamask/superstruct").Struct<string, null>;
167
+ scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
168
+ options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
169
+ entropy?: {
170
+ type: "mnemonic";
171
+ id: string;
172
+ derivationPath: string;
173
+ groupIndex: number;
174
+ } | {
175
+ type: "private-key";
176
+ } | {
177
+ type: "custom";
178
+ };
179
+ exportable?: boolean;
180
+ }, null>;
181
+ methods: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
182
+ }>;
183
+ export type GetAccountV2Response = Infer<typeof GetAccountV2ResponseStruct>;
184
+ export declare const CreateAccountsV2RequestStruct: import("@metamask/superstruct").Struct<{
185
+ method: "keyring_createAccounts";
186
+ id: string | number | null;
187
+ jsonrpc: "2.0";
188
+ params: {
189
+ type: "bip44:derive-path";
190
+ derivationPath: `m/${string}`;
191
+ entropySource: string;
192
+ } | {
193
+ type: "bip44:derive-index";
194
+ groupIndex: number;
195
+ entropySource: string;
196
+ } | {
197
+ type: "bip44:discover";
198
+ groupIndex: number;
199
+ entropySource: string;
200
+ } | {
201
+ type: "bip44:derive-index-range";
202
+ range: {
203
+ from: number;
204
+ to: number;
205
+ };
206
+ entropySource: string;
207
+ } | {
208
+ type: "custom";
209
+ } | {
210
+ type: "private-key:import";
211
+ encoding: "hexadecimal" | "base58";
212
+ privateKey: string;
213
+ accountType?: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
214
+ };
215
+ }, {
216
+ method: import("@metamask/superstruct").Struct<"keyring_createAccounts", "keyring_createAccounts">;
217
+ params: import("@metamask/superstruct").Struct<{
218
+ type: "bip44:derive-path";
219
+ derivationPath: `m/${string}`;
220
+ entropySource: string;
221
+ } | {
222
+ type: "bip44:derive-index";
223
+ groupIndex: number;
224
+ entropySource: string;
225
+ } | {
226
+ type: "bip44:discover";
227
+ groupIndex: number;
228
+ entropySource: string;
229
+ } | {
230
+ type: "bip44:derive-index-range";
231
+ range: {
232
+ from: number;
233
+ to: number;
234
+ };
235
+ entropySource: string;
236
+ } | {
237
+ type: "custom";
238
+ } | {
239
+ type: "private-key:import";
240
+ encoding: "hexadecimal" | "base58";
241
+ privateKey: string;
242
+ accountType?: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
243
+ }, null>;
244
+ jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
245
+ id: import("@metamask/superstruct").Struct<string | number | null, null>;
246
+ }>;
247
+ export type CreateAccountsV2Request = Infer<typeof CreateAccountsV2RequestStruct>;
248
+ export declare const CreateAccountsV2ResponseStruct: import("@metamask/superstruct").Struct<{
249
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
250
+ id: string;
251
+ options: Record<string, import("@metamask/utils").Json> & {
252
+ entropy?: {
253
+ type: "mnemonic";
254
+ id: string;
255
+ derivationPath: string;
256
+ groupIndex: number;
257
+ } | {
258
+ type: "private-key";
259
+ } | {
260
+ type: "custom";
261
+ };
262
+ exportable?: boolean;
263
+ };
264
+ address: string;
265
+ scopes: `${string}:${string}`[];
266
+ methods: string[];
267
+ }[], import("@metamask/superstruct").Struct<{
268
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account";
269
+ id: string;
270
+ options: Record<string, import("@metamask/utils").Json> & {
271
+ entropy?: {
272
+ type: "mnemonic";
273
+ id: string;
274
+ derivationPath: string;
275
+ groupIndex: number;
276
+ } | {
277
+ type: "private-key";
278
+ } | {
279
+ type: "custom";
280
+ };
281
+ exportable?: boolean;
282
+ };
283
+ address: string;
284
+ scopes: `${string}:${string}`[];
285
+ methods: string[];
286
+ }, {
287
+ id: import("@metamask/superstruct").Struct<string, null>;
288
+ type: import("@metamask/superstruct").Struct<"eip155:eoa" | "eip155:erc4337" | "bip122:p2pkh" | "bip122:p2sh" | "bip122:p2wpkh" | "bip122:p2tr" | "solana:data-account" | "tron:eoa" | "any:account", {
289
+ "eip155:eoa": "eip155:eoa";
290
+ "eip155:erc4337": "eip155:erc4337";
291
+ "bip122:p2pkh": "bip122:p2pkh";
292
+ "bip122:p2sh": "bip122:p2sh";
293
+ "bip122:p2wpkh": "bip122:p2wpkh";
294
+ "bip122:p2tr": "bip122:p2tr";
295
+ "solana:data-account": "solana:data-account";
296
+ "tron:eoa": "tron:eoa";
297
+ "any:account": "any:account";
298
+ }>;
299
+ address: import("@metamask/superstruct").Struct<string, null>;
300
+ scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
301
+ options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> & {
302
+ entropy?: {
303
+ type: "mnemonic";
304
+ id: string;
305
+ derivationPath: string;
306
+ groupIndex: number;
307
+ } | {
308
+ type: "private-key";
309
+ } | {
310
+ type: "custom";
311
+ };
312
+ exportable?: boolean;
313
+ }, null>;
314
+ methods: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
315
+ }>>;
316
+ export type CreateAccountsV2Response = Infer<typeof CreateAccountsV2ResponseStruct>;
317
+ export declare const DeleteAccountV2RequestStruct: import("@metamask/superstruct").Struct<{
318
+ method: "keyring_deleteAccount";
319
+ id: string | number | null;
320
+ jsonrpc: "2.0";
321
+ params: {
322
+ id: string;
323
+ };
324
+ }, {
325
+ method: import("@metamask/superstruct").Struct<"keyring_deleteAccount", "keyring_deleteAccount">;
326
+ params: import("@metamask/superstruct").Struct<{
327
+ id: string;
328
+ }, {
329
+ id: import("@metamask/superstruct").Struct<string, null>;
330
+ }>;
331
+ jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
332
+ id: import("@metamask/superstruct").Struct<string | number | null, null>;
333
+ }>;
334
+ export type DeleteAccountV2Request = Infer<typeof DeleteAccountV2RequestStruct>;
335
+ export declare const DeleteAccountV2ResponseStruct: import("@metamask/superstruct").Struct<null, null>;
336
+ export type DeleteAccountV2Response = Infer<typeof DeleteAccountV2ResponseStruct>;
337
+ export declare const ExportAccountV2RequestStruct: import("@metamask/superstruct").Struct<{
338
+ method: "keyring_exportAccount";
339
+ id: string | number | null;
340
+ jsonrpc: "2.0";
341
+ params: {
342
+ id: string;
343
+ options?: {
344
+ type: "private-key";
345
+ encoding: "hexadecimal" | "base58";
346
+ };
347
+ };
348
+ }, {
349
+ method: import("@metamask/superstruct").Struct<"keyring_exportAccount", "keyring_exportAccount">;
350
+ params: import("@metamask/superstruct").Struct<{
351
+ id: string;
352
+ options?: {
353
+ type: "private-key";
354
+ encoding: "hexadecimal" | "base58";
355
+ };
356
+ }, {
357
+ id: import("@metamask/superstruct").Struct<string, null>;
358
+ options: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
359
+ type: "private-key";
360
+ encoding: "hexadecimal" | "base58";
361
+ }, {
362
+ type: import("@metamask/superstruct").Struct<"private-key", "private-key">;
363
+ encoding: import("@metamask/superstruct").Struct<"hexadecimal" | "base58", {
364
+ hexadecimal: "hexadecimal";
365
+ base58: "base58";
366
+ }>;
367
+ }>;
368
+ }>;
369
+ jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
370
+ id: import("@metamask/superstruct").Struct<string | number | null, null>;
371
+ }>;
372
+ export type ExportAccountV2Request = Infer<typeof ExportAccountV2RequestStruct>;
373
+ export declare const ExportAccountV2ResponseStruct: import("@metamask/superstruct").Struct<{
374
+ type: "private-key";
375
+ encoding: "hexadecimal" | "base58";
376
+ privateKey: string;
377
+ }, {
378
+ type: import("@metamask/superstruct").Struct<"private-key", "private-key">;
379
+ privateKey: import("@metamask/superstruct").Struct<string, null>;
380
+ encoding: import("@metamask/superstruct").Struct<"hexadecimal" | "base58", {
381
+ hexadecimal: "hexadecimal";
382
+ base58: "base58";
383
+ }>;
384
+ }>;
385
+ export type ExportAccountV2Response = Infer<typeof ExportAccountV2ResponseStruct>;
386
+ export declare const SubmitRequestV2RequestStruct: import("@metamask/superstruct").Struct<{
387
+ method: "keyring_submitRequest";
388
+ id: string | number | null;
389
+ jsonrpc: "2.0";
390
+ params: {
391
+ id: string;
392
+ origin: string;
393
+ request: {
394
+ method: string;
395
+ params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[];
396
+ };
397
+ scope: string;
398
+ account: string;
399
+ };
400
+ }, {
401
+ method: import("@metamask/superstruct").Struct<"keyring_submitRequest", "keyring_submitRequest">;
402
+ params: import("@metamask/superstruct").Struct<{
403
+ id: string;
404
+ origin: string;
405
+ request: {
406
+ method: string;
407
+ params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[];
408
+ };
409
+ scope: string;
410
+ account: string;
411
+ }, {
412
+ id: import("@metamask/superstruct").Struct<string, null>;
413
+ scope: import("@metamask/superstruct").Struct<string, null>;
414
+ account: import("@metamask/superstruct").Struct<string, null>;
415
+ origin: import("@metamask/superstruct").Struct<string, null>;
416
+ request: import("@metamask/superstruct").Struct<{
417
+ method: string;
418
+ params?: Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[];
419
+ }, {
420
+ method: import("@metamask/superstruct").Struct<string, null>;
421
+ params: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json> | import("@metamask/utils").Json[] | import("@metamask/keyring-utils").ExactOptionalTag, null>;
422
+ }>;
423
+ }>;
424
+ jsonrpc: import("@metamask/superstruct").Struct<"2.0", "2.0">;
425
+ id: import("@metamask/superstruct").Struct<string | number | null, null>;
426
+ }>;
427
+ export type SubmitRequestV2Request = Infer<typeof SubmitRequestV2RequestStruct>;
428
+ export declare const SubmitRequestV2ResponseStruct: import("@metamask/superstruct").Struct<import("@metamask/utils").Json, unknown>;
429
+ export type SubmitRequestV2Response = Infer<typeof SubmitRequestV2ResponseStruct>;
430
+ /**
431
+ * Keyring RPC requests.
432
+ */
433
+ export type KeyringRpcV2Requests = GetAccountsV2Request | GetAccountV2Request | CreateAccountsV2Request | DeleteAccountV2Request | ExportAccountV2Request | SubmitRequestV2Request;
434
+ /**
435
+ * Extract the proper request type for a given `KeyringRpcV2Method`.
436
+ */
437
+ export type KeyringRpcV2Request<RpcMethod extends KeyringRpcV2Method> = Extract<KeyringRpcV2Requests, {
438
+ method: `${RpcMethod}`;
439
+ }>;
440
+ //# sourceMappingURL=keyring-rpc.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-rpc.d.mts","sourceRoot":"","sources":["../../../src/api/v2/keyring-rpc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AASnD,OAAO,KAAK,EAAE,SAA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BAAoB,GACpB,mBAAmB,GACnB,uBAAuB,GACvB,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,SAAS,SAAS,kBAAkB,IAAI,OAAO,CAC7E,oBAAoB,EACpB;IAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAA;CAAE,CAC3B,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { object, exactOptional, UuidStruct } from "@metamask/keyring-utils";
2
+ import { array, literal, number, string, union } from "@metamask/superstruct";
3
+ import { JsonStruct } from "@metamask/utils";
4
+ import { CreateAccountOptionsStruct } from "./create-account/index.mjs";
5
+ import { ExportAccountOptionsStruct, PrivateKeyExportedAccountStruct } from "./export-account/index.mjs";
6
+ import { KeyringAccountStruct } from "../account.mjs";
7
+ import { KeyringRequestStruct } from "../request.mjs";
8
+ /**
9
+ * Keyring RPC methods used by the API.
10
+ */
11
+ export const KeyringRpcV2Method = {
12
+ GetAccounts: 'keyring_getAccounts',
13
+ CreateAccounts: 'keyring_createAccounts',
14
+ // Inherited from v1 (but method signatures may differ...):
15
+ // NOTE: We use literals here to avoid circular dependencies.
16
+ GetAccount: 'keyring_getAccount',
17
+ DeleteAccount: 'keyring_deleteAccount',
18
+ ExportAccount: 'keyring_exportAccount',
19
+ SubmitRequest: 'keyring_submitRequest',
20
+ };
21
+ /**
22
+ * Check if a method is a keyring RPC method (v2).
23
+ *
24
+ * @param method - Method to check.
25
+ * @returns Whether the method is a keyring RPC method (v2).
26
+ */
27
+ export function isKeyringRpcV2Method(method) {
28
+ return Object.values(KeyringRpcV2Method).includes(method);
29
+ }
30
+ // ----------------------------------------------------------------------------
31
+ const CommonHeader = {
32
+ jsonrpc: literal('2.0'),
33
+ id: union([string(), number(), literal(null)]),
34
+ };
35
+ // ----------------------------------------------------------------------------
36
+ // Get accounts
37
+ export const GetAccountsV2RequestStruct = object({
38
+ ...CommonHeader,
39
+ method: literal(`${KeyringRpcV2Method.GetAccounts}`),
40
+ });
41
+ export const GetAccountsV2ResponseStruct = array(KeyringAccountStruct);
42
+ // ----------------------------------------------------------------------------
43
+ // Get account
44
+ export const GetAccountV2RequestStruct = object({
45
+ ...CommonHeader,
46
+ method: literal(`${KeyringRpcV2Method.GetAccount}`),
47
+ params: object({
48
+ id: UuidStruct,
49
+ }),
50
+ });
51
+ export const GetAccountV2ResponseStruct = KeyringAccountStruct;
52
+ // ----------------------------------------------------------------------------
53
+ // Create accounts
54
+ export const CreateAccountsV2RequestStruct = object({
55
+ ...CommonHeader,
56
+ method: literal(`${KeyringRpcV2Method.CreateAccounts}`),
57
+ params: CreateAccountOptionsStruct,
58
+ });
59
+ export const CreateAccountsV2ResponseStruct = array(KeyringAccountStruct);
60
+ // ----------------------------------------------------------------------------
61
+ // Delete account
62
+ export const DeleteAccountV2RequestStruct = object({
63
+ ...CommonHeader,
64
+ method: literal(`${KeyringRpcV2Method.DeleteAccount}`),
65
+ params: object({
66
+ id: UuidStruct,
67
+ }),
68
+ });
69
+ export const DeleteAccountV2ResponseStruct = literal(null);
70
+ // ----------------------------------------------------------------------------
71
+ // Export account
72
+ export const ExportAccountV2RequestStruct = object({
73
+ ...CommonHeader,
74
+ method: literal(`${KeyringRpcV2Method.ExportAccount}`),
75
+ params: object({
76
+ id: UuidStruct,
77
+ options: exactOptional(ExportAccountOptionsStruct),
78
+ }),
79
+ });
80
+ export const ExportAccountV2ResponseStruct = PrivateKeyExportedAccountStruct;
81
+ // ----------------------------------------------------------------------------
82
+ // Submit request
83
+ export const SubmitRequestV2RequestStruct = object({
84
+ ...CommonHeader,
85
+ method: literal(`${KeyringRpcV2Method.SubmitRequest}`),
86
+ params: KeyringRequestStruct,
87
+ });
88
+ export const SubmitRequestV2ResponseStruct = JsonStruct;
89
+ //# sourceMappingURL=keyring-rpc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring-rpc.mjs","sourceRoot":"","sources":["../../../src/api/v2/keyring-rpc.ts"],"names":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M,6BAA6B,GAAG,+BAA+B,CAAC;AAM7E,+EAA+E;AAC/E,iBAAiB;AAEjB,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;IACjD,GAAG,YAAY;IACf,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC,aAAa,EAAE,CAAC;IACtD,MAAM,EAAE,oBAAoB;CAC7B,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC","sourcesContent":["import { object, exactOptional, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, literal, number, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { CreateAccountOptionsStruct } from './create-account';\nimport {\n ExportAccountOptionsStruct,\n PrivateKeyExportedAccountStruct,\n} from './export-account';\nimport type { KeyringV2 } from './keyring';\nimport { KeyringAccountStruct } from '../account';\nimport { KeyringRequestStruct } from '../request';\n\n/**\n * Keyring interface for keyring methods that can be invoked through\n * RPC calls.\n */\nexport type KeyringRpcV2 = {\n getAccount: KeyringV2['getAccount'];\n getAccounts: KeyringV2['getAccounts'];\n createAccounts: KeyringV2['createAccounts'];\n deleteAccount: KeyringV2['deleteAccount'];\n submitRequest: KeyringV2['submitRequest'];\n exportAccount?: KeyringV2['exportAccount'];\n};\n\n/**\n * Keyring RPC methods used by the API.\n */\nexport const KeyringRpcV2Method = {\n GetAccounts: 'keyring_getAccounts',\n CreateAccounts: 'keyring_createAccounts',\n // Inherited from v1 (but method signatures may differ...):\n // NOTE: We use literals here to avoid circular dependencies.\n GetAccount: 'keyring_getAccount',\n DeleteAccount: 'keyring_deleteAccount',\n ExportAccount: 'keyring_exportAccount',\n SubmitRequest: 'keyring_submitRequest',\n} as const;\n\n/**\n * Keyring RPC methods used by the API.\n */\nexport type KeyringRpcV2Method =\n (typeof KeyringRpcV2Method)[keyof typeof KeyringRpcV2Method];\n\n/**\n * Check if a method is a keyring RPC method (v2).\n *\n * @param method - Method to check.\n * @returns Whether the method is a keyring RPC method (v2).\n */\nexport function isKeyringRpcV2Method(\n method: string,\n): method is KeyringRpcV2Method {\n return Object.values(KeyringRpcV2Method).includes(\n method as KeyringRpcV2Method,\n );\n}\n\n// ----------------------------------------------------------------------------\n\nconst CommonHeader = {\n jsonrpc: literal('2.0'),\n id: union([string(), number(), literal(null)]),\n};\n\n// ----------------------------------------------------------------------------\n// Get accounts\n\nexport const GetAccountsV2RequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcV2Method.GetAccounts}`),\n});\n\nexport type GetAccountsV2Request = Infer<typeof GetAccountsV2RequestStruct>;\n\nexport const GetAccountsV2ResponseStruct = array(KeyringAccountStruct);\n\nexport type GetAccountsV2Response = Infer<typeof GetAccountsV2ResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Get account\n\nexport const GetAccountV2RequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcV2Method.GetAccount}`),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type GetAccountV2Request = Infer<typeof GetAccountV2RequestStruct>;\n\nexport const GetAccountV2ResponseStruct = KeyringAccountStruct;\n\nexport type GetAccountV2Response = Infer<typeof GetAccountV2ResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Create accounts\n\nexport const CreateAccountsV2RequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcV2Method.CreateAccounts}`),\n params: CreateAccountOptionsStruct,\n});\n\nexport type CreateAccountsV2Request = Infer<\n typeof CreateAccountsV2RequestStruct\n>;\n\nexport const CreateAccountsV2ResponseStruct = array(KeyringAccountStruct);\n\nexport type CreateAccountsV2Response = Infer<\n typeof CreateAccountsV2ResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Delete account\n\nexport const DeleteAccountV2RequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcV2Method.DeleteAccount}`),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type DeleteAccountV2Request = Infer<typeof DeleteAccountV2RequestStruct>;\n\nexport const DeleteAccountV2ResponseStruct = literal(null);\n\nexport type DeleteAccountV2Response = Infer<\n typeof DeleteAccountV2ResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Export account\n\nexport const ExportAccountV2RequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcV2Method.ExportAccount}`),\n params: object({\n id: UuidStruct,\n options: exactOptional(ExportAccountOptionsStruct),\n }),\n});\n\nexport type ExportAccountV2Request = Infer<typeof ExportAccountV2RequestStruct>;\n\nexport const ExportAccountV2ResponseStruct = PrivateKeyExportedAccountStruct;\n\nexport type ExportAccountV2Response = Infer<\n typeof ExportAccountV2ResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Submit request\n\nexport const SubmitRequestV2RequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcV2Method.SubmitRequest}`),\n params: KeyringRequestStruct,\n});\n\nexport type SubmitRequestV2Request = Infer<typeof SubmitRequestV2RequestStruct>;\n\nexport const SubmitRequestV2ResponseStruct = JsonStruct;\n\nexport type SubmitRequestV2Response = Infer<\n typeof SubmitRequestV2ResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n\n/**\n * Keyring RPC requests.\n */\nexport type KeyringRpcV2Requests =\n | GetAccountsV2Request\n | GetAccountV2Request\n | CreateAccountsV2Request\n | DeleteAccountV2Request\n | ExportAccountV2Request\n | SubmitRequestV2Request;\n\n/**\n * Extract the proper request type for a given `KeyringRpcV2Method`.\n */\nexport type KeyringRpcV2Request<RpcMethod extends KeyringRpcV2Method> = Extract<\n KeyringRpcV2Requests,\n { method: `${RpcMethod}` }\n>;\n"]}
package/dist/rpc.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.cjs","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":";;;AAuEA,gDAEC;AAzED,2DAIiC;AAEjC,uDAQ+B;AAC/B,2CAA6C;AAE7C,yCAce;AAEf;;GAEG;AACH,IAAY,g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G,2BAAqB,CAAC;AAIjE,+EAA+E;AAC/E,kBAAkB;AAEL,QAAA,2BAA2B,GAAG,IAAA,sBAAM,EAAC;IAChD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,wBAAwB,CAAC;IACzC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;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,sBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import {\n object,\n UuidStruct,\n JsonRpcRequestStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n literal,\n nullable,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n CaipChainIdStruct,\n BalanceStruct,\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n TransactionsPageStruct,\n PaginationStruct,\n CaipAccountIdStruct,\n DiscoveredAccountStruct,\n CreateAccountOptionsStruct,\n} from './api';\n\n/**\n * Keyring RPC methods used by the API.\n */\nexport enum KeyringRpcMethod {\n // Account management\n CreateAccount = 'keyring_createAccount',\n CreateAccounts = 'keyring_createAccounts',\n DeleteAccount = 'keyring_deleteAccount',\n DiscoverAccounts = 'keyring_discoverAccounts',\n ExportAccount = 'keyring_exportAccount',\n FilterAccountChains = 'keyring_filterAccountChains',\n GetAccount = 'keyring_getAccount',\n ListAccounts = 'keyring_listAccounts',\n UpdateAccount = 'keyring_updateAccount',\n\n // Signing request management\n ApproveRequest = 'keyring_approveRequest',\n GetRequest = 'keyring_getRequest',\n ListRequests = 'keyring_listRequests',\n RejectRequest = 'keyring_rejectRequest',\n SubmitRequest = 'keyring_submitRequest',\n\n // Account assets and transactions\n GetAccountBalances = 'keyring_getAccountBalances',\n ListAccountAssets = 'keyring_listAccountAssets',\n ListAccountTransactions = 'keyring_listAccountTransactions',\n SetSelectedAccounts = 'keyring_setSelectedAccounts',\n\n // Dapp interaction\n ResolveAccountAddress = 'keyring_resolveAccountAddress',\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\n// ----------------------------------------------------------------------------\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// Create accounts\n\nexport const CreateAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccounts'),\n params: object({\n options: CreateAccountOptionsStruct,\n }),\n});\n\nexport type CreateAccountsRequest = Infer<typeof CreateAccountsRequestStruct>;\n\nexport const CreateAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type CreateAccountsResponse = Infer<typeof CreateAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Set selected accounts\n\nexport const SetSelectedAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_setSelectedAccounts'),\n params: object({\n accounts: array(string()),\n }),\n});\n\nexport type SetSelectedAccountsRequest = Infer<\n typeof SetSelectedAccountsRequestStruct\n>;\n\nexport const SetSelectedAccountsResponseStruct = literal(null);\n\nexport type SetSelectedAccountsResponse = Infer<\n typeof SetSelectedAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Discover accounts\n\nexport const DiscoverAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_discoverAccounts'),\n params: object({\n scopes: array(CaipChainIdStruct),\n entropySource: string(),\n groupIndex: number(),\n }),\n});\n\nexport type DiscoverAccountsRequest = Infer<\n typeof DiscoverAccountsRequestStruct\n>;\n\nexport const DiscoverAccountsResponseStruct = array(DiscoveredAccountStruct);\n\nexport type DiscoverAccountsResponse = Infer<\n typeof DiscoverAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account transactions\n\nexport const ListAccountTransactionsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountTransactions'),\n params: object({\n id: UuidStruct,\n pagination: PaginationStruct,\n }),\n});\n\nexport type ListAccountTransactionsRequest = Infer<\n typeof ListAccountTransactionsRequestStruct\n>;\n\nexport const ListAccountTransactionsResponseStruct = TransactionsPageStruct;\n\nexport type ListAccountTransactionsResponse = Infer<\n typeof ListAccountTransactionsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account assets\n\nexport const ListAccountAssetsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountAssets'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ListAccountAssetsRequest = Infer<\n typeof ListAccountAssetsRequestStruct\n>;\n\nexport const ListAccountAssetsResponseStruct = array(CaipAssetTypeOrIdStruct);\n\nexport type ListAccountAssetsResponse = Infer<\n typeof ListAccountAssetsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account balances\n\nexport const GetAccountBalancesRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcMethod.GetAccountBalances}`),\n params: object({\n id: UuidStruct,\n assets: array(CaipAssetTypeStruct),\n }),\n});\n\nexport type GetAccountBalancesRequest = Infer<\n typeof GetAccountBalancesRequestStruct\n>;\n\nexport const GetAccountBalancesResponseStruct = record(\n CaipAssetTypeStruct,\n BalanceStruct,\n);\n\nexport type GetAccountBalancesResponse = Infer<\n typeof GetAccountBalancesResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Resolve account address\n\nexport const ResolveAccountAddressRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_resolveAccountAddress'),\n params: object({\n scope: CaipChainIdStruct,\n request: JsonRpcRequestStruct,\n }),\n});\n\nexport type ResolveAccountAddressRequest = Infer<\n typeof ResolveAccountAddressRequestStruct\n>;\n\nexport const ResolveAccountAddressResponseStruct = nullable(\n object({\n address: CaipAccountIdStruct,\n }),\n);\n\nexport type ResolveAccountAddressResponse = Infer<\n typeof ResolveAccountAddressResponseStruct\n>;\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"]}
1
+ {"version":3,"file":"rpc.cjs","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":";;;AAuEA,gDAEC;AAzED,2DAIiC;AAEjC,uDAQ+B;AAC/B,2CAA6C;AAE7C,yCAce;AAEf;;GAEG;AACH,IAAY,gBA2BX;AA3BD,WAAY,gBAAgB;IAC1B,qBAAqB;IACrB,2DAAuC,CAAA;IAC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,GAAG,IAAA,sBAAM,EAAC;IAChD,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,wBAAwB,CAAC;IACzC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;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,sBAAM,EAAC;IAC/C,GAAG,YAAY;IACf,MAAM,EAAE,IAAA,qBAAO,EAAC,uBAAuB,CAAC;IACxC,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb,EAAE,EAAE,0BAAU;KACf,CAAC;CACH,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import {\n object,\n UuidStruct,\n JsonRpcRequestStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n array,\n literal,\n nullable,\n number,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n CaipChainIdStruct,\n BalanceStruct,\n KeyringAccountDataStruct,\n KeyringAccountStruct,\n KeyringRequestStruct,\n KeyringResponseStruct,\n TransactionsPageStruct,\n PaginationStruct,\n CaipAccountIdStruct,\n DiscoveredAccountStruct,\n CreateAccountOptionsStruct,\n} from './api';\n\n/**\n * Keyring RPC methods used by the API.\n */\nexport enum KeyringRpcMethod {\n // Account management\n CreateAccount = 'keyring_createAccount',\n CreateAccounts = 'keyring_createAccounts',\n DeleteAccount = 'keyring_deleteAccount',\n DiscoverAccounts = 'keyring_discoverAccounts',\n ExportAccount = 'keyring_exportAccount',\n FilterAccountChains = 'keyring_filterAccountChains',\n GetAccount = 'keyring_getAccount',\n ListAccounts = 'keyring_listAccounts',\n UpdateAccount = 'keyring_updateAccount',\n\n // Signing request management\n ApproveRequest = 'keyring_approveRequest',\n GetRequest = 'keyring_getRequest',\n ListRequests = 'keyring_listRequests',\n RejectRequest = 'keyring_rejectRequest',\n SubmitRequest = 'keyring_submitRequest',\n\n // Account assets and transactions\n GetAccountBalances = 'keyring_getAccountBalances',\n ListAccountAssets = 'keyring_listAccountAssets',\n ListAccountTransactions = 'keyring_listAccountTransactions',\n SetSelectedAccounts = 'keyring_setSelectedAccounts',\n\n // Dapp interaction\n ResolveAccountAddress = 'keyring_resolveAccountAddress',\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): method is KeyringRpcMethod {\n return Object.values(KeyringRpcMethod).includes(method as KeyringRpcMethod);\n}\n\n// ----------------------------------------------------------------------------\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// Create accounts\n\nexport const CreateAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_createAccounts'),\n params: object({\n options: CreateAccountOptionsStruct,\n }),\n});\n\nexport type CreateAccountsRequest = Infer<typeof CreateAccountsRequestStruct>;\n\nexport const CreateAccountsResponseStruct = array(KeyringAccountStruct);\n\nexport type CreateAccountsResponse = Infer<typeof CreateAccountsResponseStruct>;\n\n// ----------------------------------------------------------------------------\n// Set selected accounts\n\nexport const SetSelectedAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_setSelectedAccounts'),\n params: object({\n accounts: array(string()),\n }),\n});\n\nexport type SetSelectedAccountsRequest = Infer<\n typeof SetSelectedAccountsRequestStruct\n>;\n\nexport const SetSelectedAccountsResponseStruct = literal(null);\n\nexport type SetSelectedAccountsResponse = Infer<\n typeof SetSelectedAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Discover accounts\n\nexport const DiscoverAccountsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_discoverAccounts'),\n params: object({\n scopes: array(CaipChainIdStruct),\n entropySource: string(),\n groupIndex: number(),\n }),\n});\n\nexport type DiscoverAccountsRequest = Infer<\n typeof DiscoverAccountsRequestStruct\n>;\n\nexport const DiscoverAccountsResponseStruct = array(DiscoveredAccountStruct);\n\nexport type DiscoverAccountsResponse = Infer<\n typeof DiscoverAccountsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account transactions\n\nexport const ListAccountTransactionsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountTransactions'),\n params: object({\n id: UuidStruct,\n pagination: PaginationStruct,\n }),\n});\n\nexport type ListAccountTransactionsRequest = Infer<\n typeof ListAccountTransactionsRequestStruct\n>;\n\nexport const ListAccountTransactionsResponseStruct = TransactionsPageStruct;\n\nexport type ListAccountTransactionsResponse = Infer<\n typeof ListAccountTransactionsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// List account assets\n\nexport const ListAccountAssetsRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_listAccountAssets'),\n params: object({\n id: UuidStruct,\n }),\n});\n\nexport type ListAccountAssetsRequest = Infer<\n typeof ListAccountAssetsRequestStruct\n>;\n\nexport const ListAccountAssetsResponseStruct = array(CaipAssetTypeOrIdStruct);\n\nexport type ListAccountAssetsResponse = Infer<\n typeof ListAccountAssetsResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Get account balances\n\nexport const GetAccountBalancesRequestStruct = object({\n ...CommonHeader,\n method: literal(`${KeyringRpcMethod.GetAccountBalances}`),\n params: object({\n id: UuidStruct,\n assets: array(CaipAssetTypeStruct),\n }),\n});\n\nexport type GetAccountBalancesRequest = Infer<\n typeof GetAccountBalancesRequestStruct\n>;\n\nexport const GetAccountBalancesResponseStruct = record(\n CaipAssetTypeStruct,\n BalanceStruct,\n);\n\nexport type GetAccountBalancesResponse = Infer<\n typeof GetAccountBalancesResponseStruct\n>;\n\n// ----------------------------------------------------------------------------\n// Resolve account address\n\nexport const ResolveAccountAddressRequestStruct = object({\n ...CommonHeader,\n method: literal('keyring_resolveAccountAddress'),\n params: object({\n scope: CaipChainIdStruct,\n request: JsonRpcRequestStruct,\n }),\n});\n\nexport type ResolveAccountAddressRequest = Infer<\n typeof ResolveAccountAddressRequestStruct\n>;\n\nexport const ResolveAccountAddressResponseStruct = nullable(\n object({\n address: CaipAccountIdStruct,\n }),\n);\n\nexport type ResolveAccountAddressResponse = Infer<\n typeof ResolveAccountAddressResponseStruct\n>;\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"]}