@metamask/assets-controllers 112.1.3 → 113.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -1
- package/dist/NftController.d.ts +5 -3
- package/dist/NftController.d.ts.map +1 -1
- package/dist/NftController.js +12 -4
- package/dist/NftController.js.map +1 -1
- package/dist/NftDetectionController.d.ts +3 -1
- package/dist/NftDetectionController.d.ts.map +1 -1
- package/dist/NftDetectionController.js +34 -2
- package/dist/NftDetectionController.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +19 -22
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [113.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Export the `Source` enum (`Custom`, `Dapp`, `Detected`) so consumers can pass it to `NftController.addNft` and related methods ([#11106](https://github.com/MetaMask/core/pull/11106))
|
|
15
|
+
- Add optional `source` field to the `Nft` type, recording how the NFT was added: manually (`custom`), suggested by a dapp (`dapp`) or auto-detected (`detected`) ([#11106](https://github.com/MetaMask/core/pull/11106))
|
|
16
|
+
- Set when the NFT is created. Auto-detection never overwrites it, a dapp suggestion upgrades `detected`, and a manual import overrides any other source. NFTs added before this change have no `source`.
|
|
17
|
+
- `Source.Custom` is the default `source` of `addNft`, `addNfts` and `addNftVerifyOwnership`; pass `Source.Detected` when refreshing existing NFTs.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **BREAKING:** `NftDetectionController` constructor now requires a `removeNft` option (type `NftController['removeNft']`); during detection, any NFT already in state that the API now returns as spam (`isSpam: true`) is automatically removed ([#8237](https://github.com/MetaMask/core/pull/8237))
|
|
22
|
+
- Callers must pass `removeNft: nftController.removeNft.bind(nftController)` (or equivalent) when constructing `NftDetectionController`
|
|
23
|
+
- NFTs whose stored `source` is `custom` (manual import) or `dapp` (approved dapp suggestion) are never auto-removed. Detected NFTs, and NFTs added before `source` was recorded, can be removed.
|
|
24
|
+
- Bump `@metamask/transaction-controller` from `^72.2.1` to `^72.3.0` ([#11154](https://github.com/MetaMask/core/pull/11154))
|
|
25
|
+
- Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
|
|
26
|
+
- Bump `@metamask/permission-controller` from `^14.0.0` to `^14.1.0` ([#11157](https://github.com/MetaMask/core/pull/11157))
|
|
27
|
+
|
|
28
|
+
## [112.2.0]
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981))
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Bump `@metamask/network-controller` from `^37.1.0` to `^37.1.1` ([#10982](https://github.com/MetaMask/core/pull/10982))
|
|
37
|
+
- Bump `@metamask/account-tree-controller` from `^11.1.1` to `^11.2.0` ([#11092](https://github.com/MetaMask/core/pull/11092))
|
|
38
|
+
- Bump `@metamask/profile-sync-controller` from `^35.0.0` to `^36.0.0` ([#11092](https://github.com/MetaMask/core/pull/11092))
|
|
39
|
+
|
|
10
40
|
## [112.1.3]
|
|
11
41
|
|
|
12
42
|
### Changed
|
|
@@ -3595,7 +3625,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
3595
3625
|
|
|
3596
3626
|
- Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))
|
|
3597
3627
|
|
|
3598
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@
|
|
3628
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@113.0.0...HEAD
|
|
3629
|
+
[113.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@112.2.0...@metamask/assets-controllers@113.0.0
|
|
3630
|
+
[112.2.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@112.1.3...@metamask/assets-controllers@112.2.0
|
|
3599
3631
|
[112.1.3]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@112.1.2...@metamask/assets-controllers@112.1.3
|
|
3600
3632
|
[112.1.2]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@112.1.1...@metamask/assets-controllers@112.1.2
|
|
3601
3633
|
[112.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@112.1.0...@metamask/assets-controllers@112.1.1
|
package/dist/NftController.d.ts
CHANGED
|
@@ -52,11 +52,13 @@ type SuggestedNftMeta = {
|
|
|
52
52
|
* creator - The NFT owner information object
|
|
53
53
|
* isCurrentlyOwned - Boolean indicating whether the address/chainId combination where it's currently stored currently owns this NFT
|
|
54
54
|
* transactionId - Transaction Id associated with the NFT
|
|
55
|
+
* source - How the NFT was added (`custom`, `dapp` or `detected`). Set on creation; auto-detection never overwrites it, a dapp suggestion upgrades `detected`, and a manual import overrides any other source. Unset for NFTs added before this field existed.
|
|
55
56
|
*/
|
|
56
57
|
export type Nft = {
|
|
57
58
|
tokenId: string;
|
|
58
59
|
address: string;
|
|
59
60
|
isCurrentlyOwned?: boolean;
|
|
61
|
+
source?: Source;
|
|
60
62
|
} & NftMetadata;
|
|
61
63
|
/**
|
|
62
64
|
* NftContract
|
|
@@ -269,7 +271,7 @@ export declare class NftController extends BaseController<typeof controllerName,
|
|
|
269
271
|
* @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
270
272
|
* @param options - an object of arguments
|
|
271
273
|
* @param options.userAddress - The address of the current user.
|
|
272
|
-
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
|
|
274
|
+
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to `Source.Custom`; pass `Source.Detected` when refreshing existing NFTs.
|
|
273
275
|
*/
|
|
274
276
|
addNftVerifyOwnership(address: string, tokenId: string, networkClientId: NetworkClientId, { userAddress, source, }?: {
|
|
275
277
|
userAddress?: string;
|
|
@@ -284,7 +286,7 @@ export declare class NftController extends BaseController<typeof controllerName,
|
|
|
284
286
|
* @param options - an object of arguments
|
|
285
287
|
* @param options.nftMetadata - NFT optional metadata.
|
|
286
288
|
* @param options.userAddress - The address of the current user.
|
|
287
|
-
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
|
|
289
|
+
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to `Source.Custom`; pass `Source.Detected` when refreshing existing NFTs.
|
|
288
290
|
* @returns Promise resolving to the current NFT list.
|
|
289
291
|
*/
|
|
290
292
|
addNft(tokenAddress: string, tokenId: string, networkClientId: NetworkClientId, { nftMetadata, userAddress, source, }?: {
|
|
@@ -300,7 +302,7 @@ export declare class NftController extends BaseController<typeof controllerName,
|
|
|
300
302
|
* @param nfts[].tokenId - The NFT identifier.
|
|
301
303
|
* @param nfts[].nftMetadata - NFT metadata including chainId.
|
|
302
304
|
* @param userAddress - The address of the current user.
|
|
303
|
-
* @param source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to Source.Custom.
|
|
305
|
+
* @param source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to `Source.Custom`; pass `Source.Detected` when refreshing existing NFTs.
|
|
304
306
|
* @returns Promise resolving to the current NFT list.
|
|
305
307
|
*/
|
|
306
308
|
addNfts(nfts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NftController.d.ts","sourceRoot":"","sources":["../src/NftController.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,+CAA+C,EAC/C,kCAAkC,EAClC,0CAA0C,EAC3C,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAA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AAG,IAAI,CAcpC;IAED;;;;;;;OAOG;IACH,SAAS,CACP,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EACrB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,GAAG,GACX,IAAI,CA4BN;IAED;;;;;;;OAOG;IACH,wCAAwC,CACtC,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,GAAG,GACX,OAAO,CA2BT;IAEK,gBAAgB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsB3E;IA2CD;;OAEG;IACH,UAAU,IAAI,IAAI,CAIjB;CAuIF;eAEc,aAAa"}
|
package/dist/NftController.js
CHANGED
|
@@ -415,9 +415,15 @@ export class NftController extends BaseController {
|
|
|
415
415
|
if (existingEntry) {
|
|
416
416
|
const differentMetadata = compareNftMetadata(nftMetadata, existingEntry);
|
|
417
417
|
const hasNewFields = hasNewCollectionFields(nftMetadata, existingEntry);
|
|
418
|
+
// Auto-detection never overwrites a stored source and nothing
|
|
419
|
+
// overwrites a manual import.
|
|
420
|
+
const needsSourceUpdate = source !== Source.Detected &&
|
|
421
|
+
existingEntry.source !== Source.Custom &&
|
|
422
|
+
existingEntry.source !== source;
|
|
418
423
|
if (!differentMetadata &&
|
|
419
424
|
existingEntry.isCurrentlyOwned &&
|
|
420
|
-
!hasNewFields
|
|
425
|
+
!hasNewFields &&
|
|
426
|
+
!needsSourceUpdate) {
|
|
421
427
|
continue;
|
|
422
428
|
}
|
|
423
429
|
const indexToUpdate = allNftsForUserPerChain[chainId].findIndex((nft) => nft.address.toLowerCase() ===
|
|
@@ -426,6 +432,7 @@ export class NftController extends BaseController {
|
|
|
426
432
|
allNftsForUserPerChain[chainId][indexToUpdate] = {
|
|
427
433
|
...existingEntry,
|
|
428
434
|
...nftMetadata,
|
|
435
|
+
...(needsSourceUpdate && { source }),
|
|
429
436
|
};
|
|
430
437
|
}
|
|
431
438
|
}
|
|
@@ -436,6 +443,7 @@ export class NftController extends BaseController {
|
|
|
436
443
|
favorite: false,
|
|
437
444
|
isCurrentlyOwned: true,
|
|
438
445
|
...nftMetadata,
|
|
446
|
+
source,
|
|
439
447
|
};
|
|
440
448
|
allNftsForUserPerChain[chainId].push(newEntry);
|
|
441
449
|
}
|
|
@@ -732,7 +740,7 @@ export class NftController extends BaseController {
|
|
|
732
740
|
* @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
733
741
|
* @param options - an object of arguments
|
|
734
742
|
* @param options.userAddress - The address of the current user.
|
|
735
|
-
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
|
|
743
|
+
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to `Source.Custom`; pass `Source.Detected` when refreshing existing NFTs.
|
|
736
744
|
*/
|
|
737
745
|
async addNftVerifyOwnership(address, tokenId, networkClientId, { userAddress, source, } = {}) {
|
|
738
746
|
const addressToSearch = this.#getAddressOrSelectedAddress(userAddress);
|
|
@@ -753,7 +761,7 @@ export class NftController extends BaseController {
|
|
|
753
761
|
* @param options - an object of arguments
|
|
754
762
|
* @param options.nftMetadata - NFT optional metadata.
|
|
755
763
|
* @param options.userAddress - The address of the current user.
|
|
756
|
-
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
|
|
764
|
+
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to `Source.Custom`; pass `Source.Detected` when refreshing existing NFTs.
|
|
757
765
|
* @returns Promise resolving to the current NFT list.
|
|
758
766
|
*/
|
|
759
767
|
async addNft(tokenAddress, tokenId, networkClientId, { nftMetadata, userAddress, source = Source.Custom, } = {}) {
|
|
@@ -810,7 +818,7 @@ export class NftController extends BaseController {
|
|
|
810
818
|
* @param nfts[].tokenId - The NFT identifier.
|
|
811
819
|
* @param nfts[].nftMetadata - NFT metadata including chainId.
|
|
812
820
|
* @param userAddress - The address of the current user.
|
|
813
|
-
* @param source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to Source.Custom.
|
|
821
|
+
* @param source - Whether the NFT was detected, added manually or suggested by a dapp. Defaults to `Source.Custom`; pass `Source.Detected` when refreshing existing NFTs.
|
|
814
822
|
* @returns Promise resolving to the current NFT list.
|
|
815
823
|
*/
|
|
816
824
|
async addNfts(nfts, userAddress, source = Source.Custom) {
|