Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamer committed Sep 6, 2022
1 parent a81d132 commit 32a6382
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
14 changes: 0 additions & 14 deletions modules/nft/keeper/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ func (k Keeper) SaveCollection(ctx sdk.Context, collection types.Collection) err
return nil
}

// GetCollection returns the collection by the specified denom ID
func (k Keeper) GetCollection(ctx sdk.Context, denomID string) (types.Collection, error) {
denom, err := k.GetDenomInfo(ctx, denomID)
if err != nil {
return types.Collection{}, err
}

nfts, err := k.GetNFTs(ctx, denomID)
if err != nil {
return types.Collection{}, err
}
return types.NewCollection(*denom, nfts), nil
}

// GetCollections returns all the collections
func (k Keeper) GetCollections(ctx sdk.Context) (cs []types.Collection, err error) {
for _, class := range k.nk.GetClasses(ctx) {
Expand Down
18 changes: 0 additions & 18 deletions modules/nft/keeper/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@ func (suite *KeeperSuite) TestSetCollection() {
err := suite.keeper.SaveCollection(suite.ctx, collection2)
suite.Nil(err)

collection2, err = suite.keeper.GetCollection(suite.ctx, denomID)
suite.NoError(err)
suite.Len(collection2.NFTs, 2)

msg, fail := keeper.SupplyInvariant(suite.keeper)(suite.ctx)
suite.False(fail, msg)
}

func (suite *KeeperSuite) TestGetCollection() {
// SaveNFT shouldn't fail when collection does not exist
err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address)
suite.NoError(err)

// collection should exist
collection, err := suite.keeper.GetCollection(suite.ctx, denomID)
suite.NoError(err)
suite.NotEmpty(collection)

msg, fail := keeper.SupplyInvariant(suite.keeper)(suite.ctx)
suite.False(fail, msg)
}
Expand Down

0 comments on commit 32a6382

Please sign in to comment.