Skip to content

Commit

Permalink
addressed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
miladz68 committed Oct 16, 2023
1 parent b691a72 commit e7acb0e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion x/asset/nft/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func mint(
requireT.NoError(err)
}

//nolint:unparam // we don't want to use constants for helpers
func issueClass(
requireT *require.Assertions,
ctx client.Context,
Expand Down
4 changes: 2 additions & 2 deletions x/asset/nft/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type QueryKeeper interface {
IsFrozen(ctx sdk.Context, classID, nftID string) (bool, error)
IsWhitelisted(ctx sdk.Context, classID, nftID string, account sdk.AccAddress) (bool, error)
GetWhitelistedAccountsForNFT(ctx sdk.Context, classID, nftID string, q *query.PageRequest) ([]string, *query.PageResponse, error)
GetWhitelistedAccountsForClass(ctx sdk.Context, classID string, q *query.PageRequest) ([]string, *query.PageResponse, error)
GetClassWhitelistedAccounts(ctx sdk.Context, classID string, q *query.PageRequest) ([]string, *query.PageResponse, error)
GetBurntByClass(ctx sdk.Context, classID string, q *query.PageRequest) (*query.PageResponse, []string, error)
IsBurnt(ctx sdk.Context, classID, nftID string) (bool, error)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (qs QueryService) WhitelistedAccountsForNFT(ctx context.Context, req *types

// ClassWhitelistedAccounts returns the list of accounts which are whitelited to hold this NFTs in this class.
func (qs QueryService) ClassWhitelistedAccounts(ctx context.Context, req *types.QueryClassWhitelistedAccountsRequest) (*types.QueryClassWhitelistedAccountsResponse, error) {
accounts, pageRes, err := qs.keeper.GetWhitelistedAccountsForClass(sdk.UnwrapSDKContext(ctx), req.ClassId, req.Pagination)
accounts, pageRes, err := qs.keeper.GetClassWhitelistedAccounts(sdk.UnwrapSDKContext(ctx), req.ClassId, req.Pagination)
return &types.QueryClassWhitelistedAccountsResponse{
Pagination: pageRes,
Accounts: accounts,
Expand Down
4 changes: 2 additions & 2 deletions x/asset/nft/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,8 @@ func (k Keeper) GetAllClassWhitelistedAccounts(ctx sdk.Context, q *query.PageReq
return whitelisted, pageRes, nil
}

// GetWhitelistedAccountsForClass returns all whitelisted accounts for the class.
func (k Keeper) GetWhitelistedAccountsForClass(ctx sdk.Context, classID string, q *query.PageRequest) ([]string, *query.PageResponse, error) {
// GetClassWhitelistedAccounts returns all whitelisted accounts for the class.
func (k Keeper) GetClassWhitelistedAccounts(ctx sdk.Context, classID string, q *query.PageRequest) ([]string, *query.PageResponse, error) {
compositeKey, err := store.JoinKeysWithLength([]byte(classID))
if err != nil {
return nil, nil, sdkerrors.Wrapf(types.ErrInvalidKey, "failed to create a composite key for nft, err: %s", err)
Expand Down
6 changes: 3 additions & 3 deletions x/asset/nft/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ func TestKeeper_ClassWhitelist(t *testing.T) {
requireT.NoError(err)
requireT.True(isWhitelisted)

whitelistedNftAccounts, _, err := assetNFTKeeper.GetWhitelistedAccountsForClass(ctx, classID, &query.PageRequest{Limit: query.MaxLimit})
whitelistedNftAccounts, _, err := assetNFTKeeper.GetClassWhitelistedAccounts(ctx, classID, &query.PageRequest{Limit: query.MaxLimit})
requireT.NoError(err)
requireT.Len(whitelistedNftAccounts, 2)
requireT.ElementsMatch(whitelistedNftAccounts, []string{
Expand All @@ -942,12 +942,12 @@ func TestKeeper_ClassWhitelist(t *testing.T) {
})

incrementallyQueriedAccounts := []string{}
whitelistedNftAccounts, pageRes, err := assetNFTKeeper.GetWhitelistedAccountsForClass(ctx, classID, &query.PageRequest{Limit: 1})
whitelistedNftAccounts, pageRes, err := assetNFTKeeper.GetClassWhitelistedAccounts(ctx, classID, &query.PageRequest{Limit: 1})
requireT.NoError(err)
requireT.Len(whitelistedNftAccounts, 1)
incrementallyQueriedAccounts = append(incrementallyQueriedAccounts, whitelistedNftAccounts...)

whitelistedNftAccounts, pageRes, err = assetNFTKeeper.GetWhitelistedAccountsForClass(ctx, classID, &query.PageRequest{Key: pageRes.GetNextKey()})
whitelistedNftAccounts, pageRes, err = assetNFTKeeper.GetClassWhitelistedAccounts(ctx, classID, &query.PageRequest{Key: pageRes.GetNextKey()})
requireT.NoError(err)
requireT.Len(whitelistedNftAccounts, 1)
incrementallyQueriedAccounts = append(incrementallyQueriedAccounts, whitelistedNftAccounts...)
Expand Down

0 comments on commit e7acb0e

Please sign in to comment.