From e7acb0e5753d188f0d43f47d17caf387c3c828d5 Mon Sep 17 00:00:00 2001 From: Milad Zahedi Date: Mon, 16 Oct 2023 18:07:32 +0330 Subject: [PATCH] addressed PR comments --- x/asset/nft/client/cli/query_test.go | 1 - x/asset/nft/keeper/grpc_query.go | 4 ++-- x/asset/nft/keeper/keeper.go | 4 ++-- x/asset/nft/keeper/keeper_test.go | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/x/asset/nft/client/cli/query_test.go b/x/asset/nft/client/cli/query_test.go index 5366ad64d..98ae96039 100644 --- a/x/asset/nft/client/cli/query_test.go +++ b/x/asset/nft/client/cli/query_test.go @@ -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, diff --git a/x/asset/nft/keeper/grpc_query.go b/x/asset/nft/keeper/grpc_query.go index 95ca378ce..55195e0fb 100644 --- a/x/asset/nft/keeper/grpc_query.go +++ b/x/asset/nft/keeper/grpc_query.go @@ -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) } @@ -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, diff --git a/x/asset/nft/keeper/keeper.go b/x/asset/nft/keeper/keeper.go index 548e65c4c..bad3891b7 100644 --- a/x/asset/nft/keeper/keeper.go +++ b/x/asset/nft/keeper/keeper.go @@ -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) diff --git a/x/asset/nft/keeper/keeper_test.go b/x/asset/nft/keeper/keeper_test.go index a745b4ec4..d597bb25a 100644 --- a/x/asset/nft/keeper/keeper_test.go +++ b/x/asset/nft/keeper/keeper_test.go @@ -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{ @@ -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...)