Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rollapp): add tags to rollapp metadata #1572

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions proto/dymensionxyz/dymension/rollapp/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ message RollappMetadata {
string explorer_url = 9;
// fee_denom is the base denom for fees
DenomMetadata fee_denom = 10;
// Tags is a list of tags that can be used to filter rollapps.
repeated string tags = 11;
}

message DenomMetadata {
Expand Down
11 changes: 11 additions & 0 deletions proto/dymensionxyz/dymension/rollapp/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ service Query {

// Validates provided genesis bridge data against the hub.
rpc ValidateGenesisBridge(QueryValidateGenesisBridgeRequest) returns (QueryValidateGenesisBridgeResponse);

// Queries the list of possible rollapp tags
rpc Tags(QueryTagsRequest) returns (QueryTagsResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/rollapp/tags";
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
Expand Down Expand Up @@ -161,3 +166,9 @@ message QueryValidateGenesisBridgeResponse {
bool valid = 1;
string err = 2;
}

message QueryTagsRequest {}

message QueryTagsResponse {
repeated string tags = 1;
}
1 change: 1 addition & 0 deletions x/rollapp/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
cmd.AddCommand(CmdShowLatestHeight())
cmd.AddCommand(CmdShowLatestStateIndex())
cmd.AddCommand(CmdQueryRegisteredDenoms())
cmd.AddCommand(CmdQueryTags())

Check warning on line 30 in x/rollapp/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/rollapp/client/cli/query.go#L30

Added line #L30 was not covered by tests

return cmd
}
35 changes: 35 additions & 0 deletions x/rollapp/client/cli/query_tags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

"github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)

func CmdQueryTags() *cobra.Command {
cmd := &cobra.Command{
Use: "tags",
Short: "shows the tags for rollapps",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Tags(cmd.Context(), &types.QueryTagsRequest{})
if err != nil {
return err
}

Check warning on line 26 in x/rollapp/client/cli/query_tags.go

View check run for this annotation

Codecov / codecov/patch

x/rollapp/client/cli/query_tags.go#L11-L26

Added lines #L11 - L26 were not covered by tests

return clientCtx.PrintProto(res)

Check warning on line 28 in x/rollapp/client/cli/query_tags.go

View check run for this annotation

Codecov / codecov/patch

x/rollapp/client/cli/query_tags.go#L28

Added line #L28 was not covered by tests
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd

Check warning on line 34 in x/rollapp/client/cli/query_tags.go

View check run for this annotation

Codecov / codecov/patch

x/rollapp/client/cli/query_tags.go#L32-L34

Added lines #L32 - L34 were not covered by tests
}
10 changes: 10 additions & 0 deletions x/rollapp/keeper/grpc_query_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,13 @@

return resp, nil
}

func (k Keeper) Tags(context.Context, *types.QueryTagsRequest) (*types.QueryTagsResponse, error) {
zale144 marked this conversation as resolved.
Show resolved Hide resolved
tags := make([]string, 0, len(types.RollappTags))
for tag := range types.RollappTags {
tags = append(tags, tag)
}
Fixed Show fixed Hide fixed
return &types.QueryTagsResponse{
Tags: tags,
}, nil

Check warning on line 106 in x/rollapp/keeper/grpc_query_rollapp.go

View check run for this annotation

Codecov / codecov/patch

x/rollapp/keeper/grpc_query_rollapp.go#L99-L106

Added lines #L99 - L106 were not covered by tests
}
1 change: 1 addition & 0 deletions x/rollapp/keeper/msg_server_create_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ var mockRollappMetadata = types.RollappMetadata{
LogoUrl: "https://dymension.xyz/logo.png",
Telegram: "https://t.me/rolly",
X: "https://x.dymension.xyz",
Tags: []string{"AI", "DeFI", "NFT"},
}

var mockGenesisInfo = &types.GenesisInfo{
Expand Down
3 changes: 3 additions & 0 deletions x/rollapp/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var (
ErrInvalidBlockDescriptorTimestamp = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid block descriptor timestamp")
ErrInvalidNativeDenom = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid native denom")
ErrInvalidFeeDenom = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid fee denom")
ErrInvalidTag = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid tag")
ErrTooManyTags = errorsmod.Wrap(gerrc.ErrInvalidArgument, "too many tags")
ErrDuplicateTag = errorsmod.Wrap(gerrc.ErrInvalidArgument, "duplicate tag")
ErrInvalidInitialSupply = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid initial supply")
ErrInvalidBech32Prefix = errorsmod.Wrap(gerrc.ErrInvalidArgument, "invalid bech32 prefix")
ErrRollappNotFound = errorsmod.Wrap(gerrc.ErrNotFound, "rollapp")
Expand Down
62 changes: 61 additions & 1 deletion x/rollapp/types/message_update_rollapp_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types

import (
fmt "fmt"
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -92,6 +92,66 @@ func TestMsgUpdateRollappInformation_ValidateBasic(t *testing.T) {
},
err: ErrInvalidURL,
},
{
name: "invalid metadata: too many tags",
msg: MsgUpdateRollappInformation{
Owner: sample.AccAddress(),
InitialSequencer: sample.AccAddress(),
RollappId: "dym_100-1",
GenesisInfo: &GenesisInfo{
Bech32Prefix: bech32Prefix,
GenesisChecksum: "checksum",
NativeDenom: DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18},
InitialSupply: sdk.NewInt(1000),
},
Metadata: &RollappMetadata{
Website: "https://dymension.xyz",
Description: "Sample description",
Tags: []string{"tag1", "tag2", "tag3", "tag4"},
},
},
err: ErrTooManyTags,
},
{
name: "invalid metadata: invalid tag",
msg: MsgUpdateRollappInformation{
Owner: sample.AccAddress(),
InitialSequencer: sample.AccAddress(),
RollappId: "dym_100-1",
GenesisInfo: &GenesisInfo{
Bech32Prefix: bech32Prefix,
GenesisChecksum: "checksum",
NativeDenom: DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18},
InitialSupply: sdk.NewInt(1000),
},
Metadata: &RollappMetadata{
Website: "https://dymension.xyz",
Description: "Sample description",
Tags: []string{"invalid"},
},
},
err: ErrInvalidTag,
},
{
name: "invalid metadata: duplicate tag",
msg: MsgUpdateRollappInformation{
Owner: sample.AccAddress(),
InitialSequencer: sample.AccAddress(),
RollappId: "dym_100-1",
GenesisInfo: &GenesisInfo{
Bech32Prefix: bech32Prefix,
GenesisChecksum: "checksum",
NativeDenom: DenomMetadata{Display: "DEN", Base: "aden", Exponent: 18},
InitialSupply: sdk.NewInt(1000),
},
Metadata: &RollappMetadata{
Website: "https://dymension.xyz",
Description: "Sample description",
Tags: []string{"AI", "DeFI", "AI"},
},
},
err: ErrDuplicateTag,
},
{
name: "invalid genesis checksum: too long",
msg: MsgUpdateRollappInformation{
Expand Down
106 changes: 81 additions & 25 deletions x/rollapp/types/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading