@metamask/keyring-api 13.0.0 → 15.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 (80) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/api/account.cjs +2 -2
  3. package/dist/api/account.cjs.map +1 -1
  4. package/dist/api/account.d.cts +1 -1
  5. package/dist/api/account.d.mts +1 -1
  6. package/dist/api/account.mjs +3 -3
  7. package/dist/api/account.mjs.map +1 -1
  8. package/dist/api/asset.cjs +15 -9
  9. package/dist/api/asset.cjs.map +1 -1
  10. package/dist/api/asset.d.cts +25 -9
  11. package/dist/api/asset.d.cts.map +1 -1
  12. package/dist/api/asset.d.mts +25 -9
  13. package/dist/api/asset.d.mts.map +1 -1
  14. package/dist/api/asset.mjs +14 -8
  15. package/dist/api/asset.mjs.map +1 -1
  16. package/dist/api/caip.cjs +9 -36
  17. package/dist/api/caip.cjs.map +1 -1
  18. package/dist/api/caip.d.cts +11 -28
  19. package/dist/api/caip.d.cts.map +1 -1
  20. package/dist/api/caip.d.mts +11 -28
  21. package/dist/api/caip.d.mts.map +1 -1
  22. package/dist/api/caip.mjs +6 -31
  23. package/dist/api/caip.mjs.map +1 -1
  24. package/dist/api/keyring.cjs.map +1 -1
  25. package/dist/api/keyring.d.cts +11 -1
  26. package/dist/api/keyring.d.cts.map +1 -1
  27. package/dist/api/keyring.d.mts +11 -1
  28. package/dist/api/keyring.d.mts.map +1 -1
  29. package/dist/api/keyring.mjs.map +1 -1
  30. package/dist/api/transaction.d.cts +30 -30
  31. package/dist/api/transaction.d.mts +30 -30
  32. package/dist/btc/types.cjs +7 -0
  33. package/dist/btc/types.cjs.map +1 -1
  34. package/dist/btc/types.d.cts +7 -2
  35. package/dist/btc/types.d.cts.map +1 -1
  36. package/dist/btc/types.d.mts +7 -2
  37. package/dist/btc/types.d.mts.map +1 -1
  38. package/dist/btc/types.mjs +8 -1
  39. package/dist/btc/types.mjs.map +1 -1
  40. package/dist/eth/constants.cjs +1 -0
  41. package/dist/eth/constants.cjs.map +1 -1
  42. package/dist/eth/constants.d.cts +2 -1
  43. package/dist/eth/constants.d.cts.map +1 -1
  44. package/dist/eth/constants.d.mts +2 -1
  45. package/dist/eth/constants.d.mts.map +1 -1
  46. package/dist/eth/constants.mjs +1 -0
  47. package/dist/eth/constants.mjs.map +1 -1
  48. package/dist/eth/types.cjs +5 -0
  49. package/dist/eth/types.cjs.map +1 -1
  50. package/dist/eth/types.d.cts +5 -2
  51. package/dist/eth/types.d.cts.map +1 -1
  52. package/dist/eth/types.d.mts +5 -2
  53. package/dist/eth/types.d.mts.map +1 -1
  54. package/dist/eth/types.mjs +5 -0
  55. package/dist/eth/types.mjs.map +1 -1
  56. package/dist/events.cjs +75 -1
  57. package/dist/events.cjs.map +1 -1
  58. package/dist/events.d.cts +240 -1
  59. package/dist/events.d.cts.map +1 -1
  60. package/dist/events.d.mts +240 -1
  61. package/dist/events.d.mts.map +1 -1
  62. package/dist/events.mjs +78 -4
  63. package/dist/events.mjs.map +1 -1
  64. package/dist/rpc.cjs +12 -1
  65. package/dist/rpc.cjs.map +1 -1
  66. package/dist/rpc.d.cts +43 -22
  67. package/dist/rpc.d.cts.map +1 -1
  68. package/dist/rpc.d.mts +43 -22
  69. package/dist/rpc.d.mts.map +1 -1
  70. package/dist/rpc.mjs +12 -1
  71. package/dist/rpc.mjs.map +1 -1
  72. package/dist/sol/types.cjs +5 -0
  73. package/dist/sol/types.cjs.map +1 -1
  74. package/dist/sol/types.d.cts +5 -2
  75. package/dist/sol/types.d.cts.map +1 -1
  76. package/dist/sol/types.d.mts +5 -2
  77. package/dist/sol/types.d.mts.map +1 -1
  78. package/dist/sol/types.mjs +6 -1
  79. package/dist/sol/types.mjs.map +1 -1
  80. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [15.0.0]
11
+
12
+ ### Added
13
+
14
+ - Add `account{AssetList,Balances,Transactions}UpdatedEventStruct` keyring events ([#154](https://github.com/MetaMask/accounts/pull/154))
15
+
16
+ ### Changed
17
+
18
+ - **BREAKING:** Make specific `*AccountStruct.scopes` more strict ([#159](https://github.com/MetaMask/accounts/pull/159))
19
+
20
+ ## [14.0.0]
21
+
22
+ ### Added
23
+
24
+ - Add `listAccountAssets` keyring method ([#148](https://github.com/MetaMask/accounts/pull/148))
25
+
26
+ ### Changed
27
+
28
+ - **BREAKING:** Make `CaipAssetType` type more restritive ([#150](https://github.com/MetaMask/accounts/pull/150))
29
+ - It used to be a `string` but it has been restricted with a template literal type that matches CAIP-19 asset type.
30
+
10
31
  ## [13.0.0]
11
32
 
12
33
  ### Added
@@ -466,7 +487,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
466
487
  - SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
467
488
  - Helper functions to create keyring handler in the snap.
468
489
 
469
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@13.0.0...HEAD
490
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@15.0.0...HEAD
491
+ [15.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@14.0.0...@metamask/keyring-api@15.0.0
492
+ [14.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@13.0.0...@metamask/keyring-api@14.0.0
470
493
  [13.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@12.0.0...@metamask/keyring-api@13.0.0
471
494
  [12.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.1.0...@metamask/keyring-api@12.0.0
472
495
  [11.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.0.0...@metamask/keyring-api@11.1.0
@@ -37,7 +37,7 @@ exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
37
37
  /**
38
38
  * Account ID (UUIDv4).
39
39
  */
40
- id: keyring_utils_1.UuidStruct,
40
+ id: keyring_utils_1.AccountIdStruct,
41
41
  /**
42
42
  * Account type.
43
43
  */
@@ -52,7 +52,7 @@ exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
52
52
  */
53
53
  address: (0, superstruct_1.string)(),
54
54
  /**
55
- * Account supported scopes (CAIP-2 chain IDs).
55
+ * Account supported scopes (CAIP-2 chain IDs or CAIP-2 namespaces).
56
56
  */
57
57
  scopes: (0, superstruct_1.nonempty)((0, superstruct_1.array)((0, superstruct_1.union)([utils_1.CaipNamespaceStruct, utils_1.CaipChainIdStruct]))),
58
58
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,2DAA6D;AAE7D,uDAO+B;AAC/B,2CAIyB;AAEzB;;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,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,2BAAmB,EAAE,yBAAiB,CAAC,CAAC,CAAC,CAAC;IAExE;;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 {\n nonempty,\n array,\n enums,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipChainIdStruct,\n CaipNamespaceStruct,\n JsonStruct,\n} 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 supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(union([CaipNamespaceStruct, CaipChainIdStruct]))),\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,2DAAkE;AAElE,uDAO+B;AAC/B,2CAIyB;AAEzB;;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,+BAAe;IAEnB;;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,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,IAAA,mBAAK,EAAC,CAAC,2BAAmB,EAAE,yBAAiB,CAAC,CAAC,CAAC,CAAC;IAExE;;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 { AccountIdStruct, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n nonempty,\n array,\n enums,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipChainIdStruct,\n CaipNamespaceStruct,\n JsonStruct,\n} 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: AccountIdStruct,\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 supported scopes (CAIP-2 chain IDs or CAIP-2 namespaces).\n */\n scopes: nonempty(array(union([CaipNamespaceStruct, CaipChainIdStruct]))),\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"]}
@@ -55,7 +55,7 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
55
55
  */
56
56
  address: import("@metamask/superstruct").Struct<string, null>;
57
57
  /**
58
- * Account supported scopes (CAIP-2 chain IDs).
58
+ * Account supported scopes (CAIP-2 chain IDs or CAIP-2 namespaces).
59
59
  */
60
60
  scopes: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
61
61
  /**
@@ -55,7 +55,7 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
55
55
  */
56
56
  address: import("@metamask/superstruct").Struct<string, null>;
57
57
  /**
58
- * Account supported scopes (CAIP-2 chain IDs).
58
+ * Account supported scopes (CAIP-2 chain IDs or CAIP-2 namespaces).
59
59
  */
60
60
  scopes: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
61
61
  /**
@@ -1,4 +1,4 @@
1
- import { object, UuidStruct } from "@metamask/keyring-utils";
1
+ import { AccountIdStruct, object } from "@metamask/keyring-utils";
2
2
  import { nonempty, array, enums, record, string, union } from "@metamask/superstruct";
3
3
  import { CaipChainIdStruct, CaipNamespaceStruct, JsonStruct } from "@metamask/utils";
4
4
  /**
@@ -34,7 +34,7 @@ export const KeyringAccountStruct = object({
34
34
  /**
35
35
  * Account ID (UUIDv4).
36
36
  */
37
- id: UuidStruct,
37
+ id: AccountIdStruct,
38
38
  /**
39
39
  * Account type.
40
40
  */
@@ -49,7 +49,7 @@ export const KeyringAccountStruct = object({
49
49
  */
50
50
  address: string(),
51
51
  /**
52
- * Account supported scopes (CAIP-2 chain IDs).
52
+ * Account supported scopes (CAIP-2 chain IDs or CAIP-2 namespaces).
53
53
  */
54
54
  scopes: nonempty(array(union([CaipNamespaceStruct, CaipChainIdStruct]))),
55
55
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"account.mjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gCAAgC;AAE7D,OAAO,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACX,wBAAwB;AAEzB;;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,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAExE;;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 {\n nonempty,\n array,\n enums,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipChainIdStruct,\n CaipNamespaceStruct,\n JsonStruct,\n} 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 supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(union([CaipNamespaceStruct, CaipChainIdStruct]))),\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,eAAe,EAAE,MAAM,EAAE,gCAAgC;AAElE,OAAO,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACX,wBAAwB;AAEzB;;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,eAAe;IAEnB;;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,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAExE;;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 { AccountIdStruct, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n nonempty,\n array,\n enums,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipChainIdStruct,\n CaipNamespaceStruct,\n JsonStruct,\n} 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: AccountIdStruct,\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 supported scopes (CAIP-2 chain IDs or CAIP-2 namespaces).\n */\n scopes: nonempty(array(union([CaipNamespaceStruct, CaipChainIdStruct]))),\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,9 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AssetStruct = exports.NonFungibleAssetStruct = exports.FungibleAssetStruct = void 0;
3
+ exports.AssetStruct = exports.NonFungibleAssetStruct = exports.FungibleAssetStruct = exports.FungibleAssetAmountStruct = void 0;
4
4
  const keyring_utils_1 = require("@metamask/keyring-utils");
5
5
  const superstruct_1 = require("@metamask/superstruct");
6
6
  const utils_1 = require("@metamask/utils");
7
+ /**
8
+ * Fungible asset amount struct.
9
+ */
10
+ exports.FungibleAssetAmountStruct = (0, keyring_utils_1.object)({
11
+ /**
12
+ * Asset unit.
13
+ */
14
+ unit: (0, superstruct_1.string)(),
15
+ /**
16
+ * Asset amount.
17
+ */
18
+ amount: keyring_utils_1.StringNumberStruct,
19
+ });
7
20
  /**
8
21
  * Fungible asset struct.
9
22
  */
@@ -16,14 +29,7 @@ exports.FungibleAssetStruct = (0, keyring_utils_1.object)({
16
29
  * Asset type (CAIP-19).
17
30
  */
18
31
  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,
32
+ ...exports.FungibleAssetAmountStruct.schema,
27
33
  });
28
34
  /**
29
35
  * Non-fungible asset struct.
@@ -1 +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"]}
1
+ {"version":3,"file":"asset.cjs","sourceRoot":"","sources":["../../src/api/asset.ts"],"names":[],"mappings":";;;AAAA,2DAIiC;AAEjC,uDAAwD;AACxD,2CAIyB;AAEzB;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAA,sBAAM,EAAC;IAC9C;;OAEG;IACH,IAAI,EAAE,IAAA,oBAAM,GAAE;IAEd;;OAEG;IACH,MAAM,EAAE,kCAAkB;CAC3B,CAAC,CAAC;AAEH;;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,GAAG,iCAAyB,CAAC,MAAM;CACpC,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 amount struct.\n */\nexport const FungibleAssetAmountStruct = object({\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\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 ...FungibleAssetAmountStruct.schema,\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,21 +1,29 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
2
  /**
3
- * Fungible asset struct.
3
+ * Fungible asset amount struct.
4
4
  */
5
- export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
5
+ export declare const FungibleAssetAmountStruct: import("@metamask/superstruct").Struct<{
6
6
  unit: string;
7
- type: `${string}:${string}/${string}:${string}`;
8
- fungible: true;
9
7
  amount: string;
10
8
  }, {
11
9
  /**
12
- * It is a fungible asset.
10
+ * Asset unit.
13
11
  */
14
- fungible: import("@metamask/superstruct").Struct<true, true>;
12
+ unit: import("@metamask/superstruct").Struct<string, null>;
15
13
  /**
16
- * Asset type (CAIP-19).
14
+ * Asset amount.
17
15
  */
18
- type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
16
+ amount: import("@metamask/superstruct").Struct<string, null>;
17
+ }>;
18
+ /**
19
+ * Fungible asset struct.
20
+ */
21
+ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
22
+ unit: string;
23
+ type: `${string}:${string}/${string}:${string}`;
24
+ amount: string;
25
+ fungible: true;
26
+ }, {
19
27
  /**
20
28
  * Asset unit.
21
29
  */
@@ -24,6 +32,14 @@ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct
24
32
  * Asset amount.
25
33
  */
26
34
  amount: import("@metamask/superstruct").Struct<string, null>;
35
+ /**
36
+ * It is a fungible asset.
37
+ */
38
+ fungible: import("@metamask/superstruct").Struct<true, true>;
39
+ /**
40
+ * Asset type (CAIP-19).
41
+ */
42
+ type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
27
43
  }>;
28
44
  /**
29
45
  * Non-fungible asset struct.
@@ -80,8 +96,8 @@ export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Str
80
96
  export declare const AssetStruct: import("@metamask/superstruct").Struct<{
81
97
  unit: string;
82
98
  type: `${string}:${string}/${string}:${string}`;
83
- fungible: true;
84
99
  amount: string;
100
+ fungible: true;
85
101
  } | {
86
102
  id: `${string}:${string}/${string}:${string}/${string}`;
87
103
  fungible: false;
@@ -1 +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"}
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,yBAAyB;;;;IACpC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAd9B;;OAEG;;IAGH;;OAEG;;IAQH;;OAEG;;IAGH;;OAEG;;EAIH,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"}
@@ -1,21 +1,29 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
2
  /**
3
- * Fungible asset struct.
3
+ * Fungible asset amount struct.
4
4
  */
5
- export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
5
+ export declare const FungibleAssetAmountStruct: import("@metamask/superstruct").Struct<{
6
6
  unit: string;
7
- type: `${string}:${string}/${string}:${string}`;
8
- fungible: true;
9
7
  amount: string;
10
8
  }, {
11
9
  /**
12
- * It is a fungible asset.
10
+ * Asset unit.
13
11
  */
14
- fungible: import("@metamask/superstruct").Struct<true, true>;
12
+ unit: import("@metamask/superstruct").Struct<string, null>;
15
13
  /**
16
- * Asset type (CAIP-19).
14
+ * Asset amount.
17
15
  */
18
- type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
16
+ amount: import("@metamask/superstruct").Struct<string, null>;
17
+ }>;
18
+ /**
19
+ * Fungible asset struct.
20
+ */
21
+ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct<{
22
+ unit: string;
23
+ type: `${string}:${string}/${string}:${string}`;
24
+ amount: string;
25
+ fungible: true;
26
+ }, {
19
27
  /**
20
28
  * Asset unit.
21
29
  */
@@ -24,6 +32,14 @@ export declare const FungibleAssetStruct: import("@metamask/superstruct").Struct
24
32
  * Asset amount.
25
33
  */
26
34
  amount: import("@metamask/superstruct").Struct<string, null>;
35
+ /**
36
+ * It is a fungible asset.
37
+ */
38
+ fungible: import("@metamask/superstruct").Struct<true, true>;
39
+ /**
40
+ * Asset type (CAIP-19).
41
+ */
42
+ type: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
27
43
  }>;
28
44
  /**
29
45
  * Non-fungible asset struct.
@@ -80,8 +96,8 @@ export declare const NonFungibleAssetStruct: import("@metamask/superstruct").Str
80
96
  export declare const AssetStruct: import("@metamask/superstruct").Struct<{
81
97
  unit: string;
82
98
  type: `${string}:${string}/${string}:${string}`;
83
- fungible: true;
84
99
  amount: string;
100
+ fungible: true;
85
101
  } | {
86
102
  id: `${string}:${string}/${string}:${string}/${string}`;
87
103
  fungible: false;
@@ -1 +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"}
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,yBAAyB;;;;IACpC;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;IAd9B;;OAEG;;IAGH;;OAEG;;IAQH;;OAEG;;IAGH;;OAEG;;EAIH,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"}
@@ -1,6 +1,19 @@
1
1
  import { object, selectiveUnion, StringNumberStruct } from "@metamask/keyring-utils";
2
2
  import { literal, string } from "@metamask/superstruct";
3
3
  import { CaipAssetIdStruct, CaipAssetTypeStruct, isPlainObject } from "@metamask/utils";
4
+ /**
5
+ * Fungible asset amount struct.
6
+ */
7
+ export const FungibleAssetAmountStruct = object({
8
+ /**
9
+ * Asset unit.
10
+ */
11
+ unit: string(),
12
+ /**
13
+ * Asset amount.
14
+ */
15
+ amount: StringNumberStruct,
16
+ });
4
17
  /**
5
18
  * Fungible asset struct.
6
19
  */
@@ -13,14 +26,7 @@ export const FungibleAssetStruct = object({
13
26
  * Asset type (CAIP-19).
14
27
  */
15
28
  type: CaipAssetTypeStruct,
16
- /**
17
- * Asset unit.
18
- */
19
- unit: string(),
20
- /**
21
- * Asset amount.
22
- */
23
- amount: StringNumberStruct,
29
+ ...FungibleAssetAmountStruct.schema,
24
30
  });
25
31
  /**
26
32
  * Non-fungible asset struct.
@@ -1 +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
+ {"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,yBAAyB,GAAG,MAAM,CAAC;IAC9C;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE;IAEd;;OAEG;IACH,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAEH;;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,GAAG,yBAAyB,CAAC,MAAM;CACpC,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 amount struct.\n */\nexport const FungibleAssetAmountStruct = object({\n /**\n * Asset unit.\n */\n unit: string(),\n\n /**\n * Asset amount.\n */\n amount: StringNumberStruct,\n});\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 ...FungibleAssetAmountStruct.schema,\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"]}
package/dist/api/caip.cjs CHANGED
@@ -1,48 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = void 0;
4
- exports.isCaipAssetType = isCaipAssetType;
5
- exports.isCaipAssetId = isCaipAssetId;
3
+ exports.CaipAssetTypeOrIdStruct = exports.isCaipAssetId = exports.CaipAssetIdStruct = exports.isCaipAssetType = exports.CaipAssetTypeStruct = void 0;
6
4
  const keyring_utils_1 = require("@metamask/keyring-utils");
7
- const superstruct_1 = require("@metamask/superstruct");
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
- 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;
5
+ const utils_1 = require("@metamask/utils");
6
+ Object.defineProperty(exports, "isCaipAssetType", { enumerable: true, get: function () { return utils_1.isCaipAssetType; } });
7
+ Object.defineProperty(exports, "isCaipAssetId", { enumerable: true, get: function () { return utils_1.isCaipAssetId; } });
8
+ const CAIP_ASSET_TYPE_OR_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
9
  /**
11
10
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
12
11
  */
13
- exports.CaipAssetTypeStruct = (0, keyring_utils_1.definePattern)('CaipAssetType', CAIP_ASSET_TYPE_REGEX);
12
+ exports.CaipAssetTypeStruct = (0, keyring_utils_1.definePattern)('CaipAssetType', utils_1.CAIP_ASSET_TYPE_REGEX);
14
13
  /**
15
14
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
16
15
  */
17
- exports.CaipAssetIdStruct = (0, keyring_utils_1.definePattern)('CaipAssetId', CAIP_ASSET_ID_REGEX);
16
+ exports.CaipAssetIdStruct = (0, keyring_utils_1.definePattern)('CaipAssetId', utils_1.CAIP_ASSET_ID_REGEX);
18
17
  /**
19
- * Check if the given value is a {@link CaipAssetType}.
20
- *
21
- * @param value - The value to check.
22
- * @returns Whether the value is a {@link CaipAssetType}.
23
- * @example
24
- * ```ts
25
- * isCaipAssetType('eip155:1/slip44:60'); // true
26
- * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true
27
- * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false
28
- * ```
18
+ * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.
29
19
  */
30
- function isCaipAssetType(value) {
31
- return (0, superstruct_1.is)(value, exports.CaipAssetTypeStruct);
32
- }
33
- /**
34
- * Check if the given value is a {@link CaipAssetId}.
35
- *
36
- * @param value - The value to check.
37
- * @returns Whether the value is a {@link CaipAssetId}.
38
- * @example
39
- * ```ts
40
- * isCaipAssetType('eip155:1/slip44:60'); // false
41
- * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false
42
- * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true
43
- * ```
44
- */
45
- function isCaipAssetId(value) {
46
- return (0, superstruct_1.is)(value, exports.CaipAssetIdStruct);
47
- }
20
+ exports.CaipAssetTypeOrIdStruct = (0, keyring_utils_1.definePattern)('CaipAssetTypeOrId', CAIP_ASSET_TYPE_OR_ID_REGEX);
48
21
  //# sourceMappingURL=caip.cjs.map
@@ -1 +1 @@
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
+ {"version":3,"file":"caip.cjs","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAGxD,2CAKyB;AAahB,gGAfP,uBAAe,OAeO;AAUf,8FAxBP,qBAAa,OAwBO;AArBtB,MAAM,2BAA2B,GAC/B,gMAAgM,CAAC;AAEnM;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,6BAAa,EAC9C,eAAe,EACf,6BAAqB,CACtB,CAAC;AAIF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,6BAAa,EAC5C,aAAa,EACb,2BAAmB,CACpB,CAAC;AAIF;;GAEG;AACU,QAAA,uBAAuB,GAAG,IAAA,6BAAa,EAElD,mBAAmB,EAAE,2BAA2B,CAAC,CAAC","sourcesContent":["import { definePattern } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\nimport type { CaipAssetId, CaipAssetType } from '@metamask/utils';\nimport {\n CAIP_ASSET_TYPE_REGEX,\n CAIP_ASSET_ID_REGEX,\n isCaipAssetType,\n isCaipAssetId,\n} from '@metamask/utils';\n\nconst CAIP_ASSET_TYPE_OR_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<CaipAssetType>(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n);\nexport type { CaipAssetType };\nexport { isCaipAssetType };\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = definePattern<CaipAssetId>(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n);\nexport type { CaipAssetId };\nexport { isCaipAssetId };\n\n/**\n * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeOrIdStruct = definePattern<\n CaipAssetType | CaipAssetId\n>('CaipAssetTypeOrId', CAIP_ASSET_TYPE_OR_ID_REGEX);\nexport type CaipAssetTypeOrId = Infer<typeof CaipAssetTypeOrIdStruct>;\n"]}
@@ -1,38 +1,21 @@
1
1
  import { type Infer } from "@metamask/superstruct";
2
+ import type { CaipAssetId, CaipAssetType } from "@metamask/utils";
3
+ import { isCaipAssetType, isCaipAssetId } from "@metamask/utils";
2
4
  /**
3
5
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
4
6
  */
5
- export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<string, null>;
6
- export type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;
7
+ export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
8
+ export type { CaipAssetType };
9
+ export { isCaipAssetType };
7
10
  /**
8
11
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
9
12
  */
10
- export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<string, null>;
11
- export type CaipAssetId = Infer<typeof CaipAssetIdStruct>;
13
+ export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
14
+ export type { CaipAssetId };
15
+ export { isCaipAssetId };
12
16
  /**
13
- * Check if the given value is a {@link CaipAssetType}.
14
- *
15
- * @param value - The value to check.
16
- * @returns Whether the value is a {@link CaipAssetType}.
17
- * @example
18
- * ```ts
19
- * isCaipAssetType('eip155:1/slip44:60'); // true
20
- * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true
21
- * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false
22
- * ```
17
+ * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.
23
18
  */
24
- export declare function isCaipAssetType(value: unknown): value is CaipAssetType;
25
- /**
26
- * Check if the given value is a {@link CaipAssetId}.
27
- *
28
- * @param value - The value to check.
29
- * @returns Whether the value is a {@link CaipAssetId}.
30
- * @example
31
- * ```ts
32
- * isCaipAssetType('eip155:1/slip44:60'); // false
33
- * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false
34
- * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true
35
- * ```
36
- */
37
- export declare function isCaipAssetId(value: unknown): value is CaipAssetId;
19
+ export declare const CaipAssetTypeOrIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
20
+ export type CaipAssetTypeOrId = Infer<typeof CaipAssetTypeOrIdStruct>;
38
21
  //# sourceMappingURL=caip.d.cts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"caip.d.cts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,wBAAwB;AAClE,OAAO,EAGL,eAAe,EACf,aAAa,EACd,wBAAwB;AAKzB;;GAEG;AACH,eAAO,MAAM,mBAAmB,yFAG/B,CAAC;AACF,YAAY,EAAE,aAAa,EAAE,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,iBAAiB,mGAG7B,CAAC;AACF,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,uBAAuB,+IAEe,CAAC;AACpD,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -1,38 +1,21 @@
1
1
  import { type Infer } from "@metamask/superstruct";
2
+ import type { CaipAssetId, CaipAssetType } from "@metamask/utils";
3
+ import { isCaipAssetType, isCaipAssetId } from "@metamask/utils";
2
4
  /**
3
5
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
4
6
  */
5
- export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<string, null>;
6
- export type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;
7
+ export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
8
+ export type { CaipAssetType };
9
+ export { isCaipAssetType };
7
10
  /**
8
11
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
9
12
  */
10
- export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<string, null>;
11
- export type CaipAssetId = Infer<typeof CaipAssetIdStruct>;
13
+ export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
14
+ export type { CaipAssetId };
15
+ export { isCaipAssetId };
12
16
  /**
13
- * Check if the given value is a {@link CaipAssetType}.
14
- *
15
- * @param value - The value to check.
16
- * @returns Whether the value is a {@link CaipAssetType}.
17
- * @example
18
- * ```ts
19
- * isCaipAssetType('eip155:1/slip44:60'); // true
20
- * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // true
21
- * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // false
22
- * ```
17
+ * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.
23
18
  */
24
- export declare function isCaipAssetType(value: unknown): value is CaipAssetType;
25
- /**
26
- * Check if the given value is a {@link CaipAssetId}.
27
- *
28
- * @param value - The value to check.
29
- * @returns Whether the value is a {@link CaipAssetId}.
30
- * @example
31
- * ```ts
32
- * isCaipAssetType('eip155:1/slip44:60'); // false
33
- * isCaipAssetType('cosmos:cosmoshub-3/slip44:118'); // false
34
- * isCaipAssetType('hedera:mainnet/nft:0.0.55492/12'); // true
35
- * ```
36
- */
37
- export declare function isCaipAssetId(value: unknown): value is CaipAssetId;
19
+ export declare const CaipAssetTypeOrIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
20
+ export type CaipAssetTypeOrId = Infer<typeof CaipAssetTypeOrIdStruct>;
38
21
  //# sourceMappingURL=caip.d.mts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"caip.d.mts","sourceRoot":"","sources":["../../src/api/caip.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,wBAAwB;AAClE,OAAO,EAGL,eAAe,EACf,aAAa,EACd,wBAAwB;AAKzB;;GAEG;AACH,eAAO,MAAM,mBAAmB,yFAG/B,CAAC;AACF,YAAY,EAAE,aAAa,EAAE,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,iBAAiB,mGAG7B,CAAC;AACF,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,uBAAuB,+IAEe,CAAC;AACpD,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}