Skip to content

Commit

Permalink
Merge branch 'master' of github.com:desmos-labs/desmos into paul/add-…
Browse files Browse the repository at this point in the history
…post-reactions-query
  • Loading branch information
RiccardoM committed Jun 30, 2021
2 parents 729f491 + a82f1ed commit 7d87b57
Show file tree
Hide file tree
Showing 77 changed files with 2,622 additions and 1,621 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Updated Cosmos SDK to `v0.42.6` ([#509](https://github.com/desmos-labs/desmos/issues/509))
- Added the possibility to verify a profile with an external application ([#472](https://github.com/desmos-labs/desmos/issues/472))
- Improved the posts query ([#499](https://github.com/desmos-labs/desmos/issues/499))
- Added the ability to paginate user blocks ([#495](https://github.com/desmos-labs/desmos/issues/495))
- Added the post comments query ([#510](https://github.com/desmos-labs/desmos/pull/510))
- Added the ability to paginate incoming DTag transfer requests ([#519](https://github.com/desmos-labs/desmos/pull/519))
- Added the post reactions query and improved the methods of registered reactions ([#515](https://github.com/desmos-labs/desmos/pull/515))
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ proto-lint:
proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.9/proto/tendermint
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.11/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.42.4/proto/cosmos
COSMOS_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.42.6/proto/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.3
IBC_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.42.4/proto/ibc
Expand Down Expand Up @@ -370,8 +370,6 @@ proto-update-deps:
## Issue link: https://github.com/confio/ics23/issues/32
@sed -i '4ioption go_package = "github.com/confio/ics23/go";' $(CONFIO_TYPES)/proofs.proto

@mkdir -p

.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-deps

###############################################################################
Expand Down
21 changes: 20 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,26 @@ module.exports = {
collapsable: true,
children: [
["developers/overview", "Overview"],
["developers/types", "Types"],
{
title: "Types",
path: "developers/types",
collapsable: true,
children: [
{
title: "Profiles",
collapsable: true,
children: [
[ "developers/types/profiles/profile", "Profile" ],
[ "developers/types/profiles/profile-pictures", "Profile pictures" ],
[ "developers/types/profiles/dtag-transfer-request", "DTag transfer request" ],
[ "developers/types/profiles/relationship", "Relationship" ],
[ "developers/types/profiles/user-block", "User block" ],
[ "developers/types/profiles/application-link", "Application link" ],
[ "developers/types/profiles/chain-link", "Chain link" ],
]
}
]
},
["developers/perform-transactions", "Performing transactions"],
["developers/query-data", "Querying data"],
["developers/observe-data", "Observing data"],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/desmos-band-process.png
Binary file not shown.
Binary file removed docs/assets/desmos-band-setup.png
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/developers/queries/profiles/user-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This query allows you to retrieve the user blocked by the user with the given `a

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

# Example
# desmos query profiles blocklist desmos13p5pamrljhza3fp4es5m3llgmnde5fzcpq6nud
Expand Down
1 change: 1 addition & 0 deletions docs/developers/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Following you can find all the custom types that are used to represent the data
- [Relationship](types/profiles/relationship.md)
- [User block](types/profiles/user-block.md)
- [Application link](types/profiles/application-link.md)
- [Chain link](types/profiles/chain-link.md)

## Posts

Expand Down
46 changes: 26 additions & 20 deletions docs/developers/types/profiles/application-link.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Application link
An application link (abbr. _app link_) represents a link to an external (and possibly centralized) application. These links are created by the user and their validity is checked using a multi-step verification process described inside the [_"Themis"_ repository](https://github.com/desmos-labs/themis).
An application link (abbr. _app link_) represents a link to an external (and possibly centralized) application.

## `User`
## Contained data
Here follows the data of an application link.

### `User`
Address of the Desmos profile to which the link is associated.

## `Data`
### `Data`
Object that contains the details of the link.

### `Application`
#### `Application`
Name of the application to which the link refers to (eg. `twitter`, `github`, `reddit`, etc).

### `Username`
#### `Username`
Identifier of the application account which the link refers to (eg. Twitter username, GitHub profile, Reddit username, etc).

## `State`
### `State`
Representation of the current state of the link. There can be five different states in which a link can be:

- `APPLICATION_LINK_STATE_INITIALIZED_UNSPECIFIED` if the link has just been created, and it still needs to be processed;
Expand All @@ -22,48 +25,51 @@ Representation of the current state of the link. There can be five different sta
- `APPLICATION_LINK_STATE_VERIFICATION_SUCCESS` if the verification process ended with success;
- `APPLICATION_LINK_STATE_TIMED_OUT` if the verification process expired due to a timeout.

## `OracleRequest`
### `OracleRequest`
The `OracleRequest` field contains all the data that has been sent to the oracle script in order to verify the authenticity of the link.

### `ID`
#### `ID`
This is the unique id of the request that has been made to verify the link.

### `OracleScriptID`
#### `OracleScriptID`
Unique id of the script that has been called to verify the authenticity of the link.

### `CallData`
#### `CallData`
Contains the details of the data that will be used to call the oracle script.

#### `Application`
##### `Application`
Name of the application for which the link is valid (eg. `twitter`, `github`, `reddit`, etc).

#### `CallData`
##### `CallData`
The `CallData` field represents the hex-encoded data that will be given to the data source in order to fetch and verify the validity of the link.

### `ClientID`
#### `ClientID`
ID of the client that has performed the request.

## `Result`
### `Result`
The `Result` field contains the effective result of the verification process. This is set only if the link state is either `APPLICATION_LINK_STATE_VERIFICATION_SUCCESS` or `APPLICATION_LINK_STATE_VERIFICATION_ERROR`.

The `Result` field can be of two types:
- `Result_Success`
- `Result_Error`

### `Result_Success`
#### `Result_Success`
Represents a successful result. It contains two fields.

#### `Value`
##### `Value`
Plain text value that has been signed from the user with their Desmos private key to prove the ownership of the Desmos profile.

#### `Signature`
##### `Signature`
Hex-encoded result of the plain text value signature.

### `Result_Error`
#### `Result_Error`
Identifies an error during the verification process. It contains only one field.

#### `Error`
##### `Error`
Represents the description of the error that has been emitted during the verification process.

## `CreationTime`
### `CreationTime`
Contains the time at which the link has been created.

## Create an application link
Application links can be created by any user having a Desmos profile, and their validity is checked using a multi-step verification process described inside the [_"Themis"_ repository](https://github.com/desmos-labs/themis).
135 changes: 135 additions & 0 deletions docs/developers/types/profiles/chain-link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Chain link
A chain link represents a link to an external chain account that has been created by the user to connect their Desmos profile to such accounts. These links can be created either offline or using IBC following the specification described inside the [_"Create a chain link"_ section](#create-a-chain-link).

## Contained data
Here follows the data contained inside a chain link.

### `User`
Represents the Desmos address to which the chain link is associated.

### `Address`
Contains the data of the external chain address. Currently, it can be of two different types:

- `Bech32Address` to represent Bech32-based addresses
- `Base58Address` to support Base58-encoded addresses

### `Proof`
Contains the data proving the ownership of the external chain account.

#### `PubKey`
Contains the data of the public key associated with the external address that is used to verify the ownership of such address.

#### `Signature`
Represents the hex-encoded signature of the plain text that has been created signing it with the private key associated with the provided public key.

#### `PlainText`
Represents the plain text value that has been signed with the private key associated with the address in order to get the signature.

### `ChainConfig`
Contains the details of the external chain to which the link is associated.

#### `Name`
Contains the human readable chain name.

### `CreationTime`
Represents the time in which the link has been created.

## Create a chain link
### 1. Create the ownership proofs
When creating a chain link, you need to provide two different proofs to make sure the link is valid:

1. The proof that you own the external chain account
2. The proof that you own the Desmos profile to which you want to link

In order to create a proof, the following steps are needed:

1. Get a generic plain text data to sign
2. Sign the plain text data using your private key
3. Assemble the signature, plain text and public key into a `Proof` object.

Here is an example of a valid proof object encoded using JSON:
```json
{
"pub_key": {
"@type": "/cosmos.crypto.secp256k1.PubKey",
"key": "A58DXR/lXKVkIjLofXgST/OHi+pkOQbVIiOjnTy7Zoqo"
},
"signature": "ecc6175e730917fb289d3a9f4e49a5630a44b42d972f481342f540e09def2ec5169780d85c4e060d52cc3ffb3d677745a4d56cd385760735bc6db0f1816713be",
"plain_text": "cosmos15uc89vnzufu5kuhhsxdkltt38zfx8vcyggzwfm"
}
```

Note that the `pub_key` field must be encoded using Protobuf and must be compatible with the public key types that are currently supported by Cosmos. You can see a list of such key types [here](https://github.com/cosmos/cosmos-sdk/tree/master/proto/cosmos/crypto).

### 2. Create the link
Once you have created the two ownership proofs, you are now ready to create the link. This can be done in two ways:
1. [Using IBC](#using-ibc)
2. [Usign a chain message](#using-chain-message)

#### Using IBC
This is the way that you want to use when integrating the Desmos connection from your chain.
To implement the IBC capability of connecting an external account to a Desmos profile, the `x/profiles` module supports the following packet data type:

```go
// LinkChainAccountPacketData defines the object that should be sent inside a
// MsgSendPacket when wanting to link an external chain to a Desmos profile
// using IBC
type LinkChainAccountPacketData struct {
// SourceAddress contains the details of the external chain address
SourceAddress *types.Any `protobuf:"bytes,1,opt,name=source_address,json=sourceAddress,proto3" json:"source_address,omitempty" yaml:"source_address"`
// SourceProof represents the proof of ownership of the source address
SourceProof Proof `protobuf:"bytes,2,opt,name=source_proof,json=sourceProof,proto3" json:"source_proof" yaml:"source_proof"`
// SourceChainConfig contains the details of the source chain
SourceChainConfig ChainConfig `protobuf:"bytes,3,opt,name=source_chain_config,json=sourceChainConfig,proto3" json:"source_chain_config" yaml:"source_chain_config"`
// DestinationAddress represents the Desmos address of the profile that should
// be linked with the external account
DestinationAddress string `protobuf:"bytes,4,opt,name=destination_address,json=destinationAddress,proto3" json:"destination_address,omitempty" yaml:"destination_address"`
// DestinationProof contains the proof of ownership of the DestinationAddress
DestinationProof Proof `protobuf:"bytes,5,opt,name=destination_proof,json=destinationProof,proto3" json:"destination_proof" yaml:"destination_proof"`
}
```

| Field | Type | Description |
| :----: | :-----: | :------ |
| `SourceAddress` | `AddressData` | Contains the details of the external address to be linked |
| `SourceProof` | `Proof` | Contains the data to verify the ownership of the external address |
| `SourceChainConfig` | `ChainConfig` | Contains the data of the external chain to be linked |
| `DestinationAddress` | `string` | Desmos address of the profile to which link the external address |
| `DestinationProof` | `Proof` | Proof of ownership of the Desmos profile |

Note that the `SourceAddress` field must one of the currently supported types:
- `Base58Address` if the external address is represented by the Base58 encoded public key of the account
- `Bech32Address` if the external address is Bech 32 encoded

The overall view is the following:

<img :src="$withBase('/assets/desmos-chain-link-ibc.png')">

#### Using a chain message
In the case you don't want or cannot integrate IBC into your project, you can always rely on `MsgLinkChainAccount` to link an external profile to a Desmos profile:

```go
// MsgLinkChainAccount represents a message to link an account to a profile.
type MsgLinkChainAccount struct {
// ChainAddress contains the details of the external chain address to be
// linked
ChainAddress *types.Any `protobuf:"bytes,1,opt,name=chain_address,json=chainAddress,proto3" json:"chain_address,omitempty" yaml:"source_address"`
// Proof contains the proof of ownership of the external chain address
Proof Proof `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof" yaml:"source_proof"`
// ChainConfig contains the configuration of the external chain
ChainConfig ChainConfig `protobuf:"bytes,3,opt,name=chain_config,json=chainConfig,proto3" json:"chain_config" yaml:"source_chain_config"`
// Signer represents the Desmos address associated with the
// profile to which link the external account
Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"`
}
```

| Field | Type | Description |
| :----: | :-----: | :------ |
| `ChainAddress` | `AddressData` | Contains the details of the external address to be linked |
| `Proof` | `Proof` | Contains the data to verify the ownership of the external address |
| `ChainConfig` | `ChainConfig` | Contains the data of the external chain to be linked |
| `Signer` | `string` | Desmos address of the profile to which link the external address, which must be the signer of the transaction |

##### Using the CLI
Note that you can compose this message using the `desmos tx profiles link-chain` command.
2 changes: 1 addition & 1 deletion docs/validators/common-problems.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Instead of using a seed node, you can also keep relying on persistent peers. In
/net_info
```
For example, you can use the public RPC endpoint [here](http://rpc.morpheus.desmos.network:26657/net_info).
For example, you can use the public RPC endpoint [here](https://rpc.morpheus.desmos.network/net_info).
From that page, you can see all the peers connected to that node. Their info is present inside the `peers` field, which contains a list of objects made as follows:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alp
replace github.com/cosmos/cosmos-sdk => github.com/desmos-labs/cosmos-sdk v0.42.5-0.20210622061628-2057c75ad60d

replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM=
github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down Expand Up @@ -327,8 +329,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
Expand Down
2 changes: 2 additions & 0 deletions proto/desmos/profiles/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ option go_package = "github.com/desmos-labs/desmos/x/profiles/types";

// GenesisState defines the profiles module's genesis state.
message GenesisState {
option (gogoproto.goproto_getters) = false;

repeated desmos.profiles.v1beta1.DTagTransferRequest dtag_transfer_requests =
1 [
(gogoproto.nullable) = false,
Expand Down
7 changes: 7 additions & 0 deletions proto/desmos/profiles/v1beta1/models_app_links.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "google/protobuf/timestamp.proto";

// ApplicationLink contains the data of a link to a centralized application
message ApplicationLink {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = true;

// User to which the link is associated
Expand Down Expand Up @@ -41,6 +42,7 @@ message ApplicationLink {
// Data contains the data associated to a specific user of a
// generic centralized application
message Data {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = true;

// The application name (eg. Twitter, GitHub, etc)
Expand All @@ -52,6 +54,8 @@ message Data {
// OracleRequest represents a generic oracle request used to
// verify the ownership of a centralized application account
message OracleRequest {
option (gogoproto.goproto_getters) = false;

option (gogoproto.equal) = true;

// ID is the ID of the request
Expand Down Expand Up @@ -114,6 +118,7 @@ enum ApplicationLinkState {

// Result represents a verification result
message Result {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = true;

// sum is the oneof that specifies whether this represents a success or
Expand All @@ -129,6 +134,7 @@ message Result {
// Success is the result of an application link that has been successfully
// verified
message Success {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = true;

// Value that has be signed by the profile
Expand All @@ -140,6 +146,7 @@ message Result {
// Failed is the result of an application link that has not been verified
// successfully
message Failed {
option (gogoproto.goproto_getters) = false;
option (gogoproto.equal) = true;

// Error that is associated with the failure
Expand Down
Loading

0 comments on commit 7d87b57

Please sign in to comment.