@metamask/keyring-api 14.0.0 → 16.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 +28 -1
- package/dist/api/account.cjs +2 -2
- package/dist/api/account.cjs.map +1 -1
- package/dist/api/account.d.cts +2 -2
- package/dist/api/account.d.cts.map +1 -1
- package/dist/api/account.d.mts +2 -2
- package/dist/api/account.d.mts.map +1 -1
- package/dist/api/account.mjs +5 -5
- package/dist/api/account.mjs.map +1 -1
- package/dist/api/address.cjs +14 -0
- package/dist/api/address.cjs.map +1 -0
- package/dist/api/address.d.cts +19 -0
- package/dist/api/address.d.cts.map +1 -0
- package/dist/api/address.d.mts +19 -0
- package/dist/api/address.d.mts.map +1 -0
- package/dist/api/address.mjs +11 -0
- package/dist/api/address.mjs.map +1 -0
- 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/index.cjs +1 -1
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/keyring.cjs.map +1 -1
- package/dist/api/keyring.d.cts +16 -2
- package/dist/api/keyring.d.cts.map +1 -1
- package/dist/api/keyring.d.mts +16 -2
- package/dist/api/keyring.d.mts.map +1 -1
- package/dist/api/keyring.mjs.map +1 -1
- package/dist/api/transaction.d.cts +30 -30
- package/dist/api/transaction.d.mts +30 -30
- package/dist/btc/constants.cjs +9 -10
- package/dist/btc/constants.cjs.map +1 -1
- package/dist/btc/constants.d.cts +1 -2
- package/dist/btc/constants.d.cts.map +1 -1
- package/dist/btc/constants.d.mts +1 -2
- package/dist/btc/constants.d.mts.map +1 -1
- package/dist/btc/constants.mjs +8 -9
- package/dist/btc/constants.mjs.map +1 -1
- 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 +7 -6
- package/dist/eth/constants.cjs.map +1 -1
- package/dist/eth/constants.d.cts +4 -3
- package/dist/eth/constants.d.cts.map +1 -1
- package/dist/eth/constants.d.mts +4 -3
- package/dist/eth/constants.d.mts.map +1 -1
- package/dist/eth/constants.mjs +6 -5
- package/dist/eth/constants.mjs.map +1 -1
- package/dist/eth/types.cjs +7 -2
- package/dist/eth/types.cjs.map +1 -1
- package/dist/eth/types.d.cts +9 -6
- package/dist/eth/types.d.cts.map +1 -1
- package/dist/eth/types.d.mts +9 -6
- package/dist/eth/types.d.mts.map +1 -1
- package/dist/eth/types.mjs +8 -3
- 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 +248 -9
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.mts +248 -9
- package/dist/events.d.mts.map +1 -1
- package/dist/events.mjs +78 -4
- package/dist/events.mjs.map +1 -1
- package/dist/rpc.cjs +18 -4
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +77 -29
- package/dist/rpc.d.cts.map +1 -1
- package/dist/rpc.d.mts +77 -29
- package/dist/rpc.d.mts.map +1 -1
- package/dist/rpc.mjs +18 -4
- package/dist/rpc.mjs.map +1 -1
- package/dist/sol/constants.cjs +7 -8
- package/dist/sol/constants.cjs.map +1 -1
- package/dist/sol/constants.d.cts +1 -2
- package/dist/sol/constants.d.cts.map +1 -1
- package/dist/sol/constants.d.mts +1 -2
- package/dist/sol/constants.d.mts.map +1 -1
- package/dist/sol/constants.mjs +6 -7
- package/dist/sol/constants.mjs.map +1 -1
- 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 +4 -4
- package/dist/api/caip.cjs +0 -21
- package/dist/api/caip.cjs.map +0 -1
- package/dist/api/caip.d.cts +0 -21
- package/dist/api/caip.d.cts.map +0 -1
- package/dist/api/caip.d.mts +0 -21
- package/dist/api/caip.d.mts.map +0 -1
- package/dist/api/caip.mjs +0 -18
- package/dist/api/caip.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [16.0.0]
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Add `resolveAccountAddress` keyring method ([#157](https://github.com/MetaMask/accounts/pull/157))
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- **BREAKING:** Remove CAIP redefinitions ([#167](https://github.com/MetaMask/accounts/pull/167))
|
19
|
+
- We now rely on CAIP definitions coming `@metamask/utils`.
|
20
|
+
- **BREAKING:** Enforce that `scopes` contains CAIP-2 chain IDs ([#165](https://github.com/MetaMask/accounts/pull/165))
|
21
|
+
- Initially `scopes` accepted CAIP-2 namespaces as well to address the EVM EOA accounts that supports all EVM chains. This has been dropped in favor of `eip155:0` scope.
|
22
|
+
- **BREAKING:** Rename `*Scopes` enums to `*Scope` ([#165](https://github.com/MetaMask/accounts/pull/165))
|
23
|
+
- Bump `@metamask/utils` from `^11.0.1` to `^11.1.0` ([#167](https://github.com/MetaMask/accounts/pull/167))
|
24
|
+
|
25
|
+
## [15.0.0]
|
26
|
+
|
27
|
+
### Added
|
28
|
+
|
29
|
+
- Add `account{AssetList,Balances,Transactions}UpdatedEventStruct` keyring events ([#154](https://github.com/MetaMask/accounts/pull/154))
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- **BREAKING:** Make specific `*AccountStruct.scopes` more strict ([#159](https://github.com/MetaMask/accounts/pull/159))
|
34
|
+
|
10
35
|
## [14.0.0]
|
11
36
|
|
12
37
|
### Added
|
@@ -477,7 +502,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
477
502
|
- SnapController keyring client. It is intended to be used by MetaMask to talk to the snap.
|
478
503
|
- Helper functions to create keyring handler in the snap.
|
479
504
|
|
480
|
-
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@
|
505
|
+
[Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@16.0.0...HEAD
|
506
|
+
[16.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@15.0.0...@metamask/keyring-api@16.0.0
|
507
|
+
[15.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@14.0.0...@metamask/keyring-api@15.0.0
|
481
508
|
[14.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@13.0.0...@metamask/keyring-api@14.0.0
|
482
509
|
[13.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@12.0.0...@metamask/keyring-api@13.0.0
|
483
510
|
[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
|
*/
|
@@ -54,7 +54,7 @@ exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
|
|
54
54
|
/**
|
55
55
|
* Account supported scopes (CAIP-2 chain IDs).
|
56
56
|
*/
|
57
|
-
scopes: (0, superstruct_1.nonempty)((0, superstruct_1.array)(
|
57
|
+
scopes: (0, superstruct_1.nonempty)((0, superstruct_1.array)(utils_1.CaipChainIdStruct)),
|
58
58
|
/**
|
59
59
|
* Account options.
|
60
60
|
*/
|
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,uDAA+E;AAC/E,2CAAgE;AAEhE;;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,yBAAiB,CAAC,CAAC;IAE1C;;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 { nonempty, array, enums, record, string } from '@metamask/superstruct';\nimport { CaipChainIdStruct, JsonStruct } from '@metamask/utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: 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(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
@@ -34,7 +34,7 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
34
34
|
id: string;
|
35
35
|
options: Record<string, import("@metamask/utils").Json>;
|
36
36
|
address: string;
|
37
|
-
scopes: string[];
|
37
|
+
scopes: `${string}:${string}`[];
|
38
38
|
methods: string[];
|
39
39
|
}, {
|
40
40
|
/**
|
@@ -57,7 +57,7 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
57
57
|
/**
|
58
58
|
* Account supported scopes (CAIP-2 chain IDs).
|
59
59
|
*/
|
60
|
-
scopes: import("@metamask/superstruct").Struct
|
60
|
+
scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
|
61
61
|
/**
|
62
62
|
* Account options.
|
63
63
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;
|
1
|
+
{"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/api/account.d.mts
CHANGED
@@ -34,7 +34,7 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
34
34
|
id: string;
|
35
35
|
options: Record<string, import("@metamask/utils").Json>;
|
36
36
|
address: string;
|
37
|
-
scopes: string[];
|
37
|
+
scopes: `${string}:${string}`[];
|
38
38
|
methods: string[];
|
39
39
|
}, {
|
40
40
|
/**
|
@@ -57,7 +57,7 @@ export declare const KeyringAccountStruct: import("@metamask/superstruct").Struc
|
|
57
57
|
/**
|
58
58
|
* Account supported scopes (CAIP-2 chain IDs).
|
59
59
|
*/
|
60
|
-
scopes: import("@metamask/superstruct").Struct
|
60
|
+
scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
|
61
61
|
/**
|
62
62
|
* Account options.
|
63
63
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;
|
1
|
+
{"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/api/account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD;;GAEG;AACH,oBAAY,cAAc;IACxB,GAAG,eAAe;IAClB,OAAO,mBAAmB;CAC3B;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,MAAM,kBAAkB;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,WAAW,wBAAwB;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,GAAG,cAAc,CAAC,GAAG,EAAE,GACvB,GAAG,cAAc,CAAC,OAAO,EAAE,GAC3B,GAAG,cAAc,CAAC,MAAM,EAAE,GAC1B,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;IAC/B;;OAEG;;IAGH;;OAEG;;;;;;;IAQH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/api/account.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import { nonempty, array, enums, record, string
|
3
|
-
import { CaipChainIdStruct,
|
1
|
+
import { AccountIdStruct, object } from "@metamask/keyring-utils";
|
2
|
+
import { nonempty, array, enums, record, string } from "@metamask/superstruct";
|
3
|
+
import { CaipChainIdStruct, JsonStruct } from "@metamask/utils";
|
4
4
|
/**
|
5
5
|
* Supported Ethereum account types.
|
6
6
|
*/
|
@@ -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
|
*/
|
@@ -51,7 +51,7 @@ export const KeyringAccountStruct = object({
|
|
51
51
|
/**
|
52
52
|
* Account supported scopes (CAIP-2 chain IDs).
|
53
53
|
*/
|
54
|
-
scopes: nonempty(array(
|
54
|
+
scopes: nonempty(array(CaipChainIdStruct)),
|
55
55
|
/**
|
56
56
|
* Account options.
|
57
57
|
*/
|
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,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAC/E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,wBAAwB;AAEhE;;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,iBAAiB,CAAC,CAAC;IAE1C;;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 { nonempty, array, enums, record, string } from '@metamask/superstruct';\nimport { CaipChainIdStruct, JsonStruct } from '@metamask/utils';\n\n/**\n * Supported Ethereum account types.\n */\nexport enum EthAccountType {\n Eoa = 'eip155:eoa',\n Erc4337 = 'eip155:erc4337',\n}\n\n/**\n * Supported Bitcoin account types.\n */\nexport enum BtcAccountType {\n P2wpkh = 'bip122:p2wpkh',\n}\n\n/**\n * Supported Solana account types.\n */\nexport enum SolAccountType {\n DataAccount = 'solana:data-account',\n}\n\n/**\n * Supported account types.\n */\nexport type KeyringAccountType =\n | `${EthAccountType.Eoa}`\n | `${EthAccountType.Erc4337}`\n | `${BtcAccountType.P2wpkh}`\n | `${SolAccountType.DataAccount}`;\n\n/**\n * A struct which represents a Keyring account object. It is abstract enough to\n * be used with any blockchain. Specific blockchain account types should extend\n * this struct.\n *\n * See {@link KeyringAccount}.\n */\nexport const KeyringAccountStruct = object({\n /**\n * Account ID (UUIDv4).\n */\n id: 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(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"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ResolvedAccountAddressStruct = void 0;
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
5
|
+
/**
|
6
|
+
* An account's address that has been resolved from a signing request.
|
7
|
+
*/
|
8
|
+
exports.ResolvedAccountAddressStruct = (0, superstruct_1.object)({
|
9
|
+
/**
|
10
|
+
* Account main address.
|
11
|
+
*/
|
12
|
+
address: (0, superstruct_1.string)(),
|
13
|
+
});
|
14
|
+
//# sourceMappingURL=address.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"address.cjs","sourceRoot":"","sources":["../../src/api/address.ts"],"names":[],"mappings":";;;AACA,uDAAuD;AAEvD;;GAEG;AACU,QAAA,4BAA4B,GAAG,IAAA,oBAAM,EAAC;IACjD;;OAEG;IACH,OAAO,EAAE,IAAA,oBAAM,GAAE;CAClB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { object, string } from '@metamask/superstruct';\n\n/**\n * An account's address that has been resolved from a signing request.\n */\nexport const ResolvedAccountAddressStruct = object({\n /**\n * Account main address.\n */\n address: string(),\n});\n\n/**\n * Resolve account's address object.\n *\n * See {@link ResolvedAccountAddressStruct}.\n */\nexport type ResolvedAccountAddress = Infer<typeof ResolvedAccountAddressStruct>;\n"]}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
|
+
/**
|
3
|
+
* An account's address that has been resolved from a signing request.
|
4
|
+
*/
|
5
|
+
export declare const ResolvedAccountAddressStruct: import("@metamask/superstruct").Struct<{
|
6
|
+
address: string;
|
7
|
+
}, {
|
8
|
+
/**
|
9
|
+
* Account main address.
|
10
|
+
*/
|
11
|
+
address: import("@metamask/superstruct").Struct<string, null>;
|
12
|
+
}>;
|
13
|
+
/**
|
14
|
+
* Resolve account's address object.
|
15
|
+
*
|
16
|
+
* See {@link ResolvedAccountAddressStruct}.
|
17
|
+
*/
|
18
|
+
export type ResolvedAccountAddress = Infer<typeof ResolvedAccountAddressStruct>;
|
19
|
+
//# sourceMappingURL=address.d.cts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"address.d.cts","sourceRoot":"","sources":["../../src/api/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;IACvC;;OAEG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { Infer } from "@metamask/superstruct";
|
2
|
+
/**
|
3
|
+
* An account's address that has been resolved from a signing request.
|
4
|
+
*/
|
5
|
+
export declare const ResolvedAccountAddressStruct: import("@metamask/superstruct").Struct<{
|
6
|
+
address: string;
|
7
|
+
}, {
|
8
|
+
/**
|
9
|
+
* Account main address.
|
10
|
+
*/
|
11
|
+
address: import("@metamask/superstruct").Struct<string, null>;
|
12
|
+
}>;
|
13
|
+
/**
|
14
|
+
* Resolve account's address object.
|
15
|
+
*
|
16
|
+
* See {@link ResolvedAccountAddressStruct}.
|
17
|
+
*/
|
18
|
+
export type ResolvedAccountAddress = Infer<typeof ResolvedAccountAddressStruct>;
|
19
|
+
//# sourceMappingURL=address.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"address.d.mts","sourceRoot":"","sources":["../../src/api/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;IACvC;;OAEG;;EAEH,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { object, string } from "@metamask/superstruct";
|
2
|
+
/**
|
3
|
+
* An account's address that has been resolved from a signing request.
|
4
|
+
*/
|
5
|
+
export const ResolvedAccountAddressStruct = object({
|
6
|
+
/**
|
7
|
+
* Account main address.
|
8
|
+
*/
|
9
|
+
address: string(),
|
10
|
+
});
|
11
|
+
//# sourceMappingURL=address.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"address.mjs","sourceRoot":"","sources":["../../src/api/address.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE;CAClB,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { object, string } from '@metamask/superstruct';\n\n/**\n * An account's address that has been resolved from a signing request.\n */\nexport const ResolvedAccountAddressStruct = object({\n /**\n * Account main address.\n */\n address: string(),\n});\n\n/**\n * Resolve account's address object.\n *\n * See {@link ResolvedAccountAddressStruct}.\n */\nexport type ResolvedAccountAddress = Infer<typeof ResolvedAccountAddressStruct>;\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"]}
|
package/dist/api/index.cjs
CHANGED
@@ -15,9 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./account.cjs"), exports);
|
18
|
+
__exportStar(require("./address.cjs"), exports);
|
18
19
|
__exportStar(require("./asset.cjs"), exports);
|
19
20
|
__exportStar(require("./balance.cjs"), exports);
|
20
|
-
__exportStar(require("./caip.cjs"), exports);
|
21
21
|
__exportStar(require("./export.cjs"), exports);
|
22
22
|
__exportStar(require("./request.cjs"), exports);
|
23
23
|
__exportStar(require("./response.cjs"), exports);
|
package/dist/api/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,8CAAwB;AACxB,gDAA0B;AAC1B
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,gDAA0B;AAC1B,8CAAwB;AACxB,gDAA0B;AAC1B,+CAAyB;AACzB,gDAA0B;AAC1B,iDAA2B;AAC3B,oDAA8B;AAC9B,mDAA6B","sourcesContent":["export * from './account';\nexport * from './address';\nexport * from './asset';\nexport * from './balance';\nexport * from './export';\nexport * from './request';\nexport * from './response';\nexport * from './transaction';\nexport * from './pagination';\nexport type * from './keyring';\n"]}
|
package/dist/api/index.d.cts
CHANGED
package/dist/api/index.d.cts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,6BAAyB;AACzB,8BAA0B;AAC1B,+BAA2B;AAC3B,kCAA8B;AAC9B,iCAA6B;AAC7B,mCAA+B"}
|
package/dist/api/index.d.mts
CHANGED
package/dist/api/index.d.mts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,6BAAyB;AACzB,8BAA0B;AAC1B,+BAA2B;AAC3B,kCAA8B;AAC9B,iCAA6B;AAC7B,mCAA+B"}
|
package/dist/api/index.mjs
CHANGED
package/dist/api/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,8BAA0B;AAC1B,4BAAwB;AACxB,8BAA0B;AAC1B,6BAAyB;AACzB,8BAA0B;AAC1B,+BAA2B;AAC3B,kCAA8B;AAC9B,iCAA6B","sourcesContent":["export * from './account';\nexport * from './address';\nexport * from './asset';\nexport * from './balance';\nexport * from './export';\nexport * from './request';\nexport * from './response';\nexport * from './transaction';\nexport * from './pagination';\nexport type * from './keyring';\n"]}
|