@metamask/keyring-api 11.0.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/api/account.cjs +3 -4
  3. package/dist/api/account.cjs.map +1 -1
  4. package/dist/api/account.d.cts +1 -1
  5. package/dist/api/account.d.cts.map +1 -1
  6. package/dist/api/account.d.mts +1 -1
  7. package/dist/api/account.d.mts.map +1 -1
  8. package/dist/api/account.mjs +1 -2
  9. package/dist/api/account.mjs.map +1 -1
  10. package/dist/api/asset.cjs +82 -0
  11. package/dist/api/asset.cjs.map +1 -0
  12. package/dist/api/asset.d.cts +93 -0
  13. package/dist/api/asset.d.cts.map +1 -0
  14. package/dist/api/asset.d.mts +93 -0
  15. package/dist/api/asset.d.mts.map +1 -0
  16. package/dist/api/asset.mjs +79 -0
  17. package/dist/api/asset.mjs.map +1 -0
  18. package/dist/api/balance.cjs +3 -4
  19. package/dist/api/balance.cjs.map +1 -1
  20. package/dist/api/balance.d.cts +1 -1
  21. package/dist/api/balance.d.cts.map +1 -1
  22. package/dist/api/balance.d.mts +1 -1
  23. package/dist/api/balance.d.mts.map +1 -1
  24. package/dist/api/balance.mjs +1 -2
  25. package/dist/api/balance.mjs.map +1 -1
  26. package/dist/api/caip.cjs +3 -3
  27. package/dist/api/caip.cjs.map +1 -1
  28. package/dist/api/caip.d.cts.map +1 -1
  29. package/dist/api/caip.d.mts.map +1 -1
  30. package/dist/api/caip.mjs +1 -1
  31. package/dist/api/caip.mjs.map +1 -1
  32. package/dist/api/index.cjs +3 -0
  33. package/dist/api/index.cjs.map +1 -1
  34. package/dist/api/index.d.cts +4 -1
  35. package/dist/api/index.d.cts.map +1 -1
  36. package/dist/api/index.d.mts +4 -1
  37. package/dist/api/index.d.mts.map +1 -1
  38. package/dist/api/index.mjs +3 -0
  39. package/dist/api/index.mjs.map +1 -1
  40. package/dist/api/keyring.cjs +2 -0
  41. package/dist/api/keyring.cjs.map +1 -1
  42. package/dist/api/keyring.d.cts +14 -0
  43. package/dist/api/keyring.d.cts.map +1 -1
  44. package/dist/api/keyring.d.mts +14 -0
  45. package/dist/api/keyring.d.mts.map +1 -1
  46. package/dist/api/keyring.mjs +2 -0
  47. package/dist/api/keyring.mjs.map +1 -1
  48. package/dist/api/pagination.cjs +28 -0
  49. package/dist/api/pagination.cjs.map +1 -0
  50. package/dist/api/pagination.d.cts +59 -0
  51. package/dist/api/pagination.d.cts.map +1 -0
  52. package/dist/api/pagination.d.mts +59 -0
  53. package/dist/api/pagination.d.mts.map +1 -0
  54. package/dist/api/pagination.mjs +25 -0
  55. package/dist/api/pagination.mjs.map +1 -0
  56. package/dist/api/request.cjs +6 -7
  57. package/dist/api/request.cjs.map +1 -1
  58. package/dist/api/request.d.cts +5 -5
  59. package/dist/api/request.d.cts.map +1 -1
  60. package/dist/api/request.d.mts +5 -5
  61. package/dist/api/request.d.mts.map +1 -1
  62. package/dist/api/request.mjs +1 -2
  63. package/dist/api/request.mjs.map +1 -1
  64. package/dist/api/response.cjs +6 -6
  65. package/dist/api/response.cjs.map +1 -1
  66. package/dist/api/response.d.cts +1 -1
  67. package/dist/api/response.d.cts.map +1 -1
  68. package/dist/api/response.d.mts +1 -1
  69. package/dist/api/response.d.mts.map +1 -1
  70. package/dist/api/response.mjs +1 -1
  71. package/dist/api/response.mjs.map +1 -1
  72. package/dist/api/transaction.cjs +294 -0
  73. package/dist/api/transaction.cjs.map +1 -0
  74. package/dist/api/transaction.d.cts +773 -0
  75. package/dist/api/transaction.d.cts.map +1 -0
  76. package/dist/api/transaction.d.mts +773 -0
  77. package/dist/api/transaction.d.mts.map +1 -0
  78. package/dist/api/transaction.mjs +291 -0
  79. package/dist/api/transaction.mjs.map +1 -0
  80. package/dist/btc/types.cjs +2 -2
  81. package/dist/btc/types.cjs.map +1 -1
  82. package/dist/btc/types.d.cts +1 -1
  83. package/dist/btc/types.d.cts.map +1 -1
  84. package/dist/btc/types.d.mts +1 -1
  85. package/dist/btc/types.d.mts.map +1 -1
  86. package/dist/btc/types.mjs +2 -2
  87. package/dist/btc/types.mjs.map +1 -1
  88. package/dist/eth/erc4337/types.cjs +10 -11
  89. package/dist/eth/erc4337/types.cjs.map +1 -1
  90. package/dist/eth/erc4337/types.d.cts +4 -4
  91. package/dist/eth/erc4337/types.d.cts.map +1 -1
  92. package/dist/eth/erc4337/types.d.mts +4 -4
  93. package/dist/eth/erc4337/types.d.mts.map +1 -1
  94. package/dist/eth/erc4337/types.mjs +1 -2
  95. package/dist/eth/erc4337/types.mjs.map +1 -1
  96. package/dist/eth/types.cjs +6 -6
  97. package/dist/eth/types.cjs.map +1 -1
  98. package/dist/eth/types.d.cts +2 -2
  99. package/dist/eth/types.d.cts.map +1 -1
  100. package/dist/eth/types.d.mts +2 -2
  101. package/dist/eth/types.d.mts.map +1 -1
  102. package/dist/eth/types.mjs +1 -1
  103. package/dist/eth/types.mjs.map +1 -1
  104. package/dist/eth/utils.cjs.map +1 -1
  105. package/dist/eth/utils.d.cts.map +1 -1
  106. package/dist/eth/utils.d.mts.map +1 -1
  107. package/dist/eth/utils.mjs.map +1 -1
  108. package/dist/events.cjs +67 -1
  109. package/dist/events.cjs.map +1 -1
  110. package/dist/events.d.cts +161 -0
  111. package/dist/events.d.cts.map +1 -1
  112. package/dist/events.d.mts +161 -0
  113. package/dist/events.d.mts.map +1 -1
  114. package/dist/events.mjs +66 -0
  115. package/dist/events.mjs.map +1 -1
  116. package/dist/index.cjs +2 -8
  117. package/dist/index.cjs.map +1 -1
  118. package/dist/index.d.cts +3 -9
  119. package/dist/index.d.cts.map +1 -1
  120. package/dist/index.d.mts +3 -9
  121. package/dist/index.d.mts.map +1 -1
  122. package/dist/index.mjs +2 -8
  123. package/dist/index.mjs.map +1 -1
  124. package/dist/{internal/api.cjs → rpc.cjs} +78 -38
  125. package/dist/rpc.cjs.map +1 -0
  126. package/dist/{internal/api.d.cts → rpc.d.cts} +402 -59
  127. package/dist/rpc.d.cts.map +1 -0
  128. package/dist/{internal/api.d.mts → rpc.d.mts} +402 -59
  129. package/dist/rpc.d.mts.map +1 -0
  130. package/dist/{internal/api.mjs → rpc.mjs} +44 -5
  131. package/dist/rpc.mjs.map +1 -0
  132. package/dist/sol/types.cjs +3 -3
  133. package/dist/sol/types.cjs.map +1 -1
  134. package/dist/sol/types.d.cts +1 -1
  135. package/dist/sol/types.d.cts.map +1 -1
  136. package/dist/sol/types.d.mts +1 -1
  137. package/dist/sol/types.d.mts.map +1 -1
  138. package/dist/sol/types.mjs +1 -1
  139. package/dist/sol/types.mjs.map +1 -1
  140. package/package.json +11 -14
  141. package/dist/JsonRpcRequest.cjs +0 -13
  142. package/dist/JsonRpcRequest.cjs.map +0 -1
  143. package/dist/JsonRpcRequest.d.cts +0 -17
  144. package/dist/JsonRpcRequest.d.cts.map +0 -1
  145. package/dist/JsonRpcRequest.d.mts +0 -17
  146. package/dist/JsonRpcRequest.d.mts.map +0 -1
  147. package/dist/JsonRpcRequest.mjs +0 -10
  148. package/dist/JsonRpcRequest.mjs.map +0 -1
  149. package/dist/KeyringClient.cjs +0 -124
  150. package/dist/KeyringClient.cjs.map +0 -1
  151. package/dist/KeyringClient.d.cts +0 -29
  152. package/dist/KeyringClient.d.cts.map +0 -1
  153. package/dist/KeyringClient.d.mts +0 -29
  154. package/dist/KeyringClient.d.mts.map +0 -1
  155. package/dist/KeyringClient.mjs +0 -120
  156. package/dist/KeyringClient.mjs.map +0 -1
  157. package/dist/KeyringSnapRpcClient.cjs +0 -68
  158. package/dist/KeyringSnapRpcClient.cjs.map +0 -1
  159. package/dist/KeyringSnapRpcClient.d.cts +0 -40
  160. package/dist/KeyringSnapRpcClient.d.cts.map +0 -1
  161. package/dist/KeyringSnapRpcClient.d.mts +0 -40
  162. package/dist/KeyringSnapRpcClient.d.mts.map +0 -1
  163. package/dist/KeyringSnapRpcClient.mjs +0 -63
  164. package/dist/KeyringSnapRpcClient.mjs.map +0 -1
  165. package/dist/internal/api.cjs.map +0 -1
  166. package/dist/internal/api.d.cts.map +0 -1
  167. package/dist/internal/api.d.mts.map +0 -1
  168. package/dist/internal/api.mjs.map +0 -1
  169. package/dist/internal/eth/EthKeyring.cjs +0 -3
  170. package/dist/internal/eth/EthKeyring.cjs.map +0 -1
  171. package/dist/internal/eth/EthKeyring.d.cts +0 -34
  172. package/dist/internal/eth/EthKeyring.d.cts.map +0 -1
  173. package/dist/internal/eth/EthKeyring.d.mts +0 -34
  174. package/dist/internal/eth/EthKeyring.d.mts.map +0 -1
  175. package/dist/internal/eth/EthKeyring.mjs +0 -2
  176. package/dist/internal/eth/EthKeyring.mjs.map +0 -1
  177. package/dist/internal/eth/index.cjs +0 -3
  178. package/dist/internal/eth/index.cjs.map +0 -1
  179. package/dist/internal/eth/index.d.cts +0 -2
  180. package/dist/internal/eth/index.d.cts.map +0 -1
  181. package/dist/internal/eth/index.d.mts +0 -2
  182. package/dist/internal/eth/index.d.mts.map +0 -1
  183. package/dist/internal/eth/index.mjs +0 -2
  184. package/dist/internal/eth/index.mjs.map +0 -1
  185. package/dist/internal/events.cjs +0 -72
  186. package/dist/internal/events.cjs.map +0 -1
  187. package/dist/internal/events.d.cts +0 -162
  188. package/dist/internal/events.d.cts.map +0 -1
  189. package/dist/internal/events.d.mts +0 -162
  190. package/dist/internal/events.d.mts.map +0 -1
  191. package/dist/internal/events.mjs +0 -69
  192. package/dist/internal/events.mjs.map +0 -1
  193. package/dist/internal/index.cjs +0 -21
  194. package/dist/internal/index.cjs.map +0 -1
  195. package/dist/internal/index.d.cts +0 -6
  196. package/dist/internal/index.d.cts.map +0 -1
  197. package/dist/internal/index.d.mts +0 -6
  198. package/dist/internal/index.d.mts.map +0 -1
  199. package/dist/internal/index.mjs +0 -5
  200. package/dist/internal/index.mjs.map +0 -1
  201. package/dist/internal/rpc.cjs +0 -33
  202. package/dist/internal/rpc.cjs.map +0 -1
  203. package/dist/internal/rpc.d.cts +0 -26
  204. package/dist/internal/rpc.d.cts.map +0 -1
  205. package/dist/internal/rpc.d.mts +0 -26
  206. package/dist/internal/rpc.d.mts.map +0 -1
  207. package/dist/internal/rpc.mjs +0 -29
  208. package/dist/internal/rpc.mjs.map +0 -1
  209. package/dist/internal/types.cjs +0 -52
  210. package/dist/internal/types.cjs.map +0 -1
  211. package/dist/internal/types.d.cts +0 -392
  212. package/dist/internal/types.d.cts.map +0 -1
  213. package/dist/internal/types.d.mts +0 -392
  214. package/dist/internal/types.d.mts.map +0 -1
  215. package/dist/internal/types.mjs +0 -49
  216. package/dist/internal/types.mjs.map +0 -1
  217. package/dist/rpc-handler.cjs +0 -136
  218. package/dist/rpc-handler.cjs.map +0 -1
  219. package/dist/rpc-handler.d.cts +0 -30
  220. package/dist/rpc-handler.d.cts.map +0 -1
  221. package/dist/rpc-handler.d.mts +0 -30
  222. package/dist/rpc-handler.d.mts.map +0 -1
  223. package/dist/rpc-handler.mjs +0 -131
  224. package/dist/rpc-handler.mjs.map +0 -1
  225. package/dist/snap-utils.cjs +0 -20
  226. package/dist/snap-utils.cjs.map +0 -1
  227. package/dist/snap-utils.d.cts +0 -12
  228. package/dist/snap-utils.d.cts.map +0 -1
  229. package/dist/snap-utils.d.mts +0 -12
  230. package/dist/snap-utils.d.mts.map +0 -1
  231. package/dist/snap-utils.mjs +0 -17
  232. package/dist/snap-utils.mjs.map +0 -1
  233. package/dist/superstruct.cjs +0 -80
  234. package/dist/superstruct.cjs.map +0 -1
  235. package/dist/superstruct.d.cts +0 -84
  236. package/dist/superstruct.d.cts.map +0 -1
  237. package/dist/superstruct.d.mts +0 -84
  238. package/dist/superstruct.d.mts.map +0 -1
  239. package/dist/superstruct.mjs +0 -74
  240. package/dist/superstruct.mjs.map +0 -1
  241. package/dist/utils/index.cjs +0 -19
  242. package/dist/utils/index.cjs.map +0 -1
  243. package/dist/utils/index.d.cts +0 -3
  244. package/dist/utils/index.d.cts.map +0 -1
  245. package/dist/utils/index.d.mts +0 -3
  246. package/dist/utils/index.d.mts.map +0 -1
  247. package/dist/utils/index.mjs +0 -3
  248. package/dist/utils/index.mjs.map +0 -1
  249. package/dist/utils/types.cjs +0 -29
  250. package/dist/utils/types.cjs.map +0 -1
  251. package/dist/utils/types.d.cts +0 -18
  252. package/dist/utils/types.d.cts.map +0 -1
  253. package/dist/utils/types.d.mts +0 -18
  254. package/dist/utils/types.d.mts.map +0 -1
  255. package/dist/utils/types.mjs +0 -26
  256. package/dist/utils/types.mjs.map +0 -1
  257. package/dist/utils/typing.cjs +0 -20
  258. package/dist/utils/typing.cjs.map +0 -1
  259. package/dist/utils/typing.d.cts +0 -33
  260. package/dist/utils/typing.d.cts.map +0 -1
  261. package/dist/utils/typing.d.mts +0 -33
  262. package/dist/utils/typing.d.mts.map +0 -1
  263. package/dist/utils/typing.mjs +0 -17
  264. package/dist/utils/typing.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [12.0.0]
11
+
12
+ ### Changed
13
+
14
+ - Use `ts-bridge/cli@0.6.1` ([#118](https://github.com/MetaMask/accounts/pull/118))
15
+ - This new version fixes a bug with CJS re-exports.
16
+ - **BREAKING:** Split into several smaller packages ([#24](https://github.com/MetaMask/accounts/pull/24))
17
+ - This should improve dependencies management.
18
+ - Internal related types (internal to both clients) have been moved to `keyring-internal-*` packages.
19
+ - Keyring API clients (mainly used by dapps) have been moved to `keyring-snap-client` package.
20
+ - Common utils have been moevd to `keyring-utils` package.
21
+
22
+ ## [11.1.0]
23
+
24
+ ### Added
25
+
26
+ - Add `listAccountTransactions` keyring method ([#41](https://github.com/MetaMask/accounts/pull/41))
27
+
10
28
  ## [11.0.0]
11
29
 
12
30
  ### Added
@@ -438,7 +456,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
438
456
  - SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
439
457
  - Helper functions to create keyring handler in the snap.
440
458
 
441
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.0.0...HEAD
459
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@12.0.0...HEAD
460
+ [12.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.1.0...@metamask/keyring-api@12.0.0
461
+ [11.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.0.0...@metamask/keyring-api@11.1.0
442
462
  [11.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@10.1.0...@metamask/keyring-api@11.0.0
443
463
  [10.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@10.0.0...@metamask/keyring-api@10.1.0
444
464
  [10.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@9.0.0...@metamask/keyring-api@10.0.0
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KeyringAccountStruct = exports.SolAccountType = exports.BtcAccountType = exports.EthAccountType = void 0;
4
+ const keyring_utils_1 = require("@metamask/keyring-utils");
4
5
  const superstruct_1 = require("@metamask/superstruct");
5
6
  const utils_1 = require("@metamask/utils");
6
- const superstruct_2 = require("../superstruct.cjs");
7
- const utils_2 = require("../utils/index.cjs");
8
7
  /**
9
8
  * Supported Ethereum account types.
10
9
  */
@@ -34,11 +33,11 @@ var SolAccountType;
34
33
  *
35
34
  * See {@link KeyringAccount}.
36
35
  */
37
- exports.KeyringAccountStruct = (0, superstruct_2.object)({
36
+ exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
38
37
  /**
39
38
  * Account ID (UUIDv4).
40
39
  */
41
- id: utils_2.UuidStruct,
40
+ id: keyring_utils_1.UuidStruct,
42
41
  /**
43
42
  * Account type.
44
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AACA,uDAAqE;AACrE,2CAA6C;AAE7C,oDAAwC;AACxC,8CAAsC;AAEtC;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAWD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,oBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,kBAAU;IAEd;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,WAAW,EAAE;KAChC,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n `${SolAccountType.DataAccount}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
1
+ {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,2DAA6D;AAE7D,uDAAqE;AACrE,2CAA6C;AAE7C;;GAEG;AACH,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED;;GAEG;AACH,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAWD;;;;;;GAMG;AACU,QAAA,oBAAoB,GAAG,IAAA,sBAAM,EAAC;IACzC;;OAEG;IACH,EAAE,EAAE,0BAAU;IAEd;;OAEG;IACH,IAAI,EAAE,IAAA,mBAAK,EAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,WAAW,EAAE;KAChC,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,kBAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n `${SolAccountType.DataAccount}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
@@ -32,8 +32,8 @@ export type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccountType.Erc
32
32
  export declare const KeyringAccountStruct: import("@metamask/superstruct").Struct<{
33
33
  type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh" | "solana:data-account";
34
34
  id: string;
35
- address: string;
36
35
  options: Record<string, import("@metamask/utils").Json>;
36
+ address: string;
37
37
  methods: string[];
38
38
  }, {
39
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAOnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -32,8 +32,8 @@ export type KeyringAccountType = `${EthAccountType.Eoa}` | `${EthAccountType.Erc
32
32
  export declare const KeyringAccountStruct: import("@metamask/superstruct").Struct<{
33
33
  type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh" | "solana:data-account";
34
34
  id: string;
35
- address: string;
36
35
  options: Record<string, import("@metamask/utils").Json>;
36
+ address: string;
37
37
  methods: string[];
38
38
  }, {
39
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAOnD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
1
+ {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -1,7 +1,6 @@
1
+ import { object, UuidStruct } from "@metamask/keyring-utils";
1
2
  import { array, enums, record, string } from "@metamask/superstruct";
2
3
  import { JsonStruct } from "@metamask/utils";
3
- import { object } from "../superstruct.mjs";
4
- import { UuidStruct } from "../utils/index.mjs";
5
4
  /**
6
5
  * Supported Ethereum account types.
7
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"account.mjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AACrE,OAAO,EAAE,UAAU,EAAE,wBAAwB;AAE7C,OAAO,EAAE,MAAM,EAAE,2BAAuB;AACxC,OAAO,EAAE,UAAU,EAAE,2BAAiB;AAEtC;;GAEG;AACH,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC;;OAEG;IACH,EAAE,EAAE,UAAU;IAEd;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,WAAW,EAAE;KAChC,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nimport { object } from '../superstruct';\nimport { UuidStruct } from '../utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n `${SolAccountType.DataAccount}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
1
+ {"version":3,"file":"account.mjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gCAAgC;AAE7D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AACrE,OAAO,EAAE,UAAU,EAAE,wBAAwB;AAE7C;;GAEG;AACH,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,oCAAkB,CAAA;IAClB,4CAA0B,CAAA;AAC5B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,0CAAwB,CAAA;AAC1B,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,qDAAmC,CAAA;AACrC,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC;;OAEG;IACH,EAAE,EAAE,UAAU;IAEd;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;QACV,GAAG,cAAc,CAAC,GAAG,EAAE;QACvB,GAAG,cAAc,CAAC,OAAO,EAAE;QAC3B,GAAG,cAAc,CAAC,MAAM,EAAE;QAC1B,GAAG,cAAc,CAAC,WAAW,EAAE;KAChC,CAAC;IAEF;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE;IAEjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAErC;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;CACzB,CAAC,CAAC","sourcesContent":["import { object, UuidStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, record, string } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: UuidStruct,\n\n /**\n * Account type.\n */\n type: enums([\n `${EthAccountType.Eoa}`,\n `${EthAccountType.Erc4337}`,\n `${BtcAccountType.P2wpkh}`,\n `${SolAccountType.DataAccount}`,\n ]),\n\n /**\n * Account main address.\n */\n address: string(),\n\n /**\n * Account options.\n */\n options: record(string(), JsonStruct),\n\n /**\n * Account supported methods.\n */\n methods: array(string()),\n});\n\n/**\n * Keyring Account type represents an account and its properties from the\n * point of view of the keyring.\n */\nexport type KeyringAccount = Infer<typeof KeyringAccountStruct>;\n"]}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssetStruct = exports.NonFungibleAssetStruct = exports.FungibleAssetStruct = void 0;
4
+ const keyring_utils_1 = require("@metamask/keyring-utils");
5
+ const superstruct_1 = require("@metamask/superstruct");
6
+ const utils_1 = require("@metamask/utils");
7
+ /**
8
+ * Fungible asset struct.
9
+ */
10
+ exports.FungibleAssetStruct = (0, keyring_utils_1.object)({
11
+ /**
12
+ * It is a fungible asset.
13
+ */
14
+ fungible: (0, superstruct_1.literal)(true),
15
+ /**
16
+ * Asset type (CAIP-19).
17
+ */
18
+ type: utils_1.CaipAssetTypeStruct,
19
+ /**
20
+ * Asset unit.
21
+ */
22
+ unit: (0, superstruct_1.string)(),
23
+ /**
24
+ * Asset amount.
25
+ */
26
+ amount: keyring_utils_1.StringNumberStruct,
27
+ });
28
+ /**
29
+ * Non-fungible asset struct.
30
+ */
31
+ exports.NonFungibleAssetStruct = (0, keyring_utils_1.object)({
32
+ /**
33
+ * It is a non-fungible asset.
34
+ */
35
+ fungible: (0, superstruct_1.literal)(false),
36
+ /**
37
+ * Asset ID (CAIP-19).
38
+ */
39
+ id: utils_1.CaipAssetIdStruct,
40
+ });
41
+ /**
42
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
43
+ * assets include an amount and a unit in addition to the asset type. While
44
+ * non-fungible assets include only an asset ID.
45
+ *
46
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
47
+ *
48
+ * All assets have a `fungible` property that is used to tag the union and
49
+ * allow the following pattern:
50
+ *
51
+ * ```ts
52
+ * if (asset.fungible) {
53
+ * // Use asset.type
54
+ * } else {
55
+ * // Use asset.id
56
+ * }
57
+ * ```
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * {
62
+ * fungible: true,
63
+ * type: 'eip155:1/slip44:60',
64
+ * unit: 'ETH',
65
+ * amount: '0.01',
66
+ * }
67
+ * ```
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * {
72
+ * fungible: false,
73
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
74
+ * }
75
+ * ```
76
+ */
77
+ exports.AssetStruct = (0, keyring_utils_1.selectiveUnion)((value) => {
78
+ return (0, utils_1.isPlainObject)(value) && !value.fungible
79
+ ? exports.NonFungibleAssetStruct
80
+ : exports.FungibleAssetStruct;
81
+ });
82
+ //# sourceMappingURL=asset.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.cjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":";;;AAAA,2DAIiC;AAEjC,uDAAwD;AACxD,2CAIyB;AAEzB;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,sBAAM,EAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,2BAAmB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,oBAAM,GAAE;IAEd;;OAEG;IACH,MAAM,EAAE,kCAAkB;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,sBAAM,EAAC;IAC3C;;OAEG;IACH,QAAQ,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,yBAAiB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,WAAW,GAAG,IAAA,8BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACvD,OAAO,IAAA,qBAAa,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAC5C,CAAC,CAAC,8BAAsB;QACxB,CAAC,CAAC,2BAAmB,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import {\n object,\n selectiveUnion,\n StringNumberStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { literal, string } from '@metamask/superstruct';\nimport {\n CaipAssetIdStruct,\n CaipAssetTypeStruct,\n isPlainObject,\n} from '@metamask/utils';\n\n/**\n * Fungible asset struct.\n */\nexport const FungibleAssetStruct = object({\n /**\n * It is a fungible asset.\n */\n fungible: literal(true),\n\n /**\n * Asset type (CAIP-19).\n */\n type: CaipAssetTypeStruct,\n\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\n\n/**\n * Non-fungible asset struct.\n */\nexport const NonFungibleAssetStruct = object({\n /**\n * It is a non-fungible asset.\n */\n fungible: literal(false),\n\n /**\n * Asset ID (CAIP-19).\n */\n id: CaipAssetIdStruct,\n});\n\n/**\n * Asset struct. This represents a fungible or non-fungible asset. Fungible\n * assets include an amount and a unit in addition to the asset type. While\n * non-fungible assets include only an asset ID.\n *\n * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.\n *\n * All assets have a `fungible` property that is used to tag the union and\n * allow the following pattern:\n *\n * ```ts\n * if (asset.fungible) {\n * // Use asset.type\n * } else {\n * // Use asset.id\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * }\n * ```\n */\nexport const AssetStruct = selectiveUnion((value: any) => {\n return isPlainObject(value) && !value.fungible\n ? NonFungibleAssetStruct\n : FungibleAssetStruct;\n});\n\n/**\n * Asset type {@see AssetStruct}.\n */\nexport type Asset = Infer<typeof AssetStruct>;\n"]}
@@ -0,0 +1,93 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Fungible asset struct.
4
+ */
5
+ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
6
+ unit: string;
7
+ type: `${string}:${string}/${string}:${string}`;
8
+ fungible: true;
9
+ amount: string;
10
+ }, {
11
+ /**
12
+ * It is a fungible asset.
13
+ */
14
+ fungible: import("@metamask/superstruct").Struct<true, true>;
15
+ /**
16
+ * Asset type (CAIP-19).
17
+ */
18
+ type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
19
+ /**
20
+ * Asset unit.
21
+ */
22
+ unit: import("@metamask/superstruct").Struct<string, null>;
23
+ /**
24
+ * Asset amount.
25
+ */
26
+ amount: import("@metamask/superstruct").Struct<string, null>;
27
+ }>;
28
+ /**
29
+ * Non-fungible asset struct.
30
+ */
31
+ export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
32
+ id: `${string}:${string}/${string}:${string}/${string}`;
33
+ fungible: false;
34
+ }, {
35
+ /**
36
+ * It is a non-fungible asset.
37
+ */
38
+ fungible: import("@metamask/superstruct").Struct<false, false>;
39
+ /**
40
+ * Asset ID (CAIP-19).
41
+ */
42
+ id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
43
+ }>;
44
+ /**
45
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
46
+ * assets include an amount and a unit in addition to the asset type. While
47
+ * non-fungible assets include only an asset ID.
48
+ *
49
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
50
+ *
51
+ * All assets have a `fungible` property that is used to tag the union and
52
+ * allow the following pattern:
53
+ *
54
+ * ```ts
55
+ * if (asset.fungible) {
56
+ * // Use asset.type
57
+ * } else {
58
+ * // Use asset.id
59
+ * }
60
+ * ```
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * {
65
+ * fungible: true,
66
+ * type: 'eip155:1/slip44:60',
67
+ * unit: 'ETH',
68
+ * amount: '0.01',
69
+ * }
70
+ * ```
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * {
75
+ * fungible: false,
76
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
77
+ * }
78
+ * ```
79
+ */
80
+ export declare const AssetStruct: import("@metamask/superstruct").Struct<{
81
+ unit: string;
82
+ type: `${string}:${string}/${string}:${string}`;
83
+ fungible: true;
84
+ amount: string;
85
+ } | {
86
+ id: `${string}:${string}/${string}:${string}/${string}`;
87
+ fungible: false;
88
+ }, null>;
89
+ /**
90
+ * Asset type {@see AssetStruct}.
91
+ */
92
+ export type Asset = Infer<typeof AssetStruct>;
93
+ //# sourceMappingURL=asset.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.cts","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAQnD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,WAAW;;;;;;;;QAItB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,93 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Fungible asset struct.
4
+ */
5
+ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
6
+ unit: string;
7
+ type: `${string}:${string}/${string}:${string}`;
8
+ fungible: true;
9
+ amount: string;
10
+ }, {
11
+ /**
12
+ * It is a fungible asset.
13
+ */
14
+ fungible: import("@metamask/superstruct").Struct<true, true>;
15
+ /**
16
+ * Asset type (CAIP-19).
17
+ */
18
+ type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
19
+ /**
20
+ * Asset unit.
21
+ */
22
+ unit: import("@metamask/superstruct").Struct<string, null>;
23
+ /**
24
+ * Asset amount.
25
+ */
26
+ amount: import("@metamask/superstruct").Struct<string, null>;
27
+ }>;
28
+ /**
29
+ * Non-fungible asset struct.
30
+ */
31
+ export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Struct<{
32
+ id: `${string}:${string}/${string}:${string}/${string}`;
33
+ fungible: false;
34
+ }, {
35
+ /**
36
+ * It is a non-fungible asset.
37
+ */
38
+ fungible: import("@metamask/superstruct").Struct<false, false>;
39
+ /**
40
+ * Asset ID (CAIP-19).
41
+ */
42
+ id: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
43
+ }>;
44
+ /**
45
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
46
+ * assets include an amount and a unit in addition to the asset type. While
47
+ * non-fungible assets include only an asset ID.
48
+ *
49
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
50
+ *
51
+ * All assets have a `fungible` property that is used to tag the union and
52
+ * allow the following pattern:
53
+ *
54
+ * ```ts
55
+ * if (asset.fungible) {
56
+ * // Use asset.type
57
+ * } else {
58
+ * // Use asset.id
59
+ * }
60
+ * ```
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * {
65
+ * fungible: true,
66
+ * type: 'eip155:1/slip44:60',
67
+ * unit: 'ETH',
68
+ * amount: '0.01',
69
+ * }
70
+ * ```
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * {
75
+ * fungible: false,
76
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
77
+ * }
78
+ * ```
79
+ */
80
+ export declare const AssetStruct: import("@metamask/superstruct").Struct<{
81
+ unit: string;
82
+ type: `${string}:${string}/${string}:${string}`;
83
+ fungible: true;
84
+ amount: string;
85
+ } | {
86
+ id: `${string}:${string}/${string}:${string}/${string}`;
87
+ fungible: false;
88
+ }, null>;
89
+ /**
90
+ * Asset type {@see AssetStruct}.
91
+ */
92
+ export type Asset = Infer<typeof AssetStruct>;
93
+ //# sourceMappingURL=asset.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.mts","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAQnD;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAC9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,WAAW;;;;;;;;QAItB,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { object, selectiveUnion, StringNumberStruct } from "@metamask/keyring-utils";
2
+ import { literal, string } from "@metamask/superstruct";
3
+ import { CaipAssetIdStruct, CaipAssetTypeStruct, isPlainObject } from "@metamask/utils";
4
+ /**
5
+ * Fungible asset struct.
6
+ */
7
+ export const FungibleAssetStruct = object({
8
+ /**
9
+ * It is a fungible asset.
10
+ */
11
+ fungible: literal(true),
12
+ /**
13
+ * Asset type (CAIP-19).
14
+ */
15
+ type: CaipAssetTypeStruct,
16
+ /**
17
+ * Asset unit.
18
+ */
19
+ unit: string(),
20
+ /**
21
+ * Asset amount.
22
+ */
23
+ amount: StringNumberStruct,
24
+ });
25
+ /**
26
+ * Non-fungible asset struct.
27
+ */
28
+ export const NonFungibleAssetStruct = object({
29
+ /**
30
+ * It is a non-fungible asset.
31
+ */
32
+ fungible: literal(false),
33
+ /**
34
+ * Asset ID (CAIP-19).
35
+ */
36
+ id: CaipAssetIdStruct,
37
+ });
38
+ /**
39
+ * Asset struct. This represents a fungible or non-fungible asset. Fungible
40
+ * assets include an amount and a unit in addition to the asset type. While
41
+ * non-fungible assets include only an asset ID.
42
+ *
43
+ * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.
44
+ *
45
+ * All assets have a `fungible` property that is used to tag the union and
46
+ * allow the following pattern:
47
+ *
48
+ * ```ts
49
+ * if (asset.fungible) {
50
+ * // Use asset.type
51
+ * } else {
52
+ * // Use asset.id
53
+ * }
54
+ * ```
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * {
59
+ * fungible: true,
60
+ * type: 'eip155:1/slip44:60',
61
+ * unit: 'ETH',
62
+ * amount: '0.01',
63
+ * }
64
+ * ```
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * {
69
+ * fungible: false,
70
+ * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',
71
+ * }
72
+ * ```
73
+ */
74
+ export const AssetStruct = selectiveUnion((value) => {
75
+ return isPlainObject(value) && !value.fungible
76
+ ? NonFungibleAssetStruct
77
+ : FungibleAssetStruct;
78
+ });
79
+ //# sourceMappingURL=asset.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.mjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,kBAAkB,EACnB,gCAAgC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AACxD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACd,wBAAwB;AAEzB;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;IACxC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IAEvB;;OAEG;IACH,IAAI,EAAE,mBAAmB;IAEzB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE;IAEd;;OAEG;IACH,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IAExB;;OAEG;IACH,EAAE,EAAE,iBAAiB;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACvD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAC5C,CAAC,CAAC,sBAAsB;QACxB,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import {\n object,\n selectiveUnion,\n StringNumberStruct,\n} from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { literal, string } from '@metamask/superstruct';\nimport {\n CaipAssetIdStruct,\n CaipAssetTypeStruct,\n isPlainObject,\n} from '@metamask/utils';\n\n/**\n * Fungible asset struct.\n */\nexport const FungibleAssetStruct = object({\n /**\n * It is a fungible asset.\n */\n fungible: literal(true),\n\n /**\n * Asset type (CAIP-19).\n */\n type: CaipAssetTypeStruct,\n\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\n\n/**\n * Non-fungible asset struct.\n */\nexport const NonFungibleAssetStruct = object({\n /**\n * It is a non-fungible asset.\n */\n fungible: literal(false),\n\n /**\n * Asset ID (CAIP-19).\n */\n id: CaipAssetIdStruct,\n});\n\n/**\n * Asset struct. This represents a fungible or non-fungible asset. Fungible\n * assets include an amount and a unit in addition to the asset type. While\n * non-fungible assets include only an asset ID.\n *\n * See {@link NonFungibleAssetStruct} and {@link FungibleAssetStruct}.\n *\n * All assets have a `fungible` property that is used to tag the union and\n * allow the following pattern:\n *\n * ```ts\n * if (asset.fungible) {\n * // Use asset.type\n * } else {\n * // Use asset.id\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: true,\n * type: 'eip155:1/slip44:60',\n * unit: 'ETH',\n * amount: '0.01',\n * }\n * ```\n *\n * @example\n * ```ts\n * {\n * fungible: false,\n * id: 'eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769',\n * }\n * ```\n */\nexport const AssetStruct = selectiveUnion((value: any) => {\n return isPlainObject(value) && !value.fungible\n ? NonFungibleAssetStruct\n : FungibleAssetStruct;\n});\n\n/**\n * Asset type {@see AssetStruct}.\n */\nexport type Asset = Infer<typeof AssetStruct>;\n"]}
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BalanceStruct = void 0;
4
+ const keyring_utils_1 = require("@metamask/keyring-utils");
4
5
  const superstruct_1 = require("@metamask/superstruct");
5
- const superstruct_2 = require("../superstruct.cjs");
6
- const utils_1 = require("../utils/index.cjs");
7
- exports.BalanceStruct = (0, superstruct_2.object)({
8
- amount: utils_1.StringNumberStruct,
6
+ exports.BalanceStruct = (0, keyring_utils_1.object)({
7
+ amount: keyring_utils_1.StringNumberStruct,
9
8
  unit: (0, superstruct_1.string)(),
10
9
  });
11
10
  //# sourceMappingURL=balance.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"balance.cjs","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AACA,uDAA+C;AAE/C,oDAAwC;AACxC,8CAA8C;AAEjC,QAAA,aAAa,GAAG,IAAA,oBAAM,EAAC;IAClC,MAAM,EAAE,0BAAkB;IAC1B,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nimport { object } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
1
+ {"version":3,"file":"balance.cjs","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":";;;AAAA,2DAAqE;AAErE,uDAA+C;AAElC,QAAA,aAAa,GAAG,IAAA,sBAAM,EAAC;IAClC,MAAM,EAAE,kCAAkB;IAC1B,IAAI,EAAE,IAAA,oBAAM,GAAE;CACf,CAAC,CAAC","sourcesContent":["import { object, StringNumberStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
2
  export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
3
- amount: string;
4
3
  unit: string;
4
+ amount: string;
5
5
  }, {
6
6
  amount: import("@metamask/superstruct").Struct<string, null>;
7
7
  unit: import("@metamask/superstruct").Struct<string, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"balance.d.cts","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD,eAAO,MAAM,aAAa;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"balance.d.cts","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD,eAAO,MAAM,aAAa;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
2
  export declare const BalanceStruct: import("@metamask/superstruct").Struct<{
3
- amount: string;
4
3
  unit: string;
4
+ amount: string;
5
5
  }, {
6
6
  amount: import("@metamask/superstruct").Struct<string, null>;
7
7
  unit: import("@metamask/superstruct").Struct<string, null>;
@@ -1 +1 @@
1
- {"version":3,"file":"balance.d.mts","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAMnD,eAAO,MAAM,aAAa;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"balance.d.mts","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD,eAAO,MAAM,aAAa;;;;;;EAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1,6 +1,5 @@
1
+ import { object, StringNumberStruct } from "@metamask/keyring-utils";
1
2
  import { string } from "@metamask/superstruct";
2
- import { object } from "../superstruct.mjs";
3
- import { StringNumberStruct } from "../utils/index.mjs";
4
3
  export const BalanceStruct = object({
5
4
  amount: StringNumberStruct,
6
5
  unit: string(),
@@ -1 +1 @@
1
- {"version":3,"file":"balance.mjs","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,MAAM,EAAE,2BAAuB;AACxC,OAAO,EAAE,kBAAkB,EAAE,2BAAiB;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,kBAAkB;IAC1B,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nimport { object } from '../superstruct';\nimport { StringNumberStruct } from '../utils';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
1
+ {"version":3,"file":"balance.mjs","sourceRoot":"","sources":["../../src/api/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,gCAAgC;AAErE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,kBAAkB;IAC1B,IAAI,EAAE,MAAM,EAAE;CACf,CAAC,CAAC","sourcesContent":["import { object, StringNumberStruct } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { string } from '@metamask/superstruct';\n\nexport const BalanceStruct = object({\n amount: StringNumberStruct,\n unit: string(),\n});\n\nexport type Balance = Infer<typeof BalanceStruct>;\n"]}
package/dist/api/caip.cjs CHANGED
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = void 0;
4
4
  exports.isCaipAssetType = isCaipAssetType;
5
5
  exports.isCaipAssetId = isCaipAssetId;
6
+ const keyring_utils_1 = require("@metamask/keyring-utils");
6
7
  const superstruct_1 = require("@metamask/superstruct");
7
- const superstruct_2 = require("../superstruct.cjs");
8
8
  const CAIP_ASSET_TYPE_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;
9
9
  const CAIP_ASSET_ID_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;
10
10
  /**
11
11
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
12
12
  */
13
- exports.CaipAssetTypeStruct = (0, superstruct_2.definePattern)('CaipAssetType', CAIP_ASSET_TYPE_REGEX);
13
+ exports.CaipAssetTypeStruct = (0, keyring_utils_1.definePattern)('CaipAssetType', CAIP_ASSET_TYPE_REGEX);
14
14
  /**
15
15
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
16
16
  */
17
- exports.CaipAssetIdStruct = (0, superstruct_2.definePattern)('CaipAssetId', CAIP_ASSET_ID_REGEX);
17
+ exports.CaipAssetIdStruct = (0, keyring_utils_1.definePattern)('CaipAssetId', CAIP_ASSET_ID_REGEX);
18
18
  /**
19
19
  * Check if the given value is a {@link CaipAssetType}.
20
20
  *
@@ -1 +1 @@
1
- {"version":3,"file":"caip.cjs","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAwCA,0CAEC;AAcD,sCAEC;AA1DD,uDAAuD;AAEvD,oDAA+C;AAE/C,MAAM,qBAAqB,GACzB,2JAA2J,CAAC;AAE9J,MAAM,mBAAmB,GACvB,6LAA6L,CAAC;AAEhM;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,2BAAa,EAC9C,eAAe,EACf,qBAAqB,CACtB,CAAC;AAGF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,2BAAa,EAC5C,aAAa,EACb,mBAAmB,CACpB,CAAC;AAGF;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,2BAAmB,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,yBAAiB,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { is, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\nconst CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nconst CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct = definePattern(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n);\nexport type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = definePattern(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n);\nexport type CaipAssetId = Infer<typeof CaipAssetIdStruct>;\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // true\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false\n * ```\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // false\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true\n * ```\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n"]}
1
+ {"version":3,"file":"caip.cjs","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAuCA,0CAEC;AAcD,sCAEC;AAzDD,2DAAwD;AACxD,uDAAuD;AAEvD,MAAM,qBAAqB,GACzB,2JAA2J,CAAC;AAE9J,MAAM,mBAAmB,GACvB,6LAA6L,CAAC;AAEhM;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,6BAAa,EAC9C,eAAe,EACf,qBAAqB,CACtB,CAAC;AAGF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,6BAAa,EAC5C,aAAa,EACb,mBAAmB,CACpB,CAAC;AAGF;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,2BAAmB,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAA,gBAAE,EAAC,KAAK,EAAE,yBAAiB,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { definePattern } from '@metamask/keyring-utils';\nimport { is, type Infer } from '@metamask/superstruct';\n\nconst CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nconst CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct = definePattern(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n);\nexport type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = definePattern(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n);\nexport type CaipAssetId = Infer<typeof CaipAssetIdStruct>;\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // true\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false\n * ```\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n * @example\n * ```ts\n * isCaipAssetType('eip155:1/slip44:60'); // false\n * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false\n * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true\n * ```\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"caip.d.cts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,KAAK,EAAE,8BAA8B;AAUvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,sDAG/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAG7B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
1
+ {"version":3,"file":"caip.d.cts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,KAAK,EAAE,8BAA8B;AAQvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,sDAG/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAG7B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
@@ -1 +1 @@
1
- {"version":3,"file":"caip.d.mts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,KAAK,EAAE,8BAA8B;AAUvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,sDAG/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAG7B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
1
+ {"version":3,"file":"caip.d.mts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,KAAK,EAAE,8BAA8B;AAQvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,sDAG/B,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAG7B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE1D;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}