useNft() 0.9.0: faster, custom URLs, Meebits support 🐽
Meebits support
Meebits can now be supported despite being CORS restricted, thanks to the new jsonProxy
option (see next section for details).
Custom URLs
Three new and optional props have been added to the <NftProvider />
component to allow more control over URLs.
Note: if you are using the FetchWrapper
class, these options can also be passed as the second parameter of its constructor. See FetchWrapper documentation for details.
jsonProxy
jsonProxy
allows to fetch the NFT metadata through a proxy by transforming the base URLs. For example, this can be used to get around CORS restrictions or to cache the responses to improve the performances. See API documentation for details.
imageProxy
imageProxy
allows to fetch the images through a proxy. This is useful to optimize (compress / resize) the raw NFT images by passing the URL to a service. See API documentation for details.
ipfsUrl
ipfsUrl
allows to change the IPFS gateway (defaults to the ipfs.io gateway). See API documentation for details.
Related Pull Request
- Add ipfsUrl, proxyJson, proxyImage (#98)
Faster metadata fetching
useNft used to call the supportsInterface()
method (from ERC 165) to determine the nature of an NFT (ERC721 or ERC1155). A problem with this approach is that it requires an initial call before fetching the metadata from a contract, slowing down the fetching process.
Another issue, that became more and more apparent, is that some contracts support a metadata-fetching method from either ERC721 or ERC1155 without declaraing it properly, or the other way around, requiring to maintain a list of contracts “known to be compatible”.
The new approach stops using supportsInterface()
, and attempts to use the two metadata fetching methods at the same time. The first positive response is assumed to be correct.
Related Pull request
- Remove the supportsInterface() (ERC165) calls (#90)
Throw an error when fetcher
is not set
An error is now thrown when fetcher
is missing on <NftProvider />
.
Related Pull request
- Throw an error when the fetcher is not set (#91)