@metamask/keyring-api 17.3.0 → 17.5.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 (64) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/api/derivation.cjs +6 -0
  3. package/dist/api/derivation.cjs.map +1 -0
  4. package/dist/api/derivation.d.cts +4 -0
  5. package/dist/api/derivation.d.cts.map +1 -0
  6. package/dist/api/derivation.d.mts +4 -0
  7. package/dist/api/derivation.d.mts.map +1 -0
  8. package/dist/api/derivation.mjs +3 -0
  9. package/dist/api/derivation.mjs.map +1 -0
  10. package/dist/api/discovery.cjs +40 -0
  11. package/dist/api/discovery.cjs.map +1 -0
  12. package/dist/api/discovery.d.cts +65 -0
  13. package/dist/api/discovery.d.cts.map +1 -0
  14. package/dist/api/discovery.d.mts +65 -0
  15. package/dist/api/discovery.d.mts.map +1 -0
  16. package/dist/api/discovery.mjs +37 -0
  17. package/dist/api/discovery.mjs.map +1 -0
  18. package/dist/api/entropy.cjs +3 -0
  19. package/dist/api/entropy.cjs.map +1 -0
  20. package/dist/api/entropy.d.cts +5 -0
  21. package/dist/api/entropy.d.cts.map +1 -0
  22. package/dist/api/entropy.d.mts +5 -0
  23. package/dist/api/entropy.d.mts.map +1 -0
  24. package/dist/api/entropy.mjs +2 -0
  25. package/dist/api/entropy.mjs.map +1 -0
  26. package/dist/api/index.cjs +1 -0
  27. package/dist/api/index.cjs.map +1 -1
  28. package/dist/api/index.d.cts +2 -0
  29. package/dist/api/index.d.cts.map +1 -1
  30. package/dist/api/index.d.mts +2 -0
  31. package/dist/api/index.d.mts.map +1 -1
  32. package/dist/api/index.mjs +1 -0
  33. package/dist/api/index.mjs.map +1 -1
  34. package/dist/api/keyring.cjs.map +1 -1
  35. package/dist/api/keyring.d.cts +21 -0
  36. package/dist/api/keyring.d.cts.map +1 -1
  37. package/dist/api/keyring.d.mts +21 -0
  38. package/dist/api/keyring.d.mts.map +1 -1
  39. package/dist/api/keyring.mjs.map +1 -1
  40. package/dist/api/transaction.cjs +18 -0
  41. package/dist/api/transaction.cjs.map +1 -1
  42. package/dist/api/transaction.d.cts +28 -7
  43. package/dist/api/transaction.d.cts.map +1 -1
  44. package/dist/api/transaction.d.mts +28 -7
  45. package/dist/api/transaction.d.mts.map +1 -1
  46. package/dist/api/transaction.mjs +18 -0
  47. package/dist/api/transaction.mjs.map +1 -1
  48. package/dist/events.cjs +24 -0
  49. package/dist/events.cjs.map +1 -1
  50. package/dist/events.d.cts +38 -17
  51. package/dist/events.d.cts.map +1 -1
  52. package/dist/events.d.mts +38 -17
  53. package/dist/events.d.mts.map +1 -1
  54. package/dist/events.mjs +24 -0
  55. package/dist/events.mjs.map +1 -1
  56. package/dist/rpc.cjs +14 -1
  57. package/dist/rpc.cjs.map +1 -1
  58. package/dist/rpc.d.cts +46 -4
  59. package/dist/rpc.d.cts.map +1 -1
  60. package/dist/rpc.d.mts +46 -4
  61. package/dist/rpc.d.mts.map +1 -1
  62. package/dist/rpc.mjs +14 -1
  63. package/dist/rpc.mjs.map +1 -1
  64. package/package.json +1 -1
@@ -131,6 +131,21 @@ var TransactionType;
131
131
  * A swap transaction must be originated by the account.
132
132
  */
133
133
  TransactionType["Swap"] = "swap";
134
+ /**
135
+ * Represents an outgoing bridge transaction, transferring assets from
136
+ * the account to another blockchain.
137
+ */
138
+ TransactionType["BridgeSend"] = "bridge:send";
139
+ /**
140
+ * Represents an incoming bridge transaction, transferring assets from
141
+ * another blockchain to the account.
142
+ */
143
+ TransactionType["BridgeReceive"] = "bridge:receive";
144
+ /**
145
+ * The transaction type is unknown. It's not possible to determine the
146
+ * transaction type based on the information available.
147
+ */
148
+ TransactionType["Unknown"] = "unknown";
134
149
  })(TransactionType || (exports.TransactionType = TransactionType = {}));
135
150
  /**
136
151
  * This struct represents a transaction event.
@@ -243,6 +258,9 @@ exports.TransactionStruct = (0, keyring_utils_1.object)({
243
258
  `${TransactionType.Send}`,
244
259
  `${TransactionType.Receive}`,
245
260
  `${TransactionType.Swap}`,
261
+ `${TransactionType.BridgeSend}`,
262
+ `${TransactionType.BridgeReceive}`,
263
+ `${TransactionType.Unknown}`,
246
264
  ]),
247
265
  /**
248
266
  * Transaction sender addresses and amounts.
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":";;;AACA,2DAA6D;AAE7D,uDAA+E;AAE/E,uCAAsC;AACtC,qCAA2C;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,iBAAiB,GAAG,IAAA,sBAAM,EAAC;IAC/B;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,KAAK,EAAE,IAAA,sBAAQ,EAAC,mBAAW,CAAC;CAC7B,CAAC,CAAC;AAEH;;GAEG;AACH,IAAY,OAiBX;AAjBD,WAAY,OAAO;IACjB;;;;;;OAMG;IACH,wBAAa,CAAA;IAEb;;;;;OAKG;IACH,gCAAqB,CAAA;AACvB,CAAC,EAjBW,OAAO,uBAAP,OAAO,QAiBlB;AAED;;GAEG;AACH,MAAM,SAAS,GAAG,IAAA,sBAAM,EAAC;IACvB;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEvD;;OAEG;IACH,KAAK,EAAE,mBAAW;CACnB,CAAC,CAAC;AAEH;;GAEG;AACH,IAAY,iBAsBX;AAtBD,WAAY,iBAAiB;IAC3B;;;OAGG;IACH,4CAAuB,CAAA;IAEvB;;;OAGG;IACH,gDAA2B,CAAA;IAE3B;;OAEG;IACH,4CAAuB,CAAA;IAEvB;;OAEG;IACH,sCAAiB,CAAA;AACnB,CAAC,EAtBW,iBAAiB,iCAAjB,iBAAiB,QAsB5B;AAED;;GAEG;AACH,IAAY,eAqBX;AArBD,W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E;KAC1B,CAAC;IAEF;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC,iBAAiB,CAAC;IAE9B;;OAEG;IACH,EAAE,EAAE,IAAA,mBAAK,EAAC,iBAAiB,CAAC;IAE5B;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC,SAAS,CAAC;IAEtB;;;;;OAKG;IACH,MAAM,EAAE,IAAA,mBAAK,EAAC,8BAAsB,CAAC;CACtC,CAAC,CAAC;AASH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,sBAAsB,GAAG,IAAA,sBAAM,EAAC;IAC3C;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC,yBAAiB,CAAC;IAE9B;;;OAGG;IACH,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { InferEquals } from '@metamask/keyring-utils';\nimport { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, nullable, number, string } from '@metamask/superstruct';\n\nimport { AssetStruct } from './asset';\nimport { CaipChainIdStruct } from './caip';\nimport type { Paginated } from './pagination';\n\n/**\n * This struct represents a participant in a transaction.\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: null,\n * },\n * ```\n */\nconst ParticipantStruct = object({\n /**\n * Participant address.\n */\n address: string(),\n\n /**\n * Asset being transferred.\n */\n asset: nullable(AssetStruct),\n});\n\n/**\n * Fee types.\n */\nexport enum FeeType {\n /**\n * Base fee. It is the minimum fee required to include a transaction in the\n * blockchain.\n *\n * For non-confirmed transactions, it must be the maximum base fee. For\n * confirmed transactions, it must be the actual base fee paid.\n */\n Base = 'base',\n\n /**\n * Priority fee. It is an optional fee used to prioritize the transaction.\n *\n * For non-confirmed transactions, it must be the maximum priority fee. For\n * confirmed transactions, it must be the actual priority fee paid.\n */\n Priority = 'priority',\n}\n\n/**\n * This struct represents a transaction fee.\n */\nconst FeeStruct = object({\n /**\n * Fee type {@see FeeType}.\n */\n type: enums([`${FeeType.Base}`, `${FeeType.Priority}`]),\n\n /**\n * Asset used to pay for the fee.\n */\n asset: AssetStruct,\n});\n\n/**\n * Transaction statuses.\n */\nexport enum TransactionStatus {\n /**\n * The transaction has been submitted but is not yet in the\n * blockchain. For example, it can be in the mempool.\n */\n Submitted = 'submitted',\n\n /**\n * The transaction is in the blockchain but has not been\n * confirmed yet.\n */\n Unconfirmed = 'unconfirmed',\n\n /**\n * The transaction has been confirmed.\n */\n Confirmed = 'confirmed',\n\n /**\n * The transaction has failed. For example, it has been reverted.\n */\n Failed = 'failed',\n}\n\n/**\n * Transaction types.\n */\nexport enum TransactionType {\n /**\n * The transaction was originated by the account. If the transaction\n * has a change output that goes back to the same account, it must be tagged\n * as a send transaction.\n */\n Send = 'send',\n\n /**\n * The transaction was received by the account, but originated by\n * another account.\n */\n Receive = 'receive',\n\n /**\n * The transaction is a swap. It decreases the balance of one asset and\n * increases the balance of another asset in a single transaction.\n *\n * A swap transaction must be originated by the account.\n */\n Swap = 'swap',\n}\n\n/**\n * This struct represents a transaction event.\n */\nexport const TransactionEventStruct = object({\n /**\n * New status of the transaction.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the event occurred.\n */\n timestamp: nullable(number()),\n});\n\n/**\n * This struct represents a blockchain transaction.\n *\n * @example\n * ```ts\n * const tx = {\n * id: 'f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6',\n * chain: 'bip122:000000000019d6689c085ae165831e93',\n * account: 'b9beb861-9761-4b97-89ce-d992be5f34da',\n * status: 'confirmed',\n * timestamp: 1716367781,\n * type: 'send',\n * from: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * to: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * {\n * address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * fees: [\n * {\n * type: 'priority',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * };\n * ```\n */\nexport const TransactionStruct = object({\n /**\n * Chain-specific transaction ID.\n */\n id: string(),\n\n /**\n * Chain ID (CAIP-2).\n */\n chain: CaipChainIdStruct,\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Transaction status {@see TransactionStatus}.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the transaction was added to the blockchain. The\n * timestamp can be null if the transaction has not been included in the\n * blockchain yet.\n */\n timestamp: nullable(number()),\n\n /**\n * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction\n * details on the UI.\n */\n type: enums([\n `${TransactionType.Send}`,\n `${TransactionType.Receive}`,\n `${TransactionType.Swap}`,\n ]),\n\n /**\n * Transaction sender addresses and amounts.\n */\n from: array(ParticipantStruct),\n\n /**\n * Transaction receiver addresses and amounts.\n */\n to: array(ParticipantStruct),\n\n /**\n * Total transaction fee.\n */\n fees: array(FeeStruct),\n\n /**\n * List of events related to the transaction {@see TransactionEventStruct}.\n *\n * The events are tracked in a best-effort basis and may not be available for\n * all transactions.\n */\n events: array(TransactionEventStruct),\n});\n\n/**\n * Transaction object.\n *\n * See {@link TransactionStruct}.\n */\nexport type Transaction = Infer<typeof TransactionStruct>;\n\n/**\n * This struct represents a page of transactions.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: null, // No more results\n * }**\n * ```\n */\nexport const TransactionsPageStruct = object({\n /**\n * List of transactions.\n */\n data: array(TransactionStruct),\n\n /**\n * Next cursor to iterate over the results. If null, there are no more\n * results.\n */\n next: nullable(string()),\n});\n\n/**\n * Transactions page object.\n *\n * See {@link TransactionsPageStruct}.\n */\nexport type TransactionsPage = InferEquals<\n typeof TransactionsPageStruct,\n Paginated<Transaction>\n>;\n"]}
1
+ {"version":3,"file":"transaction.cjs","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":";;;AACA,2DAA6D;AAE7D,uDAA+E;AAE/E,uCAAsC;AACtC,qCAA2C;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,iBAAiB,GAAG,IAAA,sBAAM,EAAC;IAC/B;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,KAAK,EAAE,IAAA,sBAAQ,EAAC,mBAAW,CAAC;CAC7B,CAAC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;;;;;;;;;;;;;;GA0BG;AACU,QAAA,sBAAsB,GAAG,IAAA,sBAAM,EAAC;IAC3C;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC,yBAAiB,CAAC;IAE9B;;;OAGG;IACH,IAAI,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { InferEquals } from '@metamask/keyring-utils';\nimport { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, nullable, number, string } from '@metamask/superstruct';\n\nimport { AssetStruct } from './asset';\nimport { CaipChainIdStruct } from './caip';\nimport type { Paginated } from './pagination';\n\n/**\n * This struct represents a participant in a transaction.\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: null,\n * },\n * ```\n */\nconst ParticipantStruct = object({\n /**\n * Participant address.\n */\n address: string(),\n\n /**\n * Asset being transferred.\n */\n asset: nullable(AssetStruct),\n});\n\n/**\n * Fee types.\n */\nexport enum FeeType {\n /**\n * Base fee. It is the minimum fee required to include a transaction in the\n * blockchain.\n *\n * For non-confirmed transactions, it must be the maximum base fee. For\n * confirmed transactions, it must be the actual base fee paid.\n */\n Base = 'base',\n\n /**\n * Priority fee. It is an optional fee used to prioritize the transaction.\n *\n * For non-confirmed transactions, it must be the maximum priority fee. For\n * confirmed transactions, it must be the actual priority fee paid.\n */\n Priority = 'priority',\n}\n\n/**\n * This struct represents a transaction fee.\n */\nconst FeeStruct = object({\n /**\n * Fee type {@see FeeType}.\n */\n type: enums([`${FeeType.Base}`, `${FeeType.Priority}`]),\n\n /**\n * Asset used to pay for the fee.\n */\n asset: AssetStruct,\n});\n\n/**\n * Transaction statuses.\n */\nexport enum TransactionStatus {\n /**\n * The transaction has been submitted but is not yet in the\n * blockchain. For example, it can be in the mempool.\n */\n Submitted = 'submitted',\n\n /**\n * The transaction is in the blockchain but has not been\n * confirmed yet.\n */\n Unconfirmed = 'unconfirmed',\n\n /**\n * The transaction has been confirmed.\n */\n Confirmed = 'confirmed',\n\n /**\n * The transaction has failed. For example, it has been reverted.\n */\n Failed = 'failed',\n}\n\n/**\n * Transaction types.\n */\nexport enum TransactionType {\n /**\n * The transaction was originated by the account. If the transaction\n * has a change output that goes back to the same account, it must be tagged\n * as a send transaction.\n */\n Send = 'send',\n\n /**\n * The transaction was received by the account, but originated by\n * another account.\n */\n Receive = 'receive',\n\n /**\n * The transaction is a swap. It decreases the balance of one asset and\n * increases the balance of another asset in a single transaction.\n *\n * A swap transaction must be originated by the account.\n */\n Swap = 'swap',\n\n /**\n * Represents an outgoing bridge transaction, transferring assets from\n * the account to another blockchain.\n */\n BridgeSend = 'bridge:send',\n\n /**\n * Represents an incoming bridge transaction, transferring assets from\n * another blockchain to the account.\n */\n BridgeReceive = 'bridge:receive',\n\n /**\n * The transaction type is unknown. It's not possible to determine the\n * transaction type based on the information available.\n */\n Unknown = 'unknown',\n}\n\n/**\n * This struct represents a transaction event.\n */\nexport const TransactionEventStruct = object({\n /**\n * New status of the transaction.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the event occurred.\n */\n timestamp: nullable(number()),\n});\n\n/**\n * This struct represents a blockchain transaction.\n *\n * @example\n * ```ts\n * const tx = {\n * id: 'f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6',\n * chain: 'bip122:000000000019d6689c085ae165831e93',\n * account: 'b9beb861-9761-4b97-89ce-d992be5f34da',\n * status: 'confirmed',\n * timestamp: 1716367781,\n * type: 'send',\n * from: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * to: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * {\n * address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * fees: [\n * {\n * type: 'priority',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * };\n * ```\n */\nexport const TransactionStruct = object({\n /**\n * Chain-specific transaction ID.\n */\n id: string(),\n\n /**\n * Chain ID (CAIP-2).\n */\n chain: CaipChainIdStruct,\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Transaction status {@see TransactionStatus}.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the transaction was added to the blockchain. The\n * timestamp can be null if the transaction has not been included in the\n * blockchain yet.\n */\n timestamp: nullable(number()),\n\n /**\n * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction\n * details on the UI.\n */\n type: enums([\n `${TransactionType.Send}`,\n `${TransactionType.Receive}`,\n `${TransactionType.Swap}`,\n `${TransactionType.BridgeSend}`,\n `${TransactionType.BridgeReceive}`,\n `${TransactionType.Unknown}`,\n ]),\n\n /**\n * Transaction sender addresses and amounts.\n */\n from: array(ParticipantStruct),\n\n /**\n * Transaction receiver addresses and amounts.\n */\n to: array(ParticipantStruct),\n\n /**\n * Total transaction fee.\n */\n fees: array(FeeStruct),\n\n /**\n * List of events related to the transaction {@see TransactionEventStruct}.\n *\n * The events are tracked in a best-effort basis and may not be available for\n * all transactions.\n */\n events: array(TransactionEventStruct),\n});\n\n/**\n * Transaction object.\n *\n * See {@link TransactionStruct}.\n */\nexport type Transaction = Infer<typeof TransactionStruct>;\n\n/**\n * This struct represents a page of transactions.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: null, // No more results\n * }**\n * ```\n */\nexport const TransactionsPageStruct = object({\n /**\n * List of transactions.\n */\n data: array(TransactionStruct),\n\n /**\n * Next cursor to iterate over the results. If null, there are no more\n * results.\n */\n next: nullable(string()),\n});\n\n/**\n * Transactions page object.\n *\n * See {@link TransactionsPageStruct}.\n */\nexport type TransactionsPage = InferEquals<\n typeof TransactionsPageStruct,\n Paginated<Transaction>\n>;\n"]}
@@ -65,7 +65,22 @@ export declare enum TransactionType {
65
65
  *
66
66
  * A swap transaction must be originated by the account.
67
67
  */
68
- Swap = "swap"
68
+ Swap = "swap",
69
+ /**
70
+ * Represents an outgoing bridge transaction, transferring assets from
71
+ * the account to another blockchain.
72
+ */
73
+ BridgeSend = "bridge:send",
74
+ /**
75
+ * Represents an incoming bridge transaction, transferring assets from
76
+ * another blockchain to the account.
77
+ */
78
+ BridgeReceive = "bridge:receive",
79
+ /**
80
+ * The transaction type is unknown. It's not possible to determine the
81
+ * transaction type based on the information available.
82
+ */
83
+ Unknown = "unknown"
69
84
  }
70
85
  /**
71
86
  * This struct represents a transaction event.
@@ -146,7 +161,7 @@ export declare const TransactionEventStruct: import("@metamask/superstruct").Str
146
161
  * ```
147
162
  */
148
163
  export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
149
- type: "send" | "receive" | "swap";
164
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
150
165
  id: string;
151
166
  from: {
152
167
  address: string;
@@ -224,10 +239,13 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
224
239
  * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction
225
240
  * details on the UI.
226
241
  */
227
- type: import("@metamask/superstruct").Struct<"send" | "receive" | "swap", {
242
+ type: import("@metamask/superstruct").Struct<"unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive", {
243
+ unknown: "unknown";
228
244
  send: "send";
229
245
  receive: "receive";
230
246
  swap: "swap";
247
+ "bridge:send": "bridge:send";
248
+ "bridge:receive": "bridge:receive";
231
249
  }>;
232
250
  /**
233
251
  * Transaction sender addresses and amounts.
@@ -424,7 +442,7 @@ export type Transaction = Infer<typeof TransactionStruct>;
424
442
  */
425
443
  export declare const TransactionsPageStruct: import("@metamask/superstruct").Struct<{
426
444
  data: {
427
- type: "send" | "receive" | "swap";
445
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
428
446
  id: string;
429
447
  from: {
430
448
  address: string;
@@ -477,7 +495,7 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
477
495
  * List of transactions.
478
496
  */
479
497
  data: import("@metamask/superstruct").Struct<{
480
- type: "send" | "receive" | "swap";
498
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
481
499
  id: string;
482
500
  from: {
483
501
  address: string;
@@ -524,7 +542,7 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
524
542
  };
525
543
  }[];
526
544
  }[], import("@metamask/superstruct").Struct<{
527
- type: "send" | "receive" | "swap";
545
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
528
546
  id: string;
529
547
  from: {
530
548
  address: string;
@@ -602,10 +620,13 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
602
620
  * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction
603
621
  * details on the UI.
604
622
  */
605
- type: import("@metamask/superstruct").Struct<"send" | "receive" | "swap", {
623
+ type: import("@metamask/superstruct").Struct<"unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive", {
624
+ unknown: "unknown";
606
625
  send: "send";
607
626
  receive: "receive";
608
627
  swap: "swap";
628
+ "bridge:send": "bridge:send";
629
+ "bridge:receive": "bridge:receive";
609
630
  }>;
610
631
  /**
611
632
  * Transaction sender addresses and amounts.
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.cts","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gCAAgC;AAE3D,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD,OAAO,KAAK,EAAE,SAAS,EAAE,yBAAqB;AAiD9C;;GAEG;AACH,oBAAY,OAAO;IACjB;;;;;;OAMG;IACH,IAAI,SAAS;IAEb;;;;;OAKG;IACH,QAAQ,aAAa;CACtB;AAiBD;;GAEG;AACH,oBAAY,iBAAiB;IAC3B;;;OAGG;IACH,SAAS,cAAc;IAEvB;;;OAGG;IACH,WAAW,gBAAgB;IAE3B;;OAEG;IACH,SAAS,cAAc;IAEvB;;OAEG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB;;;;OAIG;IACH,IAAI,SAAS;IAEb;;;OAGG;IACH,OAAO,YAAY;IAEnB;;;;;OAKG;IACH,IAAI,SAAS;CACd;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;;;;;;IAQH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAG,WAAW,CACxC,OAAO,sBAAsB,EAC7B,SAAS,CAAC,WAAW,CAAC,CACvB,CAAC"}
@@ -65,7 +65,22 @@ export declare enum TransactionType {
65
65
  *
66
66
  * A swap transaction must be originated by the account.
67
67
  */
68
- Swap = "swap"
68
+ Swap = "swap",
69
+ /**
70
+ * Represents an outgoing bridge transaction, transferring assets from
71
+ * the account to another blockchain.
72
+ */
73
+ BridgeSend = "bridge:send",
74
+ /**
75
+ * Represents an incoming bridge transaction, transferring assets from
76
+ * another blockchain to the account.
77
+ */
78
+ BridgeReceive = "bridge:receive",
79
+ /**
80
+ * The transaction type is unknown. It's not possible to determine the
81
+ * transaction type based on the information available.
82
+ */
83
+ Unknown = "unknown"
69
84
  }
70
85
  /**
71
86
  * This struct represents a transaction event.
@@ -146,7 +161,7 @@ export declare const TransactionEventStruct: import("@metamask/superstruct").Str
146
161
  * ```
147
162
  */
148
163
  export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
149
- type: "send" | "receive" | "swap";
164
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
150
165
  id: string;
151
166
  from: {
152
167
  address: string;
@@ -224,10 +239,13 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
224
239
  * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction
225
240
  * details on the UI.
226
241
  */
227
- type: import("@metamask/superstruct").Struct<"send" | "receive" | "swap", {
242
+ type: import("@metamask/superstruct").Struct<"unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive", {
243
+ unknown: "unknown";
228
244
  send: "send";
229
245
  receive: "receive";
230
246
  swap: "swap";
247
+ "bridge:send": "bridge:send";
248
+ "bridge:receive": "bridge:receive";
231
249
  }>;
232
250
  /**
233
251
  * Transaction sender addresses and amounts.
@@ -424,7 +442,7 @@ export type Transaction = Infer<typeof TransactionStruct>;
424
442
  */
425
443
  export declare const TransactionsPageStruct: import("@metamask/superstruct").Struct<{
426
444
  data: {
427
- type: "send" | "receive" | "swap";
445
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
428
446
  id: string;
429
447
  from: {
430
448
  address: string;
@@ -477,7 +495,7 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
477
495
  * List of transactions.
478
496
  */
479
497
  data: import("@metamask/superstruct").Struct<{
480
- type: "send" | "receive" | "swap";
498
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
481
499
  id: string;
482
500
  from: {
483
501
  address: string;
@@ -524,7 +542,7 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
524
542
  };
525
543
  }[];
526
544
  }[], import("@metamask/superstruct").Struct<{
527
- type: "send" | "receive" | "swap";
545
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
528
546
  id: string;
529
547
  from: {
530
548
  address: string;
@@ -602,10 +620,13 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
602
620
  * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction
603
621
  * details on the UI.
604
622
  */
605
- type: import("@metamask/superstruct").Struct<"send" | "receive" | "swap", {
623
+ type: import("@metamask/superstruct").Struct<"unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive", {
624
+ unknown: "unknown";
606
625
  send: "send";
607
626
  receive: "receive";
608
627
  swap: "swap";
628
+ "bridge:send": "bridge:send";
629
+ "bridge:receive": "bridge:receive";
609
630
  }>;
610
631
  /**
611
632
  * Transaction sender addresses and amounts.
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.mts","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gCAAgC;AAE3D,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAKnD,OAAO,KAAK,EAAE,SAAS,EAAE,yBAAqB;AAiD9C;;GAEG;AACH,oBAAY,OAAO;IACjB;;;;;;OAMG;IACH,IAAI,SAAS;IAEb;;;;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QAGH;;WAEG;;QAGH;;WAEG;;;;;;;QAQH;;;;WAIG;;QAGH;;;WAGG;;;;;;;;;QAUH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;YApPH;;eAEG;;YAGH;;eAEG;;;;;;;;;;;QAgPH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;YAzPH;;eAEG;;YAGH;;eAEG;;;;;;;;;;;QAqPH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;YAzNH;;eAEG;;;;;YAGH;;eAEG;;;;;;;;;;;QAqNH;;;;;WAKG;;;;;;;;YA3IH;;eAEG;;;;;;;YAQH;;eAEG;;;;IA2KH;;;OAGG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,CACxC,OAAO,sBAAsB,EAC7B,SAAS,CAAC,WAAW,CAAC,CACvB,CAAC"}
@@ -128,6 +128,21 @@ export var TransactionType;
128
128
  * A swap transaction must be originated by the account.
129
129
  */
130
130
  TransactionType["Swap"] = "swap";
131
+ /**
132
+ * Represents an outgoing bridge transaction, transferring assets from
133
+ * the account to another blockchain.
134
+ */
135
+ TransactionType["BridgeSend"] = "bridge:send";
136
+ /**
137
+ * Represents an incoming bridge transaction, transferring assets from
138
+ * another blockchain to the account.
139
+ */
140
+ TransactionType["BridgeReceive"] = "bridge:receive";
141
+ /**
142
+ * The transaction type is unknown. It's not possible to determine the
143
+ * transaction type based on the information available.
144
+ */
145
+ TransactionType["Unknown"] = "unknown";
131
146
  })(TransactionType || (TransactionType = {}));
132
147
  /**
133
148
  * This struct represents a transaction event.
@@ -240,6 +255,9 @@ export const TransactionStruct = object({
240
255
  `${TransactionType.Send}`,
241
256
  `${TransactionType.Receive}`,
242
257
  `${TransactionType.Swap}`,
258
+ `${TransactionType.BridgeSend}`,
259
+ `${TransactionType.BridgeReceive}`,
260
+ `${TransactionType.Unknown}`,
243
261
  ]),
244
262
  /**
245
263
  * Transaction sender addresses and amounts.
@@ -1 +1 @@
1
- {"version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9B;;OAEG;IACH,EAAE,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAE5B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IAEtB;;;;;OAKG;IACH,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC;CACtC,CAAC,CAAC;AASH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAE9B;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { InferEquals } from '@metamask/keyring-utils';\nimport { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, nullable, number, string } from '@metamask/superstruct';\n\nimport { AssetStruct } from './asset';\nimport { CaipChainIdStruct } from './caip';\nimport type { Paginated } from './pagination';\n\n/**\n * This struct represents a participant in a transaction.\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: null,\n * },\n * ```\n */\nconst ParticipantStruct = object({\n /**\n * Participant address.\n */\n address: string(),\n\n /**\n * Asset being transferred.\n */\n asset: nullable(AssetStruct),\n});\n\n/**\n * Fee types.\n */\nexport enum FeeType {\n /**\n * Base fee. It is the minimum fee required to include a transaction in the\n * blockchain.\n *\n * For non-confirmed transactions, it must be the maximum base fee. For\n * confirmed transactions, it must be the actual base fee paid.\n */\n Base = 'base',\n\n /**\n * Priority fee. It is an optional fee used to prioritize the transaction.\n *\n * For non-confirmed transactions, it must be the maximum priority fee. For\n * confirmed transactions, it must be the actual priority fee paid.\n */\n Priority = 'priority',\n}\n\n/**\n * This struct represents a transaction fee.\n */\nconst FeeStruct = object({\n /**\n * Fee type {@see FeeType}.\n */\n type: enums([`${FeeType.Base}`, `${FeeType.Priority}`]),\n\n /**\n * Asset used to pay for the fee.\n */\n asset: AssetStruct,\n});\n\n/**\n * Transaction statuses.\n */\nexport enum TransactionStatus {\n /**\n * The transaction has been submitted but is not yet in the\n * blockchain. For example, it can be in the mempool.\n */\n Submitted = 'submitted',\n\n /**\n * The transaction is in the blockchain but has not been\n * confirmed yet.\n */\n Unconfirmed = 'unconfirmed',\n\n /**\n * The transaction has been confirmed.\n */\n Confirmed = 'confirmed',\n\n /**\n * The transaction has failed. For example, it has been reverted.\n */\n Failed = 'failed',\n}\n\n/**\n * Transaction types.\n */\nexport enum TransactionType {\n /**\n * The transaction was originated by the account. If the transaction\n * has a change output that goes back to the same account, it must be tagged\n * as a send transaction.\n */\n Send = 'send',\n\n /**\n * The transaction was received by the account, but originated by\n * another account.\n */\n Receive = 'receive',\n\n /**\n * The transaction is a swap. It decreases the balance of one asset and\n * increases the balance of another asset in a single transaction.\n *\n * A swap transaction must be originated by the account.\n */\n Swap = 'swap',\n}\n\n/**\n * This struct represents a transaction event.\n */\nexport const TransactionEventStruct = object({\n /**\n * New status of the transaction.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the event occurred.\n */\n timestamp: nullable(number()),\n});\n\n/**\n * This struct represents a blockchain transaction.\n *\n * @example\n * ```ts\n * const tx = {\n * id: 'f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6',\n * chain: 'bip122:000000000019d6689c085ae165831e93',\n * account: 'b9beb861-9761-4b97-89ce-d992be5f34da',\n * status: 'confirmed',\n * timestamp: 1716367781,\n * type: 'send',\n * from: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * to: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * {\n * address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * fees: [\n * {\n * type: 'priority',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * };\n * ```\n */\nexport const TransactionStruct = object({\n /**\n * Chain-specific transaction ID.\n */\n id: string(),\n\n /**\n * Chain ID (CAIP-2).\n */\n chain: CaipChainIdStruct,\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Transaction status {@see TransactionStatus}.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the transaction was added to the blockchain. The\n * timestamp can be null if the transaction has not been included in the\n * blockchain yet.\n */\n timestamp: nullable(number()),\n\n /**\n * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction\n * details on the UI.\n */\n type: enums([\n `${TransactionType.Send}`,\n `${TransactionType.Receive}`,\n `${TransactionType.Swap}`,\n ]),\n\n /**\n * Transaction sender addresses and amounts.\n */\n from: array(ParticipantStruct),\n\n /**\n * Transaction receiver addresses and amounts.\n */\n to: array(ParticipantStruct),\n\n /**\n * Total transaction fee.\n */\n fees: array(FeeStruct),\n\n /**\n * List of events related to the transaction {@see TransactionEventStruct}.\n *\n * The events are tracked in a best-effort basis and may not be available for\n * all transactions.\n */\n events: array(TransactionEventStruct),\n});\n\n/**\n * Transaction object.\n *\n * See {@link TransactionStruct}.\n */\nexport type Transaction = Infer<typeof TransactionStruct>;\n\n/**\n * This struct represents a page of transactions.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: null, // No more results\n * }**\n * ```\n */\nexport const TransactionsPageStruct = object({\n /**\n * List of transactions.\n */\n data: array(TransactionStruct),\n\n /**\n * Next cursor to iterate over the results. If null, there are no more\n * results.\n */\n next: nullable(string()),\n});\n\n/**\n * Transactions page object.\n *\n * See {@link TransactionsPageStruct}.\n */\nexport type TransactionsPage = InferEquals<\n typeof TransactionsPageStruct,\n Paginated<Transaction>\n>;\n"]}
1
+ {"version":3,"file":"transaction.mjs","sourceRoot":"","sources":["../../src/api/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gCAAgC;AAE7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAE/E,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,EAAE,iBAAiB,EAAE,mBAAe;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE;IAEjB;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC;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AAsB,GAAG,MAAM,CAAC;IAC3C;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAE9B;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { InferEquals } from '@metamask/keyring-utils';\nimport { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, nullable, number, string } from '@metamask/superstruct';\n\nimport { AssetStruct } from './asset';\nimport { CaipChainIdStruct } from './caip';\nimport type { Paginated } from './pagination';\n\n/**\n * This struct represents a participant in a transaction.\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * },\n * },\n * ```\n *\n * @example\n * ```ts\n * {\n * address: '0x1234...',\n * asset: null,\n * },\n * ```\n */\nconst ParticipantStruct = object({\n /**\n * Participant address.\n */\n address: string(),\n\n /**\n * Asset being transferred.\n */\n asset: nullable(AssetStruct),\n});\n\n/**\n * Fee types.\n */\nexport enum FeeType {\n /**\n * Base fee. It is the minimum fee required to include a transaction in the\n * blockchain.\n *\n * For non-confirmed transactions, it must be the maximum base fee. For\n * confirmed transactions, it must be the actual base fee paid.\n */\n Base = 'base',\n\n /**\n * Priority fee. It is an optional fee used to prioritize the transaction.\n *\n * For non-confirmed transactions, it must be the maximum priority fee. For\n * confirmed transactions, it must be the actual priority fee paid.\n */\n Priority = 'priority',\n}\n\n/**\n * This struct represents a transaction fee.\n */\nconst FeeStruct = object({\n /**\n * Fee type {@see FeeType}.\n */\n type: enums([`${FeeType.Base}`, `${FeeType.Priority}`]),\n\n /**\n * Asset used to pay for the fee.\n */\n asset: AssetStruct,\n});\n\n/**\n * Transaction statuses.\n */\nexport enum TransactionStatus {\n /**\n * The transaction has been submitted but is not yet in the\n * blockchain. For example, it can be in the mempool.\n */\n Submitted = 'submitted',\n\n /**\n * The transaction is in the blockchain but has not been\n * confirmed yet.\n */\n Unconfirmed = 'unconfirmed',\n\n /**\n * The transaction has been confirmed.\n */\n Confirmed = 'confirmed',\n\n /**\n * The transaction has failed. For example, it has been reverted.\n */\n Failed = 'failed',\n}\n\n/**\n * Transaction types.\n */\nexport enum TransactionType {\n /**\n * The transaction was originated by the account. If the transaction\n * has a change output that goes back to the same account, it must be tagged\n * as a send transaction.\n */\n Send = 'send',\n\n /**\n * The transaction was received by the account, but originated by\n * another account.\n */\n Receive = 'receive',\n\n /**\n * The transaction is a swap. It decreases the balance of one asset and\n * increases the balance of another asset in a single transaction.\n *\n * A swap transaction must be originated by the account.\n */\n Swap = 'swap',\n\n /**\n * Represents an outgoing bridge transaction, transferring assets from\n * the account to another blockchain.\n */\n BridgeSend = 'bridge:send',\n\n /**\n * Represents an incoming bridge transaction, transferring assets from\n * another blockchain to the account.\n */\n BridgeReceive = 'bridge:receive',\n\n /**\n * The transaction type is unknown. It's not possible to determine the\n * transaction type based on the information available.\n */\n Unknown = 'unknown',\n}\n\n/**\n * This struct represents a transaction event.\n */\nexport const TransactionEventStruct = object({\n /**\n * New status of the transaction.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the event occurred.\n */\n timestamp: nullable(number()),\n});\n\n/**\n * This struct represents a blockchain transaction.\n *\n * @example\n * ```ts\n * const tx = {\n * id: 'f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6',\n * chain: 'bip122:000000000019d6689c085ae165831e93',\n * account: 'b9beb861-9761-4b97-89ce-d992be5f34da',\n * status: 'confirmed',\n * timestamp: 1716367781,\n * type: 'send',\n * from: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * to: [\n * {\n * address: 'bc1qrp0yzgkf8rawkuvdlhnjfj2fnjwm0m8727kgah',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * {\n * address: 'bc1qwl8399fz829uqvqly9tcatgrgtwp3udnhxfq4k',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * fees: [\n * {\n * type: 'priority',\n * asset: {\n * fungible: true,\n * type: 'bip122:000000000019d6689c085ae165831e93/slip44:0',\n * unit: 'BTC',\n * amount: '0.1',\n * },\n * },\n * ],\n * };\n * ```\n */\nexport const TransactionStruct = object({\n /**\n * Chain-specific transaction ID.\n */\n id: string(),\n\n /**\n * Chain ID (CAIP-2).\n */\n chain: CaipChainIdStruct,\n\n /**\n * Account ID (UUIDv4).\n */\n account: UuidStruct,\n\n /**\n * Transaction status {@see TransactionStatus}.\n */\n status: enums([\n `${TransactionStatus.Submitted}`,\n `${TransactionStatus.Unconfirmed}`,\n `${TransactionStatus.Confirmed}`,\n `${TransactionStatus.Failed}`,\n ]),\n\n /**\n * UNIX timestamp of when the transaction was added to the blockchain. The\n * timestamp can be null if the transaction has not been included in the\n * blockchain yet.\n */\n timestamp: nullable(number()),\n\n /**\n * Transaction type {@see TransactionType}. This will be used by MetaMask to enrich the transaction\n * details on the UI.\n */\n type: enums([\n `${TransactionType.Send}`,\n `${TransactionType.Receive}`,\n `${TransactionType.Swap}`,\n `${TransactionType.BridgeSend}`,\n `${TransactionType.BridgeReceive}`,\n `${TransactionType.Unknown}`,\n ]),\n\n /**\n * Transaction sender addresses and amounts.\n */\n from: array(ParticipantStruct),\n\n /**\n * Transaction receiver addresses and amounts.\n */\n to: array(ParticipantStruct),\n\n /**\n * Total transaction fee.\n */\n fees: array(FeeStruct),\n\n /**\n * List of events related to the transaction {@see TransactionEventStruct}.\n *\n * The events are tracked in a best-effort basis and may not be available for\n * all transactions.\n */\n events: array(TransactionEventStruct),\n});\n\n/**\n * Transaction object.\n *\n * See {@link TransactionStruct}.\n */\nexport type Transaction = Infer<typeof TransactionStruct>;\n\n/**\n * This struct represents a page of transactions.\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: 'c3y1Q6QtqtstbxKX+oqVdEW6',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * data: [\n * {\n * // Transaction object\n * }\n * ],\n * next: null, // No more results\n * }**\n * ```\n */\nexport const TransactionsPageStruct = object({\n /**\n * List of transactions.\n */\n data: array(TransactionStruct),\n\n /**\n * Next cursor to iterate over the results. If null, there are no more\n * results.\n */\n next: nullable(string()),\n});\n\n/**\n * Transactions page object.\n *\n * See {@link TransactionsPageStruct}.\n */\nexport type TransactionsPage = InferEquals<\n typeof TransactionsPageStruct,\n Paginated<Transaction>\n>;\n"]}
package/dist/events.cjs CHANGED
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
3
+ // FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.AccountAssetListUpdatedEventStruct = exports.AccountTransactionsUpdatedEventStruct = exports.AccountBalancesUpdatedEventStruct = exports.RequestRejectedEventStruct = exports.RequestApprovedEventStruct = exports.AccountDeletedEventStruct = exports.AccountUpdatedEventStruct = exports.AccountCreatedEventStruct = exports.KeyringEvent = void 0;
4
6
  const keyring_utils_1 = require("@metamask/keyring-utils");
@@ -100,6 +102,13 @@ exports.RequestRejectedEventStruct = (0, keyring_utils_1.object)({
100
102
  });
101
103
  // Assets related events:
102
104
  // -----------------------------------------------------------------------------------------------
105
+ /**
106
+ * Event emitted when the balances of an account are updated.
107
+ *
108
+ * Only changes are reported.
109
+ *
110
+ * The Snap can choose to emit this event for multiple accounts at once.
111
+ */
103
112
  exports.AccountBalancesUpdatedEventStruct = (0, keyring_utils_1.object)({
104
113
  method: (0, superstruct_1.literal)(`${KeyringEvent.AccountBalancesUpdated}`),
105
114
  params: (0, keyring_utils_1.object)({
@@ -125,6 +134,14 @@ exports.AccountBalancesUpdatedEventStruct = (0, keyring_utils_1.object)({
125
134
  api_1.FungibleAssetAmountStruct)),
126
135
  }),
127
136
  });
137
+ /**
138
+ * Event emitted when the transactions of an account are updated (added or
139
+ * changed).
140
+ *
141
+ * Only changes are reported.
142
+ *
143
+ * The Snap can choose to emit this event for multiple accounts at once.
144
+ */
128
145
  exports.AccountTransactionsUpdatedEventStruct = (0, keyring_utils_1.object)({
129
146
  method: (0, superstruct_1.literal)(`${KeyringEvent.AccountTransactionsUpdated}`),
130
147
  params: (0, keyring_utils_1.object)({
@@ -142,6 +159,13 @@ exports.AccountTransactionsUpdatedEventStruct = (0, keyring_utils_1.object)({
142
159
  (0, superstruct_1.array)(api_1.TransactionStruct)),
143
160
  }),
144
161
  });
162
+ /**
163
+ * Event emitted when the assets of an account are updated.
164
+ *
165
+ * Only changes are reported.
166
+ *
167
+ * The Snap can choose to emit this event for multiple accounts at once.
168
+ */
145
169
  exports.AccountAssetListUpdatedEventStruct = (0, keyring_utils_1.object)({
146
170
  method: (0, superstruct_1.literal)(`${KeyringEvent.AccountAssetListUpdated}`),
147
171
  params: (0, keyring_utils_1.object)({
@@ -1 +1 @@
1
- {"version":3,"file":"events.cjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";;;AAAA,2DAKiC;AAEjC,uDAAgF;AAChF,2CAIyB;AAEzB,yCAKe;AAEf;;GAEG;AACH,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB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AAO,EAAC,GAAG,YAAY,CAAC,uBAAuB,EAAE,CAAC;IAC1D,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb;;WAEG;QACH,MAAM,EAAE,IAAA,oBAAM;QACZ;;WAEG;QACH,+BAAe;QAEf;;WAEG;QACH,IAAA,sBAAM,EAAC;YACL;;eAEG;YACH,KAAK,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;YAErC;;eAEG;YACH,OAAO,EAAE,IAAA,mBAAK,EAAC,+BAAuB,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 {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n MetaMaskOptionsStruct,\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 *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n\n /**\n * Instructs MetaMask to display the name confirmation dialog in the UI.\n * Otherwise, the account will be added with the suggested name, if it's not\n * already in use; if it is, a suffix will be appended to the name to make it\n * unique.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayAccountNameSuggestion: exactOptional(boolean()),\n\n /**\n * Metamask internal options.\n */\n ...MetaMaskOptionsStruct.schema,\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"]}
1
+ {"version":3,"file":"events.cjs","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,mFAAmF;;;AAEnF,2DAKiC;AAEjC,uDAAgF;AAChF,2CAIyB;AAEzB,yCAKe;AAEf;;GAEG;AACH,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB,iBAAiB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A,sBAAM,EAAC;IACvD,MAAM,EAAE,IAAA,qBAAO,EAAC,GAAG,YAAY,CAAC,uBAAuB,EAAE,CAAC;IAC1D,MAAM,EAAE,IAAA,sBAAM,EAAC;QACb;;WAEG;QACH,MAAM,EAAE,IAAA,oBAAM;QACZ;;WAEG;QACH,+BAAe;QAEf;;WAEG;QACH,IAAA,sBAAM,EAAC;YACL;;eAEG;YACH,KAAK,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;YAErC;;eAEG;YACH,OAAO,EAAE,IAAA,mBAAK,EAAC,+BAAuB,CAAC;SACxC,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// FIXME: This rule seems to be triggering a false positive on the `KeyringEvents`.\n\nimport {\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 {\n CaipAssetTypeStruct,\n CaipAssetTypeOrIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n FungibleAssetAmountStruct,\n KeyringAccountStruct,\n TransactionStruct,\n MetaMaskOptionsStruct,\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 *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayConfirmation: exactOptional(boolean()),\n\n /**\n * Instructs MetaMask to display the name confirmation dialog in the UI.\n * Otherwise, the account will be added with the suggested name, if it's not\n * already in use; if it is, a suffix will be appended to the name to make it\n * unique.\n *\n * **Note:** This is not guaranteed to be honored by the MetaMask client.\n */\n displayAccountNameSuggestion: exactOptional(boolean()),\n\n /**\n * Metamask internal options.\n */\n ...MetaMaskOptionsStruct.schema,\n }),\n});\nexport type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;\nexport type AccountCreatedEventPayload = AccountCreatedEvent['params'];\n\nexport const AccountUpdatedEventStruct = object({\n method: literal(`${KeyringEvent.AccountUpdated}`),\n params: object({\n /**\n * Updated account object.\n */\n account: KeyringAccountStruct,\n }),\n});\nexport type AccountUpdatedEvent = Infer<typeof AccountUpdatedEventStruct>;\nexport type AccountUpdatedEventPayload = AccountUpdatedEvent['params'];\n\nexport const AccountDeletedEventStruct = object({\n method: literal(`${KeyringEvent.AccountDeleted}`),\n params: object({\n /**\n * Deleted account ID.\n */\n id: UuidStruct,\n }),\n});\nexport type AccountDeletedEvent = Infer<typeof AccountDeletedEventStruct>;\nexport type AccountDeletedEventPayload = AccountDeletedEvent['params'];\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});\nexport type RequestApprovedEvent = Infer<typeof RequestApprovedEventStruct>;\nexport type RequestApprovedEventPayload = RequestApprovedEvent['params'];\n\nexport const RequestRejectedEventStruct = object({\n method: literal(`${KeyringEvent.RequestRejected}`),\n params: object({\n /**\n * Request ID.\n */\n id: UuidStruct,\n }),\n});\nexport type RequestRejectedEvent = Infer<typeof RequestRejectedEventStruct>;\nexport type RequestRejectedEventPayload = RequestRejectedEvent['params'];\n\n// Assets related events:\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 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});\nexport type AccountBalancesUpdatedEvent = Infer<\n typeof AccountBalancesUpdatedEventStruct\n>;\nexport type AccountBalancesUpdatedEventPayload =\n AccountBalancesUpdatedEvent['params'];\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 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});\nexport type AccountTransactionsUpdatedEvent = Infer<\n typeof AccountTransactionsUpdatedEventStruct\n>;\nexport type AccountTransactionsUpdatedEventPayload =\n AccountTransactionsUpdatedEvent['params'];\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 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});\nexport type AccountAssetListUpdatedEvent = Infer<\n typeof AccountAssetListUpdatedEventStruct\n>;\nexport type AccountAssetListUpdatedEventPayload =\n AccountAssetListUpdatedEvent['params'];\n\n/**\n * Keyring events.\n */\n// For some reason, eslint sometimes infer one of those members as `any`...\ntype KeyringEvents =\n | AccountCreatedEvent\n | AccountUpdatedEvent\n | AccountDeletedEvent\n | AccountAssetListUpdatedEvent\n | AccountBalancesUpdatedEvent\n | AccountTransactionsUpdatedEvent\n | RequestApprovedEvent\n | RequestRejectedEvent;\n\n/**\n * Extract the payload for a given `KeyringEvent` event.\n */\nexport type KeyringEventPayload<Event extends KeyringEvent> = Extract<\n KeyringEvents,\n // We need to use a literal string here, since that is what `KeyringEvents`\n // is using (probably because of `superstruct`.\n { method: `${Event}` }\n>['params'];\n"]}
package/dist/events.d.cts CHANGED
@@ -101,6 +101,8 @@ export declare const AccountCreatedEventStruct: import("@metamask/superstruct").
101
101
  displayAccountNameSuggestion: import("@metamask/superstruct").Struct<boolean | import("@metamask/keyring-utils").ExactOptionalTag, null>;
102
102
  }>;
103
103
  }>;
104
+ export type AccountCreatedEvent = Infer<typeof AccountCreatedEventStruct>;
105
+ export type AccountCreatedEventPayload = AccountCreatedEvent['params'];
104
106
  export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").Struct<{
105
107
  method: "notify:accountUpdated";
106
108
  params: {
@@ -150,6 +152,8 @@ export declare const AccountUpdatedEventStruct: import("@metamask/superstruct").
150
152
  }>;
151
153
  }>;
152
154
  }>;
155
+ export type AccountUpdatedEvent = Infer<typeof AccountUpdatedEventStruct>;
156
+ export type AccountUpdatedEventPayload = AccountUpdatedEvent['params'];
153
157
  export declare const AccountDeletedEventStruct: import("@metamask/superstruct").Struct<{
154
158
  method: "notify:accountDeleted";
155
159
  params: {
@@ -166,6 +170,8 @@ export declare const AccountDeletedEventStruct: import("@metamask/superstruct").
166
170
  id: import("@metamask/superstruct").Struct<string, null>;
167
171
  }>;
168
172
  }>;
173
+ export type AccountDeletedEvent = Infer<typeof AccountDeletedEventStruct>;
174
+ export type AccountDeletedEventPayload = AccountDeletedEvent['params'];
169
175
  export declare const RequestApprovedEventStruct: import("@metamask/superstruct").Struct<{
170
176
  method: "notify:requestApproved";
171
177
  params: {
@@ -188,6 +194,8 @@ export declare const RequestApprovedEventStruct: import("@metamask/superstruct")
188
194
  result: import("@metamask/superstruct").Struct<import("@metamask/utils").Json, unknown>;
189
195
  }>;
190
196
  }>;
197
+ export type RequestApprovedEvent = Infer<typeof RequestApprovedEventStruct>;
198
+ export type RequestApprovedEventPayload = RequestApprovedEvent['params'];
191
199
  export declare const RequestRejectedEventStruct: import("@metamask/superstruct").Struct<{
192
200
  method: "notify:requestRejected";
193
201
  params: {
@@ -204,6 +212,15 @@ export declare const RequestRejectedEventStruct: import("@metamask/superstruct")
204
212
  id: import("@metamask/superstruct").Struct<string, null>;
205
213
  }>;
206
214
  }>;
215
+ export type RequestRejectedEvent = Infer<typeof RequestRejectedEventStruct>;
216
+ export type RequestRejectedEventPayload = RequestRejectedEvent['params'];
217
+ /**
218
+ * Event emitted when the balances of an account are updated.
219
+ *
220
+ * Only changes are reported.
221
+ *
222
+ * The Snap can choose to emit this event for multiple accounts at once.
223
+ */
207
224
  export declare const AccountBalancesUpdatedEventStruct: import("@metamask/superstruct").Struct<{
208
225
  method: "notify:accountBalancesUpdated";
209
226
  params: {
@@ -229,20 +246,21 @@ export declare const AccountBalancesUpdatedEventStruct: import("@metamask/supers
229
246
  }>>, null>;
230
247
  }>;
231
248
  }>;
249
+ export type AccountBalancesUpdatedEvent = Infer<typeof AccountBalancesUpdatedEventStruct>;
250
+ export type AccountBalancesUpdatedEventPayload = AccountBalancesUpdatedEvent['params'];
232
251
  /**
233
- * Event emitted when the balances of an account are updated.
252
+ * Event emitted when the transactions of an account are updated (added or
253
+ * changed).
234
254
  *
235
255
  * Only changes are reported.
236
256
  *
237
257
  * The Snap can choose to emit this event for multiple accounts at once.
238
258
  */
239
- export type AccountBalancesUpdatedEvent = Infer<typeof AccountBalancesUpdatedEventStruct>;
240
- export type AccountBalancesUpdatedEventPayload = AccountBalancesUpdatedEvent['params'];
241
259
  export declare const AccountTransactionsUpdatedEventStruct: import("@metamask/superstruct").Struct<{
242
260
  method: "notify:accountTransactionsUpdated";
243
261
  params: {
244
262
  transactions: Record<string, {
245
- type: "send" | "receive" | "swap";
263
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
246
264
  id: string;
247
265
  from: {
248
266
  address: string;
@@ -294,7 +312,7 @@ export declare const AccountTransactionsUpdatedEventStruct: import("@metamask/su
294
312
  method: import("@metamask/superstruct").Struct<"notify:accountTransactionsUpdated", "notify:accountTransactionsUpdated">;
295
313
  params: import("@metamask/superstruct").Struct<{
296
314
  transactions: Record<string, {
297
- type: "send" | "receive" | "swap";
315
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
298
316
  id: string;
299
317
  from: {
300
318
  address: string;
@@ -346,7 +364,7 @@ export declare const AccountTransactionsUpdatedEventStruct: import("@metamask/su
346
364
  * Transactions updates of accounts owned by the Snap.
347
365
  */
348
366
  transactions: import("@metamask/superstruct").Struct<Record<string, {
349
- type: "send" | "receive" | "swap";
367
+ type: "unknown" | "send" | "receive" | "swap" | "bridge:send" | "bridge:receive";
350
368
  id: string;
351
369
  from: {
352
370
  address: string;
@@ -395,16 +413,15 @@ export declare const AccountTransactionsUpdatedEventStruct: import("@metamask/su
395
413
  }[]>, null>;
396
414
  }>;
397
415
  }>;
416
+ export type AccountTransactionsUpdatedEvent = Infer<typeof AccountTransactionsUpdatedEventStruct>;
417
+ export type AccountTransactionsUpdatedEventPayload = AccountTransactionsUpdatedEvent['params'];
398
418
  /**
399
- * Event emitted when the transactions of an account are updated (added or
400
- * changed).
419
+ * Event emitted when the assets of an account are updated.
401
420
  *
402
421
  * Only changes are reported.
403
422
  *
404
423
  * The Snap can choose to emit this event for multiple accounts at once.
405
424
  */
406
- export type AccountTransactionsUpdatedEvent = Infer<typeof AccountTransactionsUpdatedEventStruct>;
407
- export type AccountTransactionsUpdatedEventPayload = AccountTransactionsUpdatedEvent['params'];
408
425
  export declare const AccountAssetListUpdatedEventStruct: import("@metamask/superstruct").Struct<{
409
426
  method: "notify:accountAssetListUpdated";
410
427
  params: {
@@ -430,13 +447,17 @@ export declare const AccountAssetListUpdatedEventStruct: import("@metamask/super
430
447
  }>, null>;
431
448
  }>;
432
449
  }>;
433
- /**
434
- * Event emitted when the assets of an account are updated.
435
- *
436
- * Only changes are reported.
437
- *
438
- * The Snap can choose to emit this event for multiple accounts at once.
439
- */
440
450
  export type AccountAssetListUpdatedEvent = Infer<typeof AccountAssetListUpdatedEventStruct>;
441
451
  export type AccountAssetListUpdatedEventPayload = AccountAssetListUpdatedEvent['params'];
452
+ /**
453
+ * Keyring events.
454
+ */
455
+ type KeyringEvents = AccountCreatedEvent | AccountUpdatedEvent | AccountDeletedEvent | AccountAssetListUpdatedEvent | AccountBalancesUpdatedEvent | AccountTransactionsUpdatedEvent | RequestApprovedEvent | RequestRejectedEvent;
456
+ /**
457
+ * Extract the payload for a given `KeyringEvent` event.
458
+ */
459
+ export type KeyringEventPayload<Event extends KeyringEvent> = Extract<KeyringEvents, {
460
+ method: `${Event}`;
461
+ }>['params'];
462
+ export {};
442
463
  //# sourceMappingURL=events.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.cts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAenD;;GAEG;AACH,oBAAY,YAAY;IAEtB,cAAc,0BAA0B;IACxC,cAAc,0BAA0B;IACx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