@metamask/snaps-sdk 9.1.0 → 9.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/error-wrappers.d.cts +192 -192
  3. package/dist/error-wrappers.d.mts +192 -192
  4. package/dist/internals/error-wrappers.d.cts +12 -12
  5. package/dist/internals/error-wrappers.d.mts +12 -12
  6. package/dist/jsx/components/Row.cjs.map +1 -1
  7. package/dist/jsx/components/Row.d.cts +3 -9
  8. package/dist/jsx/components/Row.d.cts.map +1 -1
  9. package/dist/jsx/components/Row.d.mts +3 -9
  10. package/dist/jsx/components/Row.d.mts.map +1 -1
  11. package/dist/jsx/components/Row.mjs.map +1 -1
  12. package/dist/jsx/validation.cjs +3 -8
  13. package/dist/jsx/validation.cjs.map +1 -1
  14. package/dist/jsx/validation.d.cts.map +1 -1
  15. package/dist/jsx/validation.d.mts.map +1 -1
  16. package/dist/jsx/validation.mjs +3 -8
  17. package/dist/jsx/validation.mjs.map +1 -1
  18. package/dist/types/handlers/assets-lookup.cjs +74 -2
  19. package/dist/types/handlers/assets-lookup.cjs.map +1 -1
  20. package/dist/types/handlers/assets-lookup.d.cts +227 -5
  21. package/dist/types/handlers/assets-lookup.d.cts.map +1 -1
  22. package/dist/types/handlers/assets-lookup.d.mts +227 -5
  23. package/dist/types/handlers/assets-lookup.d.mts.map +1 -1
  24. package/dist/types/handlers/assets-lookup.mjs +75 -3
  25. package/dist/types/handlers/assets-lookup.mjs.map +1 -1
  26. package/dist/types/handlers/assets-market-data.cjs.map +1 -1
  27. package/dist/types/handlers/assets-market-data.d.cts +47 -5
  28. package/dist/types/handlers/assets-market-data.d.cts.map +1 -1
  29. package/dist/types/handlers/assets-market-data.d.mts +47 -5
  30. package/dist/types/handlers/assets-market-data.d.mts.map +1 -1
  31. package/dist/types/handlers/assets-market-data.mjs.map +1 -1
  32. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"assets-lookup.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAanD,OAAO,EAGL,KAAK,aAAa,EACnB,wBAAwB;AAEzB,eAAO,MAAM,uBAAuB;;;;;;;;EAIlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,sDAY7B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMtC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAE9E,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,uBAAuB,KAC1B,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,qBAAqB,GAAG,IAAI,CAAC,CAAC;CAC7D,CAAC"}
1
+ {"version":3,"file":"assets-lookup.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAqBnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB;AAIzD,eAAO,MAAM,uBAAuB;;;;;;;;EAIlC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,sDA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5 @@
1
1
  import type { Infer } from "@metamask/superstruct";
2
- import { type CaipAssetType } from "@metamask/utils";
2
+ import type { CaipAssetTypeOrId } from "@metamask/utils";
3
3
  export declare const FungibleAssetUnitStruct: import("@metamask/superstruct").Struct<{
4
4
  decimals: number;
5
5
  symbol?: string | undefined;
@@ -9,8 +9,26 @@ export declare const FungibleAssetUnitStruct: import("@metamask/superstruct").St
9
9
  symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
10
10
  decimals: import("@metamask/superstruct").Struct<number, null>;
11
11
  }>;
12
+ /**
13
+ * A unit of a fungible asset, which can be used to represent
14
+ * different denominations of the asset.
15
+ *
16
+ * @property name - The name of the unit, if available.
17
+ * @property symbol - The symbol of the unit, if available.
18
+ * @property decimals - The number of decimal places for the unit.
19
+ */
12
20
  export type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;
13
21
  export declare const AssetIconUrlStruct: import("@metamask/superstruct").Struct<string, null>;
22
+ /**
23
+ * A struct representing the metadata for a fungible asset.
24
+ *
25
+ * @property name - The name of the asset, if available.
26
+ * @property symbol - The symbol of the asset, if available.
27
+ * @property fungible - Indicates that this is a fungible asset. This is always `
28
+ * true` for fungible assets.
29
+ * @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.
30
+ * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.
31
+ */
14
32
  export declare const FungibleAssetMetadataStruct: import("@metamask/superstruct").Struct<{
15
33
  fungible: true;
16
34
  iconUrl: string;
@@ -40,8 +58,142 @@ export declare const FungibleAssetMetadataStruct: import("@metamask/superstruct"
40
58
  decimals: import("@metamask/superstruct").Struct<number, null>;
41
59
  }>>;
42
60
  }>;
61
+ /**
62
+ * A collection of non-fungible assets, which can be used to group
63
+ * assets that share a common theme or creator.
64
+ *
65
+ * @property name - The name of the collection.
66
+ * @property address - The CAIP-10 account ID of the collection's creator.
67
+ * @property symbol - The symbol of the collection.
68
+ * @property tokenCount - The number of tokens in the collection, if available.
69
+ * @property creator - The CAIP-10 account ID of the collection's creator, if
70
+ * available.
71
+ * @property imageUrl - The URL of the collection's image.
72
+ */
73
+ export declare const NonFungibleAssetCollectionStruct: import("@metamask/superstruct").Struct<{
74
+ symbol: string;
75
+ name: string;
76
+ address: `${string}:${string}:${string}`;
77
+ tokenCount?: number | undefined;
78
+ creator?: `${string}:${string}:${string}` | undefined;
79
+ imageUrl?: string | undefined;
80
+ }, {
81
+ name: import("@metamask/superstruct").Struct<string, null>;
82
+ address: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
83
+ symbol: import("@metamask/superstruct").Struct<string, null>;
84
+ tokenCount: import("@metamask/superstruct").Struct<number | undefined, null>;
85
+ creator: import("@metamask/superstruct").Struct<`${string}:${string}:${string}` | undefined, null>;
86
+ imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
87
+ }>;
88
+ /**
89
+ * A collection of non-fungible assets, which can be used to group
90
+ * assets that share a common theme or creator.
91
+ *
92
+ * @property name - The name of the collection.
93
+ * @property address - The CAIP-10 account ID of the collection's creator.
94
+ * @property symbol - The symbol of the collection.
95
+ * @property tokenCount - The number of tokens in the collection, if available.
96
+ * @property creator - The CAIP-10 account ID of the collection's creator, if
97
+ * available.
98
+ * @property imageUrl - The URL of the collection's image.
99
+ */
100
+ export type NonFungibleAssetCollection = Infer<typeof NonFungibleAssetCollectionStruct>;
101
+ /**
102
+ * A struct representing the metadata for a non-fungible asset.
103
+ *
104
+ * @property fungible - Indicates that this is a non-fungible asset.
105
+ * This is always `false` for non-fungible assets.
106
+ * @property name - The name of the asset, if available.
107
+ * @property symbol - The symbol of the asset, if available.
108
+ * @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.
109
+ * @property description - A description of the asset, if available.
110
+ * @property acquiredAt - The timestamp when the asset was acquired, if available.
111
+ * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
112
+ * @property attributes - Additional attributes of the asset, represented as a record of string keys and
113
+ * string or number values.
114
+ * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.
115
+ */
116
+ export declare const NonFungibleAssetMetadataStruct: import("@metamask/superstruct").Struct<{
117
+ fungible: false;
118
+ symbol?: string | undefined;
119
+ description?: string | undefined;
120
+ name?: string | undefined;
121
+ imageUrl?: string | undefined;
122
+ acquiredAt?: number | undefined;
123
+ isPossibleSpam?: boolean | undefined;
124
+ attributes?: Record<string, string | number> | undefined;
125
+ collection?: {
126
+ symbol: string;
127
+ name: string;
128
+ address: `${string}:${string}:${string}`;
129
+ tokenCount?: number | undefined;
130
+ creator?: `${string}:${string}:${string}` | undefined;
131
+ imageUrl?: string | undefined;
132
+ } | undefined;
133
+ }, {
134
+ fungible: import("@metamask/superstruct").Struct<false, false>;
135
+ name: import("@metamask/superstruct").Struct<string | undefined, null>;
136
+ symbol: import("@metamask/superstruct").Struct<string | undefined, null>;
137
+ imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
138
+ description: import("@metamask/superstruct").Struct<string | undefined, null>;
139
+ acquiredAt: import("@metamask/superstruct").Struct<number | undefined, null>;
140
+ isPossibleSpam: import("@metamask/superstruct").Struct<boolean | undefined, null>;
141
+ attributes: import("@metamask/superstruct").Struct<Record<string, string | number> | undefined, null>;
142
+ collection: import("@metamask/superstruct").Struct<{
143
+ symbol: string;
144
+ name: string;
145
+ address: `${string}:${string}:${string}`;
146
+ tokenCount?: number | undefined;
147
+ creator?: `${string}:${string}:${string}` | undefined;
148
+ imageUrl?: string | undefined;
149
+ } | undefined, {
150
+ name: import("@metamask/superstruct").Struct<string, null>;
151
+ address: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
152
+ symbol: import("@metamask/superstruct").Struct<string, null>;
153
+ tokenCount: import("@metamask/superstruct").Struct<number | undefined, null>;
154
+ creator: import("@metamask/superstruct").Struct<`${string}:${string}:${string}` | undefined, null>;
155
+ imageUrl: import("@metamask/superstruct").Struct<string | undefined, null>;
156
+ }>;
157
+ }>;
158
+ /**
159
+ * A struct representing the metadata for an asset, which can be either
160
+ * {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.
161
+ */
162
+ export declare const AssetMetadataStruct: import("@metamask/superstruct").Struct<{
163
+ fungible: true;
164
+ iconUrl: string;
165
+ units: {
166
+ decimals: number;
167
+ symbol?: string | undefined;
168
+ name?: string | undefined;
169
+ }[];
170
+ symbol?: string | undefined;
171
+ name?: string | undefined;
172
+ } | {
173
+ fungible: false;
174
+ symbol?: string | undefined;
175
+ description?: string | undefined;
176
+ name?: string | undefined;
177
+ imageUrl?: string | undefined;
178
+ acquiredAt?: number | undefined;
179
+ isPossibleSpam?: boolean | undefined;
180
+ attributes?: Record<string, string | number> | undefined;
181
+ collection?: {
182
+ symbol: string;
183
+ name: string;
184
+ address: `${string}:${string}:${string}`;
185
+ tokenCount?: number | undefined;
186
+ creator?: `${string}:${string}:${string}` | undefined;
187
+ imageUrl?: string | undefined;
188
+ } | undefined;
189
+ }, null>;
190
+ /**
191
+ * A struct representing the response of the `onAssetsLookup` method.
192
+ *
193
+ * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
194
+ */
43
195
  export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct").Struct<{
44
- assets: Record<`${string}:${string}/${string}:${string}`, {
196
+ assets: Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, {
45
197
  fungible: true;
46
198
  iconUrl: string;
47
199
  units: {
@@ -51,9 +203,26 @@ export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct
51
203
  }[];
52
204
  symbol?: string | undefined;
53
205
  name?: string | undefined;
206
+ } | {
207
+ fungible: false;
208
+ symbol?: string | undefined;
209
+ description?: string | undefined;
210
+ name?: string | undefined;
211
+ imageUrl?: string | undefined;
212
+ acquiredAt?: number | undefined;
213
+ isPossibleSpam?: boolean | undefined;
214
+ attributes?: Record<string, string | number> | undefined;
215
+ collection?: {
216
+ symbol: string;
217
+ name: string;
218
+ address: `${string}:${string}:${string}`;
219
+ tokenCount?: number | undefined;
220
+ creator?: `${string}:${string}:${string}` | undefined;
221
+ imageUrl?: string | undefined;
222
+ } | undefined;
54
223
  } | null>;
55
224
  }, {
56
- assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, {
225
+ assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, {
57
226
  fungible: true;
58
227
  iconUrl: string;
59
228
  units: {
@@ -63,11 +232,64 @@ export declare const OnAssetsLookupResponseStruct: import("@metamask/superstruct
63
232
  }[];
64
233
  symbol?: string | undefined;
65
234
  name?: string | undefined;
235
+ } | {
236
+ fungible: false;
237
+ symbol?: string | undefined;
238
+ description?: string | undefined;
239
+ name?: string | undefined;
240
+ imageUrl?: string | undefined;
241
+ acquiredAt?: number | undefined;
242
+ isPossibleSpam?: boolean | undefined;
243
+ attributes?: Record<string, string | number> | undefined;
244
+ collection?: {
245
+ symbol: string;
246
+ name: string;
247
+ address: `${string}:${string}:${string}`;
248
+ tokenCount?: number | undefined;
249
+ creator?: `${string}:${string}:${string}` | undefined;
250
+ imageUrl?: string | undefined;
251
+ } | undefined;
66
252
  } | null>, null>;
67
253
  }>;
254
+ /**
255
+ * The metadata for an asset, which can be either fungible or non-fungible.
256
+ *
257
+ */
258
+ export type AssetMetadata = Infer<typeof AssetMetadataStruct>;
259
+ /**
260
+ * The metadata for a fungible asset.
261
+ *
262
+ * @property fungible - Indicates that this is a fungible asset.
263
+ * This is always `true` for fungible assets.
264
+ * @property name - The name of the asset.
265
+ * @property symbol - The symbol of the asset.
266
+ * @property iconUrl - The URL of the asset's icon.
267
+ * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnit}.
268
+ */
68
269
  export type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;
270
+ /**
271
+ * The metadata for a non-fungible asset.
272
+ *
273
+ * @property fungible - Indicates that this is a non-fungible asset.
274
+ * This is always `false` for non-fungible assets.
275
+ * @property name - The name of the asset.
276
+ * @property symbol - The symbol of the asset.
277
+ * @property imageUrl - The URL of the asset's image.
278
+ * @property description - A description of the asset.
279
+ * @property acquiredAt - The timestamp when the asset was acquired, if available.
280
+ * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
281
+ * @property attributes - Additional attributes of the asset, represented as a record of string keys and
282
+ * string or number values.
283
+ * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollection}.
284
+ */
285
+ export type NonFungibleAssetMetadata = Infer<typeof NonFungibleAssetMetadataStruct>;
286
+ /**
287
+ * The arguments for the `onAssetsLookup` handler.
288
+ *
289
+ * @property assets - An array of CAIP-19 asset types to look up.
290
+ */
69
291
  export type OnAssetsLookupArguments = {
70
- assets: CaipAssetType[];
292
+ assets: CaipAssetTypeOrId[];
71
293
  };
72
294
  /**
73
295
  * The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.
@@ -82,6 +304,6 @@ export type OnAssetsLookupHandler = (args: OnAssetsLookupArguments) => Promise<O
82
304
  * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
83
305
  */
84
306
  export type OnAssetsLookupResponse = {
85
- assets: Record<CaipAssetType, FungibleAssetMetadata | null>;
307
+ assets: Record<CaipAssetTypeOrId, AssetMetadata | null>;
86
308
  };
87
309
  //# sourceMappingURL=assets-lookup.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets-lookup.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAanD,OAAO,EAGL,KAAK,aAAa,EACnB,wBAAwB;AAEzB,eAAO,MAAM,uBAAuB;;;;;;;;EAIlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,sDAY7B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;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;;;;;;;;;EAUzC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;QAM9B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEvC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAC1C,OAAO,8BAA8B,CACtC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,uBAAuB,KAC1B,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC,iBAAiB,EAAE,aAAa,GAAG,IAAI,CAAC,CAAC;CACzD,CAAC"}
@@ -1,5 +1,6 @@
1
- import { array, size, literal, number, object, refine, string, record, nullable, optional } from "@metamask/superstruct";
2
- import { assert, CaipAssetTypeStruct } from "@metamask/utils";
1
+ import { array, size, literal, number, object, refine, string, record, nullable, optional, boolean, union } from "@metamask/superstruct";
2
+ import { CaipAccountIdStruct, CaipAssetTypeOrIdStruct, assert, isObject } from "@metamask/utils";
3
+ import { selectiveUnion } from "../../internals/index.mjs";
3
4
  export const FungibleAssetUnitStruct = object({
4
5
  name: optional(string()),
5
6
  symbol: optional(string()),
@@ -17,6 +18,16 @@ export const AssetIconUrlStruct = refine(string(), 'Asset URL', (value) => {
17
18
  return 'Invalid URL';
18
19
  }
19
20
  });
21
+ /**
22
+ * A struct representing the metadata for a fungible asset.
23
+ *
24
+ * @property name - The name of the asset, if available.
25
+ * @property symbol - The symbol of the asset, if available.
26
+ * @property fungible - Indicates that this is a fungible asset. This is always `
27
+ * true` for fungible assets.
28
+ * @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.
29
+ * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.
30
+ */
20
31
  export const FungibleAssetMetadataStruct = object({
21
32
  name: optional(string()),
22
33
  symbol: optional(string()),
@@ -24,7 +35,68 @@ export const FungibleAssetMetadataStruct = object({
24
35
  iconUrl: AssetIconUrlStruct,
25
36
  units: size(array(FungibleAssetUnitStruct), 1, Infinity),
26
37
  });
38
+ /**
39
+ * A collection of non-fungible assets, which can be used to group
40
+ * assets that share a common theme or creator.
41
+ *
42
+ * @property name - The name of the collection.
43
+ * @property address - The CAIP-10 account ID of the collection's creator.
44
+ * @property symbol - The symbol of the collection.
45
+ * @property tokenCount - The number of tokens in the collection, if available.
46
+ * @property creator - The CAIP-10 account ID of the collection's creator, if
47
+ * available.
48
+ * @property imageUrl - The URL of the collection's image.
49
+ */
50
+ export const NonFungibleAssetCollectionStruct = object({
51
+ name: string(),
52
+ address: CaipAccountIdStruct,
53
+ symbol: string(),
54
+ tokenCount: optional(number()),
55
+ creator: optional(CaipAccountIdStruct),
56
+ imageUrl: optional(AssetIconUrlStruct),
57
+ });
58
+ /**
59
+ * A struct representing the metadata for a non-fungible asset.
60
+ *
61
+ * @property fungible - Indicates that this is a non-fungible asset.
62
+ * This is always `false` for non-fungible assets.
63
+ * @property name - The name of the asset, if available.
64
+ * @property symbol - The symbol of the asset, if available.
65
+ * @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.
66
+ * @property description - A description of the asset, if available.
67
+ * @property acquiredAt - The timestamp when the asset was acquired, if available.
68
+ * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.
69
+ * @property attributes - Additional attributes of the asset, represented as a record of string keys and
70
+ * string or number values.
71
+ * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.
72
+ */
73
+ export const NonFungibleAssetMetadataStruct = object({
74
+ fungible: literal(false),
75
+ name: optional(string()),
76
+ symbol: optional(string()),
77
+ imageUrl: optional(AssetIconUrlStruct),
78
+ description: optional(string()),
79
+ acquiredAt: optional(number()),
80
+ isPossibleSpam: optional(boolean()),
81
+ attributes: optional(record(string(), union([string(), number()]))),
82
+ collection: optional(NonFungibleAssetCollectionStruct),
83
+ });
84
+ /**
85
+ * A struct representing the metadata for an asset, which can be either
86
+ * {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.
87
+ */
88
+ export const AssetMetadataStruct = selectiveUnion((metadata) => {
89
+ if (isObject(metadata) && metadata.fungible) {
90
+ return FungibleAssetMetadataStruct;
91
+ }
92
+ return NonFungibleAssetMetadataStruct;
93
+ });
94
+ /**
95
+ * A struct representing the response of the `onAssetsLookup` method.
96
+ *
97
+ * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.
98
+ */
27
99
  export const OnAssetsLookupResponseStruct = object({
28
- assets: record(CaipAssetTypeStruct, nullable(FungibleAssetMetadataStruct)),
100
+ assets: record(CaipAssetTypeOrIdStruct, nullable(AssetMetadataStruct)),
29
101
  });
30
102
  //# sourceMappingURL=assets-lookup.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets-lookup.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EACL,MAAM,EACN,mBAAmB,EAEpB,wBAAwB;AAEzB,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;IAC5C,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE;CACnB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,+EAA+E;QAC/E,MAAM,CACJ,GAAG,CAAC,QAAQ,KAAK,QAAQ;YACvB,KAAK,CAAC,UAAU,CAAC,4BAA4B,CAAC,CACjD,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC;IACvB,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;IAChD,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;IACvB,OAAO,EAAE,kBAAkB;IAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;CACzD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,CAAC;CAC3E,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n size,\n literal,\n number,\n object,\n refine,\n string,\n record,\n nullable,\n optional,\n} from '@metamask/superstruct';\nimport {\n assert,\n CaipAssetTypeStruct,\n type CaipAssetType,\n} from '@metamask/utils';\n\nexport const FungibleAssetUnitStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n decimals: number(),\n});\n\nexport type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;\n\nexport const AssetIconUrlStruct = refine(string(), 'Asset URL', (value) => {\n try {\n const url = new URL(value);\n // For now, we require asset URLs to either be base64 SVGs or remote HTTPS URLs\n assert(\n url.protocol === 'https:' ||\n value.startsWith('data:image/svg+xml;base64,'),\n );\n return true;\n } catch {\n return 'Invalid URL';\n }\n});\n\nexport const FungibleAssetMetadataStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n fungible: literal(true),\n iconUrl: AssetIconUrlStruct,\n units: size(array(FungibleAssetUnitStruct), 1, Infinity),\n});\n\nexport const OnAssetsLookupResponseStruct = object({\n assets: record(CaipAssetTypeStruct, nullable(FungibleAssetMetadataStruct)),\n});\n\nexport type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;\n\nexport type OnAssetsLookupArguments = {\n assets: CaipAssetType[];\n};\n\n/**\n * The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.\n *\n * @returns The metadata about each asset. See\n * {@link OnAssetsLookupResponse}.\n */\nexport type OnAssetsLookupHandler = (\n args: OnAssetsLookupArguments,\n) => Promise<OnAssetsLookupResponse>;\n\n/**\n * The response from the query, containing metadata about each requested asset.\n *\n * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.\n */\nexport type OnAssetsLookupResponse = {\n assets: Record<CaipAssetType, FungibleAssetMetadata | null>;\n};\n"]}
1
+ {"version":3,"file":"assets-lookup.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-lookup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACN,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,E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nullable,\n optional,\n boolean,\n union,\n} from '@metamask/superstruct';\nimport {\n CaipAccountIdStruct,\n CaipAssetTypeOrIdStruct,\n assert,\n isObject,\n} from '@metamask/utils';\nimport type { CaipAssetTypeOrId } from '@metamask/utils';\n\nimport { selectiveUnion } from '../../internals';\n\nexport const FungibleAssetUnitStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n decimals: number(),\n});\n\n/**\n * A unit of a fungible asset, which can be used to represent\n * different denominations of the asset.\n *\n * @property name - The name of the unit, if available.\n * @property symbol - The symbol of the unit, if available.\n * @property decimals - The number of decimal places for the unit.\n */\nexport type FungibleAssetUnit = Infer<typeof FungibleAssetUnitStruct>;\n\nexport const AssetIconUrlStruct = refine(string(), 'Asset URL', (value) => {\n try {\n const url = new URL(value);\n // For now, we require asset URLs to either be base64 SVGs or remote HTTPS URLs\n assert(\n url.protocol === 'https:' ||\n value.startsWith('data:image/svg+xml;base64,'),\n );\n return true;\n } catch {\n return 'Invalid URL';\n }\n});\n\n/**\n * A struct representing the metadata for a fungible asset.\n *\n * @property name - The name of the asset, if available.\n * @property symbol - The symbol of the asset, if available.\n * @property fungible - Indicates that this is a fungible asset. This is always `\n * true` for fungible assets.\n * @property iconUrl - The URL of the asset's icon, which can be a base64 SVG or a remote HTTPS URL.\n * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnitStruct}.\n */\nexport const FungibleAssetMetadataStruct = object({\n name: optional(string()),\n symbol: optional(string()),\n fungible: literal(true),\n iconUrl: AssetIconUrlStruct,\n units: size(array(FungibleAssetUnitStruct), 1, Infinity),\n});\n\n/**\n * A collection of non-fungible assets, which can be used to group\n * assets that share a common theme or creator.\n *\n * @property name - The name of the collection.\n * @property address - The CAIP-10 account ID of the collection's creator.\n * @property symbol - The symbol of the collection.\n * @property tokenCount - The number of tokens in the collection, if available.\n * @property creator - The CAIP-10 account ID of the collection's creator, if\n * available.\n * @property imageUrl - The URL of the collection's image.\n */\nexport const NonFungibleAssetCollectionStruct = object({\n name: string(),\n address: CaipAccountIdStruct,\n symbol: string(),\n tokenCount: optional(number()),\n creator: optional(CaipAccountIdStruct),\n imageUrl: optional(AssetIconUrlStruct),\n});\n\n/**\n * A collection of non-fungible assets, which can be used to group\n * assets that share a common theme or creator.\n *\n * @property name - The name of the collection.\n * @property address - The CAIP-10 account ID of the collection's creator.\n * @property symbol - The symbol of the collection.\n * @property tokenCount - The number of tokens in the collection, if available.\n * @property creator - The CAIP-10 account ID of the collection's creator, if\n * available.\n * @property imageUrl - The URL of the collection's image.\n */\nexport type NonFungibleAssetCollection = Infer<\n typeof NonFungibleAssetCollectionStruct\n>;\n\n/**\n * A struct representing the metadata for a non-fungible asset.\n *\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property name - The name of the asset, if available.\n * @property symbol - The symbol of the asset, if available.\n * @property imageUrl - The URL of the asset's image, which can be a base64 SVG or a remote HTTPS URL.\n * @property description - A description of the asset, if available.\n * @property acquiredAt - The timestamp when the asset was acquired, if available.\n * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.\n * @property attributes - Additional attributes of the asset, represented as a record of string keys and\n * string or number values.\n * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollectionStruct}.\n */\nexport const NonFungibleAssetMetadataStruct = object({\n fungible: literal(false),\n name: optional(string()),\n symbol: optional(string()),\n imageUrl: optional(AssetIconUrlStruct),\n description: optional(string()),\n acquiredAt: optional(number()),\n isPossibleSpam: optional(boolean()),\n attributes: optional(record(string(), union([string(), number()]))),\n collection: optional(NonFungibleAssetCollectionStruct),\n});\n\n/**\n * A struct representing the metadata for an asset, which can be either\n * {@link FungibleAssetMetadataStruct} or {@link NonFungibleAssetMetadataStruct}.\n */\nexport const AssetMetadataStruct = selectiveUnion((metadata) => {\n if (isObject(metadata) && metadata.fungible) {\n return FungibleAssetMetadataStruct;\n }\n\n return NonFungibleAssetMetadataStruct;\n});\n\n/**\n * A struct representing the response of the `onAssetsLookup` method.\n *\n * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.\n */\nexport const OnAssetsLookupResponseStruct = object({\n assets: record(CaipAssetTypeOrIdStruct, nullable(AssetMetadataStruct)),\n});\n\n/**\n * The metadata for an asset, which can be either fungible or non-fungible.\n *\n */\nexport type AssetMetadata = Infer<typeof AssetMetadataStruct>;\n\n/**\n * The metadata 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 name - The name of the asset.\n * @property symbol - The symbol of the asset.\n * @property iconUrl - The URL of the asset's icon.\n * @property units - An array of units for the asset, each represented by {@link FungibleAssetUnit}.\n */\nexport type FungibleAssetMetadata = Infer<typeof FungibleAssetMetadataStruct>;\n\n/**\n * The metadata for a non-fungible asset.\n *\n * @property fungible - Indicates that this is a non-fungible asset.\n * This is always `false` for non-fungible assets.\n * @property name - The name of the asset.\n * @property symbol - The symbol of the asset.\n * @property imageUrl - The URL of the asset's image.\n * @property description - A description of the asset.\n * @property acquiredAt - The timestamp when the asset was acquired, if available.\n * @property isPossibleSpam - Indicates if the asset is possibly spam, if available.\n * @property attributes - Additional attributes of the asset, represented as a record of string keys and\n * string or number values.\n * @property collection - The collection the asset belongs to, if available. See {@link NonFungibleAssetCollection}.\n */\nexport type NonFungibleAssetMetadata = Infer<\n typeof NonFungibleAssetMetadataStruct\n>;\n\n/**\n * The arguments for the `onAssetsLookup` handler.\n *\n * @property assets - An array of CAIP-19 asset types to look up.\n */\nexport type OnAssetsLookupArguments = {\n assets: CaipAssetTypeOrId[];\n};\n\n/**\n * The `onAssetsLookup` handler. This is called by MetaMask when querying about specific assets on specific chains.\n *\n * @returns The metadata about each asset. See\n * {@link OnAssetsLookupResponse}.\n */\nexport type OnAssetsLookupHandler = (\n args: OnAssetsLookupArguments,\n) => Promise<OnAssetsLookupResponse>;\n\n/**\n * The response from the query, containing metadata about each requested asset.\n *\n * @property assets - An object containing a mapping between the CAIP-19 key and a metadata object or null.\n */\nexport type OnAssetsLookupResponse = {\n assets: Record<CaipAssetTypeOrId, AssetMetadata | null>;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n/**\n * 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 type FungibleAssetMarketData = {\n fungible: true;\n marketCap?: string;\n totalVolume?: string;\n circulatingSupply?: string;\n allTimeHigh?: string;\n allTimeLow?: string;\n pricePercentChange?: {\n [interval: string]: number;\n };\n};\n\n/**\n * The arguments for the `onAssetsMarketData` handler.\n *\n * @property assets - An array of objects containing the asset and unit types.\n * @property assets.asset - The CAIP-19 asset type of the asset.\n * @property assets.unit - The CAIP-19 asset type of the unit to use.\n */\nexport type OnAssetsMarketDataArguments = {\n assets: {\n asset: CaipAssetType;\n unit: CaipAssetType;\n }[];\n};\n\n/**\n * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsMarketDataArguments}.\n * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.\n */\nexport type OnAssetsMarketDataHandler = (\n args: OnAssetsMarketDataArguments,\n) => Promise<OnAssetsMarketDataResponse>;\n\n/**\n * The response from the market data query, containing market data for the requested assets.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.\n */\nexport type OnAssetsMarketDataResponse = {\n marketData: Record<\n CaipAssetType,\n Record<CaipAssetType, FungibleAssetMarketData | null>\n >;\n};\n"]}
1
+ {"version":3,"file":"assets-market-data.cjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipAssetTypeOrId } from '@metamask/utils';\n\n/**\n * 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 type FungibleAssetMarketData = {\n fungible: true;\n marketCap?: string;\n totalVolume?: string;\n circulatingSupply?: string;\n allTimeHigh?: string;\n allTimeLow?: string;\n pricePercentChange?: {\n [interval: string]: number;\n };\n};\n\n/**\n * 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 type AssetValue = {\n asset: CaipAssetTypeOrId;\n amount: string;\n};\n\n/**\n * The market data for a non-fungible asset.\n *\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 AssetValue}.\n * @property topBid - The top bid price for the asset, if available. See {@link AssetValue}.\n * @property floorPrice - The floor price of the asset, if available. See {@link AssetValue}.\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 type NonFungibleAssetMarketData = {\n fungible: false;\n lastSale?: AssetValue;\n topBid?: AssetValue;\n floorPrice?: AssetValue;\n rarity?: {\n ranking?: {\n source: string;\n rank: number;\n };\n metadata?: Record<string, number>;\n };\n};\n\n/**\n * The market data for an asset, which can be either {@link FungibleAssetMarketData} or {@link NonFungibleAssetMarketData}.\n */\nexport type AssetMarketData =\n | FungibleAssetMarketData\n | NonFungibleAssetMarketData;\n\n/**\n * The arguments for the `onAssetsMarketData` handler.\n *\n * @property assets - An array of objects containing the asset and unit types.\n * @property assets.asset - The CAIP-19 asset type or ID of the asset.\n * @property assets.unit - The CAIP-19 asset type of the unit to use.\n */\nexport type OnAssetsMarketDataArguments = {\n assets: {\n asset: CaipAssetTypeOrId;\n unit: CaipAssetType;\n }[];\n};\n\n/**\n * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsMarketDataArguments}.\n * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.\n */\nexport type OnAssetsMarketDataHandler = (\n args: OnAssetsMarketDataArguments,\n) => Promise<OnAssetsMarketDataResponse>;\n\n/**\n * The response from the market data query, containing market data for the requested assets.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.\n */\nexport type OnAssetsMarketDataResponse = {\n marketData: Record<\n CaipAssetTypeOrId,\n Record<CaipAssetType, AssetMarketData | null>\n >;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { CaipAssetType } from "@metamask/utils";
1
+ import type { CaipAssetType, CaipAssetTypeOrId } from "@metamask/utils";
2
2
  /**
3
3
  * The market data for a fungible asset.
4
4
  *
@@ -24,16 +24,58 @@ export type FungibleAssetMarketData = {
24
24
  [interval: string]: number;
25
25
  };
26
26
  };
27
+ /**
28
+ * An asset value, which includes the asset type and the amount.
29
+ *
30
+ * @property asset - The CAIP-19 asset type or ID of the asset.
31
+ * @property amount - The pice represented as a number in string format.
32
+ */
33
+ export type AssetValue = {
34
+ asset: CaipAssetTypeOrId;
35
+ amount: string;
36
+ };
37
+ /**
38
+ * The market data for a non-fungible asset.
39
+ *
40
+ * @property fungible - Indicates that this is a non-fungible asset.
41
+ * This is always `false` for non-fungible assets.
42
+ * @property lastSale - The last sale price of the asset, if available. See {@link AssetValue}.
43
+ * @property topBid - The top bid price for the asset, if available. See {@link AssetValue}.
44
+ * @property floorPrice - The floor price of the asset, if available. See {@link AssetValue}.
45
+ * @property rarity - The rarity information for the asset, if available.
46
+ * @property rarity.ranking - The ranking of the asset's rarity, if available.
47
+ * @property rarity.ranking.source - The source of the rarity ranking.
48
+ * @property rarity.ranking.rank - The rank of the asset in the rarity ranking.
49
+ * @property rarity.metadata - Additional metadata about the asset's rarity, if available.
50
+ * This is a record of string keys and number values.
51
+ */
52
+ export type NonFungibleAssetMarketData = {
53
+ fungible: false;
54
+ lastSale?: AssetValue;
55
+ topBid?: AssetValue;
56
+ floorPrice?: AssetValue;
57
+ rarity?: {
58
+ ranking?: {
59
+ source: string;
60
+ rank: number;
61
+ };
62
+ metadata?: Record<string, number>;
63
+ };
64
+ };
65
+ /**
66
+ * The market data for an asset, which can be either {@link FungibleAssetMarketData} or {@link NonFungibleAssetMarketData}.
67
+ */
68
+ export type AssetMarketData = FungibleAssetMarketData | NonFungibleAssetMarketData;
27
69
  /**
28
70
  * The arguments for the `onAssetsMarketData` handler.
29
71
  *
30
72
  * @property assets - An array of objects containing the asset and unit types.
31
- * @property assets.asset - The CAIP-19 asset type of the asset.
73
+ * @property assets.asset - The CAIP-19 asset type or ID of the asset.
32
74
  * @property assets.unit - The CAIP-19 asset type of the unit to use.
33
75
  */
34
76
  export type OnAssetsMarketDataArguments = {
35
77
  assets: {
36
- asset: CaipAssetType;
78
+ asset: CaipAssetTypeOrId;
37
79
  unit: CaipAssetType;
38
80
  }[];
39
81
  };
@@ -48,9 +90,9 @@ export type OnAssetsMarketDataHandler = (args: OnAssetsMarketDataArguments) => P
48
90
  /**
49
91
  * The response from the market data query, containing market data for the requested assets.
50
92
  *
51
- * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.
93
+ * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.
52
94
  */
53
95
  export type OnAssetsMarketDataResponse = {
54
- marketData: Record<CaipAssetType, Record<CaipAssetType, FungibleAssetMarketData | null>>;
96
+ marketData: Record<CaipAssetTypeOrId, Record<CaipAssetType, AssetMarketData | null>>;
55
97
  };
56
98
  //# sourceMappingURL=assets-market-data.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets-market-data.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,KAAK,EAAE,aAAa,CAAC;QACrB,IAAI,EAAE,aAAa,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAChB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,uBAAuB,GAAG,IAAI,CAAC,CACtD,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"assets-market-data.d.cts","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,wBAAwB;AAExE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,KAAK,CAAC;IAChB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE;YACR,MAAM,EAAE,MAAM,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,uBAAuB,GACvB,0BAA0B,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,KAAK,EAAE,iBAAiB,CAAC;QACzB,IAAI,EAAE,aAAa,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAChB,iBAAiB,EACjB,MAAM,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC,CAC9C,CAAC;CACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CaipAssetType } from "@metamask/utils";
1
+ import type { CaipAssetType, CaipAssetTypeOrId } from "@metamask/utils";
2
2
  /**
3
3
  * The market data for a fungible asset.
4
4
  *
@@ -24,16 +24,58 @@ export type FungibleAssetMarketData = {
24
24
  [interval: string]: number;
25
25
  };
26
26
  };
27
+ /**
28
+ * An asset value, which includes the asset type and the amount.
29
+ *
30
+ * @property asset - The CAIP-19 asset type or ID of the asset.
31
+ * @property amount - The pice represented as a number in string format.
32
+ */
33
+ export type AssetValue = {
34
+ asset: CaipAssetTypeOrId;
35
+ amount: string;
36
+ };
37
+ /**
38
+ * The market data for a non-fungible asset.
39
+ *
40
+ * @property fungible - Indicates that this is a non-fungible asset.
41
+ * This is always `false` for non-fungible assets.
42
+ * @property lastSale - The last sale price of the asset, if available. See {@link AssetValue}.
43
+ * @property topBid - The top bid price for the asset, if available. See {@link AssetValue}.
44
+ * @property floorPrice - The floor price of the asset, if available. See {@link AssetValue}.
45
+ * @property rarity - The rarity information for the asset, if available.
46
+ * @property rarity.ranking - The ranking of the asset's rarity, if available.
47
+ * @property rarity.ranking.source - The source of the rarity ranking.
48
+ * @property rarity.ranking.rank - The rank of the asset in the rarity ranking.
49
+ * @property rarity.metadata - Additional metadata about the asset's rarity, if available.
50
+ * This is a record of string keys and number values.
51
+ */
52
+ export type NonFungibleAssetMarketData = {
53
+ fungible: false;
54
+ lastSale?: AssetValue;
55
+ topBid?: AssetValue;
56
+ floorPrice?: AssetValue;
57
+ rarity?: {
58
+ ranking?: {
59
+ source: string;
60
+ rank: number;
61
+ };
62
+ metadata?: Record<string, number>;
63
+ };
64
+ };
65
+ /**
66
+ * The market data for an asset, which can be either {@link FungibleAssetMarketData} or {@link NonFungibleAssetMarketData}.
67
+ */
68
+ export type AssetMarketData = FungibleAssetMarketData | NonFungibleAssetMarketData;
27
69
  /**
28
70
  * The arguments for the `onAssetsMarketData` handler.
29
71
  *
30
72
  * @property assets - An array of objects containing the asset and unit types.
31
- * @property assets.asset - The CAIP-19 asset type of the asset.
73
+ * @property assets.asset - The CAIP-19 asset type or ID of the asset.
32
74
  * @property assets.unit - The CAIP-19 asset type of the unit to use.
33
75
  */
34
76
  export type OnAssetsMarketDataArguments = {
35
77
  assets: {
36
- asset: CaipAssetType;
78
+ asset: CaipAssetTypeOrId;
37
79
  unit: CaipAssetType;
38
80
  }[];
39
81
  };
@@ -48,9 +90,9 @@ export type OnAssetsMarketDataHandler = (args: OnAssetsMarketDataArguments) => P
48
90
  /**
49
91
  * The response from the market data query, containing market data for the requested assets.
50
92
  *
51
- * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.
93
+ * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.
52
94
  */
53
95
  export type OnAssetsMarketDataResponse = {
54
- marketData: Record<CaipAssetType, Record<CaipAssetType, FungibleAssetMarketData | null>>;
96
+ marketData: Record<CaipAssetTypeOrId, Record<CaipAssetType, AssetMarketData | null>>;
55
97
  };
56
98
  //# sourceMappingURL=assets-market-data.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assets-market-data.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,KAAK,EAAE,aAAa,CAAC;QACrB,IAAI,EAAE,aAAa,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAChB,aAAa,EACb,MAAM,CAAC,aAAa,EAAE,uBAAuB,GAAG,IAAI,CAAC,CACtD,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"assets-market-data.d.mts","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,wBAAwB;AAExE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,IAAI,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,KAAK,CAAC;IAChB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE;YACR,MAAM,EAAE,MAAM,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,uBAAuB,GACvB,0BAA0B,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE;QACN,KAAK,EAAE,iBAAiB,CAAC;QACzB,IAAI,EAAE,aAAa,CAAC;KACrB,EAAE,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACtC,IAAI,EAAE,2BAA2B,KAC9B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAChB,iBAAiB,EACjB,MAAM,CAAC,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC,CAC9C,CAAC;CACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType } from '@metamask/utils';\n\n/**\n * 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 type FungibleAssetMarketData = {\n fungible: true;\n marketCap?: string;\n totalVolume?: string;\n circulatingSupply?: string;\n allTimeHigh?: string;\n allTimeLow?: string;\n pricePercentChange?: {\n [interval: string]: number;\n };\n};\n\n/**\n * The arguments for the `onAssetsMarketData` handler.\n *\n * @property assets - An array of objects containing the asset and unit types.\n * @property assets.asset - The CAIP-19 asset type of the asset.\n * @property assets.unit - The CAIP-19 asset type of the unit to use.\n */\nexport type OnAssetsMarketDataArguments = {\n assets: {\n asset: CaipAssetType;\n unit: CaipAssetType;\n }[];\n};\n\n/**\n * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsMarketDataArguments}.\n * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.\n */\nexport type OnAssetsMarketDataHandler = (\n args: OnAssetsMarketDataArguments,\n) => Promise<OnAssetsMarketDataResponse>;\n\n/**\n * The response from the market data query, containing market data for the requested assets.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link FungibleAssetMarketData} object or null between the two keys.\n */\nexport type OnAssetsMarketDataResponse = {\n marketData: Record<\n CaipAssetType,\n Record<CaipAssetType, FungibleAssetMarketData | null>\n >;\n};\n"]}
1
+ {"version":3,"file":"assets-market-data.mjs","sourceRoot":"","sources":["../../../src/types/handlers/assets-market-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipAssetTypeOrId } from '@metamask/utils';\n\n/**\n * 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 type FungibleAssetMarketData = {\n fungible: true;\n marketCap?: string;\n totalVolume?: string;\n circulatingSupply?: string;\n allTimeHigh?: string;\n allTimeLow?: string;\n pricePercentChange?: {\n [interval: string]: number;\n };\n};\n\n/**\n * 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 type AssetValue = {\n asset: CaipAssetTypeOrId;\n amount: string;\n};\n\n/**\n * The market data for a non-fungible asset.\n *\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 AssetValue}.\n * @property topBid - The top bid price for the asset, if available. See {@link AssetValue}.\n * @property floorPrice - The floor price of the asset, if available. See {@link AssetValue}.\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 type NonFungibleAssetMarketData = {\n fungible: false;\n lastSale?: AssetValue;\n topBid?: AssetValue;\n floorPrice?: AssetValue;\n rarity?: {\n ranking?: {\n source: string;\n rank: number;\n };\n metadata?: Record<string, number>;\n };\n};\n\n/**\n * The market data for an asset, which can be either {@link FungibleAssetMarketData} or {@link NonFungibleAssetMarketData}.\n */\nexport type AssetMarketData =\n | FungibleAssetMarketData\n | NonFungibleAssetMarketData;\n\n/**\n * The arguments for the `onAssetsMarketData` handler.\n *\n * @property assets - An array of objects containing the asset and unit types.\n * @property assets.asset - The CAIP-19 asset type or ID of the asset.\n * @property assets.unit - The CAIP-19 asset type of the unit to use.\n */\nexport type OnAssetsMarketDataArguments = {\n assets: {\n asset: CaipAssetTypeOrId;\n unit: CaipAssetType;\n }[];\n};\n\n/**\n * The `onAssetsMarketData` handler. This is called by MetaMask when querying about market data for a specific asset.\n *\n * @param args - The arguments for the handler.\n * see {@link OnAssetsMarketDataArguments}.\n * @returns The market data for the asset. See {@link OnAssetsMarketDataResponse}.\n */\nexport type OnAssetsMarketDataHandler = (\n args: OnAssetsMarketDataArguments,\n) => Promise<OnAssetsMarketDataResponse>;\n\n/**\n * The response from the market data query, containing market data for the requested assets.\n *\n * @property marketData - A nested object with two CAIP-19 keys that contains a {@link AssetMarketData} object or null.\n */\nexport type OnAssetsMarketDataResponse = {\n marketData: Record<\n CaipAssetTypeOrId,\n Record<CaipAssetType, AssetMarketData | null>\n >;\n};\n"]}