Skip to content

Commit

Permalink
Parameterize NftController.addNft by networkClientId (#1698)
Browse files Browse the repository at this point in the history
Fixes: MetaMask/MetaMask-planning#1022

# Changelog

## @metamask/assets-controllers

- **BREAKING:** `NFTController` now expects `getNetworkClientById` in
constructor options
- **BREAKING:** `NftController. addNft()` function signature has
changed:
   - Previously 
   ```
    address: string,
    tokenId: string,
    nftMetadata?: NftMetadata,
    accountParams?: {
       userAddress: string;
       chainId: Hex;
    },
    source = Source.Custom,
   ```
   now:
   ```
    tokenAddress: string,
    tokenId: string,
      {
      nftMetadata?: NftMetadata;
      chainId?: Hex; // extracts from AccountParams
      userAddress?: string // extracted from AccountParams
      source?: Source;
      networkClientId?: NetworkClientId; // new
    },
    ```
    
- CHANGED: `NftController.addNftVerifyOwnership`: now accepts optional
`networkClientId` which is used to fetch NFT metadata and determine by
which chainId the added NFT should be stored in state.
- CHANGED: `NftController.isNftOwner`: now accepts optional
`networkClientId` which is used to instantiate the provider for the
correct chain and call the NFT contract to verify ownership.
- CHANGED: `NftController. addNft()` will use the chainId value derived
from `networkClientId` if provided
- CHANGED: `NftController. watchNft()` options now accepts optional
`networkClientId` which is used to fetch NFT metadata and determine by
which chainId the added NFT should be stored in state.
  • Loading branch information
adonesky1 authored and MajorLift committed Oct 11, 2023
1 parent 1e3fe31 commit febcd8c
Show file tree
Hide file tree
Showing 4 changed files with 639 additions and 244 deletions.
Loading

0 comments on commit febcd8c

Please sign in to comment.