Use key if possible
In the nft module, for the Metadata object we used the keys structures which increase the readability of the code in the interaction with store (save/delete)
https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/types/keys.go#L28-L34
Similarly, we could create keys structures also for the other objects.
For example (not only): for the NFTByID https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L69
or NFTByOwner https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L75
This could be useful also because, we increase the reusability of the code and, as a consequence the coherence. It could need a refactor among different files. What do you think?
Another example is the one in the nft/keeper/collection.go file.
Here the methods GetCollectionById and the SetCollection could make use of the key.
More specifically, we could make uniform the usage in lines 36 and 39 in SetCollection
https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/collection.go#L35-L40
And similarly in line 26 for GetCollectionById
https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/collection.go#L24-L33
Agree with that! This will reduce potential unexpected bug caused by one more developer
The same could also be used in nft.go file at lines:
-
14 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L14
-
33 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L33
-
51 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L51
-
69 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L69
-
75 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L75
-
81 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L81
-
87 https://github.com/bitsongofficial/go-bitsong/blob/84691c819214a1f9b9dd844ea2b49b7ccc8ece1b/x/nft/keeper/nft.go#L87
Okay, will make the suggested changes
This is done on this commit. https://github.com/bitsongofficial/go-bitsong/pull/153/commits/afcba32b4f1dfc1a6db7140b01d17eec347daf99