Skip to content

Commit 4f2e29f

Browse files
committed
Remove description in NFT and Collection
- Removed the 'description' field from the Collection and Nft messages in nft.proto. - Updated CreateCollection and MintNFT functions to eliminate the description parameter. - Adjusted validation functions to exclude description checks. - Modified test cases to reflect the removal of description from collection and NFT creation. - Updated the protobuf generated files to align with the new structure.
1 parent 42402ba commit 4f2e29f

File tree

8 files changed

+121
-160
lines changed

8 files changed

+121
-160
lines changed

proto/bitsong/nft/v1beta1/nft.proto

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ message Collection {
1212

1313
string symbol = 2;
1414
string name = 3;
15-
string description = 4;
1615
string uri = 5;
1716

1817
string creator = 6;
@@ -29,7 +28,6 @@ message Nft {
2928
string token_id = 2;
3029

3130
string name = 3;
32-
string description = 4;
3331
string uri = 5;
3432

3533
string owner = 6;

x/nft/keeper/collection.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func (k Keeper) CreateCollection(
1717
minter sdk.AccAddress,
1818
symbol,
1919
name,
20-
description,
2120
uri string,
2221
) (denom string, err error) {
2322
denom, err = k.validateCollectionDenom(ctx, creator, symbol)
@@ -27,18 +26,17 @@ func (k Keeper) CreateCollection(
2726

2827
// TODO: charge fee
2928

30-
if err := k.validateCollectionMetadata(name, description, uri); err != nil {
29+
if err := k.validateCollectionMetadata(name, uri); err != nil {
3130
return "", err
3231
}
3332

3433
coll := types.Collection{
35-
Denom: denom,
36-
Symbol: symbol,
37-
Name: name,
38-
Description: description,
39-
Uri: uri,
40-
Creator: creator.String(),
41-
Minter: minter.String(),
34+
Denom: denom,
35+
Symbol: symbol,
36+
Name: name,
37+
Uri: uri,
38+
Creator: creator.String(),
39+
Minter: minter.String(),
4240
}
4341

4442
if err := k.setCollection(ctx, coll); err != nil {
@@ -136,15 +134,11 @@ func (k Keeper) getCollection(ctx context.Context, denom string) (types.Collecti
136134
return coll, nil
137135
}
138136

139-
func (k Keeper) validateCollectionMetadata(name, description, uri string) error {
137+
func (k Keeper) validateCollectionMetadata(name, uri string) error {
140138
if len(name) > types.MaxNameLength {
141139
return fmt.Errorf("name cannot be longer than %d characters", types.MaxNameLength)
142140
}
143141

144-
if len(description) > types.MaxDescriptionLength {
145-
return fmt.Errorf("description cannot be longer than %d characters", types.MaxDescriptionLength)
146-
}
147-
148142
if len(uri) > types.MaxURILength {
149143
return fmt.Errorf("uri cannot be longer than %d characters", types.MaxURILength)
150144
}

x/nft/keeper/edition_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ func (suite *KeeperTestSuite) TestPrintEdition() {
77
minter1,
88
testCollection1.Symbol,
99
testCollection1.Name,
10-
testCollection1.Description,
1110
testCollection1.Uri,
1211
)
1312
suite.NoError(err)
@@ -19,7 +18,6 @@ func (suite *KeeperTestSuite) TestPrintEdition() {
1918
collectionDenom,
2019
testNft1.TokenId,
2120
testNft1.Name,
22-
testNft1.Description,
2321
testNft1.Uri,
2422
)
2523
suite.NoError(err)

x/nft/keeper/grpc_query_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ func (suite *KeeperTestSuite) TestQueryCollection() {
1111
minter1,
1212
testCollection1.Symbol,
1313
testCollection1.Name,
14-
testCollection1.Description,
1514
testCollection1.Uri,
1615
)
1716
suite.NoError(err)
@@ -22,7 +21,6 @@ func (suite *KeeperTestSuite) TestQueryCollection() {
2221
suite.NoError(err)
2322
suite.Equal(testCollection1.Name, res.Collection.Name)
2423
suite.Equal(testCollection1.Symbol, res.Collection.Symbol)
25-
suite.Equal(testCollection1.Description, res.Collection.Description)
2624
suite.Equal(testCollection1.Uri, res.Collection.Uri)
2725
suite.Equal(testCollection1.Minter, res.Collection.Minter)
2826
}
@@ -34,7 +32,6 @@ func (suite *KeeperTestSuite) TestQueryOwnerOf() {
3432
minter1,
3533
testCollection1.Symbol,
3634
testCollection1.Name,
37-
testCollection1.Description,
3835
testCollection1.Uri,
3936
)
4037
suite.NoError(err)
@@ -46,7 +43,6 @@ func (suite *KeeperTestSuite) TestQueryOwnerOf() {
4643
collectionDenom,
4744
testNft1.TokenId,
4845
testNft1.Name,
49-
testNft1.Description,
5046
testNft1.Uri,
5147
)
5248
suite.NoError(err)
@@ -66,7 +62,6 @@ func (suite *KeeperTestSuite) TestQueryNftInfo() {
6662
minter1,
6763
testCollection1.Symbol,
6864
testCollection1.Name,
69-
testCollection1.Description,
7065
testCollection1.Uri,
7166
)
7267
suite.NoError(err)
@@ -78,7 +73,6 @@ func (suite *KeeperTestSuite) TestQueryNftInfo() {
7873
collectionDenom,
7974
testNft1.TokenId,
8075
testNft1.Name,
81-
testNft1.Description,
8276
testNft1.Uri,
8377
)
8478
suite.NoError(err)
@@ -90,7 +84,6 @@ func (suite *KeeperTestSuite) TestQueryNftInfo() {
9084
suite.NoError(err)
9185
suite.Equal(testNft1.TokenId, res.Nft.TokenId)
9286
suite.Equal(testNft1.Name, res.Nft.Name)
93-
suite.Equal(testNft1.Description, res.Nft.Description)
9487
suite.Equal(testNft1.Uri, res.Nft.Uri)
9588
suite.Equal(collectionDenom, res.Nft.Collection)
9689
suite.Equal(owner1.String(), res.Nft.Owner)
@@ -103,7 +96,6 @@ func (suite *KeeperTestSuite) TestQueryNftsOfOwner() {
10396
minter1,
10497
testCollection1.Symbol,
10598
testCollection1.Name,
106-
testCollection1.Description,
10799
testCollection1.Uri,
108100
)
109101
suite.NoError(err)
@@ -115,7 +107,6 @@ func (suite *KeeperTestSuite) TestQueryNftsOfOwner() {
115107
collectionDenom,
116108
testNft1.TokenId,
117109
testNft1.Name,
118-
testNft1.Description,
119110
testNft1.Uri,
120111
)
121112
suite.NoError(err)
@@ -127,7 +118,6 @@ func (suite *KeeperTestSuite) TestQueryNftsOfOwner() {
127118
collectionDenom,
128119
testNft2.TokenId,
129120
testNft2.Name,
130-
testNft2.Description,
131121
testNft2.Uri,
132122
)
133123
suite.NoError(err)
@@ -148,7 +138,6 @@ func (suite *KeeperTestSuite) TestQueryNftsByOwner() {
148138
minter1,
149139
testCollection1.Symbol,
150140
testCollection1.Name,
151-
testCollection1.Description,
152141
testCollection1.Uri,
153142
)
154143
suite.NoError(err)
@@ -160,7 +149,6 @@ func (suite *KeeperTestSuite) TestQueryNftsByOwner() {
160149
collectionDenom,
161150
testNft1.TokenId,
162151
testNft1.Name,
163-
testNft1.Description,
164152
testNft1.Uri,
165153
)
166154
suite.NoError(err)
@@ -172,7 +160,6 @@ func (suite *KeeperTestSuite) TestQueryNftsByOwner() {
172160
collectionDenom,
173161
testNft2.TokenId,
174162
testNft2.Name,
175-
testNft2.Description,
176163
testNft2.Uri,
177164
)
178165
suite.NoError(err)
@@ -200,7 +187,6 @@ func (suite *KeeperTestSuite) TestQueryNftsByOwner() {
200187
collectionDenom,
201188
testNft3.TokenId,
202189
testNft3.Name,
203-
testNft3.Description,
204190
testNft3.Uri,
205191
)
206192
suite.NoError(err)

x/nft/keeper/keeper_test.go

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,29 @@ var (
2525
owner2 = sdk.AccAddress(tmhash.SumTruncated([]byte("owner2")))
2626

2727
testCollection1 = types.Collection{
28-
Name: "My NFT Collection",
29-
Symbol: "MYNFT",
30-
Description: "My NFT Collection Description",
31-
Uri: "ipfs://my-nft-collection-metadata.json",
32-
Minter: minter1.String(),
28+
Name: "My NFT Collection",
29+
Symbol: "MYNFT",
30+
Uri: "ipfs://my-nft-collection-metadata.json",
31+
Minter: minter1.String(),
3332
}
3433
expectedDenom1 = "nft9436DDD23FB751AEA7BC6C767F20F943DD735E06"
3534

3635
testNft1 = types.Nft{
37-
TokenId: "1",
38-
Name: "My First NFT",
39-
Description: "This is my first NFT",
40-
Uri: "ipfs://my-first-nft-metadata.json",
36+
TokenId: "1",
37+
Name: "My First NFT",
38+
Uri: "ipfs://my-first-nft-metadata.json",
4139
}
4240

4341
testNft2 = types.Nft{
44-
TokenId: "2",
45-
Name: "My Second NFT",
46-
Description: "This is my second NFT",
47-
Uri: "ipfs://my-second-nft-metadata.json",
42+
TokenId: "2",
43+
Name: "My Second NFT",
44+
Uri: "ipfs://my-second-nft-metadata.json",
4845
}
4946

5047
testNft3 = types.Nft{
51-
TokenId: "3",
52-
Name: "My Third NFT",
53-
Description: "This is my third NFT",
54-
Uri: "ipfs://my-third-nft-metadata.json",
48+
TokenId: "3",
49+
Name: "My Third NFT",
50+
Uri: "ipfs://my-third-nft-metadata.json",
5551
}
5652
)
5753

@@ -83,7 +79,6 @@ func (suite *KeeperTestSuite) TestCreateCollection() {
8379
minter1,
8480
testCollection1.Symbol,
8581
testCollection1.Name,
86-
testCollection1.Description,
8782
testCollection1.Uri,
8883
)
8984
suite.NoError(err)
@@ -95,7 +90,6 @@ func (suite *KeeperTestSuite) TestCreateCollection() {
9590
minter1,
9691
testCollection1.Symbol,
9792
testCollection1.Name,
98-
testCollection1.Description,
9993
testCollection1.Uri,
10094
)
10195
suite.Error(err)
@@ -108,7 +102,6 @@ func (suite *KeeperTestSuite) TestMintNFT() {
108102
minter1,
109103
testCollection1.Symbol,
110104
testCollection1.Name,
111-
testCollection1.Description,
112105
testCollection1.Uri,
113106
)
114107
suite.NoError(err)
@@ -124,7 +117,6 @@ func (suite *KeeperTestSuite) TestMintNFT() {
124117
collectionDenom,
125118
testNft1.TokenId,
126119
testNft1.Name,
127-
testNft1.Description,
128120
testNft1.Uri,
129121
)
130122
suite.NoError(err)
@@ -139,7 +131,6 @@ func (suite *KeeperTestSuite) TestMintNFT() {
139131
collectionDenom,
140132
testNft2.TokenId,
141133
testNft2.Name,
142-
testNft2.Description,
143134
testNft2.Uri,
144135
)
145136
suite.NoError(err)
@@ -155,7 +146,6 @@ func (suite *KeeperTestSuite) TestSendNFT() {
155146
minter1,
156147
testCollection1.Symbol,
157148
testCollection1.Name,
158-
testCollection1.Description,
159149
testCollection1.Uri,
160150
)
161151
suite.NoError(err)
@@ -167,7 +157,6 @@ func (suite *KeeperTestSuite) TestSendNFT() {
167157
collectionDenom,
168158
testNft1.TokenId,
169159
testNft1.Name,
170-
testNft1.Description,
171160
testNft1.Uri,
172161
)
173162
suite.NoError(err)

x/nft/keeper/nft.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ func (k Keeper) MintNFT(
1818
collectionDenom,
1919
tokenId,
2020
name,
21-
description,
2221
uri string,
2322
) error {
24-
if err := k.validateNftMetadata(tokenId, name, description, uri); err != nil {
23+
if err := k.validateNftMetadata(tokenId, name, uri); err != nil {
2524
return err
2625
}
2726

@@ -55,13 +54,12 @@ func (k Keeper) MintNFT(
5554
// TODO: Charge fee if necessary
5655

5756
nft := types.Nft{
58-
Collection: collectionDenom,
59-
TokenId: tokenId,
60-
Name: name,
61-
Description: description,
62-
Uri: uri,
63-
Owner: owner.String(),
64-
Editions: 0,
57+
Collection: collectionDenom,
58+
TokenId: tokenId,
59+
Name: name,
60+
Uri: uri,
61+
Owner: owner.String(),
62+
Editions: 0,
6563
}
6664

6765
if err := k.setNft(ctx, nft); err != nil {
@@ -129,7 +127,7 @@ func (k Keeper) GetNft(ctx context.Context, collectionDenom, tokenId string) (*t
129127
return &nft, nil
130128
}
131129

132-
func (k Keeper) validateNftMetadata(tokenId, name, description, uri string) error {
130+
func (k Keeper) validateNftMetadata(tokenId, name, uri string) error {
133131
if strings.TrimSpace(tokenId) == "" {
134132
return fmt.Errorf("token ID cannot be empty")
135133
}
@@ -142,9 +140,6 @@ func (k Keeper) validateNftMetadata(tokenId, name, description, uri string) erro
142140
return fmt.Errorf("name length exceeds maximum of %d", types.MaxNameLength)
143141

144142
}
145-
if len(description) > types.MaxDescriptionLength {
146-
return fmt.Errorf("description length exceeds maximum of %d", types.MaxDescriptionLength)
147-
}
148143

149144
if len(uri) > types.MaxURILength {
150145
return fmt.Errorf("URI length exceeds maximum of %d", types.MaxURILength)

x/nft/types/keys.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ const (
1616

1717
MaxDenomLength = 43
1818

19-
MaxTokenIdLength = 20
20-
MaxSymbolLength = 15
21-
MaxNameLength = 128
22-
MaxDescriptionLength = 256
23-
MaxURILength = 150
19+
MaxTokenIdLength = 20
20+
MaxSymbolLength = 15
21+
MaxNameLength = 128
22+
MaxURILength = 150
2423
)
2524

2625
var (

0 commit comments

Comments
 (0)