@metamask-previews/keyring-api 13.0.0-a527719 → 14.0.0-0b22ddc

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [14.0.0]
11
+
12
+ ### Added
13
+
14
+ - Add `listAccountAssets` keyring method ([#148](https://github.com/MetaMask/accounts/pull/148))
15
+
16
+ ### Changed
17
+
18
+ - **BREAKING:** Make `CaipAssetType` type more restritive ([#150](https://github.com/MetaMask/accounts/pull/150))
19
+ - It used to be a `string` but it has been restricted with a template literal type that matches CAIP-19 asset type.
20
+
10
21
  ## [13.0.0]
11
22
 
12
23
  ### Added
@@ -466,7 +477,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
466
477
  - SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
467
478
  - Helper functions to create keyring handler in the snap.
468
479
 
469
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@13.0.0...HEAD
480
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@14.0.0...HEAD
481
+ [14.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@13.0.0...@metamask/keyring-api@14.0.0
470
482
  [13.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@12.0.0...@metamask/keyring-api@13.0.0
471
483
  [12.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.1.0...@metamask/keyring-api@12.0.0
472
484
  [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
  */
@@ -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).\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,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
  */
@@ -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).\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"]}
@@ -146,8 +146,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
146
146
  asset: {
147
147
  unit: string;
148
148
  type: `${string}:${string}/${string}:${string}`;
149
- fungible: true;
150
149
  amount: string;
150
+ fungible: true;
151
151
  } | {
152
152
  id: `${string}:${string}/${string}:${string}/${string}`;
153
153
  fungible: false;
@@ -166,8 +166,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
166
166
  asset: {
167
167
  unit: string;
168
168
  type: `${string}:${string}/${string}:${string}`;
169
- fungible: true;
170
169
  amount: string;
170
+ fungible: true;
171
171
  } | {
172
172
  id: `${string}:${string}/${string}:${string}/${string}`;
173
173
  fungible: false;
@@ -178,8 +178,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
178
178
  asset: {
179
179
  unit: string;
180
180
  type: `${string}:${string}/${string}:${string}`;
181
- fungible: true;
182
181
  amount: string;
182
+ fungible: true;
183
183
  } | {
184
184
  id: `${string}:${string}/${string}:${string}/${string}`;
185
185
  fungible: false;
@@ -229,8 +229,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
229
229
  asset: {
230
230
  unit: string;
231
231
  type: `${string}:${string}/${string}:${string}`;
232
- fungible: true;
233
232
  amount: string;
233
+ fungible: true;
234
234
  } | {
235
235
  id: `${string}:${string}/${string}:${string}/${string}`;
236
236
  fungible: false;
@@ -240,8 +240,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
240
240
  asset: {
241
241
  unit: string;
242
242
  type: `${string}:${string}/${string}:${string}`;
243
- fungible: true;
244
243
  amount: string;
244
+ fungible: true;
245
245
  } | {
246
246
  id: `${string}:${string}/${string}:${string}/${string}`;
247
247
  fungible: false;
@@ -257,8 +257,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
257
257
  asset: import("@metamask/superstruct").Struct<{
258
258
  unit: string;
259
259
  type: `${string}:${string}/${string}:${string}`;
260
- fungible: true;
261
260
  amount: string;
261
+ fungible: true;
262
262
  } | {
263
263
  id: `${string}:${string}/${string}:${string}/${string}`;
264
264
  fungible: false;
@@ -272,8 +272,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
272
272
  asset: {
273
273
  unit: string;
274
274
  type: `${string}:${string}/${string}:${string}`;
275
- fungible: true;
276
275
  amount: string;
276
+ fungible: true;
277
277
  } | {
278
278
  id: `${string}:${string}/${string}:${string}/${string}`;
279
279
  fungible: false;
@@ -283,8 +283,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
283
283
  asset: {
284
284
  unit: string;
285
285
  type: `${string}:${string}/${string}:${string}`;
286
- fungible: true;
287
286
  amount: string;
287
+ fungible: true;
288
288
  } | {
289
289
  id: `${string}:${string}/${string}:${string}/${string}`;
290
290
  fungible: false;
@@ -300,8 +300,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
300
300
  asset: import("@metamask/superstruct").Struct<{
301
301
  unit: string;
302
302
  type: `${string}:${string}/${string}:${string}`;
303
- fungible: true;
304
303
  amount: string;
304
+ fungible: true;
305
305
  } | {
306
306
  id: `${string}:${string}/${string}:${string}/${string}`;
307
307
  fungible: false;
@@ -315,8 +315,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
315
315
  asset: {
316
316
  unit: string;
317
317
  type: `${string}:${string}/${string}:${string}`;
318
- fungible: true;
319
318
  amount: string;
319
+ fungible: true;
320
320
  } | {
321
321
  id: `${string}:${string}/${string}:${string}/${string}`;
322
322
  fungible: false;
@@ -326,8 +326,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
326
326
  asset: {
327
327
  unit: string;
328
328
  type: `${string}:${string}/${string}:${string}`;
329
- fungible: true;
330
329
  amount: string;
330
+ fungible: true;
331
331
  } | {
332
332
  id: `${string}:${string}/${string}:${string}/${string}`;
333
333
  fungible: false;
@@ -346,8 +346,8 @@ export declare const TransactionStruct: import("@metamask/superstruct").Struct<{
346
346
  asset: import("@metamask/superstruct").Struct<{
347
347
  unit: string;
348
348
  type: `${string}:${string}/${string}:${string}`;
349
- fungible: true;
350
349
  amount: string;
350
+ fungible: true;
351
351
  } | {
352
352
  id: `${string}:${string}/${string}:${string}/${string}`;
353
353
  fungible: false;
@@ -423,8 +423,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
423
423
  asset: {
424
424
  unit: string;
425
425
  type: `${string}:${string}/${string}:${string}`;
426
- fungible: true;
427
426
  amount: string;
427
+ fungible: true;
428
428
  } | {
429
429
  id: `${string}:${string}/${string}:${string}/${string}`;
430
430
  fungible: false;
@@ -443,8 +443,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
443
443
  asset: {
444
444
  unit: string;
445
445
  type: `${string}:${string}/${string}:${string}`;
446
- fungible: true;
447
446
  amount: string;
447
+ fungible: true;
448
448
  } | {
449
449
  id: `${string}:${string}/${string}:${string}/${string}`;
450
450
  fungible: false;
@@ -455,8 +455,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
455
455
  asset: {
456
456
  unit: string;
457
457
  type: `${string}:${string}/${string}:${string}`;
458
- fungible: true;
459
458
  amount: string;
459
+ fungible: true;
460
460
  } | {
461
461
  id: `${string}:${string}/${string}:${string}/${string}`;
462
462
  fungible: false;
@@ -476,8 +476,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
476
476
  asset: {
477
477
  unit: string;
478
478
  type: `${string}:${string}/${string}:${string}`;
479
- fungible: true;
480
479
  amount: string;
480
+ fungible: true;
481
481
  } | {
482
482
  id: `${string}:${string}/${string}:${string}/${string}`;
483
483
  fungible: false;
@@ -496,8 +496,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
496
496
  asset: {
497
497
  unit: string;
498
498
  type: `${string}:${string}/${string}:${string}`;
499
- fungible: true;
500
499
  amount: string;
500
+ fungible: true;
501
501
  } | {
502
502
  id: `${string}:${string}/${string}:${string}/${string}`;
503
503
  fungible: false;
@@ -508,8 +508,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
508
508
  asset: {
509
509
  unit: string;
510
510
  type: `${string}:${string}/${string}:${string}`;
511
- fungible: true;
512
511
  amount: string;
512
+ fungible: true;
513
513
  } | {
514
514
  id: `${string}:${string}/${string}:${string}/${string}`;
515
515
  fungible: false;
@@ -523,8 +523,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
523
523
  asset: {
524
524
  unit: string;
525
525
  type: `${string}:${string}/${string}:${string}`;
526
- fungible: true;
527
526
  amount: string;
527
+ fungible: true;
528
528
  } | {
529
529
  id: `${string}:${string}/${string}:${string}/${string}`;
530
530
  fungible: false;
@@ -543,8 +543,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
543
543
  asset: {
544
544
  unit: string;
545
545
  type: `${string}:${string}/${string}:${string}`;
546
- fungible: true;
547
546
  amount: string;
547
+ fungible: true;
548
548
  } | {
549
549
  id: `${string}:${string}/${string}:${string}/${string}`;
550
550
  fungible: false;
@@ -555,8 +555,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
555
555
  asset: {
556
556
  unit: string;
557
557
  type: `${string}:${string}/${string}:${string}`;
558
- fungible: true;
559
558
  amount: string;
559
+ fungible: true;
560
560
  } | {
561
561
  id: `${string}:${string}/${string}:${string}/${string}`;
562
562
  fungible: false;
@@ -606,8 +606,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
606
606
  asset: {
607
607
  unit: string;
608
608
  type: `${string}:${string}/${string}:${string}`;
609
- fungible: true;
610
609
  amount: string;
610
+ fungible: true;
611
611
  } | {
612
612
  id: `${string}:${string}/${string}:${string}/${string}`;
613
613
  fungible: false;
@@ -617,8 +617,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
617
617
  asset: {
618
618
  unit: string;
619
619
  type: `${string}:${string}/${string}:${string}`;
620
- fungible: true;
621
620
  amount: string;
621
+ fungible: true;
622
622
  } | {
623
623
  id: `${string}:${string}/${string}:${string}/${string}`;
624
624
  fungible: false;
@@ -634,8 +634,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
634
634
  asset: import("@metamask/superstruct").Struct<{
635
635
  unit: string;
636
636
  type: `${string}:${string}/${string}:${string}`;
637
- fungible: true;
638
637
  amount: string;
638
+ fungible: true;
639
639
  } | {
640
640
  id: `${string}:${string}/${string}:${string}/${string}`;
641
641
  fungible: false;
@@ -649,8 +649,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
649
649
  asset: {
650
650
  unit: string;
651
651
  type: `${string}:${string}/${string}:${string}`;
652
- fungible: true;
653
652
  amount: string;
653
+ fungible: true;
654
654
  } | {
655
655
  id: `${string}:${string}/${string}:${string}/${string}`;
656
656
  fungible: false;
@@ -660,8 +660,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
660
660
  asset: {
661
661
  unit: string;
662
662
  type: `${string}:${string}/${string}:${string}`;
663
- fungible: true;
664
663
  amount: string;
664
+ fungible: true;
665
665
  } | {
666
666
  id: `${string}:${string}/${string}:${string}/${string}`;
667
667
  fungible: false;
@@ -677,8 +677,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
677
677
  asset: import("@metamask/superstruct").Struct<{
678
678
  unit: string;
679
679
  type: `${string}:${string}/${string}:${string}`;
680
- fungible: true;
681
680
  amount: string;
681
+ fungible: true;
682
682
  } | {
683
683
  id: `${string}:${string}/${string}:${string}/${string}`;
684
684
  fungible: false;
@@ -692,8 +692,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
692
692
  asset: {
693
693
  unit: string;
694
694
  type: `${string}:${string}/${string}:${string}`;
695
- fungible: true;
696
695
  amount: string;
696
+ fungible: true;
697
697
  } | {
698
698
  id: `${string}:${string}/${string}:${string}/${string}`;
699
699
  fungible: false;
@@ -703,8 +703,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
703
703
  asset: {
704
704
  unit: string;
705
705
  type: `${string}:${string}/${string}:${string}`;
706
- fungible: true;
707
706
  amount: string;
707
+ fungible: true;
708
708
  } | {
709
709
  id: `${string}:${string}/${string}:${string}/${string}`;
710
710
  fungible: false;
@@ -723,8 +723,8 @@ export declare const TransactionsPageStruct: import("@metamask/superstruct").Str
723
723
  asset: import("@metamask/superstruct").Struct<{
724
724
  unit: string;
725
725
  type: `${string}:${string}/${string}:${string}`;
726
- fungible: true;
727
726
  amount: string;
727
+ fungible: true;
728
728
  } | {
729
729
  id: `${string}:${string}/${string}:${string}/${string}`;
730
730
  fungible: false;