@metamask/keyring-api 14.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.
- package/CHANGELOG.md +12 -1
- package/dist/api/account.cjs +2 -2
- package/dist/api/account.cjs.map +1 -1
- package/dist/api/account.d.cts +1 -1
- package/dist/api/account.d.mts +1 -1
- package/dist/api/account.mjs +3 -3
- package/dist/api/account.mjs.map +1 -1
- package/dist/api/asset.cjs +15 -9
- package/dist/api/asset.cjs.map +1 -1
- package/dist/api/asset.d.cts +25 -9
- package/dist/api/asset.d.cts.map +1 -1
- package/dist/api/asset.d.mts +25 -9
- package/dist/api/asset.d.mts.map +1 -1
- package/dist/api/asset.mjs +14 -8
- package/dist/api/asset.mjs.map +1 -1
- package/dist/api/transaction.d.cts +30 -30
- package/dist/api/transaction.d.mts +30 -30
- package/dist/btc/types.cjs +7 -0
- package/dist/btc/types.cjs.map +1 -1
- package/dist/btc/types.d.cts +7 -2
- package/dist/btc/types.d.cts.map +1 -1
- package/dist/btc/types.d.mts +7 -2
- package/dist/btc/types.d.mts.map +1 -1
- package/dist/btc/types.mjs +8 -1
- package/dist/btc/types.mjs.map +1 -1
- package/dist/eth/constants.cjs +1 -0
- package/dist/eth/constants.cjs.map +1 -1
- package/dist/eth/constants.d.cts +2 -1
- package/dist/eth/constants.d.cts.map +1 -1
- package/dist/eth/constants.d.mts +2 -1
- package/dist/eth/constants.d.mts.map +1 -1
- package/dist/eth/constants.mjs +1 -0
- package/dist/eth/constants.mjs.map +1 -1
- package/dist/eth/types.cjs +5 -0
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +5 -2
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +5 -2
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs +5 -0
- package/dist/eth/types.mjs.map +1 -1
- package/dist/events.cjs +75 -1
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +240 -1
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +240 -1
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +78 -4
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.d.cts +18 -18
- package/dist/rpc.d.mts +18 -18
- package/dist/sol/types.cjs +5 -0
- package/dist/sol/types.cjs.map +1 -1
- package/dist/sol/types.d.cts +5 -2
- package/dist/sol/types.d.cts.map +1 -1
- package/dist/sol/types.d.mts +5 -2
- package/dist/sol/types.d.mts.map +1 -1
- package/dist/sol/types.mjs +6 -1
- package/dist/sol/types.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -7,6 +7,16 @@ 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
|
+
|
10
20
|
## [14.0.0]
|
11
21
|
|
12
22
|
### Added
|
@@ -477,7 +487,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
477
487
|
- SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
|
478
488
|
- Helper functions to create keyring handler in the snap.
|
479
489
|
|
480
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@
|
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
|
481
492
|
[14.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@13.0.0...@metamask/keyring-api@14.0.0
|
482
493
|
[13.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@12.0.0...@metamask/keyring-api@13.0.0
|
483
494
|
[12.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@11.1.0...@metamask/keyring-api@12.0.0
|
package/dist/api/account.cjs
CHANGED
@@ -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.
|
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
|
/**
|
package/dist/api/account.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.cjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":";;;AAAA,
|
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"]}
|
package/dist/api/account.d.cts
CHANGED
@@ -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
|
/**
|
package/dist/api/account.d.mts
CHANGED
@@ -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
|
/**
|
package/dist/api/account.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
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:
|
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
|
/**
|
package/dist/api/account.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.mjs","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
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"]}
|
package/dist/api/asset.cjs
CHANGED
@@ -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.
|
package/dist/api/asset.cjs.map
CHANGED
@@ -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,
|
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"]}
|
package/dist/api/asset.d.cts
CHANGED
@@ -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
|
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
|
-
*
|
10
|
+
* Asset unit.
|
13
11
|
*/
|
14
|
-
|
12
|
+
unit: import("@metamask/superstruct").Struct<string, null>;
|
15
13
|
/**
|
16
|
-
* Asset
|
14
|
+
* Asset amount.
|
17
15
|
*/
|
18
|
-
|
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;
|
package/dist/api/asset.d.cts.map
CHANGED
@@ -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;;;;;;
|
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"}
|
package/dist/api/asset.d.mts
CHANGED
@@ -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
|
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
|
-
*
|
10
|
+
* Asset unit.
|
13
11
|
*/
|
14
|
-
|
12
|
+
unit: import("@metamask/superstruct").Struct<string, null>;
|
15
13
|
/**
|
16
|
-
* Asset
|
14
|
+
* Asset amount.
|
17
15
|
*/
|
18
|
-
|
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;
|
package/dist/api/asset.d.mts.map
CHANGED
@@ -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;;;;;;
|
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"}
|
package/dist/api/asset.mjs
CHANGED
@@ -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.
|
package/dist/api/asset.mjs.map
CHANGED
@@ -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,
|
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"]}
|