fix: restore isCurrentlyOwned when re-adding an NFT - #9814
Open
SnowingFox wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #9787
When an NFT leaves a wallet and is later re-acquired, the manual import path
reports success but the NFT stays invisible.
#addMultipleNftsrefreshes anexisting state entry with
{ ...existingEntry, ...nftMetadata }, and becausenftMetadatanever carriesisCurrentlyOwned, the staleisCurrentlyOwned: falsewritten earlier bycheckAndUpdateSingleNftOwnershipStatussurvives themerge.
Ownership is already proven on the manual import path:
addNftVerifyOwnershipthrows unless the user owns the token on-chain, and
addNft/addNftsdefaultto
Source.Customwhen invoked for manual imports. This PR restoresisCurrentlyOwned: truewhen refreshing an existing entry on theSource.Custompath, so re-acquired NFTs reappear. Other sources (autodetectionSource.Detected, dapp-suggestedSource.Dapp) are untouched.Changes
packages/assets-controllers/src/NftController.ts: restoreisCurrentlyOwnedto
truein#addMultipleNftswhensource === Source.Custom.packages/assets-controllers/src/NftController.test.ts: add a regression testthat re-adds a previously-unowned NFT via
addNftVerifyOwnershipand assertsisCurrentlyOwnedflips back totrue.packages/assets-controllers/CHANGELOG.md: add[Unreleased]Fixedentry.Test plan
cd packages/assets-controllers NODE_OPTIONS=--experimental-vm-modules yarn jest src/NftController.test.ts src/NftDetectionController.test.ts --coverage=falsemain(Expected: true, Received: false) andpasses with the fix.
NftController.test.ts: 117 passed, 4 snapshots.NftDetectionController.test.ts: 20 passed.eslintclean on changed files;changelog:validatepasses.Note
Low Risk
Narrow fix to manual NFT import merge logic with a targeted regression test; no auth, security, or broad behavioral changes outside Custom source updates.
Overview
Fixes re-acquired NFTs staying hidden after a successful manual import when state still had
isCurrentlyOwned: falsefrom an earlier ownership check.In
#addMultipleNfts, updating an existing entry now setsisCurrentlyOwned: truewhensource === Source.Custom(manual import /addNftVerifyOwnership), instead of leaving the stale flag from the spread merge. Autodetection and dapp-suggested sources are unchanged.Adds a regression test for
addNftVerifyOwnershipand an[Unreleased]changelog entry.Reviewed by Cursor Bugbot for commit 13aba0e. Bugbot is set up for automated code reviews on this repo. Configure here.