Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

NFT Module - Use Store Indexes #6

Closed
rigelrozanski opened this issue Aug 26, 2019 · 1 comment
Closed

NFT Module - Use Store Indexes #6

rigelrozanski opened this issue Aug 26, 2019 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed x/nft

Comments

@rigelrozanski
Copy link

Stemming from


Eliminate structs IDCollection, Collection and replace their functionality with index lookups

The NFT design should be restructured to eliminate the:

  • Owner struct
  • IDCollection struct

We should instead by applying the use of secondary indexes similarly to how the staking module stores references to the same validators by: operator-address, consensus-address, power, etc. (see example https://github.com/cosmos/cosmos-sdk/blob/master/x/staking/keeper/validator.go#L70)
(see spec: https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/staking/01_state.md#validator)

This way we should be able to easily create functions on the NFTKeeper to get the NFTs efficiently without requiring these extra object. For example I'd suggest the keeper look like:

type NFTKeeper interface {
    GetNFTByID(string) NFT
    GetCollectionByDenom(string) []*NFT
    GetCollectionsByOwner(sdk.AccAddress) []Collection
}

Or something along those lines.


Additionally this means that all this Collection back-updating logic can be removed (see cosmos/cosmos-sdk#4209 (comment))

@rigelrozanski
Copy link
Author

rigelrozanski commented Aug 26, 2019

CC @fedekunze @alexanderbez @okwme

@tac0turtle tac0turtle transferred this issue from cosmos/cosmos-sdk Oct 9, 2019
@tac0turtle tac0turtle added enhancement New feature or request help wanted Extra attention is needed x/nft labels Oct 9, 2019
@fedekunze fedekunze mentioned this issue Oct 9, 2019
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed x/nft
Projects
None yet
Development

No branches or pull requests

2 participants