From 60a187bb7144ca4599fc9bea60207f7cf53c970f Mon Sep 17 00:00:00 2001 From: zale144 Date: Thu, 28 Nov 2024 22:07:47 +0100 Subject: [PATCH] change rollapp tags map to list --- x/rollapp/keeper/grpc_query_rollapp.go | 6 +----- x/rollapp/types/rollapp.go | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/x/rollapp/keeper/grpc_query_rollapp.go b/x/rollapp/keeper/grpc_query_rollapp.go index 0830813fe..c97604a34 100644 --- a/x/rollapp/keeper/grpc_query_rollapp.go +++ b/x/rollapp/keeper/grpc_query_rollapp.go @@ -99,11 +99,7 @@ func getSummaryResponse(ctx sdk.Context, k Keeper, rollapp types.Rollapp, ok, wi // Tags returns all the tags available for rollapps. // The order is non-deterministic. func (k Keeper) Tags(context.Context, *types.QueryTagsRequest) (*types.QueryTagsResponse, error) { - tags := make([]string, 0, len(types.RollappTags)) - for tag := range types.RollappTags { - tags = append(tags, tag) - } return &types.QueryTagsResponse{ - Tags: tags, + Tags: types.RollappTags, }, nil } diff --git a/x/rollapp/types/rollapp.go b/x/rollapp/types/rollapp.go index 6556ebf18..0749e92a6 100644 --- a/x/rollapp/types/rollapp.go +++ b/x/rollapp/types/rollapp.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net/url" + "slices" "strings" errorsmod "cosmossdk.io/errors" @@ -23,17 +24,17 @@ const ( ) // RollappTags are hardcoded for now TODO: manage them through the store -var RollappTags = map[string]struct{}{ - "Meme": {}, - "AI": {}, - "DeFI": {}, - "NFT": {}, - "Gaming": {}, - "Betting": {}, - "Community": {}, - "Social": {}, - "DePIN": {}, - "Launchpad": {}, +var RollappTags = []string{ + "Meme", + "AI", + "DeFI", + "NFT", + "Gaming", + "Betting", + "Community", + "Social", + "DePIN", + "Launchpad", } type AllowedDecimals uint32 @@ -253,7 +254,7 @@ func (md *RollappMetadata) Validate() error { seen := make(map[string]struct{}) for _, tag := range md.Tags { - if _, ok := RollappTags[tag]; !ok { + if !slices.Contains(RollappTags, tag) { return ErrInvalidTag } if _, ok := seen[tag]; ok {