@metamask-previews/assets-controllers 11.0.1-preview.d32a7cc

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 (80) hide show
  1. package/CHANGELOG.md +235 -0
  2. package/LICENSE +20 -0
  3. package/README.md +30 -0
  4. package/dist/AccountTrackerController.d.ts +106 -0
  5. package/dist/AccountTrackerController.d.ts.map +1 -0
  6. package/dist/AccountTrackerController.js +163 -0
  7. package/dist/AccountTrackerController.js.map +1 -0
  8. package/dist/AssetsContractController.d.ts +188 -0
  9. package/dist/AssetsContractController.d.ts.map +1 -0
  10. package/dist/AssetsContractController.js +330 -0
  11. package/dist/AssetsContractController.js.map +1 -0
  12. package/dist/CurrencyRateController.d.ts +101 -0
  13. package/dist/CurrencyRateController.d.ts.map +1 -0
  14. package/dist/CurrencyRateController.js +219 -0
  15. package/dist/CurrencyRateController.js.map +1 -0
  16. package/dist/NftController.d.ts +464 -0
  17. package/dist/NftController.d.ts.map +1 -0
  18. package/dist/NftController.js +924 -0
  19. package/dist/NftController.js.map +1 -0
  20. package/dist/NftDetectionController.d.ts +182 -0
  21. package/dist/NftDetectionController.d.ts.map +1 -0
  22. package/dist/NftDetectionController.js +188 -0
  23. package/dist/NftDetectionController.js.map +1 -0
  24. package/dist/Standards/ERC20Standard.d.ts +50 -0
  25. package/dist/Standards/ERC20Standard.d.ts.map +1 -0
  26. package/dist/Standards/ERC20Standard.js +144 -0
  27. package/dist/Standards/ERC20Standard.js.map +1 -0
  28. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts +79 -0
  29. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.d.ts.map +1 -0
  30. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +148 -0
  31. package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js.map +1 -0
  32. package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.ts +89 -0
  33. package/dist/Standards/NftStandards/ERC721/ERC721Standard.d.ts.map +1 -0
  34. package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +182 -0
  35. package/dist/Standards/NftStandards/ERC721/ERC721Standard.js.map +1 -0
  36. package/dist/Standards/standards-types.d.ts +15 -0
  37. package/dist/Standards/standards-types.d.ts.map +1 -0
  38. package/dist/Standards/standards-types.js +3 -0
  39. package/dist/Standards/standards-types.js.map +1 -0
  40. package/dist/TokenBalancesController.d.ts +71 -0
  41. package/dist/TokenBalancesController.d.ts.map +1 -0
  42. package/dist/TokenBalancesController.js +94 -0
  43. package/dist/TokenBalancesController.js.map +1 -0
  44. package/dist/TokenDetectionController.d.ts +87 -0
  45. package/dist/TokenDetectionController.d.ts.map +1 -0
  46. package/dist/TokenDetectionController.js +189 -0
  47. package/dist/TokenDetectionController.js.map +1 -0
  48. package/dist/TokenListController.d.ts +117 -0
  49. package/dist/TokenListController.d.ts.map +1 -0
  50. package/dist/TokenListController.js +248 -0
  51. package/dist/TokenListController.js.map +1 -0
  52. package/dist/TokenRatesController.d.ts +172 -0
  53. package/dist/TokenRatesController.d.ts.map +1 -0
  54. package/dist/TokenRatesController.js +327 -0
  55. package/dist/TokenRatesController.js.map +1 -0
  56. package/dist/TokensController.d.ts +250 -0
  57. package/dist/TokensController.d.ts.map +1 -0
  58. package/dist/TokensController.js +550 -0
  59. package/dist/TokensController.js.map +1 -0
  60. package/dist/assetsUtil.d.ts +109 -0
  61. package/dist/assetsUtil.d.ts.map +1 -0
  62. package/dist/assetsUtil.js +227 -0
  63. package/dist/assetsUtil.js.map +1 -0
  64. package/dist/constants.d.ts +6 -0
  65. package/dist/constants.d.ts.map +1 -0
  66. package/dist/constants.js +10 -0
  67. package/dist/constants.js.map +1 -0
  68. package/dist/crypto-compare.d.ts +13 -0
  69. package/dist/crypto-compare.d.ts.map +1 -0
  70. package/dist/crypto-compare.js +67 -0
  71. package/dist/crypto-compare.js.map +1 -0
  72. package/dist/index.d.ts +12 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +32 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/token-service.d.ts +31 -0
  77. package/dist/token-service.d.ts.map +1 -0
  78. package/dist/token-service.js +134 -0
  79. package/dist/token-service.js.map +1 -0
  80. package/package.json +82 -0
@@ -0,0 +1,464 @@
1
+ /// <reference types="node" />
2
+ import type { AddApprovalRequest } from '@metamask/approval-controller';
3
+ import type { BaseConfig, BaseState, RestrictedControllerMessenger } from '@metamask/base-controller';
4
+ import { BaseController } from '@metamask/base-controller';
5
+ import type { NetworkState } from '@metamask/network-controller';
6
+ import type { PreferencesState } from '@metamask/preferences-controller';
7
+ import type { Hex } from '@metamask/utils';
8
+ import { EventEmitter } from 'events';
9
+ import type { AssetsContractController } from './AssetsContractController';
10
+ import { Source } from './constants';
11
+ import type { ApiNftCreator, ApiNftLastSale } from './NftDetectionController';
12
+ declare type NFTStandardType = 'ERC721' | 'ERC1155';
13
+ declare type SuggestedNftMeta = {
14
+ asset: {
15
+ address: string;
16
+ tokenId: string;
17
+ } & NftMetadata;
18
+ id: string;
19
+ time: number;
20
+ type: NFTStandardType;
21
+ interactingAddress: string;
22
+ origin: string;
23
+ };
24
+ /**
25
+ * @type Nft
26
+ *
27
+ * NFT representation
28
+ * @property address - Hex address of a ERC721 contract
29
+ * @property description - The NFT description
30
+ * @property image - URI of custom NFT image associated with this tokenId
31
+ * @property name - Name associated with this tokenId and contract address
32
+ * @property tokenId - The NFT identifier
33
+ * @property numberOfSales - Number of sales
34
+ * @property backgroundColor - The background color to be displayed with the item
35
+ * @property imagePreview - URI of a smaller image associated with this NFT
36
+ * @property imageThumbnail - URI of a thumbnail image associated with this NFT
37
+ * @property imageOriginal - URI of the original image associated with this NFT
38
+ * @property animation - URI of a animation associated with this NFT
39
+ * @property animationOriginal - URI of the original animation associated with this NFT
40
+ * @property externalLink - External link containing additional information
41
+ * @property creator - The NFT owner information object
42
+ * @property isCurrentlyOwned - Boolean indicating whether the address/chainId combination where it's currently stored currently owns this NFT
43
+ * @property transactionId - Transaction Id associated with the NFT
44
+ */
45
+ export interface Nft extends NftMetadata {
46
+ tokenId: string;
47
+ address: string;
48
+ isCurrentlyOwned?: boolean;
49
+ }
50
+ /**
51
+ * @type NftContract
52
+ *
53
+ * NFT contract information representation
54
+ * @property name - Contract name
55
+ * @property logo - Contract logo
56
+ * @property address - Contract address
57
+ * @property symbol - Contract symbol
58
+ * @property description - Contract description
59
+ * @property totalSupply - Total supply of NFTs
60
+ * @property assetContractType - The NFT type, it could be `semi-fungible` or `non-fungible`
61
+ * @property createdDate - Creation date
62
+ * @property schemaName - The schema followed by the contract, it could be `ERC721` or `ERC1155`
63
+ * @property externalLink - External link containing additional information
64
+ */
65
+ export interface NftContract {
66
+ name?: string;
67
+ logo?: string;
68
+ address: string;
69
+ symbol?: string;
70
+ description?: string;
71
+ totalSupply?: string;
72
+ assetContractType?: string;
73
+ createdDate?: string;
74
+ schemaName?: string;
75
+ externalLink?: string;
76
+ }
77
+ /**
78
+ * @type NftMetadata
79
+ *
80
+ * NFT custom information
81
+ * @property name - NFT custom name
82
+ * @property description - The NFT description
83
+ * @property numberOfSales - Number of sales
84
+ * @property backgroundColor - The background color to be displayed with the item
85
+ * @property image - Image custom image URI
86
+ * @property imagePreview - URI of a smaller image associated with this NFT
87
+ * @property imageThumbnail - URI of a thumbnail image associated with this NFT
88
+ * @property imageOriginal - URI of the original image associated with this NFT
89
+ * @property animation - URI of a animation associated with this NFT
90
+ * @property animationOriginal - URI of the original animation associated with this NFT
91
+ * @property externalLink - External link containing additional information
92
+ * @property creator - The NFT owner information object
93
+ * @property standard - NFT standard name for the NFT, e.g., ERC-721 or ERC-1155
94
+ */
95
+ export interface NftMetadata {
96
+ name: string | null;
97
+ description: string | null;
98
+ image: string | null;
99
+ standard: string | null;
100
+ favorite?: boolean;
101
+ numberOfSales?: number;
102
+ backgroundColor?: string;
103
+ imagePreview?: string;
104
+ imageThumbnail?: string;
105
+ imageOriginal?: string;
106
+ animation?: string;
107
+ animationOriginal?: string;
108
+ externalLink?: string;
109
+ creator?: ApiNftCreator;
110
+ lastSale?: ApiNftLastSale;
111
+ transactionId?: string;
112
+ }
113
+ interface AccountParams {
114
+ userAddress: string;
115
+ chainId: Hex;
116
+ }
117
+ /**
118
+ * @type NftConfig
119
+ *
120
+ * NFT controller configuration
121
+ * @property selectedAddress - Vault selected address
122
+ */
123
+ export interface NftConfig extends BaseConfig {
124
+ selectedAddress: string;
125
+ chainId: Hex;
126
+ ipfsGateway: string;
127
+ openSeaEnabled: boolean;
128
+ useIPFSSubdomains: boolean;
129
+ }
130
+ /**
131
+ * @type NftState
132
+ *
133
+ * NFT controller state
134
+ * @property allNftContracts - Object containing NFT contract information
135
+ * @property allNfts - Object containing NFTs per account and network
136
+ * @property ignoredNfts - List of NFTs that should be ignored
137
+ */
138
+ export interface NftState extends BaseState {
139
+ allNftContracts: {
140
+ [key: string]: {
141
+ [chainId: Hex]: NftContract[];
142
+ };
143
+ };
144
+ allNfts: {
145
+ [key: string]: {
146
+ [chainId: Hex]: Nft[];
147
+ };
148
+ };
149
+ ignoredNfts: Nft[];
150
+ }
151
+ interface NftAsset {
152
+ address: string;
153
+ tokenId: string;
154
+ }
155
+ /**
156
+ * The name of the {@link NftController}.
157
+ */
158
+ declare const controllerName = "NftController";
159
+ /**
160
+ * The external actions available to the {@link NftController}.
161
+ */
162
+ declare type AllowedActions = AddApprovalRequest;
163
+ /**
164
+ * The messenger of the {@link NftController}.
165
+ */
166
+ export declare type NftControllerMessenger = RestrictedControllerMessenger<typeof controllerName, AllowedActions, never, AllowedActions['type'], never>;
167
+ /**
168
+ * Controller that stores assets and exposes convenience methods
169
+ */
170
+ export declare class NftController extends BaseController<NftConfig, NftState> {
171
+ private readonly mutex;
172
+ private readonly messagingSystem;
173
+ private getNftApi;
174
+ private getNftContractInformationApi;
175
+ /**
176
+ * Helper method to update nested state for allNfts and allNftContracts.
177
+ *
178
+ * @param newCollection - the modified piece of state to update in the controller's store
179
+ * @param baseStateKey - The root key in the store to update.
180
+ * @param passedConfig - An object containing the selectedAddress and chainId that are passed through the auto-detection flow.
181
+ * @param passedConfig.userAddress - the address passed through the NFT detection flow to ensure assets are stored to the correct account
182
+ * @param passedConfig.chainId - the chainId passed through the NFT detection flow to ensure assets are stored to the correct account
183
+ */
184
+ private updateNestedNftState;
185
+ /**
186
+ * Request individual NFT information from OpenSea API.
187
+ *
188
+ * @param contractAddress - Hex address of the NFT contract.
189
+ * @param tokenId - The NFT identifier.
190
+ * @returns Promise resolving to the current NFT name and image.
191
+ */
192
+ private getNftInformationFromApi;
193
+ /**
194
+ * Request individual NFT information from contracts that follows Metadata Interface.
195
+ *
196
+ * @param contractAddress - Hex address of the NFT contract.
197
+ * @param tokenId - The NFT identifier.
198
+ * @returns Promise resolving to the current NFT name and image.
199
+ */
200
+ private getNftInformationFromTokenURI;
201
+ /**
202
+ * Retrieve NFT uri with metadata. TODO Update method to use IPFS.
203
+ *
204
+ * @param contractAddress - NFT contract address.
205
+ * @param tokenId - NFT token id.
206
+ * @returns Promise resolving NFT uri and token standard.
207
+ */
208
+ private getNftURIAndStandard;
209
+ /**
210
+ * Request individual NFT information (name, image url and description).
211
+ *
212
+ * @param contractAddress - Hex address of the NFT contract.
213
+ * @param tokenId - The NFT identifier.
214
+ * @returns Promise resolving to the current NFT name and image.
215
+ */
216
+ private getNftInformation;
217
+ /**
218
+ * Request NFT contract information from OpenSea API.
219
+ *
220
+ * @param contractAddress - Hex address of the NFT contract.
221
+ * @returns Promise resolving to the current NFT name and image.
222
+ */
223
+ private getNftContractInformationFromApi;
224
+ /**
225
+ * Request NFT contract information from the contract itself.
226
+ *
227
+ * @param contractAddress - Hex address of the NFT contract.
228
+ * @returns Promise resolving to the current NFT name and image.
229
+ */
230
+ private getNftContractInformationFromContract;
231
+ /**
232
+ * Request NFT contract information from OpenSea API.
233
+ *
234
+ * @param contractAddress - Hex address of the NFT contract.
235
+ * @returns Promise resolving to the NFT contract name, image and description.
236
+ */
237
+ private getNftContractInformation;
238
+ /**
239
+ * Adds an individual NFT to the stored NFT list.
240
+ *
241
+ * @param address - Hex address of the NFT contract.
242
+ * @param tokenId - The NFT identifier.
243
+ * @param nftMetadata - NFT optional information (name, image and description).
244
+ * @param nftContract - An object containing contract data of the NFT being added.
245
+ * @param accountParams - The chain ID and address of network and account to which the nftContract should be added.
246
+ * @param source - Whether the NFT was detected, added manually or suggested by a dapp.
247
+ * @returns Promise resolving to the current NFT list.
248
+ */
249
+ private addIndividualNft;
250
+ /**
251
+ * Adds an NFT contract to the stored NFT contracts list.
252
+ *
253
+ * @param address - Hex address of the NFT contract.
254
+ * @param accountParams - The chain ID and address of network and account to which the nftContract should be added.
255
+ * @param source - Whether the NFT was detected, added manually or suggested by a dapp.
256
+ * @returns Promise resolving to the current NFT contracts list.
257
+ */
258
+ private addNftContract;
259
+ /**
260
+ * Removes an individual NFT from the stored token list and saves it in ignored NFTs list.
261
+ *
262
+ * @param address - Hex address of the NFT contract.
263
+ * @param tokenId - Token identifier of the NFT.
264
+ */
265
+ private removeAndIgnoreIndividualNft;
266
+ /**
267
+ * Removes an individual NFT from the stored token list.
268
+ *
269
+ * @param address - Hex address of the NFT contract.
270
+ * @param tokenId - Token identifier of the NFT.
271
+ */
272
+ private removeIndividualNft;
273
+ /**
274
+ * Removes an NFT contract to the stored NFT contracts list.
275
+ *
276
+ * @param address - Hex address of the NFT contract.
277
+ * @returns Promise resolving to the current NFT contracts list.
278
+ */
279
+ private removeNftContract;
280
+ /**
281
+ * EventEmitter instance used to listen to specific EIP747 events
282
+ */
283
+ hub: EventEmitter;
284
+ /**
285
+ * Optional API key to use with opensea
286
+ */
287
+ openSeaApiKey?: string;
288
+ /**
289
+ * Name of this controller used during composition
290
+ */
291
+ name: string;
292
+ private readonly getERC721AssetName;
293
+ private readonly getERC721AssetSymbol;
294
+ private readonly getERC721TokenURI;
295
+ private readonly getERC721OwnerOf;
296
+ private readonly getERC1155BalanceOf;
297
+ private readonly getERC1155TokenURI;
298
+ private readonly onNftAdded?;
299
+ /**
300
+ * Creates an NftController instance.
301
+ *
302
+ * @param options - The controller options.
303
+ * @param options.chainId - The chain ID of the current network.
304
+ * @param options.onPreferencesStateChange - Allows subscribing to preference controller state changes.
305
+ * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
306
+ * @param options.getERC721AssetName - Gets the name of the asset at the given address.
307
+ * @param options.getERC721AssetSymbol - Gets the symbol of the asset at the given address.
308
+ * @param options.getERC721TokenURI - Gets the URI of the ERC721 token at the given address, with the given ID.
309
+ * @param options.getERC721OwnerOf - Get the owner of a ERC-721 NFT.
310
+ * @param options.getERC1155BalanceOf - Gets balance of a ERC-1155 NFT.
311
+ * @param options.getERC1155TokenURI - Gets the URI of the ERC1155 token at the given address, with the given ID.
312
+ * @param options.onNftAdded - Callback that is called when an NFT is added. Currently used pass data
313
+ * for tracking the NFT added event.
314
+ * @param options.messenger - The controller messenger.
315
+ * @param config - Initial options used to configure this controller.
316
+ * @param state - Initial state to set on this controller.
317
+ */
318
+ constructor({ chainId: initialChainId, onPreferencesStateChange, onNetworkStateChange, getERC721AssetName, getERC721AssetSymbol, getERC721TokenURI, getERC721OwnerOf, getERC1155BalanceOf, getERC1155TokenURI, onNftAdded, messenger, }: {
319
+ chainId: Hex;
320
+ onPreferencesStateChange: (listener: (preferencesState: PreferencesState) => void) => void;
321
+ onNetworkStateChange: (listener: (networkState: NetworkState) => void) => void;
322
+ getERC721AssetName: AssetsContractController['getERC721AssetName'];
323
+ getERC721AssetSymbol: AssetsContractController['getERC721AssetSymbol'];
324
+ getERC721TokenURI: AssetsContractController['getERC721TokenURI'];
325
+ getERC721OwnerOf: AssetsContractController['getERC721OwnerOf'];
326
+ getERC1155BalanceOf: AssetsContractController['getERC1155BalanceOf'];
327
+ getERC1155TokenURI: AssetsContractController['getERC1155TokenURI'];
328
+ onNftAdded?: (data: {
329
+ address: string;
330
+ symbol: string | undefined;
331
+ tokenId: string;
332
+ standard: string | null;
333
+ source: string;
334
+ }) => void;
335
+ messenger: NftControllerMessenger;
336
+ }, config?: Partial<BaseConfig>, state?: Partial<NftState>);
337
+ validateWatchNft(asset: NftAsset, type: NFTStandardType, accountAddress: string): Promise<void>;
338
+ /**
339
+ * Adds a new suggestedAsset to state. Parameters will be validated according to
340
+ * asset type being watched. A `<suggestedNftMeta.id>:pending` hub event will be emitted once added.
341
+ *
342
+ * @param asset - The asset to be watched. For now ERC721 and ERC1155 tokens are accepted.
343
+ * @param asset.address - The address of the asset contract.
344
+ * @param asset.tokenId - The ID of the asset.
345
+ * @param type - The asset type.
346
+ * @param origin - Domain origin to register the asset from.
347
+ * @returns Object containing a Promise resolving to the suggestedAsset address if accepted.
348
+ */
349
+ watchNft(asset: NftAsset, type: NFTStandardType, origin: string): Promise<void>;
350
+ /**
351
+ * Sets an OpenSea API key to retrieve NFT information.
352
+ *
353
+ * @param openSeaApiKey - OpenSea API key.
354
+ */
355
+ setApiKey(openSeaApiKey: string): void;
356
+ /**
357
+ * Checks the ownership of a ERC-721 or ERC-1155 NFT for a given address.
358
+ *
359
+ * @param ownerAddress - User public address.
360
+ * @param nftAddress - NFT contract address.
361
+ * @param nftId - NFT token ID.
362
+ * @returns Promise resolving the NFT ownership.
363
+ */
364
+ isNftOwner(ownerAddress: string, nftAddress: string, nftId: string): Promise<boolean>;
365
+ /**
366
+ * Verifies currently selected address owns entered NFT address/tokenId combo and
367
+ * adds the NFT and respective NFT contract to the stored NFT and NFT contracts lists.
368
+ *
369
+ * @param address - Hex address of the NFT contract.
370
+ * @param tokenId - The NFT identifier.
371
+ */
372
+ addNftVerifyOwnership(address: string, tokenId: string): Promise<void>;
373
+ /**
374
+ * Adds an NFT and respective NFT contract to the stored NFT and NFT contracts lists.
375
+ *
376
+ * @param address - Hex address of the NFT contract.
377
+ * @param tokenId - The NFT identifier.
378
+ * @param nftMetadata - NFT optional metadata.
379
+ * @param accountParams - The chain ID and address of network and account to which the nftContract should be added.
380
+ * @param source - Whether the NFT was detected, added manually or suggested by a dapp.
381
+ * @returns Promise resolving to the current NFT list.
382
+ */
383
+ addNft(address: string, tokenId: string, nftMetadata?: NftMetadata, accountParams?: AccountParams, source?: Source): Promise<void>;
384
+ /**
385
+ * Removes an NFT from the stored token list.
386
+ *
387
+ * @param address - Hex address of the NFT contract.
388
+ * @param tokenId - Token identifier of the NFT.
389
+ */
390
+ removeNft(address: string, tokenId: string): void;
391
+ /**
392
+ * Removes an NFT from the stored token list and saves it in ignored NFTs list.
393
+ *
394
+ * @param address - Hex address of the NFT contract.
395
+ * @param tokenId - Token identifier of the NFT.
396
+ */
397
+ removeAndIgnoreNft(address: string, tokenId: string): void;
398
+ /**
399
+ * Removes all NFTs from the ignored list.
400
+ */
401
+ clearIgnoredNfts(): void;
402
+ /**
403
+ * Checks whether input NFT is still owned by the user
404
+ * And updates the isCurrentlyOwned value on the NFT object accordingly.
405
+ *
406
+ * @param nft - The NFT object to check and update.
407
+ * @param batch - A boolean indicating whether this method is being called as part of a batch or single update.
408
+ * @param accountParams - The userAddress and chainId to check ownership against
409
+ * @param accountParams.userAddress - the address passed through the confirmed transaction flow to ensure assets are stored to the correct account
410
+ * @param accountParams.chainId - the chainId passed through the confirmed transaction flow to ensure assets are stored to the correct account
411
+ * @returns the NFT with the updated isCurrentlyOwned value
412
+ */
413
+ checkAndUpdateSingleNftOwnershipStatus(nft: Nft, batch: boolean, { userAddress, chainId }?: {
414
+ userAddress: string;
415
+ chainId: `0x${string}`;
416
+ }): Promise<Nft>;
417
+ /**
418
+ * Checks whether NFTs associated with current selectedAddress/chainId combination are still owned by the user
419
+ * And updates the isCurrentlyOwned value on each accordingly.
420
+ */
421
+ checkAndUpdateAllNftsOwnershipStatus(): Promise<void>;
422
+ /**
423
+ * Update NFT favorite status.
424
+ *
425
+ * @param address - Hex address of the NFT contract.
426
+ * @param tokenId - Hex address of the NFT contract.
427
+ * @param favorite - NFT new favorite status.
428
+ */
429
+ updateNftFavoriteStatus(address: string, tokenId: string, favorite: boolean): void;
430
+ /**
431
+ * Returns an NFT by the address and token id.
432
+ *
433
+ * @param address - Hex address of the NFT contract.
434
+ * @param tokenId - Number that represents the id of the token.
435
+ * @param selectedAddress - Hex address of the user account.
436
+ * @param chainId - Id of the current network.
437
+ * @returns Object containing the NFT and its position in the array
438
+ */
439
+ findNftByAddressAndTokenId(address: string, tokenId: string, selectedAddress: string, chainId: Hex): {
440
+ nft: Nft;
441
+ index: number;
442
+ } | null;
443
+ /**
444
+ * Update NFT data.
445
+ *
446
+ * @param nft - NFT object to find the right NFT to updates.
447
+ * @param updates - NFT partial object to update properties of the NFT.
448
+ * @param selectedAddress - Hex address of the user account.
449
+ * @param chainId - Id of the current network.
450
+ */
451
+ updateNft(nft: Nft, updates: Partial<Nft>, selectedAddress: string, chainId: Hex): void;
452
+ /**
453
+ * Resets the transaction status of an NFT.
454
+ *
455
+ * @param transactionId - NFT transaction id.
456
+ * @param selectedAddress - Hex address of the user account.
457
+ * @param chainId - Id of the current network.
458
+ * @returns a boolean indicating if the reset was well succeded or not
459
+ */
460
+ resetNftTransactionStatusByTransactionId(transactionId: string, selectedAddress: string, chainId: Hex): boolean;
461
+ _requestApproval(suggestedNftMeta: SuggestedNftMeta): Promise<unknown>;
462
+ }
463
+ export default NftController;
464
+ //# sourceMappingURL=NftController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NftController.d.ts","sourceRoot":"","sources":["../src/NftController.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAc3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AA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