Releases: bpierre/use-nft
useNft() 0.12.0: farewell CommonJS
This release removes CommonJS support and makes use-nft a pure ESM module.
To make sure your project is compatible with it, please use the latest version of Node.js and/or add "type": "module"
to your package.json.
useNft() 0.11.0: upgrade all the things
useNft() 0.10.2: Bored Ape Yacht Club compatibility
This version brings compatibility with the metadata format used by Bored Ape Yacht Club NFTs.
Thanks to @dibeling for the PR ❤️
useNft() 0.10.1: SWR update
This version adapts to a change in the SWR API while also upgrading SWR to the latest version.
Pull Request
- Upgrade SWR (#157)
useNft() 0.10.0: on-chain punks and new NFT fields
On-chain Cryptopunks
The images of Cryptopunks are now fetched directly from the new image contract, as SVG files rather than PNG. The quality is improved, and it allows to not rely on Larvalabs hosting these files anymore.
Related pull request
- Cryptopunks: fetch images on chain (#155)
Ethers is now an optional peer dependency
By doing this change, injecting ethers
is now unnecessary, even though it will continue working to support advanced scenarios.
You might want to upgrade your code from this:
import ethers from 'ethers'
const provider = getDefaultProvider("homestead")
function App() {
return (
<NftProvider fetcher={["ethers", { ethers, provider }]} />
)
}
To this:
const provider = getDefaultProvider("homestead")
function App() {
return (
<NftProvider fetcher={["ethers", { provider }]} />
)
}
Related pull request
- Make Ethers an optional peer dependency (#153)
New fields: rawData
, imageType
Two new fields have been added on the nft
object:
rawData
contains the entire JSON data as being fetched from the source.imageType
can beimage
,video
orunknown
. useNft() tries to detect its type based on the URL extension, so it should only be used as an indicative information.
Related pull requests
Other changes
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)
Other changes
useNft() 0.8: nft.metadataUrl
useNft() 0.7.0: nft.owner, full Decentraland support 🪐
Decentraland
This version provides a full support for Decentraland NFTs: wearables were already supported, and support for Parcels and Estates have been added.
Related pull request
- Add support for Decentraland Estates + Parcels (#73)
NFT owner field
Another change is the addition of the nft.owner
field. When available, it will contain the address of the current owner of the NFT.
Related pull request
- Add new field: nft.owner (#78)
Other changes
useNft() 0.6.2
Changes
- IPFS protocol: make the ipfs/ prefix optional (#68)