@metamask-previews/keyring-api 13.0.0-a527719 → 14.0.0-7ba2de1

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 (52) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/api/account.cjs +2 -2
  3. package/dist/api/account.cjs.map +1 -1
  4. package/dist/api/account.d.cts +1 -1
  5. package/dist/api/account.d.mts +1 -1
  6. package/dist/api/account.mjs +3 -3
  7. package/dist/api/account.mjs.map +1 -1
  8. package/dist/api/asset.cjs +15 -9
  9. package/dist/api/asset.cjs.map +1 -1
  10. package/dist/api/asset.d.cts +25 -9
  11. package/dist/api/asset.d.cts.map +1 -1
  12. package/dist/api/asset.d.mts +25 -9
  13. package/dist/api/asset.d.mts.map +1 -1
  14. package/dist/api/asset.mjs +14 -8
  15. package/dist/api/asset.mjs.map +1 -1
  16. package/dist/api/transaction.d.cts +30 -30
  17. package/dist/api/transaction.d.mts +30 -30
  18. package/dist/btc/types.cjs +5 -0
  19. package/dist/btc/types.cjs.map +1 -1
  20. package/dist/btc/types.d.cts +5 -2
  21. package/dist/btc/types.d.cts.map +1 -1
  22. package/dist/btc/types.d.mts +5 -2
  23. package/dist/btc/types.d.mts.map +1 -1
  24. package/dist/btc/types.mjs +6 -1
  25. package/dist/btc/types.mjs.map +1 -1
  26. package/dist/eth/types.cjs +5 -0
  27. package/dist/eth/types.cjs.map +1 -1
  28. package/dist/eth/types.d.cts +5 -2
  29. package/dist/eth/types.d.cts.map +1 -1
  30. package/dist/eth/types.d.mts +5 -2
  31. package/dist/eth/types.d.mts.map +1 -1
  32. package/dist/eth/types.mjs +5 -0
  33. package/dist/eth/types.mjs.map +1 -1
  34. package/dist/events.cjs +75 -1
  35. package/dist/events.cjs.map +1 -1
  36. package/dist/events.d.cts +240 -1
  37. package/dist/events.d.cts.map +1 -1
  38. package/dist/events.d.mts +240 -1
  39. package/dist/events.d.mts.map +1 -1
  40. package/dist/events.mjs +78 -4
  41. package/dist/events.mjs.map +1 -1
  42. package/dist/rpc.d.cts +18 -18
  43. package/dist/rpc.d.mts +18 -18
  44. package/dist/sol/types.cjs +5 -0
  45. package/dist/sol/types.cjs.map +1 -1
  46. package/dist/sol/types.d.cts +5 -2
  47. package/dist/sol/types.d.cts.map +1 -1
  48. package/dist/sol/types.d.mts +5 -2
  49. package/dist/sol/types.d.mts.map +1 -1
  50. package/dist/sol/types.mjs +6 -1
  51. package/dist/sol/types.mjs.map +1 -1
  52. package/package.json +3 -3
package/dist/events.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Infer } from "@metamask/superstruct";
1
2
  /**
2
3
  * Supported keyring events.
3
4
  */
@@ -6,7 +7,10 @@ export declare enum KeyringEvent {
6
7
  AccountUpdated = "notify:accountUpdated",
7
8
  AccountDeleted = "notify:accountDeleted",
8
9
  RequestApproved = "notify:requestApproved",
9
- RequestRejected = "notify:requestRejected"
10
+ RequestRejected = "notify:requestRejected",
11
+ AccountBalancesUpdated = "notify:accountBalancesUpdated",
12
+ AccountAssetListUpdated = "notify:accountAssetListUpdated",
13
+ AccountTransactionsUpdated = "notify:accountTransactionsUpdated"
10
14
  }
11
15
  export declare const AccountCreatedEventStruct: import("@metamask/superstruct").Struct<{
12
16
  method: "notify:accountCreated";
@@ -177,4 +181,239 @@ export declare const RequestRejectedEventStruct: import("@metamask/superstruct")
177
181
  id: import("@metamask/superstruct").Struct<string, null>;
178
182
  }>;
179
183
  }>;
184
+ export declare const AccountBalancesUpdatedEventStruct: import("@metamask/superstruct").Struct<{
185
+ method: "notify:accountBalancesUpdated";
186
+ params: {
187
+ balances: Record<string, Record<`${string}:${string}/${string}:${string}`, {
188
+ unit: string;
189
+ amount: string;
190
+ }>>;
191
+ };
192
+ }, {
193
+ method: import("@metamask/superstruct").Struct<"notify:accountBalancesUpdated", "notify:accountBalancesUpdated">;
194
+ params: import("@metamask/superstruct").Struct<{
195
+ balances: Record<string, Record<`${string}:${string}/${string}:${string}`, {
196
+ unit: string;
197
+ amount: string;
198
+ }>>;
199
+ }, {
200
+ /**
201
+ * Balances updates of accounts owned by the Snap.
202
+ */
203
+ balances: import("@metamask/superstruct").Struct<Record<string, Record<`${string}:${string}/${string}:${string}`, {
204
+ unit: string;
205
+ amount: string;
206
+ }>>, null>;
207
+ }>;
208
+ }>;
209
+ /**
210
+ * Event emitted when the balances of an account are updated.
211
+ *
212
+ * Only changes are reported.
213
+ *
214
+ * The Snap can choose to emit this event for multiple accounts at once.
215
+ */
216
+ export type AccountBalancesUpdatedEvent = Infer<typeof AccountBalancesUpdatedEventStruct>;
217
+ export type AccountBalancesUpdatedEventPayload = AccountBalancesUpdatedEvent['params'];
218
+ export declare const AccountTransactionsUpdatedEventStruct: import("@metamask/superstruct").Struct<{
219
+ method: "notify:accountTransactionsUpdated";
220
+ params: {
221
+ transactions: Record<string, {
222
+ type: "send" | "receive";
223
+ id: string;
224
+ from: {
225
+ address: string;
226
+ asset: {
227
+ unit: string;
228
+ type: `${string}:${string}/${string}:${string}`;
229
+ amount: string;
230
+ fungible: true;
231
+ } | {
232
+ id: `${string}:${string}/${string}:${string}/${string}`;
233
+ fungible: false;
234
+ } | null;
235
+ }[];
236
+ events: {
237
+ status: "submitted" | "unconfirmed" | "confirmed" | "failed";
238
+ timestamp: number | null;
239
+ }[];
240
+ chain: `${string}:${string}`;
241
+ account: string;
242
+ status: "submitted" | "unconfirmed" | "confirmed" | "failed";
243
+ timestamp: number | null;
244
+ to: {
245
+ address: string;
246
+ asset: {
247
+ unit: string;
248
+ type: `${string}:${string}/${string}:${string}`;
249
+ amount: string;
250
+ fungible: true;
251
+ } | {
252
+ id: `${string}:${string}/${string}:${string}/${string}`;
253
+ fungible: false;
254
+ } | null;
255
+ }[];
256
+ fees: {
257
+ type: "base" | "priority";
258
+ asset: {
259
+ unit: string;
260
+ type: `${string}:${string}/${string}:${string}`;
261
+ amount: string;
262
+ fungible: true;
263
+ } | {
264
+ id: `${string}:${string}/${string}:${string}/${string}`;
265
+ fungible: false;
266
+ };
267
+ }[];
268
+ }[]>;
269
+ };
270
+ }, {
271
+ method: import("@metamask/superstruct").Struct<"notify:accountTransactionsUpdated", "notify:accountTransactionsUpdated">;
272
+ params: import("@metamask/superstruct").Struct<{
273
+ transactions: Record<string, {
274
+ type: "send" | "receive";
275
+ id: string;
276
+ from: {
277
+ address: string;
278
+ asset: {
279
+ unit: string;
280
+ type: `${string}:${string}/${string}:${string}`;
281
+ amount: string;
282
+ fungible: true;
283
+ } | {
284
+ id: `${string}:${string}/${string}:${string}/${string}`;
285
+ fungible: false;
286
+ } | null;
287
+ }[];
288
+ events: {
289
+ status: "submitted" | "unconfirmed" | "confirmed" | "failed";
290
+ timestamp: number | null;
291
+ }[];
292
+ chain: `${string}:${string}`;
293
+ account: string;
294
+ status: "submitted" | "unconfirmed" | "confirmed" | "failed";
295
+ timestamp: number | null;
296
+ to: {
297
+ address: string;
298
+ asset: {
299
+ unit: string;
300
+ type: `${string}:${string}/${string}:${string}`;
301
+ amount: string;
302
+ fungible: true;
303
+ } | {
304
+ id: `${string}:${string}/${string}:${string}/${string}`;
305
+ fungible: false;
306
+ } | null;
307
+ }[];
308
+ fees: {
309
+ type: "base" | "priority";
310
+ asset: {
311
+ unit: string;
312
+ type: `${string}:${string}/${string}:${string}`;
313
+ amount: string;
314
+ fungible: true;
315
+ } | {
316
+ id: `${string}:${string}/${string}:${string}/${string}`;
317
+ fungible: false;
318
+ };
319
+ }[];
320
+ }[]>;
321
+ }, {
322
+ /**
323
+ * Transactions updates of accounts owned by the Snap.
324
+ */
325
+ transactions: import("@metamask/superstruct").Struct<Record<string, {
326
+ type: "send" | "receive";
327
+ id: string;
328
+ from: {
329
+ address: string;
330
+ asset: {
331
+ unit: string;
332
+ type: `${string}:${string}/${string}:${string}`;
333
+ amount: string;
334
+ fungible: true;
335
+ } | {
336
+ id: `${string}:${string}/${string}:${string}/${string}`;
337
+ fungible: false;
338
+ } | null;
339
+ }[];
340
+ events: {
341
+ status: "submitted" | "unconfirmed" | "confirmed" | "failed";
342
+ timestamp: number | null;
343
+ }[];
344
+ chain: `${string}:${string}`;
345
+ account: string;
346
+ status: "submitted" | "unconfirmed" | "confirmed" | "failed";
347
+ timestamp: number | null;
348
+ to: {
349
+ address: string;
350
+ asset: {
351
+ unit: string;
352
+ type: `${string}:${string}/${string}:${string}`;
353
+ amount: string;
354
+ fungible: true;
355
+ } | {
356
+ id: `${string}:${string}/${string}:${string}/${string}`;
357
+ fungible: false;
358
+ } | null;
359
+ }[];
360
+ fees: {
361
+ type: "base" | "priority";
362
+ asset: {
363
+ unit: string;
364
+ type: `${string}:${string}/${string}:${string}`;
365
+ amount: string;
366
+ fungible: true;
367
+ } | {
368
+ id: `${string}:${string}/${string}:${string}/${string}`;
369
+ fungible: false;
370
+ };
371
+ }[];
372
+ }[]>, null>;
373
+ }>;
374
+ }>;
375
+ /**
376
+ * Event emitted when the transactions of an account are updated (added or
377
+ * changed).
378
+ *
379
+ * Only changes are reported.
380
+ *
381
+ * The Snap can choose to emit this event for multiple accounts at once.
382
+ */
383
+ export type AccountTransactionsUpdatedEvent = Infer<typeof AccountTransactionsUpdatedEventStruct>;
384
+ export type AccountTransactionsUpdatedEventPayload = AccountTransactionsUpdatedEvent['params'];
385
+ export declare const AccountAssetListUpdatedEventStruct: import("@metamask/superstruct").Struct<{
386
+ method: "notify:accountAssetListUpdated";
387
+ params: {
388
+ assets: Record<string, {
389
+ added: (`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`)[];
390
+ removed: (`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`)[];
391
+ }>;
392
+ };
393
+ }, {
394
+ method: import("@metamask/superstruct").Struct<"notify:accountAssetListUpdated", "notify:accountAssetListUpdated">;
395
+ params: import("@metamask/superstruct").Struct<{
396
+ assets: Record<string, {
397
+ added: (`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`)[];
398
+ removed: (`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`)[];
399
+ }>;
400
+ }, {
401
+ /**
402
+ * Asset list update of accounts owned by the Snap.
403
+ */
404
+ assets: import("@metamask/superstruct").Struct<Record<string, {
405
+ added: (`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`)[];
406
+ removed: (`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`)[];
407
+ }>, null>;
408
+ }>;
409
+ }>;
410
+ /**
411
+ * Event emitted when the assets of an account are updated.
412
+ *
413
+ * Only changes are reported.
414
+ *
415
+ * The Snap can choose to emit this event for multiple accounts at once.
416
+ */
417
+ export type AccountAssetListUpdatedEvent = Infer<typeof AccountAssetListUpdatedEventStruct>;
418
+ export type AccountAssetListUpdatedEventPayload = AccountAssetListUpdatedEvent['params'];
180
419
  //# sourceMappingURL=events.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.mts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,oBAAY,YAAY;IAEtB,cAAc,0BAA0B;IACxC,cAAc,0BAA0B;IACxC,cAAc,0BAA0B;IAGxC,eAAe,2BAA2B;IAC1C,eAAe,2BAA2B;CAC3C;AAED,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAGlC;;WAEG;;;;;;;;;;;;;;;;;;;;;QAGH;;;;;;WAMG;;QAGH;;;WAGG;;;EAGL,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;QAGlC;;WAEG;;;;;;;;;;;;;;;;;;;;;;EAGL,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;QAGlC;;WAEG;;;EAGL,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;QAGnC;;WAEG;;QAGH;;WAEG;;;EAGL,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;QAGnC;;WAEG;;;EAGL,CAAC"}
1
+ {"version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;;;;;;EAaL,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CACjD,OAAO,qCAAqC,CAC7C,CAAC;AACF,MAAM,MAAM,sCAAsC,GAChD,+BAA+B,CAAC,QAAQ,CAAC,CAAC;AAE5C,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;QAG3C;;WAEG;;;;;;EAuBL,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAC9C,OAAO,kCAAkC,CAC1C,CAAC;AACF,MAAM,MAAM,mCAAmC,GAC7C,4BAA4B,CAAC,QAAQ,CAAC,CAAC"}
package/dist/events.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { exactOptional, object, UuidStruct } from "@metamask/keyring-utils";
2
- import { boolean, literal, string } from "@metamask/superstruct";
3
- import { JsonStruct } from "@metamask/utils";
4
- import { KeyringAccountStruct } from "./api/index.mjs";
1
+ import { exactOptional, object, UuidStruct, AccountIdStruct } from "@metamask/keyring-utils";
2
+ import { array, boolean, literal, record, string } from "@metamask/superstruct";
3
+ import { CaipAssetTypeStruct, JsonStruct } from "@metamask/utils";
4
+ import { CaipAssetTypeOrIdStruct, FungibleAssetAmountStruct, KeyringAccountStruct, TransactionStruct } from "./api/index.mjs";
5
5
  /**
6
6
  * Supported keyring events.
7
7
  */
@@ -14,6 +14,10 @@ export var KeyringEvent;
14
14
  // Request events
15
15
  KeyringEvent["RequestApproved"] = "notify:requestApproved";
16
16
  KeyringEvent["RequestRejected"] = "notify:requestRejected";
17
+ // Assets related events
18
+ KeyringEvent["AccountBalancesUpdated"] = "notify:accountBalancesUpdated";
19
+ KeyringEvent["AccountAssetListUpdated"] = "notify:accountAssetListUpdated";
20
+ KeyringEvent["AccountTransactionsUpdated"] = "notify:accountTransactionsUpdated";
17
21
  })(KeyringEvent || (KeyringEvent = {}));
18
22
  export const AccountCreatedEventStruct = object({
19
23
  method: literal(`${KeyringEvent.AccountCreated}`),
@@ -77,4 +81,74 @@ export const RequestRejectedEventStruct = object({
77
81
  id: UuidStruct,
78
82
  }),
79
83
  });
84
+ // Assets related events:
85
+ // -----------------------------------------------------------------------------------------------
86
+ export const AccountBalancesUpdatedEventStruct = object({
87
+ method: literal(`${KeyringEvent.AccountBalancesUpdated}`),
88
+ params: object({
89
+ /**
90
+ * Balances updates of accounts owned by the Snap.
91
+ */
92
+ balances: record(
93
+ /**
94
+ * Account ID.
95
+ */
96
+ AccountIdStruct,
97
+ /**
98
+ * Mapping of each owned assets and their respective balances for that account.
99
+ */
100
+ record(
101
+ /**
102
+ * Asset type (CAIP-19).
103
+ */
104
+ CaipAssetTypeStruct,
105
+ /**
106
+ * Balance information for a given asset.
107
+ */
108
+ FungibleAssetAmountStruct)),
109
+ }),
110
+ });
111
+ export const AccountTransactionsUpdatedEventStruct = object({
112
+ method: literal(`${KeyringEvent.AccountTransactionsUpdated}`),
113
+ params: object({
114
+ /**
115
+ * Transactions updates of accounts owned by the Snap.
116
+ */
117
+ transactions: record(
118
+ /**
119
+ * Account ID.
120
+ */
121
+ AccountIdStruct,
122
+ /**
123
+ * List of updated transactions for that account.
124
+ */
125
+ array(TransactionStruct)),
126
+ }),
127
+ });
128
+ export const AccountAssetListUpdatedEventStruct = object({
129
+ method: literal(`${KeyringEvent.AccountAssetListUpdated}`),
130
+ params: object({
131
+ /**
132
+ * Asset list update of accounts owned by the Snap.
133
+ */
134
+ assets: record(
135
+ /**
136
+ * Account ID.
137
+ */
138
+ AccountIdStruct,
139
+ /**
140
+ * Asset list changes for that account.
141
+ */
142
+ object({
143
+ /**
144
+ * New assets detected.
145
+ */
146
+ added: array(CaipAssetTypeOrIdStruct),
147
+ /**
148
+ * Assets no longer available on that account.
149
+ */
150
+ removed: array(CaipAssetTypeOrIdStruct),
151
+ })),
152
+ }),
153
+ });
80
154
  //# sourceMappingURL=events.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":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AM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;IAC/C,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,eAAe,EAAE,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,EAAE,EAAE,UAAU;QAEd;;WAEG;QACH,MAAM,EAAE,UAAU;KACnB,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;IAC/C,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,eAAe,EAAE,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,EAAE,EAAE,UAAU;KACf,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, object, UuidStruct } from '@metamask/keyring-utils';\nimport { boolean, literal, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { KeyringAccountStruct } from './api';\n\n/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n}\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n }),\n});\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\n"]}
1
+ {"version":3,"file":"events.mjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,MAAM,EACN,UAAU,EACV,eAAe,EAChB,gCAAgC;AAEjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAChF,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,wBAAwB;AAElE,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EAClB,wBAAc;AAEf;;GAEG;AACH,MAAM,CAAN,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB,iBAAiB;IACjB,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IACxC,wDAAwC,CAAA;IAExC,iBAAiB;IACjB,0DAA0C,CAAA;IAC1C,0DAA0C,CAAA;IAE1C,wBAAwB;IACxB,wEAAwD,CAAA;IACxD,0EAA0D,CAAA;IAC1D,gFAAgE,CAAA;AAClE,CAAC,EAdW,YAAY,KAAZ,YAAY,QAcvB;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAC9C,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,cAAc,EAAE,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,OAAO,EAAE,oBAAoB;QAE7B;;;;;;WAMG;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AAE,MAAM;QACd;;WAEG;QACH,eAAe;QAEf;;WAEG;QACH,MAAM;QACJ;;WAEG;QACH,mBAAmB;QAEnB;;WAEG;QACH,yBAAyB,CAC1B,CACF;KACF,CAAC;CACH,CAAC,CAAC;AAeH,MAAM,CAAC,MAAM,qCAAqC,GAAG,MAAM,CAAC;IAC1D,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,0BAA0B,EAAE,CAAC;IAC7D,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,YAAY,EAAE,MAAM;QAClB;;WAEG;QACH,eAAe;QAEf;;WAEG;QACH,KAAK,CAAC,iBAAiB,CAAC,CACzB;KACF,CAAC;CACH,CAAC,CAAC;AAgBH,MAAM,CAAC,MAAM,kCAAkC,GAAG,MAAM,CAAC;IACvD,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,uBAAuB,EAAE,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;QACb;;WAEG;QACH,MAAM,EAAE,MAAM;QACZ;;WAEG;QACH,eAAe;QAEf;;WAEG;QACH,MAAM,CAAC;YACL;;eAEG;YACH,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC;YAErC;;eAEG;YACH,OAAO,EAAE,KAAK,CAAC,uBAAuB,CAAC;SACxC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n exactOptional,\n object,\n UuidStruct,\n AccountIdStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, boolean, literal, record, string } from '@metamask/superstruct';\nimport { CaipAssetTypeStruct, JsonStruct } from '@metamask/utils';\n\nimport {\n CaipAssetTypeOrIdStruct,\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n} from './api';\n\n/**\n * Supported keyring events.\n */\nexport enum KeyringEvent {\n // Account events\n AccountCreated = 'notify:accountCreated',\n AccountUpdated = 'notify:accountUpdated',\n AccountDeleted = 'notify:accountDeleted',\n\n // Request events\n RequestApproved = 'notify:requestApproved',\n RequestRejected = 'notify:requestRejected',\n\n // Assets related events\n AccountBalancesUpdated = 'notify:accountBalancesUpdated',\n AccountAssetListUpdated = 'notify:accountAssetListUpdated',\n AccountTransactionsUpdated = 'notify:accountTransactionsUpdated',\n}\n\nexport const AccountCreatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountCreated}`),\n params: object({\n /**\n * New account object.\n */\n account: KeyringAccountStruct,\n\n /**\n * Account name suggestion provided to the MetaMask client.\n *\n * The keyring can suggest a name for the account, but it's up to the\n * client to decide whether to use it. The keyring won't be informed if the\n * client decides to use a different name.\n */\n accountNameSuggestion: exactOptional(string()),\n\n /**\n * Instructs MetaMask to display the add account confirmation dialog in the UI.\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n }),\n});\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\n\nexport const RequestApprovedEventStruct = object({\n method: literal(`${KeyringEvent.RequestApproved}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n\n /**\n * Request result.\n */\n result: JsonStruct,\n }),\n});\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\n\n// Assets related events:\n// -----------------------------------------------------------------------------------------------\n\nexport const AccountBalancesUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountBalancesUpdated}`),\n params: object({\n /**\n * Balances updates of accounts owned by the Snap.\n */\n balances: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Mapping of each owned assets and their respective balances for that account.\n */\n record(\n /**\n * Asset type (CAIP-19).\n */\n CaipAssetTypeStruct,\n\n /**\n * Balance information for a given asset.\n */\n FungibleAssetAmountStruct,\n ),\n ),\n }),\n});\n\n/**\n * Event emitted when the balances of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport type AccountBalancesUpdatedEvent = Infer<\n typeof AccountBalancesUpdatedEventStruct\n>;\nexport type AccountBalancesUpdatedEventPayload =\n AccountBalancesUpdatedEvent['params'];\n\nexport const AccountTransactionsUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountTransactionsUpdated}`),\n params: object({\n /**\n * Transactions updates of accounts owned by the Snap.\n */\n transactions: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * List of updated transactions for that account.\n */\n array(TransactionStruct),\n ),\n }),\n});\n\n/**\n * Event emitted when the transactions of an account are updated (added or\n * changed).\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport type AccountTransactionsUpdatedEvent = Infer<\n typeof AccountTransactionsUpdatedEventStruct\n>;\nexport type AccountTransactionsUpdatedEventPayload =\n AccountTransactionsUpdatedEvent['params'];\n\nexport const AccountAssetListUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountAssetListUpdated}`),\n params: object({\n /**\n * Asset list update of accounts owned by the Snap.\n */\n assets: record(\n /**\n * Account ID.\n */\n AccountIdStruct,\n\n /**\n * Asset list changes for that account.\n */\n object({\n /**\n * New assets detected.\n */\n added: array(CaipAssetTypeOrIdStruct),\n\n /**\n * Assets no longer available on that account.\n */\n removed: array(CaipAssetTypeOrIdStruct),\n }),\n ),\n }),\n});\n\n/**\n * Event emitted when the assets of an account are updated.\n *\n * Only changes are reported.\n *\n * The Snap can choose to emit this event for multiple accounts at once.\n */\nexport type AccountAssetListUpdatedEvent = Infer<\n typeof AccountAssetListUpdatedEventStruct\n>;\nexport type AccountAssetListUpdatedEventPayload =\n AccountAssetListUpdatedEvent['params'];\n"]}
package/dist/rpc.d.cts CHANGED
@@ -184,8 +184,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
184
184
  asset: {
185
185
  unit: string;
186
186
  type: `${string}:${string}/${string}:${string}`;
187
- fungible: true;
188
187
  amount: string;
188
+ fungible: true;
189
189
  } | {
190
190
  id: `${string}:${string}/${string}:${string}/${string}`;
191
191
  fungible: false;
@@ -204,8 +204,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
204
204
  asset: {
205
205
  unit: string;
206
206
  type: `${string}:${string}/${string}:${string}`;
207
- fungible: true;
208
207
  amount: string;
208
+ fungible: true;
209
209
  } | {
210
210
  id: `${string}:${string}/${string}:${string}/${string}`;
211
211
  fungible: false;
@@ -216,8 +216,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
216
216
  asset: {
217
217
  unit: string;
218
218
  type: `${string}:${string}/${string}:${string}`;
219
- fungible: true;
220
219
  amount: string;
220
+ fungible: true;
221
221
  } | {
222
222
  id: `${string}:${string}/${string}:${string}/${string}`;
223
223
  fungible: false;
@@ -234,8 +234,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
234
234
  asset: {
235
235
  unit: string;
236
236
  type: `${string}:${string}/${string}:${string}`;
237
- fungible: true;
238
237
  amount: string;
238
+ fungible: true;
239
239
  } | {
240
240
  id: `${string}:${string}/${string}:${string}/${string}`;
241
241
  fungible: false;
@@ -254,8 +254,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
254
254
  asset: {
255
255
  unit: string;
256
256
  type: `${string}:${string}/${string}:${string}`;
257
- fungible: true;
258
257
  amount: string;
258
+ fungible: true;
259
259
  } | {
260
260
  id: `${string}:${string}/${string}:${string}/${string}`;
261
261
  fungible: false;
@@ -266,8 +266,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
266
266
  asset: {
267
267
  unit: string;
268
268
  type: `${string}:${string}/${string}:${string}`;
269
- fungible: true;
270
269
  amount: string;
270
+ fungible: true;
271
271
  } | {
272
272
  id: `${string}:${string}/${string}:${string}/${string}`;
273
273
  fungible: false;
@@ -281,8 +281,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
281
281
  asset: {
282
282
  unit: string;
283
283
  type: `${string}:${string}/${string}:${string}`;
284
- fungible: true;
285
284
  amount: string;
285
+ fungible: true;
286
286
  } | {
287
287
  id: `${string}:${string}/${string}:${string}/${string}`;
288
288
  fungible: false;
@@ -301,8 +301,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
301
301
  asset: {
302
302
  unit: string;
303
303
  type: `${string}:${string}/${string}:${string}`;
304
- fungible: true;
305
304
  amount: string;
305
+ fungible: true;
306
306
  } | {
307
307
  id: `${string}:${string}/${string}:${string}/${string}`;
308
308
  fungible: false;
@@ -313,8 +313,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
313
313
  asset: {
314
314
  unit: string;
315
315
  type: `${string}:${string}/${string}:${string}`;
316
- fungible: true;
317
316
  amount: string;
317
+ fungible: true;
318
318
  } | {
319
319
  id: `${string}:${string}/${string}:${string}/${string}`;
320
320
  fungible: false;
@@ -340,8 +340,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
340
340
  asset: {
341
341
  unit: string;
342
342
  type: `${string}:${string}/${string}:${string}`;
343
- fungible: true;
344
343
  amount: string;
344
+ fungible: true;
345
345
  } | {
346
346
  id: `${string}:${string}/${string}:${string}/${string}`;
347
347
  fungible: false;
@@ -351,8 +351,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
351
351
  asset: {
352
352
  unit: string;
353
353
  type: `${string}:${string}/${string}:${string}`;
354
- fungible: true;
355
354
  amount: string;
355
+ fungible: true;
356
356
  } | {
357
357
  id: `${string}:${string}/${string}:${string}/${string}`;
358
358
  fungible: false;
@@ -362,8 +362,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
362
362
  asset: import("@metamask/superstruct").Struct<{
363
363
  unit: string;
364
364
  type: `${string}:${string}/${string}:${string}`;
365
- fungible: true;
366
365
  amount: string;
366
+ fungible: true;
367
367
  } | {
368
368
  id: `${string}:${string}/${string}:${string}/${string}`;
369
369
  fungible: false;
@@ -374,8 +374,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
374
374
  asset: {
375
375
  unit: string;
376
376
  type: `${string}:${string}/${string}:${string}`;
377
- fungible: true;
378
377
  amount: string;
378
+ fungible: true;
379
379
  } | {
380
380
  id: `${string}:${string}/${string}:${string}/${string}`;
381
381
  fungible: false;
@@ -385,8 +385,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
385
385
  asset: {
386
386
  unit: string;
387
387
  type: `${string}:${string}/${string}:${string}`;
388
- fungible: true;
389
388
  amount: string;
389
+ fungible: true;
390
390
  } | {
391
391
  id: `${string}:${string}/${string}:${string}/${string}`;
392
392
  fungible: false;
@@ -396,8 +396,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
396
396
  asset: import("@metamask/superstruct").Struct<{
397
397
  unit: string;
398
398
  type: `${string}:${string}/${string}:${string}`;
399
- fungible: true;
400
399
  amount: string;
400
+ fungible: true;
401
401
  } | {
402
402
  id: `${string}:${string}/${string}:${string}/${string}`;
403
403
  fungible: false;
@@ -408,8 +408,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
408
408
  asset: {
409
409
  unit: string;
410
410
  type: `${string}:${string}/${string}:${string}`;
411
- fungible: true;
412
411
  amount: string;
412
+ fungible: true;
413
413
  } | {
414
414
  id: `${string}:${string}/${string}:${string}/${string}`;
415
415
  fungible: false;
@@ -419,8 +419,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
419
419
  asset: {
420
420
  unit: string;
421
421
  type: `${string}:${string}/${string}:${string}`;
422
- fungible: true;
423
422
  amount: string;
423
+ fungible: true;
424
424
  } | {
425
425
  id: `${string}:${string}/${string}:${string}/${string}`;
426
426
  fungible: false;
@@ -433,8 +433,8 @@ export declare const ListAccountTransactionsResponseStruct: import("@metamask/su
433
433
  asset: import("@metamask/superstruct").Struct<{
434
434
  unit: string;
435
435
  type: `${string}:${string}/${string}:${string}`;
436
- fungible: true;
437
436
  amount: string;
437
+ fungible: true;
438
438
  } | {
439
439
  id: `${string}:${string}/${string}:${string}/${string}`;
440
440
  fungible: false;