NFTs
NFTs Module
This module is responsible for watching and updating the Non-Fungible Token (NFT) balances of wallets and vaults. It uses signals to maintain a reactive state of NFT data in the form of lists and maps.
Import
This module imports the following dependencies:
endpoints
from./endpoints
KiroboService
from@kiroboio/fct-service
NFTUpdateDto
,nftDto
from./types/nfts.dto
network
from./network
Constants
ENDPOINT
: contains the endpoint of the NFT service.
Type definitions
NFTData
: a type that extendsnftDto
with an additionalid
property.
State
_callId
: a number representing the current call id.nfts
: an object that containsvault
andwallet
objects, each withraw
andformatted
properties, containing lists and maps of NFT data.
Computed Properties
networkName
: a computed property that returns the current network name.
Functions
itemId(item: nftDto | NFTUpdateDto, networkName: string)
This function generates a unique id for the given NFT item in the format of {token_address}#{token_id}@{networkName}
.
unwatchNFTs()
This function removes all listeners for the NFT service and resets the NFT state.
watchNFTs({wallet, vault})
This function watches for NFT updates in the specified wallet and vault. It updates the NFT state accordingly when there are changes in the balances. It also sets up listeners for the NFT service to respond to events like transfers.
Exports
nfts
: the state object containing the NFT data.unwatchNFTs
: a function to stop watching NFT updates.watchNFTs
: a function to start watching NFT updates.
Last updated