-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add x/relationships spec (#837)
## Description This PR adds the spec folder inside the `x/relationships` module, containing the whole specification. Depends-On: #829 Depends-On: #838 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html) - [ ] included the necessary unit and integration [tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
- Loading branch information
Showing
6 changed files
with
347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- | ||
order: 1 | ||
--> | ||
|
||
# Concepts | ||
|
||
## Relationship | ||
A relationships between two users is a **mono-directional** link between a _creator_ and a _recipient_. This is equivalent to the concept of "follow" that is present on traditional social networks (i.e. Twitter). | ||
|
||
When a user A creates a relationships towards a user B, it means that they are interested in being notified about what user B does. | ||
|
||
_Friendship_ can be represented by a mutual relationship, which consists of two mono-directional relationships. If user A creates a relationships towards user B (`A -> B`), and user B creates a relationship towards user A (`B -> A`), then user A and B can be considered to be _friends_ since a mutual relationship (`A <-> B`) exists. | ||
|
||
## User Block | ||
A user block from one user (_blocker_) to another (_blocked_) represents the willingness of the first to block any future interaction that the latter might have with them. This concept is used to allow users to block misbehaving users from future harassment or unwanted interactions. | ||
|
||
When a user A creates a user block towards a user B, they can specify inside which subspace they want to block the user. If no particular subspace is provided, this means the B will not be allowed to have Desmos-level interactions with A in the future (e.g. requesting A to exchange their DTag). Blocking a user on subspace with id `0` (default value) **will not** block such user from interacting inside other subspaces. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- | ||
order: 2 | ||
--> | ||
|
||
# State | ||
|
||
## Relationships | ||
Relationships are stored tied to the subspace in which they were created as well as the creator and counterparty addresses: | ||
|
||
* `0x01 | Subspace ID | Creator address | Counterparty address | -> ProtocolBuffer(Relationship)` | ||
|
||
## User Blocks | ||
User blocks are stored tied to the subspace for which they were created, the blocker and blocked addresses: | ||
|
||
* `0x02 | Subspace ID | Blocker address | Blocked address | -> ProtocolBuffer(UserBlock)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- | ||
order: 3 | ||
--> | ||
|
||
# Msg Service | ||
|
||
## Msg/CreateRelationship | ||
A new relationship can be created with the `MsgCreateRelationship`, which allows to specify the subspace inside which the relationship should live and the counterparty address. | ||
|
||
+++ https://github.com/desmos-labs/desmos/blob/v3.0.0/proto/desmos/relationships/v1/msg_server.proto#L27-L39 | ||
|
||
It's expected to fail if a relationships between the same user and counterparty already exists inside the same subspace. | ||
|
||
## Msg/DeleteRelationship | ||
An existing relationship can be deleted with the `MsgDeleteRelationship`. | ||
|
||
+++ https://github.com/desmos-labs/desmos/blob/v3.0.0/proto/desmos/relationships/v1/msg_server.proto#L47-L56 | ||
|
||
It's expected to fail if a relationships between the signer and counterparty does not exist inside the specified subspace. | ||
|
||
## Msg/BlockUser | ||
A new user block can be created with the `MsgBlockUser`, which allows to specify the subspace inside which the block should be valid, the address of the blocked user and an optional reason for the block. | ||
|
||
+++ https://github.com/desmos-labs/desmos/blob/v3.0.0/proto/desmos/relationships/v1/msg_server.proto#L64-L74 | ||
|
||
It's expected to fail if a user block between the same user and blocker already exists inside the same subspace. | ||
|
||
## Msg/UnblockUser | ||
An existing user block can be deleted with the `MsgUnblockUser`. | ||
|
||
+++ https://github.com/desmos-labs/desmos/blob/v3.0.0/proto/desmos/relationships/v1/msg_server.proto#L81-L89 | ||
|
||
It's expected to fail if the user block does not exist inside the specified subspace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!-- | ||
order: 4 | ||
--> | ||
|
||
# Events | ||
|
||
The relationships module emits the following events: | ||
|
||
## Handlers | ||
|
||
### MsgCreateRelationship | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
|:--------------------|:--------------|:-----------------------------------------------| | ||
| create_relationship | creator | {userAddress} | | ||
| create_relationship | counterparty | {counterpartyAddress} | | ||
| create_relationship | subspace | {subspaceID} | | ||
| message | module | relationships | | ||
| message | action | /desmos.relationships.v1.MsgCreateRelationship | | ||
| message | sender | {userAddress} | | ||
|
||
### MsgDeleteRelationship | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
|:--------------------|:--------------|:-----------------------------------------------| | ||
| delete_relationship | creator | {userAddress} | | ||
| delete_relationship | counterparty | {counterpartyAddress} | | ||
| delete_relationship | subspace | {subspaceID} | | ||
| message | module | relationships | | ||
| message | action | /desmos.relationships.v1.MsgDeleteRelationship | | ||
| message | sender | {userAddress} | | ||
|
||
### MsgBlockUser | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
|:-----------|:--------------|:--------------------------------------| | ||
| block_user | blocker | {blockerAddress} | | ||
| block_user | blocked | {blockedAddress} | | ||
| block_user | subspace | {subspaceID} | | ||
| message | module | relationships | | ||
| message | action | /desmos.relationships.v1.MsgBlockUser | | ||
| message | sender | {userAddress} | | ||
|
||
### MsgUnblockUser | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
|:-------------|:--------------|:----------------------------------------| | ||
| unblock_user | blocker | {blockerAddress} | | ||
| unblock_user | blocked | {blockedAddress} | | ||
| unblock_user | subspace | {subspaceID} | | ||
| message | module | relationships | | ||
| message | action | /desmos.relationships.v1.MsgUnblockUser | | ||
| message | sender | {userAddress} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
<!-- | ||
order: 5 | ||
--> | ||
|
||
# Client | ||
|
||
## CLI | ||
|
||
A user can query and interact with the `relationships` module using the CLI. | ||
|
||
### Query | ||
|
||
The `query` commands allow users to query the `relationships` state. | ||
|
||
```bash | ||
desmos query relationships --help | ||
``` | ||
|
||
#### relationships | ||
The `relationships` command allows user to query the relationships inside a subspace having a specific id, providing an optional creator and counterparty. | ||
|
||
```bash | ||
desmos query relationships [subspace-id] [[creator]] [[counterparty]] [flags] | ||
``` | ||
|
||
Example: | ||
```bash | ||
desmos query relationships relationships 1 desmos1... desmos1... | ||
``` | ||
|
||
Example Output: | ||
```yaml | ||
pagination: | ||
next_key: null | ||
total: "0" | ||
relationships: | ||
- counterparty: desmos1tamzg6rfj9wlmqhthgfmn9awq0d8ssgfr8fjns | ||
creator: desmos13yp2fq3tslq6mmtq4628q38xzj75ethzela9uu | ||
subspace_id: "1" | ||
``` | ||
#### blocks | ||
The `blocks` command allows to query the user blocks stored inside a subspace having a given id, providing an optional blocker and blocked addresses. | ||
|
||
```bash | ||
desmos query relationships blocks [subspace-id] [[blocker]] [[blocked]] [flags] | ||
``` | ||
|
||
Example: | ||
```bash | ||
desmos query relationships blocks 1 desmos1... desmos1... | ||
``` | ||
|
||
Example Output: | ||
```yaml | ||
blocks: | ||
- blocked: desmos1tamzg6rfj9wlmqhthgfmn9awq0d8ssgfr8fjns | ||
blocker: desmos13yp2fq3tslq6mmtq4628q38xzj75ethzela9uu | ||
reason: "" | ||
subspace_id: "1" | ||
pagination: | ||
next_key: null | ||
total: "0" | ||
``` | ||
|
||
### Transactions | ||
The `tx` commands allow users to interact with the `relationships` module. | ||
|
||
```bash | ||
desmos tx relationships --help | ||
``` | ||
|
||
#### create-relationship | ||
The `create-relationship` allows users to create a relationship with another user inside a specific subspace. | ||
|
||
```bash | ||
desmos tx relationships create-relationship [counterparty] [subspace-id] [flags] | ||
``` | ||
|
||
Example: | ||
```bash | ||
desmos tx relationships create-relationship desmos1... 1 | ||
``` | ||
|
||
#### delete-relationship | ||
The `delete-relationship` allows users to delete an existing relationship. | ||
|
||
```bash | ||
desmos tx relationships delete-relationship [counterparty] [subspace-id] [flags] | ||
``` | ||
|
||
Example: | ||
```bash | ||
desmos tx relationships delete-relationship desmos1... 1 | ||
``` | ||
|
||
#### block | ||
The `block` command allows users to block another user inside a specific subspace, optionally providing a reason. | ||
|
||
```bash | ||
desmos tx relationships block [address] [subspace] [[reason]] [flags] | ||
``` | ||
|
||
Example: | ||
```bash | ||
desmos tx relationships block desmos1... 1 "My reason" | ||
``` | ||
|
||
#### unblock | ||
The `unblock` command allows users to unblock a previously blocked user. | ||
|
||
```bash | ||
desmos tx relationships unblock [address] [subspace] [flags] | ||
``` | ||
|
||
Example: | ||
```bash | ||
desmos tx relationships unblock desmos1... 1 | ||
``` | ||
|
||
|
||
## gRPC | ||
A user can query the `relationships` module gRPC endpoints. | ||
|
||
### Relationships | ||
The `Relationships` endpoint allows users to query for the relationships inside a subspace having a given id, optionally providing user and counterparty addresses. | ||
|
||
```bash | ||
desmos.relationships.v1.Query/Relationships | ||
``` | ||
|
||
Example: | ||
```bash | ||
grpcurl -plaintext \ | ||
-d '{"subspace_id": "1"}' localhost:9090 desmos.relationships.v1.Query/Relationships | ||
``` | ||
|
||
Example Output: | ||
```json | ||
{ | ||
"relationships": [ | ||
{ | ||
"creator": "desmos13yp2fq3tslq6mmtq4628q38xzj75ethzela9uu", | ||
"counterparty": "desmos1tamzg6rfj9wlmqhthgfmn9awq0d8ssgfr8fjns", | ||
"subspaceId": "1" | ||
} | ||
], | ||
"pagination": { | ||
"total": "1" | ||
} | ||
} | ||
``` | ||
|
||
### Blocks | ||
The `Blocks` endpoint allows users to query for the user blocks inside a subspace having a given id, optionally providing user and counterparty addresses. | ||
|
||
```bash | ||
desmos.relationships.v1.Query/Blocks | ||
``` | ||
|
||
Example: | ||
```bash | ||
grpcurl -plaintext \ | ||
-d '{"subspace_id": "1"}' localhost:9090 desmos.relationships.v1.Query/Blocks | ||
``` | ||
|
||
Example Output: | ||
```json | ||
{ | ||
"blocks": [ | ||
{ | ||
"blocker": "desmos13yp2fq3tslq6mmtq4628q38xzj75ethzela9uu", | ||
"blocked": "desmos1tamzg6rfj9wlmqhthgfmn9awq0d8ssgfr8fjns", | ||
"subspaceId": "1" | ||
} | ||
], | ||
"pagination": { | ||
"total": "1" | ||
} | ||
} | ||
``` | ||
|
||
## REST | ||
A user can query the `relationships` module using REST endpoints. | ||
|
||
## Relationships | ||
The `relationships` endpoint allows users to query for the relationships inside a subspace having a given id, optionally providing user and counterparty addresses. | ||
|
||
``` | ||
/desmos/relationships/v1/relationships?subspace_id={subspaceID}&user={userAddress}&counterparty={counterpartyAddress} | ||
``` | ||
## Blocks | ||
The `blocks` endpoint allows users to query for the user blocks inside a subspace having a given id, optionally providing user and counterparty addresses. | ||
``` | ||
/desmos/relationships/v1/blocks?subspace_id={subspaceID}&blocker={blockerAddress}&blocked={blockedAddress} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- | ||
order: 0 | ||
title: Relationships Overview | ||
parent: | ||
title: "relationships" | ||
--> | ||
|
||
# `relationships` | ||
|
||
This document specifies the Relationships module of Desmos. | ||
|
||
The module allows Desmos users to establish relationships between them, and also to block misbehaving users from harassing them in the future. | ||
|
||
## Contents | ||
1. **[Concepts](01_concepts.md)** | ||
- [Relationship](01_concepts.md#relationship) | ||
- [User Block](01_concepts.md#user-block) | ||
2. **[State](02_state.md)** | ||
- [Relationship](02_state.md#relationships) | ||
- [User Blocks](02_state.md#user-blocks) | ||
3. **[Msg Server](03_messages.md)** | ||
- [Msg/CreateRelationship](03_messages.md#msgcreaterelationship) | ||
- [Msg/DeleteRelationship](03_messages.md#msgdeleterelationship) | ||
- [Msg/BlockUser](03_messages.md#msgblockuser) | ||
- [Msg/UnblockUser](03_messages.md#msgunblockuser) | ||
4. **[Events](04_events.md)** | ||
- [Handlers](04_events.md#handlers) | ||
5. **[Client](05_client.md)** | ||
- [CLI](05_client.md#cli) | ||
- [gRPC](05_client.md#grpc) | ||
- [REST](05_client.md#rest) |