Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional networkClientId and userAddress args to remaining NftController public methods #2006

Merged
merged 7 commits into from
Nov 14, 2023

Conversation

adonesky1
Copy link
Contributor

@adonesky1 adonesky1 commented Nov 7, 2023

@metamask/assets-controllers

Changed:

  • watchNft, removeNft, removeAndIgnoreNft, removeNftContract, updateNftFavoriteStatus, and checkAndUpdateAllNftsOwnershipStatus methods on NftController all now accept an optional options object argument containing networkClientId and userAddress to identify where in state to mutate.
  • BREAKING: addNft no longer accepts a chainId property in its options argument since this value can be retrieved by the networkClientId property and is therefore redundant.
  • BREAKING: The third and fourth arguments on NftController's addNftVerifyOwnership method, have been replaced with an options object containing optional properties networkClientId, userAddress and source. This method signature is more aligned with the options pattern for passing networkClientId and userAddress on this controller and elsewhere.
  • BREAKING: checkAndUpdateSingleNftOwnershipStatus on NftController no longer accepts a chainId in its options argument. This is replaced with an optional networkClientId property which can be used to fetch chainId.
    *BREAKING: The fourth argument of the isNftOwner method on NftController is now an options object with an optional networkClientId property. This method signature is more aligned with the options pattern for passing networkClientId on this controller and elsewhere.
  • BREAKING: validateWatchNft method on NftController is now private.
  • BREAKING: detectNfts on NftDetectionController now accepts a single object argument with optional properties networkClientId and userAddress, rather than taking these as two sequential arguments.

@adonesky1 adonesky1 requested a review from a team as a code owner November 7, 2023 21:04
@adonesky1 adonesky1 changed the title add optional networkClientId + userAddress args to remaining NftController public methods Add optional networkClientId and userAddress args to remaining NftController public methods Nov 7, 2023
@adonesky1 adonesky1 force-pushed the add-missing-nft-controller-multichain-updates branch 3 times, most recently from b1d2243 to 6a6b6cc Compare November 9, 2023 19:08
@adonesky1 adonesky1 marked this pull request as draft November 9, 2023 19:08
@adonesky1 adonesky1 force-pushed the add-missing-nft-controller-multichain-updates branch 2 times, most recently from 522997c to 4a9ea83 Compare November 13, 2023 17:08
@adonesky1 adonesky1 force-pushed the add-missing-nft-controller-multichain-updates branch from df2879d to 49563a6 Compare November 13, 2023 17:18
@adonesky1 adonesky1 force-pushed the add-missing-nft-controller-multichain-updates branch from ff487e7 to d59dc18 Compare November 13, 2023 17:40
@adonesky1 adonesky1 marked this pull request as ready for review November 13, 2023 17:54
@adonesky1 adonesky1 force-pushed the add-missing-nft-controller-multichain-updates branch from d59dc18 to c235299 Compare November 13, 2023 18:13
};

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-next-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are we ignoring about the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a type error, watchNft expects the tokenId in the first arg object to be a string. We're ignoring it precisely to test that the error is thrown for this case, since we currently don't enforce types in the extension where this is called.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could cast the fn to any or equivalent type instead:
const erc721Result = (nftController.watchNft as any)(ERC721_NFT, type);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep that would also work. Happy to do that if you think its better. Seems kindof the same to me

@jiexi
Copy link
Contributor

jiexi commented Nov 13, 2023

Most of these changes should be marked as BREAKING

Copy link
Contributor

@jiexi jiexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 87.77,
branches: 88.2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

Copy link
Contributor

@BelfordZ BelfordZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lookin good

@adonesky1 adonesky1 merged commit 2938d37 into main Nov 14, 2023
128 checks passed
@adonesky1 adonesky1 deleted the add-missing-nft-controller-multichain-updates branch November 14, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants