@metamask/snaps-utils 11.0.0 → 11.1.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 +8 -1
- package/dist/handlers/assets-market-data.cjs +65 -3
- package/dist/handlers/assets-market-data.cjs.map +1 -1
- package/dist/handlers/assets-market-data.d.cts +182 -3
- package/dist/handlers/assets-market-data.d.cts.map +1 -1
- package/dist/handlers/assets-market-data.d.mts +182 -3
- package/dist/handlers/assets-market-data.d.mts.map +1 -1
- package/dist/handlers/assets-market-data.mjs +66 -4
- package/dist/handlers/assets-market-data.mjs.map +1 -1
- package/dist/localization.d.cts +1 -1
- package/dist/localization.d.mts +1 -1
- package/dist/manifest/validation.d.cts +1 -1
- package/dist/manifest/validation.d.mts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [11.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add support for non-fungible assets to `endowment:assets` ([#3527](https://github.com/MetaMask/snaps/pull/3527))
|
|
15
|
+
|
|
10
16
|
## [11.0.0]
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -660,7 +666,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
660
666
|
- The version of the package no longer needs to match the version of all other
|
|
661
667
|
MetaMask Snaps packages.
|
|
662
668
|
|
|
663
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.
|
|
669
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.1.0...HEAD
|
|
670
|
+
[11.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.0.0...@metamask/snaps-utils@11.1.0
|
|
664
671
|
[11.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@10.1.0...@metamask/snaps-utils@11.0.0
|
|
665
672
|
[10.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@10.0.0...@metamask/snaps-utils@10.1.0
|
|
666
673
|
[10.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@9.4.0...@metamask/snaps-utils@10.0.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OnAssetsMarketDataResponseStruct = exports.FungibleAssetMarketDataStruct = exports.PricePercentChangeStruct = void 0;
|
|
3
|
+
exports.OnAssetsMarketDataResponseStruct = exports.AssetMarketDataStruct = exports.NonFungibleAssetMarketDataStruct = exports.AssetValueStruct = exports.FungibleAssetMarketDataStruct = exports.PricePercentChangeStruct = void 0;
|
|
4
4
|
const snaps_sdk_1 = require("@metamask/snaps-sdk");
|
|
5
5
|
const superstruct_1 = require("@metamask/superstruct");
|
|
6
6
|
const utils_1 = require("@metamask/utils");
|
|
@@ -10,7 +10,18 @@ const time_1 = require("../time.cjs");
|
|
|
10
10
|
*/
|
|
11
11
|
exports.PricePercentChangeStruct = (0, snaps_sdk_1.nonEmptyRecord)((0, superstruct_1.union)([(0, superstruct_1.literal)('all'), time_1.ISO8601DurationStruct]), (0, superstruct_1.number)());
|
|
12
12
|
/**
|
|
13
|
-
* A struct representing the market data for
|
|
13
|
+
* A struct representing the market data for a fungible asset.
|
|
14
|
+
*
|
|
15
|
+
* @property fungible - Indicates that this is a fungible asset.
|
|
16
|
+
* This is always `true` for fungible assets.
|
|
17
|
+
* @property marketCap - The market capitalization of the asset.
|
|
18
|
+
* @property totalVolume - The total volume of the asset.
|
|
19
|
+
* @property circulatingSupply - The circulating supply of the asset.
|
|
20
|
+
* @property allTimeHigh - The all-time high price of the asset.
|
|
21
|
+
* @property allTimeLow - The all-time low price of the asset.
|
|
22
|
+
* @property pricePercentChange - The percentage change in price over different intervals.
|
|
23
|
+
* @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
|
|
24
|
+
* or the string "all" to represent the all-time change.
|
|
14
25
|
*/
|
|
15
26
|
exports.FungibleAssetMarketDataStruct = (0, superstruct_1.object)({
|
|
16
27
|
fungible: (0, superstruct_1.literal)(true),
|
|
@@ -21,10 +32,61 @@ exports.FungibleAssetMarketDataStruct = (0, superstruct_1.object)({
|
|
|
21
32
|
allTimeLow: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
22
33
|
pricePercentChange: (0, superstruct_1.optional)(exports.PricePercentChangeStruct),
|
|
23
34
|
});
|
|
35
|
+
/**
|
|
36
|
+
* A struct representing an asset value, which includes the asset type and the amount.
|
|
37
|
+
*
|
|
38
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
39
|
+
* @property amount - The pice represented as a number in string format.
|
|
40
|
+
*/
|
|
41
|
+
exports.AssetValueStruct = (0, superstruct_1.object)({
|
|
42
|
+
asset: utils_1.CaipAssetTypeOrIdStruct,
|
|
43
|
+
amount: (0, superstruct_1.string)(),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* A struct representing the market data for a non-fungible asset.
|
|
47
|
+
*
|
|
48
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
49
|
+
* @property amount - The pice represented as a number in string format.
|
|
50
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
51
|
+
* This is always `false` for non-fungible assets.
|
|
52
|
+
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
53
|
+
* @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.
|
|
54
|
+
* @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.
|
|
55
|
+
* @property rarity - The rarity information for the asset, if available.
|
|
56
|
+
* @property rarity.ranking - The ranking of the asset's rarity, if available.
|
|
57
|
+
* @property rarity.ranking.source - The source of the rarity ranking.
|
|
58
|
+
* @property rarity.ranking.rank - The rank of the asset in the rarity ranking.
|
|
59
|
+
* @property rarity.metadata - Additional metadata about the asset's rarity, if available.
|
|
60
|
+
* This is a record of string keys and number values.
|
|
61
|
+
*/
|
|
62
|
+
exports.NonFungibleAssetMarketDataStruct = (0, superstruct_1.object)({
|
|
63
|
+
fungible: (0, superstruct_1.literal)(false),
|
|
64
|
+
lastSale: (0, superstruct_1.optional)(exports.AssetValueStruct),
|
|
65
|
+
topBid: (0, superstruct_1.optional)(exports.AssetValueStruct),
|
|
66
|
+
floorPrice: (0, superstruct_1.optional)(exports.AssetValueStruct),
|
|
67
|
+
rarity: (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
68
|
+
ranking: (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
69
|
+
source: (0, superstruct_1.string)(),
|
|
70
|
+
rank: (0, superstruct_1.number)(),
|
|
71
|
+
})),
|
|
72
|
+
metadata: (0, superstruct_1.optional)((0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.number)())),
|
|
73
|
+
})),
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.
|
|
77
|
+
*/
|
|
78
|
+
exports.AssetMarketDataStruct = (0, snaps_sdk_1.selectiveUnion)((marketData) => {
|
|
79
|
+
if ((0, utils_1.isObject)(marketData) && marketData.fungible) {
|
|
80
|
+
return exports.FungibleAssetMarketDataStruct;
|
|
81
|
+
}
|
|
82
|
+
return exports.NonFungibleAssetMarketDataStruct;
|
|
83
|
+
});
|
|
24
84
|
/**
|
|
25
85
|
* A struct representing the response of the `onAssetsMarketData` method.
|
|
86
|
+
*
|
|
87
|
+
* @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.
|
|
26
88
|
*/
|
|
27
89
|
exports.OnAssetsMarketDataResponseStruct = (0, superstruct_1.object)({
|
|
28
|
-
marketData: (0, superstruct_1.record)(utils_1.
|
|
90
|
+
marketData: (0, superstruct_1.record)(utils_1.CaipAssetTypeOrIdStruct, (0, superstruct_1.record)(utils_1.CaipAssetTypeStruct, (0, superstruct_1.nullable)(exports.AssetMarketDataStruct))),
|
|
29
91
|
});
|
|
30
92
|
//# sourceMappingURL=assets-market-data.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":";;;AAAA,mDAAqE;AACrE,uDAS+B;AAC/B,2CAIyB;AAEzB,sCAAgD;AAEhD;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,0BAAc,EACpD,IAAA,mBAAK,EAAC,CAAC,IAAA,qBAAO,EAAC,KAAK,CAAC,EAAE,4BAAqB,CAAC,CAAC,EAC9C,IAAA,oBAAM,GAAE,CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACU,QAAA,6BAA6B,GAAG,IAAA,oBAAM,EAAC;IAClD,QAAQ,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;IACvB,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC7B,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,iBAAiB,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACrC,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,UAAU,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC9B,kBAAkB,EAAE,IAAA,sBAAQ,EAAC,gCAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IACrC,KAAK,EAAE,+BAAuB;IAC9B,MAAM,EAAE,IAAA,oBAAM,GAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,QAAQ,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACpC,MAAM,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IAClC,UAAU,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IACtC,MAAM,EAAE,IAAA,sBAAQ,EACd,IAAA,oBAAM,EAAC;QACL,OAAO,EAAE,IAAA,sBAAQ,EACf,IAAA,oBAAM,EAAC;YACL,MAAM,EAAE,IAAA,oBAAM,GAAE;YAChB,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;QACD,QAAQ,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC;KAC/C,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,0BAAc,EAAC,CAAC,UAAU,EAAE,EAAE;IACjE,IAAI,IAAA,gBAAQ,EAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,qCAA6B,CAAC;IACvC,CAAC;IAED,OAAO,wCAAgC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,UAAU,EAAE,IAAA,oBAAM,EAChB,+BAAuB,EACvB,IAAA,oBAAM,EAAC,2BAAmB,EAAE,IAAA,sBAAQ,EAAC,6BAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord, selectiveUnion } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeOrIdStruct,\n CaipAssetTypeStruct,\n isObject,\n} from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport const FungibleAssetMarketDataStruct = object({\n fungible: literal(true),\n marketCap: optional(string()),\n totalVolume: optional(string()),\n circulatingSupply: optional(string()),\n allTimeHigh: optional(string()),\n allTimeLow: optional(string()),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing an asset value, which includes the asset type and the amount.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The pice represented as a number in string format.\n */\nexport const AssetValueStruct = object({\n asset: CaipAssetTypeOrIdStruct,\n amount: string(),\n});\n\n/**\n * A struct representing the market data for a non-fungible asset.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The pice represented as a number in string format.\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.\n * @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.\n * @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.\n * @property rarity - The rarity information for the asset, if available.\n * @property rarity.ranking - The ranking of the asset's rarity, if available.\n * @property rarity.ranking.source - The source of the rarity ranking.\n * @property rarity.ranking.rank - The rank of the asset in the rarity ranking.\n * @property rarity.metadata - Additional metadata about the asset's rarity, if available.\n * This is a record of string keys and number values.\n */\nexport const NonFungibleAssetMarketDataStruct = object({\n fungible: literal(false),\n lastSale: optional(AssetValueStruct),\n topBid: optional(AssetValueStruct),\n floorPrice: optional(AssetValueStruct),\n rarity: optional(\n object({\n ranking: optional(\n object({\n source: string(),\n rank: number(),\n }),\n ),\n metadata: optional(record(string(), number())),\n }),\n ),\n});\n\n/**\n * A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.\n */\nexport const AssetMarketDataStruct = selectiveUnion((marketData) => {\n if (isObject(marketData) && marketData.fungible) {\n return FungibleAssetMarketDataStruct;\n }\n\n return NonFungibleAssetMarketDataStruct;\n});\n\n/**\n * A struct representing the response of the `onAssetsMarketData` method.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.\n */\nexport const OnAssetsMarketDataResponseStruct = object({\n marketData: record(\n CaipAssetTypeOrIdStruct,\n record(CaipAssetTypeStruct, nullable(AssetMarketDataStruct)),\n ),\n});\n"]}
|
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const PricePercentChangeStruct: import("@metamask/superstruct").Struct<Record<string, number>, null>;
|
|
5
5
|
/**
|
|
6
|
-
* A struct representing the market data for
|
|
6
|
+
* A struct representing the market data for a fungible asset.
|
|
7
|
+
*
|
|
8
|
+
* @property fungible - Indicates that this is a fungible asset.
|
|
9
|
+
* This is always `true` for fungible assets.
|
|
10
|
+
* @property marketCap - The market capitalization of the asset.
|
|
11
|
+
* @property totalVolume - The total volume of the asset.
|
|
12
|
+
* @property circulatingSupply - The circulating supply of the asset.
|
|
13
|
+
* @property allTimeHigh - The all-time high price of the asset.
|
|
14
|
+
* @property allTimeLow - The all-time low price of the asset.
|
|
15
|
+
* @property pricePercentChange - The percentage change in price over different intervals.
|
|
16
|
+
* @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
|
|
17
|
+
* or the string "all" to represent the all-time change.
|
|
7
18
|
*/
|
|
8
19
|
export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
9
20
|
fungible: true;
|
|
@@ -22,11 +33,137 @@ export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruc
|
|
|
22
33
|
allTimeLow: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
23
34
|
pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
24
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* A struct representing an asset value, which includes the asset type and the amount.
|
|
38
|
+
*
|
|
39
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
40
|
+
* @property amount - The pice represented as a number in string format.
|
|
41
|
+
*/
|
|
42
|
+
export declare const AssetValueStruct: import("@metamask/superstruct").Struct<{
|
|
43
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
44
|
+
amount: string;
|
|
45
|
+
}, {
|
|
46
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
47
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* A struct representing the market data for a non-fungible asset.
|
|
51
|
+
*
|
|
52
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
53
|
+
* @property amount - The pice represented as a number in string format.
|
|
54
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
55
|
+
* This is always `false` for non-fungible assets.
|
|
56
|
+
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
57
|
+
* @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.
|
|
58
|
+
* @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.
|
|
59
|
+
* @property rarity - The rarity information for the asset, if available.
|
|
60
|
+
* @property rarity.ranking - The ranking of the asset's rarity, if available.
|
|
61
|
+
* @property rarity.ranking.source - The source of the rarity ranking.
|
|
62
|
+
* @property rarity.ranking.rank - The rank of the asset in the rarity ranking.
|
|
63
|
+
* @property rarity.metadata - Additional metadata about the asset's rarity, if available.
|
|
64
|
+
* This is a record of string keys and number values.
|
|
65
|
+
*/
|
|
66
|
+
export declare const NonFungibleAssetMarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
67
|
+
fungible: false;
|
|
68
|
+
lastSale?: {
|
|
69
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
70
|
+
amount: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
topBid?: {
|
|
73
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
74
|
+
amount: string;
|
|
75
|
+
} | undefined;
|
|
76
|
+
floorPrice?: {
|
|
77
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
78
|
+
amount: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
rarity?: {
|
|
81
|
+
ranking?: {
|
|
82
|
+
source: string;
|
|
83
|
+
rank: number;
|
|
84
|
+
} | undefined;
|
|
85
|
+
metadata?: Record<string, number> | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
fungible: import("@metamask/superstruct").Struct<false, false>;
|
|
89
|
+
lastSale: import("@metamask/superstruct").Struct<{
|
|
90
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
91
|
+
amount: string;
|
|
92
|
+
} | undefined, {
|
|
93
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
94
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
95
|
+
}>;
|
|
96
|
+
topBid: import("@metamask/superstruct").Struct<{
|
|
97
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
98
|
+
amount: string;
|
|
99
|
+
} | undefined, {
|
|
100
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
101
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
102
|
+
}>;
|
|
103
|
+
floorPrice: import("@metamask/superstruct").Struct<{
|
|
104
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
105
|
+
amount: string;
|
|
106
|
+
} | undefined, {
|
|
107
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
108
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
109
|
+
}>;
|
|
110
|
+
rarity: import("@metamask/superstruct").Struct<{
|
|
111
|
+
ranking?: {
|
|
112
|
+
source: string;
|
|
113
|
+
rank: number;
|
|
114
|
+
} | undefined;
|
|
115
|
+
metadata?: Record<string, number> | undefined;
|
|
116
|
+
} | undefined, {
|
|
117
|
+
ranking: import("@metamask/superstruct").Struct<{
|
|
118
|
+
source: string;
|
|
119
|
+
rank: number;
|
|
120
|
+
} | undefined, {
|
|
121
|
+
source: import("@metamask/superstruct").Struct<string, null>;
|
|
122
|
+
rank: import("@metamask/superstruct").Struct<number, null>;
|
|
123
|
+
}>;
|
|
124
|
+
metadata: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
125
|
+
}>;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.
|
|
129
|
+
*/
|
|
130
|
+
export declare const AssetMarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
131
|
+
fungible: true;
|
|
132
|
+
marketCap?: string | undefined;
|
|
133
|
+
totalVolume?: string | undefined;
|
|
134
|
+
circulatingSupply?: string | undefined;
|
|
135
|
+
allTimeHigh?: string | undefined;
|
|
136
|
+
allTimeLow?: string | undefined;
|
|
137
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
138
|
+
} | {
|
|
139
|
+
fungible: false;
|
|
140
|
+
lastSale?: {
|
|
141
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
142
|
+
amount: string;
|
|
143
|
+
} | undefined;
|
|
144
|
+
topBid?: {
|
|
145
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
146
|
+
amount: string;
|
|
147
|
+
} | undefined;
|
|
148
|
+
floorPrice?: {
|
|
149
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
150
|
+
amount: string;
|
|
151
|
+
} | undefined;
|
|
152
|
+
rarity?: {
|
|
153
|
+
ranking?: {
|
|
154
|
+
source: string;
|
|
155
|
+
rank: number;
|
|
156
|
+
} | undefined;
|
|
157
|
+
metadata?: Record<string, number> | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
}, null>;
|
|
25
160
|
/**
|
|
26
161
|
* A struct representing the response of the `onAssetsMarketData` method.
|
|
162
|
+
*
|
|
163
|
+
* @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.
|
|
27
164
|
*/
|
|
28
165
|
export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superstruct").Struct<{
|
|
29
|
-
marketData: Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
166
|
+
marketData: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
30
167
|
fungible: true;
|
|
31
168
|
marketCap?: string | undefined;
|
|
32
169
|
totalVolume?: string | undefined;
|
|
@@ -34,9 +171,30 @@ export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superst
|
|
|
34
171
|
allTimeHigh?: string | undefined;
|
|
35
172
|
allTimeLow?: string | undefined;
|
|
36
173
|
pricePercentChange?: Record<string, number> | undefined;
|
|
174
|
+
} | {
|
|
175
|
+
fungible: false;
|
|
176
|
+
lastSale?: {
|
|
177
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
178
|
+
amount: string;
|
|
179
|
+
} | undefined;
|
|
180
|
+
topBid?: {
|
|
181
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
182
|
+
amount: string;
|
|
183
|
+
} | undefined;
|
|
184
|
+
floorPrice?: {
|
|
185
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
186
|
+
amount: string;
|
|
187
|
+
} | undefined;
|
|
188
|
+
rarity?: {
|
|
189
|
+
ranking?: {
|
|
190
|
+
source: string;
|
|
191
|
+
rank: number;
|
|
192
|
+
} | undefined;
|
|
193
|
+
metadata?: Record<string, number> | undefined;
|
|
194
|
+
} | undefined;
|
|
37
195
|
} | null>>;
|
|
38
196
|
}, {
|
|
39
|
-
marketData: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
197
|
+
marketData: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
40
198
|
fungible: true;
|
|
41
199
|
marketCap?: string | undefined;
|
|
42
200
|
totalVolume?: string | undefined;
|
|
@@ -44,6 +202,27 @@ export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superst
|
|
|
44
202
|
allTimeHigh?: string | undefined;
|
|
45
203
|
allTimeLow?: string | undefined;
|
|
46
204
|
pricePercentChange?: Record<string, number> | undefined;
|
|
205
|
+
} | {
|
|
206
|
+
fungible: false;
|
|
207
|
+
lastSale?: {
|
|
208
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
209
|
+
amount: string;
|
|
210
|
+
} | undefined;
|
|
211
|
+
topBid?: {
|
|
212
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
213
|
+
amount: string;
|
|
214
|
+
} | undefined;
|
|
215
|
+
floorPrice?: {
|
|
216
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
217
|
+
amount: string;
|
|
218
|
+
} | undefined;
|
|
219
|
+
rarity?: {
|
|
220
|
+
ranking?: {
|
|
221
|
+
source: string;
|
|
222
|
+
rank: number;
|
|
223
|
+
} | undefined;
|
|
224
|
+
metadata?: Record<string, number> | undefined;
|
|
225
|
+
} | undefined;
|
|
47
226
|
} | null>>, null>;
|
|
48
227
|
}>;
|
|
49
228
|
//# sourceMappingURL=assets-market-data.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-market-data.d.cts","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assets-market-data.d.cts","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,eAAO,MAAM,wBAAwB,sEAGpC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;EAQxC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;EAG3B,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB3C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAMhC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAC"}
|
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const PricePercentChangeStruct: import("@metamask/superstruct").Struct<Record<string, number>, null>;
|
|
5
5
|
/**
|
|
6
|
-
* A struct representing the market data for
|
|
6
|
+
* A struct representing the market data for a fungible asset.
|
|
7
|
+
*
|
|
8
|
+
* @property fungible - Indicates that this is a fungible asset.
|
|
9
|
+
* This is always `true` for fungible assets.
|
|
10
|
+
* @property marketCap - The market capitalization of the asset.
|
|
11
|
+
* @property totalVolume - The total volume of the asset.
|
|
12
|
+
* @property circulatingSupply - The circulating supply of the asset.
|
|
13
|
+
* @property allTimeHigh - The all-time high price of the asset.
|
|
14
|
+
* @property allTimeLow - The all-time low price of the asset.
|
|
15
|
+
* @property pricePercentChange - The percentage change in price over different intervals.
|
|
16
|
+
* @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
|
|
17
|
+
* or the string "all" to represent the all-time change.
|
|
7
18
|
*/
|
|
8
19
|
export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
9
20
|
fungible: true;
|
|
@@ -22,11 +33,137 @@ export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruc
|
|
|
22
33
|
allTimeLow: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
23
34
|
pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
24
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* A struct representing an asset value, which includes the asset type and the amount.
|
|
38
|
+
*
|
|
39
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
40
|
+
* @property amount - The pice represented as a number in string format.
|
|
41
|
+
*/
|
|
42
|
+
export declare const AssetValueStruct: import("@metamask/superstruct").Struct<{
|
|
43
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
44
|
+
amount: string;
|
|
45
|
+
}, {
|
|
46
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
47
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* A struct representing the market data for a non-fungible asset.
|
|
51
|
+
*
|
|
52
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
53
|
+
* @property amount - The pice represented as a number in string format.
|
|
54
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
55
|
+
* This is always `false` for non-fungible assets.
|
|
56
|
+
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
57
|
+
* @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.
|
|
58
|
+
* @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.
|
|
59
|
+
* @property rarity - The rarity information for the asset, if available.
|
|
60
|
+
* @property rarity.ranking - The ranking of the asset's rarity, if available.
|
|
61
|
+
* @property rarity.ranking.source - The source of the rarity ranking.
|
|
62
|
+
* @property rarity.ranking.rank - The rank of the asset in the rarity ranking.
|
|
63
|
+
* @property rarity.metadata - Additional metadata about the asset's rarity, if available.
|
|
64
|
+
* This is a record of string keys and number values.
|
|
65
|
+
*/
|
|
66
|
+
export declare const NonFungibleAssetMarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
67
|
+
fungible: false;
|
|
68
|
+
lastSale?: {
|
|
69
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
70
|
+
amount: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
topBid?: {
|
|
73
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
74
|
+
amount: string;
|
|
75
|
+
} | undefined;
|
|
76
|
+
floorPrice?: {
|
|
77
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
78
|
+
amount: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
rarity?: {
|
|
81
|
+
ranking?: {
|
|
82
|
+
source: string;
|
|
83
|
+
rank: number;
|
|
84
|
+
} | undefined;
|
|
85
|
+
metadata?: Record<string, number> | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
fungible: import("@metamask/superstruct").Struct<false, false>;
|
|
89
|
+
lastSale: import("@metamask/superstruct").Struct<{
|
|
90
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
91
|
+
amount: string;
|
|
92
|
+
} | undefined, {
|
|
93
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
94
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
95
|
+
}>;
|
|
96
|
+
topBid: import("@metamask/superstruct").Struct<{
|
|
97
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
98
|
+
amount: string;
|
|
99
|
+
} | undefined, {
|
|
100
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
101
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
102
|
+
}>;
|
|
103
|
+
floorPrice: import("@metamask/superstruct").Struct<{
|
|
104
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
105
|
+
amount: string;
|
|
106
|
+
} | undefined, {
|
|
107
|
+
asset: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
|
|
108
|
+
amount: import("@metamask/superstruct").Struct<string, null>;
|
|
109
|
+
}>;
|
|
110
|
+
rarity: import("@metamask/superstruct").Struct<{
|
|
111
|
+
ranking?: {
|
|
112
|
+
source: string;
|
|
113
|
+
rank: number;
|
|
114
|
+
} | undefined;
|
|
115
|
+
metadata?: Record<string, number> | undefined;
|
|
116
|
+
} | undefined, {
|
|
117
|
+
ranking: import("@metamask/superstruct").Struct<{
|
|
118
|
+
source: string;
|
|
119
|
+
rank: number;
|
|
120
|
+
} | undefined, {
|
|
121
|
+
source: import("@metamask/superstruct").Struct<string, null>;
|
|
122
|
+
rank: import("@metamask/superstruct").Struct<number, null>;
|
|
123
|
+
}>;
|
|
124
|
+
metadata: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
|
|
125
|
+
}>;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.
|
|
129
|
+
*/
|
|
130
|
+
export declare const AssetMarketDataStruct: import("@metamask/superstruct").Struct<{
|
|
131
|
+
fungible: true;
|
|
132
|
+
marketCap?: string | undefined;
|
|
133
|
+
totalVolume?: string | undefined;
|
|
134
|
+
circulatingSupply?: string | undefined;
|
|
135
|
+
allTimeHigh?: string | undefined;
|
|
136
|
+
allTimeLow?: string | undefined;
|
|
137
|
+
pricePercentChange?: Record<string, number> | undefined;
|
|
138
|
+
} | {
|
|
139
|
+
fungible: false;
|
|
140
|
+
lastSale?: {
|
|
141
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
142
|
+
amount: string;
|
|
143
|
+
} | undefined;
|
|
144
|
+
topBid?: {
|
|
145
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
146
|
+
amount: string;
|
|
147
|
+
} | undefined;
|
|
148
|
+
floorPrice?: {
|
|
149
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
150
|
+
amount: string;
|
|
151
|
+
} | undefined;
|
|
152
|
+
rarity?: {
|
|
153
|
+
ranking?: {
|
|
154
|
+
source: string;
|
|
155
|
+
rank: number;
|
|
156
|
+
} | undefined;
|
|
157
|
+
metadata?: Record<string, number> | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
}, null>;
|
|
25
160
|
/**
|
|
26
161
|
* A struct representing the response of the `onAssetsMarketData` method.
|
|
162
|
+
*
|
|
163
|
+
* @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.
|
|
27
164
|
*/
|
|
28
165
|
export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superstruct").Struct<{
|
|
29
|
-
marketData: Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
166
|
+
marketData: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
30
167
|
fungible: true;
|
|
31
168
|
marketCap?: string | undefined;
|
|
32
169
|
totalVolume?: string | undefined;
|
|
@@ -34,9 +171,30 @@ export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superst
|
|
|
34
171
|
allTimeHigh?: string | undefined;
|
|
35
172
|
allTimeLow?: string | undefined;
|
|
36
173
|
pricePercentChange?: Record<string, number> | undefined;
|
|
174
|
+
} | {
|
|
175
|
+
fungible: false;
|
|
176
|
+
lastSale?: {
|
|
177
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
178
|
+
amount: string;
|
|
179
|
+
} | undefined;
|
|
180
|
+
topBid?: {
|
|
181
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
182
|
+
amount: string;
|
|
183
|
+
} | undefined;
|
|
184
|
+
floorPrice?: {
|
|
185
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
186
|
+
amount: string;
|
|
187
|
+
} | undefined;
|
|
188
|
+
rarity?: {
|
|
189
|
+
ranking?: {
|
|
190
|
+
source: string;
|
|
191
|
+
rank: number;
|
|
192
|
+
} | undefined;
|
|
193
|
+
metadata?: Record<string, number> | undefined;
|
|
194
|
+
} | undefined;
|
|
37
195
|
} | null>>;
|
|
38
196
|
}, {
|
|
39
|
-
marketData: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
197
|
+
marketData: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
|
|
40
198
|
fungible: true;
|
|
41
199
|
marketCap?: string | undefined;
|
|
42
200
|
totalVolume?: string | undefined;
|
|
@@ -44,6 +202,27 @@ export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superst
|
|
|
44
202
|
allTimeHigh?: string | undefined;
|
|
45
203
|
allTimeLow?: string | undefined;
|
|
46
204
|
pricePercentChange?: Record<string, number> | undefined;
|
|
205
|
+
} | {
|
|
206
|
+
fungible: false;
|
|
207
|
+
lastSale?: {
|
|
208
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
209
|
+
amount: string;
|
|
210
|
+
} | undefined;
|
|
211
|
+
topBid?: {
|
|
212
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
213
|
+
amount: string;
|
|
214
|
+
} | undefined;
|
|
215
|
+
floorPrice?: {
|
|
216
|
+
asset: `${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`;
|
|
217
|
+
amount: string;
|
|
218
|
+
} | undefined;
|
|
219
|
+
rarity?: {
|
|
220
|
+
ranking?: {
|
|
221
|
+
source: string;
|
|
222
|
+
rank: number;
|
|
223
|
+
} | undefined;
|
|
224
|
+
metadata?: Record<string, number> | undefined;
|
|
225
|
+
} | undefined;
|
|
47
226
|
} | null>>, null>;
|
|
48
227
|
}>;
|
|
49
228
|
//# sourceMappingURL=assets-market-data.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-market-data.d.mts","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assets-market-data.d.mts","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,eAAO,MAAM,wBAAwB,sEAGpC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;EAQxC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;EAG3B,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB3C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAMhC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAC"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import { nonEmptyRecord } from "@metamask/snaps-sdk";
|
|
1
|
+
import { nonEmptyRecord, selectiveUnion } from "@metamask/snaps-sdk";
|
|
2
2
|
import { literal, nullable, number, object, optional, record, string, union } from "@metamask/superstruct";
|
|
3
|
-
import { CaipAssetTypeStruct } from "@metamask/utils";
|
|
3
|
+
import { CaipAssetTypeOrIdStruct, CaipAssetTypeStruct, isObject } from "@metamask/utils";
|
|
4
4
|
import { ISO8601DurationStruct } from "../time.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* A struct representing the market data for an asset.
|
|
7
7
|
*/
|
|
8
8
|
export const PricePercentChangeStruct = nonEmptyRecord(union([literal('all'), ISO8601DurationStruct]), number());
|
|
9
9
|
/**
|
|
10
|
-
* A struct representing the market data for
|
|
10
|
+
* A struct representing the market data for a fungible asset.
|
|
11
|
+
*
|
|
12
|
+
* @property fungible - Indicates that this is a fungible asset.
|
|
13
|
+
* This is always `true` for fungible assets.
|
|
14
|
+
* @property marketCap - The market capitalization of the asset.
|
|
15
|
+
* @property totalVolume - The total volume of the asset.
|
|
16
|
+
* @property circulatingSupply - The circulating supply of the asset.
|
|
17
|
+
* @property allTimeHigh - The all-time high price of the asset.
|
|
18
|
+
* @property allTimeLow - The all-time low price of the asset.
|
|
19
|
+
* @property pricePercentChange - The percentage change in price over different intervals.
|
|
20
|
+
* @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration
|
|
21
|
+
* or the string "all" to represent the all-time change.
|
|
11
22
|
*/
|
|
12
23
|
export const FungibleAssetMarketDataStruct = object({
|
|
13
24
|
fungible: literal(true),
|
|
@@ -18,10 +29,61 @@ export const FungibleAssetMarketDataStruct = object({
|
|
|
18
29
|
allTimeLow: optional(string()),
|
|
19
30
|
pricePercentChange: optional(PricePercentChangeStruct),
|
|
20
31
|
});
|
|
32
|
+
/**
|
|
33
|
+
* A struct representing an asset value, which includes the asset type and the amount.
|
|
34
|
+
*
|
|
35
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
36
|
+
* @property amount - The pice represented as a number in string format.
|
|
37
|
+
*/
|
|
38
|
+
export const AssetValueStruct = object({
|
|
39
|
+
asset: CaipAssetTypeOrIdStruct,
|
|
40
|
+
amount: string(),
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* A struct representing the market data for a non-fungible asset.
|
|
44
|
+
*
|
|
45
|
+
* @property asset - The CAIP-19 asset type or ID of the asset.
|
|
46
|
+
* @property amount - The pice represented as a number in string format.
|
|
47
|
+
* @property fungible - Indicates that this is a non-fungible asset.
|
|
48
|
+
* This is always `false` for non-fungible assets.
|
|
49
|
+
* @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.
|
|
50
|
+
* @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.
|
|
51
|
+
* @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.
|
|
52
|
+
* @property rarity - The rarity information for the asset, if available.
|
|
53
|
+
* @property rarity.ranking - The ranking of the asset's rarity, if available.
|
|
54
|
+
* @property rarity.ranking.source - The source of the rarity ranking.
|
|
55
|
+
* @property rarity.ranking.rank - The rank of the asset in the rarity ranking.
|
|
56
|
+
* @property rarity.metadata - Additional metadata about the asset's rarity, if available.
|
|
57
|
+
* This is a record of string keys and number values.
|
|
58
|
+
*/
|
|
59
|
+
export const NonFungibleAssetMarketDataStruct = object({
|
|
60
|
+
fungible: literal(false),
|
|
61
|
+
lastSale: optional(AssetValueStruct),
|
|
62
|
+
topBid: optional(AssetValueStruct),
|
|
63
|
+
floorPrice: optional(AssetValueStruct),
|
|
64
|
+
rarity: optional(object({
|
|
65
|
+
ranking: optional(object({
|
|
66
|
+
source: string(),
|
|
67
|
+
rank: number(),
|
|
68
|
+
})),
|
|
69
|
+
metadata: optional(record(string(), number())),
|
|
70
|
+
})),
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.
|
|
74
|
+
*/
|
|
75
|
+
export const AssetMarketDataStruct = selectiveUnion((marketData) => {
|
|
76
|
+
if (isObject(marketData) && marketData.fungible) {
|
|
77
|
+
return FungibleAssetMarketDataStruct;
|
|
78
|
+
}
|
|
79
|
+
return NonFungibleAssetMarketDataStruct;
|
|
80
|
+
});
|
|
21
81
|
/**
|
|
22
82
|
* A struct representing the response of the `onAssetsMarketData` method.
|
|
83
|
+
*
|
|
84
|
+
* @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.
|
|
23
85
|
*/
|
|
24
86
|
export const OnAssetsMarketDataResponseStruct = object({
|
|
25
|
-
marketData: record(
|
|
87
|
+
marketData: record(CaipAssetTypeOrIdStruct, record(CaipAssetTypeStruct, nullable(AssetMarketDataStruct))),
|
|
26
88
|
});
|
|
27
89
|
//# sourceMappingURL=assets-market-data.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../src/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,4BAA4B;AACrE,OAAO,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACT,wBAAwB;AAEzB,OAAO,EAAE,qBAAqB,EAAE,oBAAgB;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CACpD,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAC9C,MAAM,EAAE,CACT,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;IAClD,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC7B,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACrC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC9B,kBAAkB,EAAE,QAAQ,CAAC,wBAAwB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACrC,KAAK,EAAE,uBAAuB;IAC9B,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IACpC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAClC,UAAU,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IACtC,MAAM,EAAE,QAAQ,CACd,MAAM,CAAC;QACL,OAAO,EAAE,QAAQ,CACf,MAAM,CAAC;YACL,MAAM,EAAE,MAAM,EAAE;YAChB,IAAI,EAAE,MAAM,EAAE;SACf,CAAC,CACH;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;KAC/C,CAAC,CACH;CACF,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC,CAAC,UAAU,EAAE,EAAE;IACjE,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,6BAA6B,CAAC;IACvC,CAAC;IAED,OAAO,gCAAgC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,UAAU,EAAE,MAAM,CAChB,uBAAuB,EACvB,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAC7D;CACF,CAAC,CAAC","sourcesContent":["import { nonEmptyRecord, selectiveUnion } from '@metamask/snaps-sdk';\nimport {\n literal,\n nullable,\n number,\n object,\n optional,\n record,\n string,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeOrIdStruct,\n CaipAssetTypeStruct,\n isObject,\n} from '@metamask/utils';\n\nimport { ISO8601DurationStruct } from '../time';\n\n/**\n * A struct representing the market data for an asset.\n */\nexport const PricePercentChangeStruct = nonEmptyRecord(\n union([literal('all'), ISO8601DurationStruct]),\n number(),\n);\n\n/**\n * A struct representing the market data for a fungible asset.\n *\n * @property fungible - Indicates that this is a fungible asset.\n * This is always `true` for fungible assets.\n * @property marketCap - The market capitalization of the asset.\n * @property totalVolume - The total volume of the asset.\n * @property circulatingSupply - The circulating supply of the asset.\n * @property allTimeHigh - The all-time high price of the asset.\n * @property allTimeLow - The all-time low price of the asset.\n * @property pricePercentChange - The percentage change in price over different intervals.\n * @property pricePercentChange.interval - The time interval for the price change as a ISO 8601 duration\n * or the string \"all\" to represent the all-time change.\n */\nexport const FungibleAssetMarketDataStruct = object({\n fungible: literal(true),\n marketCap: optional(string()),\n totalVolume: optional(string()),\n circulatingSupply: optional(string()),\n allTimeHigh: optional(string()),\n allTimeLow: optional(string()),\n pricePercentChange: optional(PricePercentChangeStruct),\n});\n\n/**\n * A struct representing an asset value, which includes the asset type and the amount.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The pice represented as a number in string format.\n */\nexport const AssetValueStruct = object({\n asset: CaipAssetTypeOrIdStruct,\n amount: string(),\n});\n\n/**\n * A struct representing the market data for a non-fungible asset.\n *\n * @property asset - The CAIP-19 asset type or ID of the asset.\n * @property amount - The pice represented as a number in string format.\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property lastSale - The last sale price of the asset, if available. See {@link AssetValueStruct}.\n * @property topBid - The top bid price for the asset, if available. See {@link AssetValueStruct}.\n * @property floorPrice - The floor price of the asset, if available. See {@link AssetValueStruct}.\n * @property rarity - The rarity information for the asset, if available.\n * @property rarity.ranking - The ranking of the asset's rarity, if available.\n * @property rarity.ranking.source - The source of the rarity ranking.\n * @property rarity.ranking.rank - The rank of the asset in the rarity ranking.\n * @property rarity.metadata - Additional metadata about the asset's rarity, if available.\n * This is a record of string keys and number values.\n */\nexport const NonFungibleAssetMarketDataStruct = object({\n fungible: literal(false),\n lastSale: optional(AssetValueStruct),\n topBid: optional(AssetValueStruct),\n floorPrice: optional(AssetValueStruct),\n rarity: optional(\n object({\n ranking: optional(\n object({\n source: string(),\n rank: number(),\n }),\n ),\n metadata: optional(record(string(), number())),\n }),\n ),\n});\n\n/**\n * A struct representing the market data for an asset, which can be either {@link FungibleAssetMarketDataStruct} or {@link NonFungibleAssetMarketDataStruct}.\n */\nexport const AssetMarketDataStruct = selectiveUnion((marketData) => {\n if (isObject(marketData) && marketData.fungible) {\n return FungibleAssetMarketDataStruct;\n }\n\n return NonFungibleAssetMarketDataStruct;\n});\n\n/**\n * A struct representing the response of the `onAssetsMarketData` method.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.\n */\nexport const OnAssetsMarketDataResponseStruct = object({\n marketData: record(\n CaipAssetTypeOrIdStruct,\n record(CaipAssetTypeStruct, nullable(AssetMarketDataStruct)),\n ),\n});\n"]}
|
package/dist/localization.d.cts
CHANGED
|
@@ -63,7 +63,6 @@ export declare function translate(value: string, file: LocalizationFile | undefi
|
|
|
63
63
|
* @returns The localized Snap manifest.
|
|
64
64
|
*/
|
|
65
65
|
export declare function getLocalizedSnapManifest(snapManifest: SnapManifest, locale: string, localizationFiles: LocalizationFile[]): {
|
|
66
|
-
description: string;
|
|
67
66
|
source: {
|
|
68
67
|
shasum: string;
|
|
69
68
|
location: {
|
|
@@ -77,6 +76,7 @@ export declare function getLocalizedSnapManifest(snapManifest: SnapManifest, loc
|
|
|
77
76
|
files?: string[] | undefined;
|
|
78
77
|
locales?: string[] | undefined;
|
|
79
78
|
};
|
|
79
|
+
description: string;
|
|
80
80
|
version: import("@metamask/utils").SemVerVersion;
|
|
81
81
|
proposedName: string;
|
|
82
82
|
initialPermissions: Partial<{
|
package/dist/localization.d.mts
CHANGED
|
@@ -63,7 +63,6 @@ export declare function translate(value: string, file: LocalizationFile | undefi
|
|
|
63
63
|
* @returns The localized Snap manifest.
|
|
64
64
|
*/
|
|
65
65
|
export declare function getLocalizedSnapManifest(snapManifest: SnapManifest, locale: string, localizationFiles: LocalizationFile[]): {
|
|
66
|
-
description: string;
|
|
67
66
|
source: {
|
|
68
67
|
shasum: string;
|
|
69
68
|
location: {
|
|
@@ -77,6 +76,7 @@ export declare function getLocalizedSnapManifest(snapManifest: SnapManifest, loc
|
|
|
77
76
|
files?: string[] | undefined;
|
|
78
77
|
locales?: string[] | undefined;
|
|
79
78
|
};
|
|
79
|
+
description: string;
|
|
80
80
|
version: import("@metamask/utils").SemVerVersion;
|
|
81
81
|
proposedName: string;
|
|
82
82
|
initialPermissions: Partial<{
|
|
@@ -60,7 +60,6 @@ export declare const SnapAuxilaryFilesStruct: Struct<string[], Struct<string, nu
|
|
|
60
60
|
export declare const InitialConnectionsStruct: Struct<Record<string, {}>, null>;
|
|
61
61
|
export type InitialConnections = Infer<typeof InitialConnectionsStruct>;
|
|
62
62
|
export declare const SnapManifestStruct: Struct<{
|
|
63
|
-
description: string;
|
|
64
63
|
source: {
|
|
65
64
|
shasum: string;
|
|
66
65
|
location: {
|
|
@@ -74,6 +73,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
74
73
|
files?: string[] | undefined;
|
|
75
74
|
locales?: string[] | undefined;
|
|
76
75
|
};
|
|
76
|
+
description: string;
|
|
77
77
|
version: import("@metamask/utils").SemVerVersion;
|
|
78
78
|
proposedName: string;
|
|
79
79
|
initialPermissions: Partial<{
|
|
@@ -60,7 +60,6 @@ export declare const SnapAuxilaryFilesStruct: Struct<string[], Struct<string, nu
|
|
|
60
60
|
export declare const InitialConnectionsStruct: Struct<Record<string, {}>, null>;
|
|
61
61
|
export type InitialConnections = Infer<typeof InitialConnectionsStruct>;
|
|
62
62
|
export declare const SnapManifestStruct: Struct<{
|
|
63
|
-
description: string;
|
|
64
63
|
source: {
|
|
65
64
|
shasum: string;
|
|
66
65
|
location: {
|
|
@@ -74,6 +73,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
74
73
|
files?: string[] | undefined;
|
|
75
74
|
locales?: string[] | undefined;
|
|
76
75
|
};
|
|
76
|
+
description: string;
|
|
77
77
|
version: import("@metamask/utils").SemVerVersion;
|
|
78
78
|
proposedName: string;
|
|
79
79
|
initialPermissions: Partial<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "A collection of utilities for MetaMask Snaps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
"@metamask/base-controller": "^8.0.1",
|
|
84
84
|
"@metamask/key-tree": "^10.1.1",
|
|
85
85
|
"@metamask/permission-controller": "^11.0.6",
|
|
86
|
-
"@metamask/rpc-errors": "^7.0.
|
|
86
|
+
"@metamask/rpc-errors": "^7.0.3",
|
|
87
87
|
"@metamask/slip44": "^4.2.0",
|
|
88
88
|
"@metamask/snaps-registry": "^3.2.3",
|
|
89
|
-
"@metamask/snaps-sdk": "^9.
|
|
89
|
+
"@metamask/snaps-sdk": "^9.2.0",
|
|
90
90
|
"@metamask/superstruct": "^3.2.1",
|
|
91
|
-
"@metamask/utils": "^11.4.
|
|
91
|
+
"@metamask/utils": "^11.4.2",
|
|
92
92
|
"@noble/hashes": "^1.7.1",
|
|
93
93
|
"@scure/base": "^1.1.1",
|
|
94
94
|
"chalk": "^4.1.2",
|