@metamask/snaps-utils 10.1.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/base64.cjs +1 -1
  3. package/dist/base64.cjs.map +1 -1
  4. package/dist/base64.d.cts +1 -1
  5. package/dist/base64.d.mts +1 -1
  6. package/dist/base64.mjs +1 -1
  7. package/dist/base64.mjs.map +1 -1
  8. package/dist/errors.cjs +2 -2
  9. package/dist/errors.cjs.map +1 -1
  10. package/dist/errors.mjs +2 -2
  11. package/dist/errors.mjs.map +1 -1
  12. package/dist/handlers/assets-conversion.cjs +1 -19
  13. package/dist/handlers/assets-conversion.cjs.map +1 -1
  14. package/dist/handlers/assets-conversion.d.cts +0 -61
  15. package/dist/handlers/assets-conversion.d.cts.map +1 -1
  16. package/dist/handlers/assets-conversion.d.mts +0 -61
  17. package/dist/handlers/assets-conversion.d.mts.map +1 -1
  18. package/dist/handlers/assets-conversion.mjs +1 -19
  19. package/dist/handlers/assets-conversion.mjs.map +1 -1
  20. package/dist/handlers/assets-market-data.cjs +92 -0
  21. package/dist/handlers/assets-market-data.cjs.map +1 -0
  22. package/dist/handlers/assets-market-data.d.cts +228 -0
  23. package/dist/handlers/assets-market-data.d.cts.map +1 -0
  24. package/dist/handlers/assets-market-data.d.mts +228 -0
  25. package/dist/handlers/assets-market-data.d.mts.map +1 -0
  26. package/dist/handlers/assets-market-data.mjs +89 -0
  27. package/dist/handlers/assets-market-data.mjs.map +1 -0
  28. package/dist/handlers/exports.cjs +7 -0
  29. package/dist/handlers/exports.cjs.map +1 -1
  30. package/dist/handlers/exports.d.cts +6 -1
  31. package/dist/handlers/exports.d.cts.map +1 -1
  32. package/dist/handlers/exports.d.mts +6 -1
  33. package/dist/handlers/exports.d.mts.map +1 -1
  34. package/dist/handlers/exports.mjs +7 -0
  35. package/dist/handlers/exports.mjs.map +1 -1
  36. package/dist/handlers/home-page.d.cts +15 -15
  37. package/dist/handlers/home-page.d.mts +15 -15
  38. package/dist/handlers/index.cjs +1 -0
  39. package/dist/handlers/index.cjs.map +1 -1
  40. package/dist/handlers/index.d.cts +1 -0
  41. package/dist/handlers/index.d.cts.map +1 -1
  42. package/dist/handlers/index.d.mts +1 -0
  43. package/dist/handlers/index.d.mts.map +1 -1
  44. package/dist/handlers/index.mjs +1 -0
  45. package/dist/handlers/index.mjs.map +1 -1
  46. package/dist/handlers/settings-page.d.cts +5 -5
  47. package/dist/handlers/settings-page.d.mts +5 -5
  48. package/dist/handlers/signature.d.cts +5 -5
  49. package/dist/handlers/signature.d.mts +5 -5
  50. package/dist/handlers/transaction.d.cts +15 -15
  51. package/dist/handlers/transaction.d.mts +15 -15
  52. package/dist/handlers/types.cjs +1 -0
  53. package/dist/handlers/types.cjs.map +1 -1
  54. package/dist/handlers/types.d.cts +1 -0
  55. package/dist/handlers/types.d.cts.map +1 -1
  56. package/dist/handlers/types.d.mts +1 -0
  57. package/dist/handlers/types.d.mts.map +1 -1
  58. package/dist/handlers/types.mjs +1 -0
  59. package/dist/handlers/types.mjs.map +1 -1
  60. package/dist/localization.d.cts +1 -1
  61. package/dist/localization.d.mts +1 -1
  62. package/dist/manifest/validation.d.cts +1 -1
  63. package/dist/manifest/validation.d.mts +1 -1
  64. package/package.json +8 -11
@@ -0,0 +1 @@
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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,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"]}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * A struct representing the market data for an asset.
3
+ */
4
+ export declare const PricePercentChangeStruct: import("@metamask/superstruct").Struct<Record<string, number>, null>;
5
+ /**
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.
18
+ */
19
+ export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruct").Struct<{
20
+ fungible: true;
21
+ marketCap?: string | undefined;
22
+ totalVolume?: string | undefined;
23
+ circulatingSupply?: string | undefined;
24
+ allTimeHigh?: string | undefined;
25
+ allTimeLow?: string | undefined;
26
+ pricePercentChange?: Record<string, number> | undefined;
27
+ }, {
28
+ fungible: import("@metamask/superstruct").Struct<true, true>;
29
+ marketCap: import("@metamask/superstruct").Struct<string | undefined, null>;
30
+ totalVolume: import("@metamask/superstruct").Struct<string | undefined, null>;
31
+ circulatingSupply: import("@metamask/superstruct").Struct<string | undefined, null>;
32
+ allTimeHigh: import("@metamask/superstruct").Struct<string | undefined, null>;
33
+ allTimeLow: import("@metamask/superstruct").Struct<string | undefined, null>;
34
+ pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
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>;
160
+ /**
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.
164
+ */
165
+ export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superstruct").Struct<{
166
+ marketData: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
167
+ fungible: true;
168
+ marketCap?: string | undefined;
169
+ totalVolume?: string | undefined;
170
+ circulatingSupply?: string | undefined;
171
+ allTimeHigh?: string | undefined;
172
+ allTimeLow?: string | undefined;
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;
195
+ } | null>>;
196
+ }, {
197
+ marketData: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
198
+ fungible: true;
199
+ marketCap?: string | undefined;
200
+ totalVolume?: string | undefined;
201
+ circulatingSupply?: string | undefined;
202
+ allTimeHigh?: string | undefined;
203
+ allTimeLow?: string | undefined;
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;
226
+ } | null>>, null>;
227
+ }>;
228
+ //# sourceMappingURL=assets-market-data.d.cts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,228 @@
1
+ /**
2
+ * A struct representing the market data for an asset.
3
+ */
4
+ export declare const PricePercentChangeStruct: import("@metamask/superstruct").Struct<Record<string, number>, null>;
5
+ /**
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.
18
+ */
19
+ export declare const FungibleAssetMarketDataStruct: import("@metamask/superstruct").Struct<{
20
+ fungible: true;
21
+ marketCap?: string | undefined;
22
+ totalVolume?: string | undefined;
23
+ circulatingSupply?: string | undefined;
24
+ allTimeHigh?: string | undefined;
25
+ allTimeLow?: string | undefined;
26
+ pricePercentChange?: Record<string, number> | undefined;
27
+ }, {
28
+ fungible: import("@metamask/superstruct").Struct<true, true>;
29
+ marketCap: import("@metamask/superstruct").Struct<string | undefined, null>;
30
+ totalVolume: import("@metamask/superstruct").Struct<string | undefined, null>;
31
+ circulatingSupply: import("@metamask/superstruct").Struct<string | undefined, null>;
32
+ allTimeHigh: import("@metamask/superstruct").Struct<string | undefined, null>;
33
+ allTimeLow: import("@metamask/superstruct").Struct<string | undefined, null>;
34
+ pricePercentChange: import("@metamask/superstruct").Struct<Record<string, number> | undefined, null>;
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>;
160
+ /**
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.
164
+ */
165
+ export declare const OnAssetsMarketDataResponseStruct: import("@metamask/superstruct").Struct<{
166
+ marketData: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
167
+ fungible: true;
168
+ marketCap?: string | undefined;
169
+ totalVolume?: string | undefined;
170
+ circulatingSupply?: string | undefined;
171
+ allTimeHigh?: string | undefined;
172
+ allTimeLow?: string | undefined;
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;
195
+ } | null>>;
196
+ }, {
197
+ marketData: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, Record<`${string}:${string}/${string}:${string}`, {
198
+ fungible: true;
199
+ marketCap?: string | undefined;
200
+ totalVolume?: string | undefined;
201
+ circulatingSupply?: string | undefined;
202
+ allTimeHigh?: string | undefined;
203
+ allTimeLow?: string | undefined;
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;
226
+ } | null>>, null>;
227
+ }>;
228
+ //# sourceMappingURL=assets-market-data.d.mts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,89 @@
1
+ import { nonEmptyRecord, selectiveUnion } from "@metamask/snaps-sdk";
2
+ import { literal, nullable, number, object, optional, record, string, union } from "@metamask/superstruct";
3
+ import { CaipAssetTypeOrIdStruct, CaipAssetTypeStruct, isObject } from "@metamask/utils";
4
+ import { ISO8601DurationStruct } from "../time.mjs";
5
+ /**
6
+ * A struct representing the market data for an asset.
7
+ */
8
+ export const PricePercentChangeStruct = nonEmptyRecord(union([literal('all'), ISO8601DurationStruct]), number());
9
+ /**
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.
22
+ */
23
+ export const FungibleAssetMarketDataStruct = object({
24
+ fungible: literal(true),
25
+ marketCap: optional(string()),
26
+ totalVolume: optional(string()),
27
+ circulatingSupply: optional(string()),
28
+ allTimeHigh: optional(string()),
29
+ allTimeLow: optional(string()),
30
+ pricePercentChange: optional(PricePercentChangeStruct),
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
+ });
81
+ /**
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.
85
+ */
86
+ export const OnAssetsMarketDataResponseStruct = object({
87
+ marketData: record(CaipAssetTypeOrIdStruct, record(CaipAssetTypeStruct, nullable(AssetMarketDataStruct))),
88
+ });
89
+ //# sourceMappingURL=assets-market-data.mjs.map
@@ -0,0 +1 @@
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,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AM,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"]}
@@ -108,6 +108,13 @@ exports.SNAP_EXPORTS = {
108
108
  return typeof snapExport === 'function';
109
109
  },
110
110
  },
111
+ [types_1.HandlerType.OnAssetsMarketData]: {
112
+ type: types_1.HandlerType.OnAssetsMarketData,
113
+ required: true,
114
+ validator: (snapExport) => {
115
+ return typeof snapExport === 'function';
116
+ },
117
+ },
111
118
  [types_1.HandlerType.OnProtocolRequest]: {
112
119
  type: types_1.HandlerType.OnProt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AAK,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 OnAssetHistoricalPriceHandler,\n OnAssetsConversionHandler,\n OnAssetsLookupHandler,\n OnClientRequestHandler,\n OnCronjobHandler,\n OnHomePageHandler,\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.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.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"]}
1
+ {"version":3,"file":"exports.cjs","sourceRoot":"","sources":["../../src/handlers/exports.ts"],"names":[],"mappings":";;;AAsBA,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,aAAa,CAAC,EAAE;QAC3B,IAAI,EAAE,mBAAW,CAAC,aAAa;QAC/B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAsC,EAAE;YACrE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,mBAAW,CAAC,SAAS,CAAC,EAAE;QACvB,IAAI,EAAE,mBAAW,CAAC,SAAS;QAC3B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAkC,EAAE;YACjE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,mBAAW,CAAC,YAAY,CAAC,EAAE;QAC1B,IAAI,EAAE,mBAAW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CAAC,mBAAW,CAAC,kBAAkB,CAAC,EAAE;QAChC,IAAI,EAAE,mBAAW,CAAC,kBAAkB;QACpC,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CACT,UAAmB,EACsB,EAAE;YAC3C,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,mBAAW,CAAC,iBAAiB,CAAC,EAAE;QAC/B,IAAI,EAAE,mBAAW,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,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 OnAssetHistoricalPriceHandler,\n OnAssetsConversionHandler,\n OnAssetsLookupHandler,\n OnAssetsMarketDataHandler,\n OnClientRequestHandler,\n OnCronjobHandler,\n OnHomePageHandler,\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.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"]}