@metamask/snaps-utils 11.0.0 → 11.2.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 +15 -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/handlers/exports.cjs +14 -0
- package/dist/handlers/exports.cjs.map +1 -1
- package/dist/handlers/exports.d.cts +10 -0
- package/dist/handlers/exports.d.cts.map +1 -1
- package/dist/handlers/exports.d.mts +10 -0
- package/dist/handlers/exports.d.mts.map +1 -1
- package/dist/handlers/exports.mjs +14 -0
- package/dist/handlers/exports.mjs.map +1 -1
- package/dist/handlers/types.cjs +2 -0
- package/dist/handlers/types.cjs.map +1 -1
- package/dist/handlers/types.d.cts +2 -0
- package/dist/handlers/types.d.cts.map +1 -1
- package/dist/handlers/types.d.mts +2 -0
- package/dist/handlers/types.d.mts.map +1 -1
- package/dist/handlers/types.mjs +2 -0
- package/dist/handlers/types.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,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [11.2.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add support for `onActive` and `onInactive` lifecycle hooks ([#3542](https://github.com/MetaMask/snaps/pull/3542))
|
|
15
|
+
|
|
16
|
+
## [11.1.0]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Add support for non-fungible assets to `endowment:assets` ([#3527](https://github.com/MetaMask/snaps/pull/3527))
|
|
21
|
+
|
|
10
22
|
## [11.0.0]
|
|
11
23
|
|
|
12
24
|
### Added
|
|
@@ -660,7 +672,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
660
672
|
- The version of the package no longer needs to match the version of all other
|
|
661
673
|
MetaMask Snaps packages.
|
|
662
674
|
|
|
663
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.
|
|
675
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.2.0...HEAD
|
|
676
|
+
[11.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.1.0...@metamask/snaps-utils@11.2.0
|
|
677
|
+
[11.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@11.0.0...@metamask/snaps-utils@11.1.0
|
|
664
678
|
[11.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@10.1.0...@metamask/snaps-utils@11.0.0
|
|
665
679
|
[10.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@10.0.0...@metamask/snaps-utils@10.1.0
|
|
666
680
|
[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,C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AAE;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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M,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"]}
|
|
@@ -52,6 +52,20 @@ exports.SNAP_EXPORTS = {
|
|
|
52
52
|
return typeof snapExport === 'function';
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
+
[types_1.HandlerType.OnActive]: {
|
|
56
|
+
type: types_1.HandlerType.OnActive,
|
|
57
|
+
required: false,
|
|
58
|
+
validator: (snapExport) => {
|
|
59
|
+
return typeof snapExport === 'function';
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
[types_1.HandlerType.OnInactive]: {
|
|
63
|
+
type: types_1.HandlerType.OnInactive,
|
|
64
|
+
required: false,
|
|
65
|
+
validator: (snapExport) => {
|
|
66
|
+
return typeof snapExport === 'function';
|
|
67
|
+
},
|
|
68
|
+
},
|
|
55
69
|
[types_1.HandlerType.OnKeyringRequest]: {
|
|
56
70
|
type: types_1.HandlerType.OnKeyringRequest,
|
|
57
71
|
required: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.cjs","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"exports.cjs","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":";;;AAwBA,uCAAsC;AAEzB,QAAA,YAAY,GAAG;IAC1B,CAAC,mBAAW,CAAC,YAAY,CAAC,EAAE;QAC1B,IAAI,EAAE,mBAAW,CAAC,YAAY;QAC9B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAqC,EAAE;YACpE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,mBAAW,CAAC,aA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B,EAAE;YAC1C,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,mBAAW,CAAC,eAAe,CAAC,EAAE;QAC7B,IAAI,EAAE,mBAAW,CAAC,eAAe;QACjC,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAwC,EAAE;YACvE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,mBAAW,CAAC,gBAAgB,CAAC,EAAE;QAC9B,IAAI,EAAE,mBAAW,CAAC,gBAAgB;QAClC,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAyC,EAAE;YACxE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;CACO,CAAC;AAEE,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAW,CAAC,CAAC","sourcesContent":["import type {\n OnActiveHandler,\n OnAssetHistoricalPriceHandler,\n OnAssetsConversionHandler,\n OnAssetsLookupHandler,\n OnAssetsMarketDataHandler,\n OnClientRequestHandler,\n OnCronjobHandler,\n OnHomePageHandler,\n OnInactiveHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnProtocolRequestHandler,\n OnRpcRequestHandler,\n OnSettingsPageHandler,\n OnSignatureHandler,\n OnStartHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n OnWebSocketEventHandler,\n} from '@metamask/snaps-sdk';\n\nimport { HandlerType } from './types';\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnStart]: {\n type: HandlerType.OnStart,\n required: false,\n validator: (snapExport: unknown): snapExport is OnStartHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnActive]: {\n type: HandlerType.OnActive,\n required: false,\n validator: (snapExport: unknown): snapExport is OnActiveHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInactive]: {\n type: HandlerType.OnInactive,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInactiveHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSettingsPage]: {\n type: HandlerType.OnSettingsPage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSettingsPageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetHistoricalPrice]: {\n type: HandlerType.OnAssetHistoricalPrice,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetHistoricalPriceHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsLookup]: {\n type: HandlerType.OnAssetsLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnAssetsLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsConversion]: {\n type: HandlerType.OnAssetsConversion,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetsConversionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsMarketData]: {\n type: HandlerType.OnAssetsMarketData,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetsMarketDataHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnProtocolRequest]: {\n type: HandlerType.OnProtocolRequest,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnProtocolRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnClientRequest]: {\n type: HandlerType.OnClientRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnClientRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnWebSocketEvent]: {\n type: HandlerType.OnWebSocketEvent,\n required: true,\n validator: (snapExport: unknown): snapExport is OnWebSocketEventHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"]}
|
|
@@ -36,6 +36,16 @@ export declare const SNAP_EXPORTS: {
|
|
|
36
36
|
readonly required: false;
|
|
37
37
|
readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
|
|
38
38
|
};
|
|
39
|
+
readonly onActive: {
|
|
40
|
+
readonly type: HandlerType.OnActive;
|
|
41
|
+
readonly required: false;
|
|
42
|
+
readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
|
|
43
|
+
};
|
|
44
|
+
readonly onInactive: {
|
|
45
|
+
readonly type: HandlerType.OnInactive;
|
|
46
|
+
readonly required: false;
|
|
47
|
+
readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
|
|
48
|
+
};
|
|
39
49
|
readonly onKeyringRequest: {
|
|
40
50
|
readonly type: HandlerType.OnKeyringRequest;
|
|
41
51
|
readonly required: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.cts","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"exports.d.cts","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAGjB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAElB,oBAAoB,EAEpB,kBAAkB,EAClB,uBAAuB,EACxB,4BAA4B;AAE7B,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,eAAO,MAAM,YAAY;;;;yCAIG,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAQjB,OAAO;;;;;yCAQG,OAAO;;;;;yCAQjB,OAAO;;;;;yCASP,OAAO;;;;;yCASP,OAAO;;;;;yCAQG,OAAO;;;;;yCAOP,OAAO;;CAIzB,CAAC;AAEX,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}
|
|
@@ -36,6 +36,16 @@ export declare const SNAP_EXPORTS: {
|
|
|
36
36
|
readonly required: false;
|
|
37
37
|
readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
|
|
38
38
|
};
|
|
39
|
+
readonly onActive: {
|
|
40
|
+
readonly type: HandlerType.OnActive;
|
|
41
|
+
readonly required: false;
|
|
42
|
+
readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
|
|
43
|
+
};
|
|
44
|
+
readonly onInactive: {
|
|
45
|
+
readonly type: HandlerType.OnInactive;
|
|
46
|
+
readonly required: false;
|
|
47
|
+
readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
|
|
48
|
+
};
|
|
39
49
|
readonly onKeyringRequest: {
|
|
40
50
|
readonly type: HandlerType.OnKeyringRequest;
|
|
41
51
|
readonly required: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.mts","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"exports.d.mts","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAGjB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAElB,oBAAoB,EAEpB,kBAAkB,EAClB,uBAAuB,EACxB,4BAA4B;AAE7B,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,eAAO,MAAM,YAAY;;;;yCAIG,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAOP,OAAO;;;;;yCAQjB,OAAO;;;;;yCAQG,OAAO;;;;;yCAQjB,OAAO;;;;;yCASP,OAAO;;;;;yCASP,OAAO;;;;;yCAQG,OAAO;;;;;yCAOP,OAAO;;CAIzB,CAAC;AAEX,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}
|
|
@@ -49,6 +49,20 @@ export const SNAP_EXPORTS = {
|
|
|
49
49
|
return typeof snapExport === 'function';
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
+
[HandlerType.OnActive]: {
|
|
53
|
+
type: HandlerType.OnActive,
|
|
54
|
+
required: false,
|
|
55
|
+
validator: (snapExport) => {
|
|
56
|
+
return typeof snapExport === 'function';
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
[HandlerType.OnInactive]: {
|
|
60
|
+
type: HandlerType.OnInactive,
|
|
61
|
+
required: false,
|
|
62
|
+
validator: (snapExport) => {
|
|
63
|
+
return typeof snapExport === 'function';
|
|
64
|
+
},
|
|
65
|
+
},
|
|
52
66
|
[HandlerType.OnKeyringRequest]: {
|
|
53
67
|
type: HandlerType.OnKeyringRequest,
|
|
54
68
|
required: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.mjs","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exports.mjs","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,CAAC,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AU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE;QAC/B,IAAI,EAAE,WAAW,CAAC,iBAAiB;QACnC,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CACT,UAAmB,EACqB,EAAE;YAC1C,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE;QAC7B,IAAI,EAAE,WAAW,CAAC,eAAe;QACjC,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAwC,EAAE;YACvE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE;QAC9B,IAAI,EAAE,WAAW,CAAC,gBAAgB;QAClC,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAyC,EAAE;YACxE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import type {\n OnActiveHandler,\n OnAssetHistoricalPriceHandler,\n OnAssetsConversionHandler,\n OnAssetsLookupHandler,\n OnAssetsMarketDataHandler,\n OnClientRequestHandler,\n OnCronjobHandler,\n OnHomePageHandler,\n OnInactiveHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnProtocolRequestHandler,\n OnRpcRequestHandler,\n OnSettingsPageHandler,\n OnSignatureHandler,\n OnStartHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n OnWebSocketEventHandler,\n} from '@metamask/snaps-sdk';\n\nimport { HandlerType } from './types';\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnStart]: {\n type: HandlerType.OnStart,\n required: false,\n validator: (snapExport: unknown): snapExport is OnStartHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnActive]: {\n type: HandlerType.OnActive,\n required: false,\n validator: (snapExport: unknown): snapExport is OnActiveHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInactive]: {\n type: HandlerType.OnInactive,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInactiveHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSettingsPage]: {\n type: HandlerType.OnSettingsPage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSettingsPageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetHistoricalPrice]: {\n type: HandlerType.OnAssetHistoricalPrice,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetHistoricalPriceHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsLookup]: {\n type: HandlerType.OnAssetsLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnAssetsLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsConversion]: {\n type: HandlerType.OnAssetsConversion,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetsConversionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsMarketData]: {\n type: HandlerType.OnAssetsMarketData,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetsMarketDataHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnProtocolRequest]: {\n type: HandlerType.OnProtocolRequest,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnProtocolRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnClientRequest]: {\n type: HandlerType.OnClientRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnClientRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnWebSocketEvent]: {\n type: HandlerType.OnWebSocketEvent,\n required: true,\n validator: (snapExport: unknown): snapExport is OnWebSocketEventHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"]}
|
package/dist/handlers/types.cjs
CHANGED
|
@@ -10,6 +10,8 @@ var HandlerType;
|
|
|
10
10
|
HandlerType["OnInstall"] = "onInstall";
|
|
11
11
|
HandlerType["OnUpdate"] = "onUpdate";
|
|
12
12
|
HandlerType["OnStart"] = "onStart";
|
|
13
|
+
HandlerType["OnActive"] = "onActive";
|
|
14
|
+
HandlerType["OnInactive"] = "onInactive";
|
|
13
15
|
HandlerType["OnNameLookup"] = "onNameLookup";
|
|
14
16
|
HandlerType["OnKeyringRequest"] = "onKeyringRequest";
|
|
15
17
|
HandlerType["OnHomePage"] = "onHomePage";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":";;;AA8BA,IAAY,
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":";;;AA8BA,IAAY,WAsBX;AAtBD,WAAY,WAAW;IACrB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;IAC/B,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,4CAA6B,CAAA;IAC7B,oDAAqC,CAAA;IACrC,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,0CAA2B,CAAA;IAC3B,gDAAiC,CAAA;IACjC,wDAAyC,CAAA;IACzC,gEAAiD,CAAA;IACjD,wDAAyC,CAAA;IACzC,sDAAuC,CAAA;IACvC,kDAAmC,CAAA;IACnC,oDAAqC,CAAA;AACvC,CAAC,EAtBW,WAAW,2BAAX,WAAW,QAsBtB","sourcesContent":["import type { SNAP_EXPORTS } from './exports';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n\nexport enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnStart = 'onStart',\n OnActive = 'onActive',\n OnInactive = 'onInactive',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnSettingsPage = 'onSettingsPage',\n OnUserInput = 'onUserInput',\n OnAssetsLookup = 'onAssetsLookup',\n OnAssetsConversion = 'onAssetsConversion',\n OnAssetHistoricalPrice = 'onAssetHistoricalPrice',\n OnAssetsMarketData = 'onAssetsMarketData',\n OnProtocolRequest = 'onProtocolRequest',\n OnClientRequest = 'onClientRequest',\n OnWebSocketEvent = 'onWebSocketEvent',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n"]}
|
|
@@ -26,6 +26,8 @@ export declare enum HandlerType {
|
|
|
26
26
|
OnInstall = "onInstall",
|
|
27
27
|
OnUpdate = "onUpdate",
|
|
28
28
|
OnStart = "onStart",
|
|
29
|
+
OnActive = "onActive",
|
|
30
|
+
OnInactive = "onInactive",
|
|
29
31
|
OnNameLookup = "onNameLookup",
|
|
30
32
|
OnKeyringRequest = "onKeyringRequest",
|
|
31
33
|
OnHomePage = "onHomePage",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAkB;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,WAAW,IAClD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,KAAK,UAAU,IAAI,MAAM,OAAO,GAC1E,OAAO,GACP,KAAK,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;KAC/B,GAAG,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,EAAE,eAAe,CAClD,CAAC,OAAO,YAAY,CAAC,CAAC,GAAG,CAAC,CAC3B;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE9C,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,gBAAg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AAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC"}
|
|
@@ -26,6 +26,8 @@ export declare enum HandlerType {
|
|
|
26
26
|
OnInstall = "onInstall",
|
|
27
27
|
OnUpdate = "onUpdate",
|
|
28
28
|
OnStart = "onStart",
|
|
29
|
+
OnActive = "onActive",
|
|
30
|
+
OnInactive = "onInactive",
|
|
29
31
|
OnNameLookup = "onNameLookup",
|
|
30
32
|
OnKeyringRequest = "onKeyringRequest",
|
|
31
33
|
OnHomePage = "onHomePage",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAkB;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,WAAW,IAClD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,KAAK,UAAU,IAAI,MAAM,OAAO,GAC1E,OAAO,GACP,KAAK,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;KAC/B,GAAG,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,EAAE,e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EZ;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;KAC/B,GAAG,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,EAAE,eAAe,CAClD,CAAC,OAAO,YAAY,CAAC,CAAC,GAAG,CAAC,CAC3B;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE9C,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC"}
|
package/dist/handlers/types.mjs
CHANGED
|
@@ -7,6 +7,8 @@ export var HandlerType;
|
|
|
7
7
|
HandlerType["OnInstall"] = "onInstall";
|
|
8
8
|
HandlerType["OnUpdate"] = "onUpdate";
|
|
9
9
|
HandlerType["OnStart"] = "onStart";
|
|
10
|
+
HandlerType["OnActive"] = "onActive";
|
|
11
|
+
HandlerType["OnInactive"] = "onInactive";
|
|
10
12
|
HandlerType["OnNameLookup"] = "onNameLookup";
|
|
11
13
|
HandlerType["OnKeyringRequest"] = "onKeyringRequest";
|
|
12
14
|
HandlerType["OnHomePage"] = "onHomePage";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/handlers/types.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAN,IAAY,WAsBX;AAtBD,WAAY,WAAW;IACrB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;IAC/B,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,4CAA6B,CAAA;IAC7B,oDAAqC,CAAA;IACrC,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,0CAA2B,CAAA;IAC3B,gDAAiC,CAAA;IACjC,wDAAyC,CAAA;IACzC,gEAAiD,CAAA;IACjD,wDAAyC,CAAA;IACzC,sDAAuC,CAAA;IACvC,kDAAmC,CAAA;IACnC,oDAAqC,CAAA;AACvC,CAAC,EAtBW,WAAW,KAAX,WAAW,QAsBtB","sourcesContent":["import type { SNAP_EXPORTS } from './exports';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n\nexport enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnStart = 'onStart',\n OnActive = 'onActive',\n OnInactive = 'onInactive',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnSettingsPage = 'onSettingsPage',\n OnUserInput = 'onUserInput',\n OnAssetsLookup = 'onAssetsLookup',\n OnAssetsConversion = 'onAssetsConversion',\n OnAssetHistoricalPrice = 'onAssetHistoricalPrice',\n OnAssetsMarketData = 'onAssetsMarketData',\n OnProtocolRequest = 'onProtocolRequest',\n OnClientRequest = 'onClientRequest',\n OnWebSocketEvent = 'onWebSocketEvent',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\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.2.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.3.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",
|