neuron icon indicating copy to clipboard operation
neuron copied to clipboard

Feature Request: Display NFTClass data details for NFT

Open requaos opened this issue 3 years ago • 5 comments

In the custom assets section, we can go to the cells on explorer via details. On explorer site for an address with NFT assets, thumbnails are displayed. From the nervos wallet, loading the image may be a security risk, but the url should be displayed.

requaos avatar Aug 24 '21 16:08 requaos

Yep, to display the image/media embedded in NFT is a security risk. And it's the main concern that why Neuron doesn't show up them. I think we could display the static information as json format.

CipherWang avatar Aug 30 '21 08:08 CipherWang

okay, then I will create the object with schema:

  • version
  • total
  • issued
  • name
  • description
  • renderer (the url)

This is specific to m-nft-class data, which will require a cell lookup from the m-nft cell type script to obtain. I have not done this type of work before, so I will start with the parser and look for guidance on the MR for indexer calls required to perform this lookup.

requaos avatar Aug 31 '21 01:08 requaos

the m-nft-class "type script" code_hash on mainnet is known, at this time correlates to the value 0xd51e6eaf48124c601f41abe173f1da550b4cbca9c6a166781906a287abbb3d9a. The args for the m-nft-class cell are the args from the "type script" of the m-nft cell, less the trailing 4 bytes

EX: Given m-nft type script:

{
    "code_hash": 0x2b24f0d644ccbdd77bbf86b27c8cca02efa0ad051e447c212636d9ee7acaaec9 (m-nft)
    "args": 0x33875441627b9cfc1096e7b86eba271af3a2a85c0000000100000002
    "hash_type": type
}

Corresponding m-nft-class type script:

{
    "code_hash": 0xd51e6eaf48124c601f41abe173f1da550b4cbca9c6a166781906a287abbb3d9a (m-nft_class)
    "args": 0x33875441627b9cfc1096e7b86eba271af3a2a85c00000001
    "hash_type": type
}

Specification of the data section for an m-nft-class follows a mix of static and self-described sections, similar to but less complicated than asn1: Reference from ckb-explorer ruby-on-rail backend

requaos avatar Aug 31 '21 02:08 requaos

I don't know how to lookup another cell data for reference. In the transaction list its a list of item, and for items that are m-NFT or CustomizedType.NFT the formatter works directly on the args of that cells type script. On the wallet side, how to add this lookup of CustomizedType.NFTClass when a CustomizedType.NFT is encountered? What is the storage schema? Can we perform the lookup more than once, because the cell data changes each time an mNFT is issued and we don't want to store stale data.

requaos avatar Aug 31 '21 04:08 requaos

I don't know how to lookup another cell data for reference. In the transaction list its a list of item, and for items that are m-NFT or CustomizedType.NFT the formatter works directly on the args of that cells type script. On the wallet side, how to add this lookup of CustomizedType.NFTClass when a CustomizedType.NFT is encountered? What is the storage schema? Can we perform the lookup more than once, because the cell data changes each time an mNFT is issued and we don't want to store stale data.

If you know the type script args of a certain NFT Cell, the part that slice the IssuerID and classID is the type script args of that NFT class cell. Then you can use LiveCellService.getLiveCellsByScript to find the corresponding NFT Class cell.

// NFT Cell
...
Type:
	code_hash: NFT_TYPE
	args: **IssuerID** | **class_id** | TokenID**
Lock:
	--

// NFT Class Cell
...
Type:
	code_hash: NFT_CLASS_TYPE
	args: **IssuerID** | **class_id**
Lock:
	--

yuche avatar Sep 01 '21 03:09 yuche