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

Make profiles query user parameter optional #539

Merged
merged 26 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8b91356
Set query user params optional
dadamu Jul 6, 2021
09a241d
Update CHANGELOG
dadamu Jul 6, 2021
4a605e5
Merge branch 'master' of github.com:desmos-labs/desmos into paul/quer…
dadamu Jul 6, 2021
1f247a5
Merge branch 'master' of github.com:desmos-labs/desmos into paul/quer…
dadamu Jul 7, 2021
4cda1e7
Add unit test
dadamu Jul 8, 2021
80dabfe
Remov user field of relationship
dadamu Jul 8, 2021
7f6006d
Remove DTag user address checking
dadamu Jul 8, 2021
b0c76a5
Merge branch 'master' of github.com:desmos-labs/desmos into paul/quer…
dadamu Jul 8, 2021
0b930e6
Remove User prefix of the rpc methods
dadamu Jul 23, 2021
9d56220
Update the comments
dadamu Jul 23, 2021
151dabf
Remove User prefix in the query cmds
dadamu Jul 23, 2021
163289e
Update comments
dadamu Jul 23, 2021
20ee315
Fix comments of grpc queries
dadamu Jul 23, 2021
dd3c001
Update docs
dadamu Jul 23, 2021
6aa0e23
Fix docs typo
dadamu Jul 23, 2021
a51e64b
Update proto/desmos/profiles/v1beta1/query.proto
dadamu Jul 27, 2021
cfe0b5f
Update proto/desmos/profiles/v1beta1/query.proto
dadamu Jul 27, 2021
d7b4bdb
Update proto/desmos/profiles/v1beta1/query.proto
dadamu Jul 27, 2021
f7ac18f
Update proto/desmos/profiles/v1beta1/query.proto
dadamu Jul 27, 2021
f51f252
Update x/profiles/client/cli/cli_app_links.go
dadamu Jul 27, 2021
d690329
Update x/profiles/client/cli/cli_chain_links.go
dadamu Jul 27, 2021
9f62c6c
Generate proto
dadamu Jul 27, 2021
906a9d0
Merge branch 'master' of github.com:desmos-labs/desmos into paul/quer…
dadamu Jul 27, 2021
2b4a15b
Add changeset entry
dadamu Jul 27, 2021
039aa16
Merge branch 'master' into paul/query-params-optional
RiccardoM Jul 27, 2021
36f58f0
Merge branch 'master' into paul/query-params-optional
RiccardoM Jul 27, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Improved pagination ([#544](https://github.com/desmos-labs/desmos/pull/544))
- Renamed `PollData` and `PollAnswer` to `Poll` and `ProvidedAnswer` ([#536]((https://github.com/desmos-labs/desmos/issues/536)))
- Enabled snapshot by default ([#529](https://github.com/desmos-labs/desmos/pull/529))
- Made profiles query user parameter optional ([#539](https://github.com/desmos-labs/desmos/pull/539))

# Version 0.17.0
## Changes
Expand Down
5 changes: 3 additions & 2 deletions docs/developers/queries/profiles/user-blocks.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Query user blocked users
This query allows you to retrieve the user blocked by the user with the given `address`.
This query allows you to retrieve the user blocked list with the optional user `address`.

**CLI**
```bash
desmos query profiles blocks [address] [[subspace]]
desmos query profiles blocks [[address]] [[subspace]]

# Example
# desmos query profiles blocks
# desmos query profiles blocks desmos13p5pamrljhza3fp4es5m3llgmnde5fzcpq6nud
```
5 changes: 3 additions & 2 deletions docs/developers/queries/profiles/user-dtag-requests.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Query user's DTag requests
This query allows you to retrieve the DTag requests of the user with the given `address`.
This query allows you to retrieve the DTag requests with the optional user `address`.

**CLI**
```bash
desmos query profiles incoming-dtag-transfer-requests [address]
desmos query profiles incoming-dtag-transfer-requests [[address]]

# Example
# desmos query profiles incoming-dtag-transfer-requests
# desmos query profiles incoming-dtag-transfer-requests desmos13p5pamrljhza3fp4es5m3llgmnde5fzcpq6nud
```
7 changes: 4 additions & 3 deletions docs/developers/queries/profiles/user-relationships.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Query user relationships
This query allows you to retrieve the details of a relationship where the creator has the given `address`.
This query allows you to retrieve the relationships with the optional creator `address`.

**CLI**
```bash
desmos query profiles relationships [address]
desmos query profiles relationships [[address]]

# Example
# desmos query relationships user desmos13p5pamrljhza3fp4es5m3llgmnde5fzcpq6nud
# desmos query relationships
# desmos query relationships desmos13p5pamrljhza3fp4es5m3llgmnde5fzcpq6nud
```
5 changes: 2 additions & 3 deletions proto/desmos/profiles/v1beta1/query_relationships.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ message QueryUserRelationshipsRequest {
// QueryUserRelationshipsResponse is the response type for the
// Query/UserRelationships RPC method.
message QueryUserRelationshipsResponse {
dadamu marked this conversation as resolved.
Show resolved Hide resolved
string user = 1;

// relationships represent the list of all the relationships for the queried
// user
dadamu marked this conversation as resolved.
Show resolved Hide resolved
repeated desmos.profiles.v1beta1.Relationship relationships = 2
repeated desmos.profiles.v1beta1.Relationship relationships = 1
[ (gogoproto.nullable) = false ];

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageResponse pagination = 3;
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// ___________________________________________________________________________________________________________________
Expand Down
13 changes: 9 additions & 4 deletions x/profiles/client/cli/cli_app_links.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,29 @@ func GetCmdUnlinkApplication() *cobra.Command {
// GetCmdQueryUserApplicationsLinks returns the command allowing to query the application links associated with a profile
func GetCmdQueryUserApplicationsLinks() *cobra.Command {
cmd := &cobra.Command{
Use: "app-links [user]",
Short: "Get all the application links associated to the given username with optional pagination",
Args: cobra.ExactArgs(1),
Use: "app-links [[user]]",
Short: "Get all the application links with optional user address and pagination",
Args: cobra.RangeArgs(0, 1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

var user string
if len(args) == 1 {
user = args[0]
}

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

res, err := queryClient.UserApplicationLinks(
context.Background(),
&types.QueryUserApplicationLinksRequest{User: args[0], Pagination: pageReq},
&types.QueryUserApplicationLinksRequest{User: user, Pagination: pageReq},
)
if err != nil {
return err
Expand Down
28 changes: 26 additions & 2 deletions x/profiles/client/cli/cli_app_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,31 @@ func (s *IntegrationTestSuite) TestCmdQueryUserApplicationsLinks() {
expectedOutput types.QueryUserApplicationLinksResponse
}{
{
name: "no links found",
name: "existing links are returned properly",
args: []string{
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
expectErr: false,
expectedOutput: types.QueryUserApplicationLinksResponse{
Links: []types.ApplicationLink{
types.NewApplicationLink(
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
types.NewData("reddit", "reddit-user"),
types.ApplicationLinkStateInitialized,
types.NewOracleRequest(
-1,
1,
types.NewOracleRequestCallData("twitter", "call_data"),
"client_id",
),
nil,
time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC),
),
},
},
},
{
name: "existing links of the given user address are not found",
args: []string{
"cosmos122u6u9gpdr2rp552fkkvlgyecjlmtqhkascl5a",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
Expand All @@ -34,7 +58,7 @@ func (s *IntegrationTestSuite) TestCmdQueryUserApplicationsLinks() {
},
},
{
name: "existing link is returned properly",
name: "existing links of the given user are returned properly",
args: []string{
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
Expand Down
13 changes: 9 additions & 4 deletions x/profiles/client/cli/cli_chain_links.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,29 @@ func GetCmdUnlinkChainAccount() *cobra.Command {
// GetCmdQueryUserChainLinks returns the command allowing to query all the chain links of a specific user
func GetCmdQueryUserChainLinks() *cobra.Command {
cmd := &cobra.Command{
Use: "chain-links [address]",
Short: "Retrieve all the user's chain links with optional pagination",
Args: cobra.ExactArgs(1),
Use: "chain-links [[address]]",
Short: "Retrieve all chain links with optional user address and pagination",
Args: cobra.RangeArgs(0, 1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

var user string
if len(args) == 1 {
user = args[0]
}

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

res, err := queryClient.UserChainLinks(
context.Background(),
&types.QueryUserChainLinksRequest{User: args[0], Pagination: pageReq},
&types.QueryUserChainLinksRequest{User: user, Pagination: pageReq},
)
if err != nil {
return err
Expand Down
39 changes: 38 additions & 1 deletion x/profiles/client/cli/cli_chain_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,43 @@ func (s *IntegrationTestSuite) TestCmdQueryUserChainLinks() {
expectErr bool
expectedOutput types.QueryUserChainLinksResponse
}{
{
name: "existing chain links are returned properly",
args: []string{
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
expectErr: false,
expectedOutput: types.QueryUserChainLinksResponse{
Links: []types.ChainLink{
types.NewChainLink(
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
types.NewBech32Address("cosmos1cjf97gpzwmaf30pzvaargfgr884mpp5ak8f7ns", "cosmos"),
types.NewProof(
pubKey,
"909e38994b1583d3f14384c2e9a03c90064e8fd8e19b780bb0ba303dfe671a27287da04d0ce096ce9a140bd070ee36818f5519eb2070a16971efd8143855524b",
"text",
),
types.NewChainConfig("cosmos"),
time.Date(2019, 1, 1, 00, 00, 00, 000, time.UTC),
),
types.NewChainLink(
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
types.NewBech32Address("cosmos1xmquc944hzu6n6qtljcexkuhhz76mucxtgm5x0", "cosmos"),
types.NewProof(
pubKey,
"909e38994b1583d3f14384c2e9a03c90064e8fd8e19b780bb0ba303dfe671a27287da04d0ce096ce9a140bd070ee36818f5519eb2070a16971efd8143855524b",
"text",
),
types.NewChainConfig("cosmos"),
time.Date(2019, 1, 1, 00, 00, 00, 000, time.UTC),
),
},
Pagination: &query.PageResponse{
NextKey: nil,
Total: 0,
},
},
},
{
name: "empty array is returned properly",
args: []string{
Expand All @@ -47,7 +84,7 @@ func (s *IntegrationTestSuite) TestCmdQueryUserChainLinks() {
},
},
{
name: "existing chain links is returned properly",
name: "existing chain links of the given user are returned properly",
args: []string{
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
Expand Down
13 changes: 9 additions & 4 deletions x/profiles/client/cli/cli_dtag_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,29 @@ func GetCmdRefuseDTagTransfer() *cobra.Command {
// GetCmdQueryDTagRequests returns the command allowing to query all the DTag transfer requests made towards a user
func GetCmdQueryDTagRequests() *cobra.Command {
cmd := &cobra.Command{
Use: "incoming-dtag-transfer-requests [address]",
Short: "Retrieve the DTag transfer requests made to the given address with optional pagination",
Args: cobra.ExactArgs(1),
Use: "incoming-dtag-transfer-requests [[address]]",
Short: "Retrieve the DTag transfer requests with optional address and pagination",
Args: cobra.RangeArgs(0, 1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

var receiver string
if len(args) == 1 {
receiver = args[0]
}

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

res, err := queryClient.IncomingDTagTransferRequests(
context.Background(),
&types.QueryIncomingDTagTransferRequestsRequest{Receiver: args[0], Pagination: pageReq},
&types.QueryIncomingDTagTransferRequestsRequest{Receiver: receiver, Pagination: pageReq},
)
if err != nil {
return err
Expand Down
16 changes: 15 additions & 1 deletion x/profiles/client/cli/cli_dtag_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ func (s *IntegrationTestSuite) TestCmdQueryDTagRequests() {
expectErr bool
expRequests []types.DTagTransferRequest
}{
{
name: "existing requests are returned properly",
args: []string{
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
expectErr: false,
expRequests: []types.DTagTransferRequest{
types.NewDTagTransferRequest(
"dtag",
"cosmos122u6u9gpdr2rp552fkkvlgyecjlmtqhkascl5a",
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
),
},
},
{
name: "empty slice is returned properly",
args: []string{
Expand All @@ -32,7 +46,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDTagRequests() {
expRequests: []types.DTagTransferRequest{},
},
{
name: "existing requests are returned properly",
name: "existing requests of the given user are returned properly",
args: []string{
"cosmos1ftkjv8njvkekk00ehwdfl5sst8zgdpenjfm4hs",
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
Expand Down
24 changes: 16 additions & 8 deletions x/profiles/client/cli/cli_relationships.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,21 @@ func GetCmdUnblockUser() *cobra.Command {
// GetCmdQueryUserRelationships returns the command allowing to query all the relationships of a specific user
func GetCmdQueryUserRelationships() *cobra.Command {
cmd := &cobra.Command{
Use: "relationships [address] [[subspace-id]]",
Short: "Retrieve all the user's relationships with optional subspace",
Args: cobra.RangeArgs(1, 2),
Use: "relationships [[address]] [[subspace-id]]",
Short: "Retrieve all the relationships with optional address and subspace",
Args: cobra.RangeArgs(0, 2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

user := args[0]
var user string
if len(args) >= 1 {
user = args[0]
}

var subspace string
if len(args) == 2 {
subspace = args[1]
Expand Down Expand Up @@ -168,17 +172,21 @@ func GetCmdQueryUserRelationships() *cobra.Command {
// GetCmdQueryUserBlocks returns the command allowing to query all the blocks of a single user with optional subspace
func GetCmdQueryUserBlocks() *cobra.Command {
cmd := &cobra.Command{
Use: "blocks [address] [[subspace-id]] ",
Short: "Retrieve the list of all the blocked users of the given address",
Args: cobra.RangeArgs(1, 2),
Use: "blocks [[address]] [[subspace-id]] ",
Short: "Retrieve the list of all the blocked users with optional address and subspace",
Args: cobra.RangeArgs(0, 2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

user := args[0]
var user string
if len(args) >= 1 {
user = args[0]
}

var subspace string
if len(args) == 2 {
subspace = args[1]
Expand Down
Loading