Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFT types suggestions #210

Open
giorgionocera opened this issue Oct 2, 2022 · 4 comments
Open

NFT types suggestions #210

giorgionocera opened this issue Oct 2, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request NFT question Further information is requested

Comments

@giorgionocera
Copy link
Contributor

In the nft module, there is the nft/types/nft.go file, which contains utilities for the nft type.

I have some questions/suggestions for these:

  1. As for point 5 in NFT structure #159, why do we use CollectionID, MetadataID, and SequenceNumber for each NFT as the id? Is there a motivation?
  2. The two functions IsValidNftId and NftIdToBytes could be merged in a single function with error if the nftID is not valid, since they share a very important part of logic.

func IsValidNftId(id string) bool {
splits := strings.Split(id, ":")
if len(splits) != 3 {
return false
}
collId, err := strconv.Atoi(splits[0])
if err != nil || collId < 0 {
return false
}
metadataId, err := strconv.Atoi(splits[1])
if err != nil || metadataId < 0 {
return false
}
seq, err := strconv.Atoi(splits[2])
if err != nil || seq < 0 {
return false
}
return true
}
func NftIdToBytes(id string) []byte {
splits := strings.Split(id, ":")
if !IsValidNftId(id) {
panic(fmt.Sprintf("invalid nft id: %s", id))
}
collId, _ := strconv.Atoi(splits[0])
metadataId, _ := strconv.Atoi(splits[1])
seq, _ := strconv.Atoi(splits[2])
return (NFT{
CollId: uint64(collId),
MetadataId: uint64(metadataId),
Seq: uint64(seq),
}).IdBytes()
}

@ryusmo
Copy link
Contributor

ryusmo commented Oct 3, 2022

For 1st one, this was what @angelorc suggested.
For 2nd one, I will make changes to use same codebase.

@ryusmo
Copy link
Contributor

ryusmo commented Oct 3, 2022

For 2nd one, it's done on this commit.
6afb22c

@giorgionocera
Copy link
Contributor Author

Yeah, for me, 2nd point is ok after commit 6afb22c.

@giorgionocera
Copy link
Contributor Author

With respect to the first point

As for point 5 in #159, why do we use CollectionID, MetadataID, and SequenceNumber for each NFT as the id? Is there a motivation?

I talked with @angelorc and he said that such a suggestion was valid at the beginning. But giving a look to the other implementation, it could be better to use a global ID for metadata and a sort of "address" (a hash) for the collection.

@giorgionocera giorgionocera added enhancement New feature or request question Further information is requested NFT and removed ready-for-review labels Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request NFT question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants