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

Move posts' const to chain params #204

Merged
merged 13 commits into from
Jul 1, 2020
Merged
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
## Changes
- Changed the data stored inside the profile objects (#193)
- Renamed the `profile_cov` field of `MsgSaveProfile` to `cover_picture`
- Rename the `profile_pic` field of `MsgSaveProfile` to `profile_picture`
- Moved profile module constants to chain parameters (#171)
- Renamed the `profile_pic` field of `MsgSaveProfile` to `profile_picture`
- Renamed the `profile` module to `profiles` (#200)
- Moved `profiles` module constants to chain parameters (#171)
- Moved `posts` module constants to chain parameters (#172)

## Bug fixes
- Fixed a bug inside the `Equals` method of the `Pictures` object
Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func NewDesmosApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
app.subspaces[gov.ModuleName] = app.paramsKeeper.Subspace(gov.DefaultParamspace).WithKeyTable(gov.ParamKeyTable())
app.subspaces[evidence.ModuleName] = app.paramsKeeper.Subspace(evidence.DefaultParamspace)
app.subspaces[crisis.ModuleName] = app.paramsKeeper.Subspace(crisis.DefaultParamspace)
app.subspaces[posts.ModuleName] = app.paramsKeeper.Subspace(posts.DefaultParamspace)
app.subspaces[profiles.ModuleName] = app.paramsKeeper.Subspace(profiles.DefaultParamspace)

// Add keepers
Expand Down Expand Up @@ -264,6 +265,7 @@ func NewDesmosApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
app.postsKeeper = posts.NewKeeper(
app.cdc,
keys[posts.StoreKey],
app.subspaces[posts.ModuleName],
)
app.profileKeeper = profiles.NewKeeper(
app.cdc,
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/msgs/edit_param_proposal.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# `EditParamsProposal`
Inside Desmos there are some parameters set for the `profiles` module which can be changed by submitting a proposal through
Inside Desmos there are some parameters set for the `profiles` and `posts` modules which can be changed by submitting a proposal through
the `gov` module of the `cosmosSDK`.

## Structure
Expand Down
36 changes: 36 additions & 0 deletions docs/developers/queries/params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Query posts module parameters
This query endpoint returns all the parameters of the `posts` module.

**CLI**
```bash
desmoscli query posts params

# Example
# desmoscli query posts params
```
**REST**
```
/posts/params

# Example
# curl http://lcd.morpheus.desmos.network:1317/posts/params
```

# Query profiles module parameters
This query endpoint returns all the parameters of the `profiles` module.

**CLI**
```bash
desmoscli query profiles params

# Example
# desmoscli query profiles params
```
**REST**
```
/profiles/params

# Example
# curl http://lcd.morpheus.desmos.network:1317/profiles/params
```

4 changes: 2 additions & 2 deletions docs/developers/queries/profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ desmoscli query profiles profile [address_or_moniker]
/profiles/{address_or_moniker}

# Example
# curl https://morpheus4000.desmos.network/profiles/desmos12a2y7fflz6g4e5gn0mh0n9dkrzllj0q5vx7c6t
# curl https://morpheus4000.desmos.network/profiles/leonardo
# curl http://lcd.morpheus.desmos.network:1317/profiles/desmos12a2y7fflz6g4e5gn0mh0n9dkrzllj0q5vx7c6t
# curl http://lcd.morpheus.desmos.network:1317/profiles/leonardo
```
24 changes: 3 additions & 21 deletions docs/developers/queries/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ desmoscli query profiles all
/profiles

# Example
# curl https://morpheus7000.desmos.network/profiles
# curl http://lcd.morpheus.desmos.network:1317/profiles
```

# Query a profile with the given moniker
Expand All @@ -32,23 +32,5 @@ desmoscli query profiles profile bob
/profiles/{address_or_moniker}

# Example
# curl https://morpheus7000.desmos.network/profiles/bob
```

# Query profiles module parameters
This query endpoint returns all the parameters of the profiles module.

**CLI**
```bash
desmoscli query profiles params

# Example
# desmoscli query profiles params
```
**REST**
```
/profiles/params

# Example
# curl https://morpheus7000.desmos.network/profiles/params
```
# curl http://lcd.morpheus.desmos.network:1317/profiles/bob
```
2 changes: 1 addition & 1 deletion docs/developers/queries/reactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ desmoscli query posts registered-reactions
/reactions

# Example
# curl https://morpheus4000.desmos.network/reactions
# curl http://lcd.morpheus.desmos.network:1317/reactions
```
2 changes: 1 addition & 1 deletion docs/developers/queries/reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ desmoscli query reports post [id]
/reports/{postID}

# Example
# curl https://morpheus7000.desmos.network/reports/301921ac3c8e623d8f35aef1886fea20849e49f08ec8ddfdd9b96feaf0c4fd15
# curl http://lcd.morpheus.desmos.network:1317/reports/301921ac3c8e623d8f35aef1886fea20849e49f08ec8ddfdd9b96feaf0c4fd15
```
5 changes: 4 additions & 1 deletion docs/developers/query-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ Aside from [performing transactions](perform-transactions.md) you can also query
- [Query the stored profiles](queries/profiles.md)

## Reports
- [Query the post's related reports](queries/reports.md)
- [Query the post's related reports](queries/reports.md)

## Modules Parameters
- [Query parameters](queries/params.md)
12 changes: 12 additions & 0 deletions x/genutil/legacy/v0.8.0/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/genutil"
v060posts "github.com/desmos-labs/desmos/x/posts/legacy/v0.6.0"
v080posts "github.com/desmos-labs/desmos/x/posts/legacy/v0.8.0"
v060profile "github.com/desmos-labs/desmos/x/profiles/legacy/v0.6.0"
v080profile "github.com/desmos-labs/desmos/x/profiles/legacy/v0.8.0"
)
Expand All @@ -23,6 +25,16 @@ func Migrate(appState genutil.AppMap, values ...interface{}) genutil.AppMap {
}

// Migrate posts state
if appState[v060posts.ModuleName] != nil {
var genDocs v060posts.GenesisState
v080Codec.MustUnmarshalJSON(appState[v060posts.ModuleName], &genDocs)

appState[v060posts.ModuleName] = v080Codec.MustMarshalJSON(
v080posts.Migrate(genDocs),
)
}

// Migrate profile state
if appState[v060profile.ModuleName] != nil {
var genDocs v060profile.GenesisState
v060Codec.MustUnmarshalJSON(appState[v060profile.ModuleName], &genDocs)
Expand Down
16 changes: 8 additions & 8 deletions x/magpie/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
)

const (
QuerySessions = keeper.QuerySessions
OpWeightMsgCreatePost = simulation.OpWeightMsgCreatePost
ModuleName = types.ModuleName
RouterKey = types.RouterKey
StoreKey = types.StoreKey
Expand All @@ -23,18 +21,17 @@ const (
AttributeKeyExternalOwner = types.AttributeKeyExternalOwner
AttributeKeyExpiry = types.AttributeKeyExpiry
AttributeValueCategory = types.AttributeValueCategory
QuerySessions = keeper.QuerySessions
OpWeightMsgCreatePost = simulation.OpWeightMsgCreatePost
)

var (
// functions aliases
NewHandler = keeper.NewHandler
NewKeeper = keeper.NewKeeper
NewQuerier = keeper.NewQuerier
DecodeStore = simulation.DecodeStore
RandomSessionData = simulation.RandomSessionData
WeightedOperations = simulation.WeightedOperations
SimulateMsgCreateSession = simulation.SimulateMsgCreateSession
RandomizedGenState = simulation.RandomizedGenState
DecodeStore = simulation.DecodeStore
NewMsgCreateSession = types.NewMsgCreateSession
SessionStoreKey = types.SessionStoreKey
ParseSessionID = types.ParseSessionID
Expand All @@ -43,21 +40,24 @@ var (
DefaultGenesisState = types.DefaultGenesisState
ValidateGenesis = types.ValidateGenesis
RegisterCodec = types.RegisterCodec
NewHandler = keeper.NewHandler
NewKeeper = keeper.NewKeeper
NewQuerier = keeper.NewQuerier

// variable aliases
RandomNamespaces = simulation.RandomNamespaces
SessionLengthKey = types.SessionLengthKey
LastSessionIDStoreKey = types.LastSessionIDStoreKey
SessionStorePrefix = types.SessionStorePrefix
ModuleCdc = types.ModuleCdc
RandomNamespaces = simulation.RandomNamespaces
)

type (
Keeper = keeper.Keeper
SessionData = simulation.SessionData
MsgCreateSession = types.MsgCreateSession
SessionID = types.SessionID
Session = types.Session
Sessions = types.Sessions
GenesisState = types.GenesisState
Keeper = keeper.Keeper
)
11 changes: 5 additions & 6 deletions x/posts/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ package posts

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/desmos-labs/desmos/x/posts/internal/types"
)

// EndBlocker called upon each block end to close expired polls
// TODO look how to iterate only over open poll
func EndBlocker(ctx sdk.Context, keeper Keeper) {

store := ctx.KVStore(keeper.StoreKey)
iterator := sdk.KVStorePrefixIterator(store, types.PostStorePrefix)
iterator := sdk.KVStorePrefixIterator(store, PostStorePrefix)
defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
var post types.Post
var post Post
keeper.Cdc.MustUnmarshalBinaryBare(iterator.Value(), &post)
if ctx.BlockTime().After(post.PollData.EndDate) || ctx.BlockTime().Equal(post.PollData.EndDate) {
post.PollData.Open = false
Expand All @@ -23,9 +22,9 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) {

ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeClosePoll,
sdk.NewAttribute(types.AttributeKeyPostID, post.PostID.String()),
sdk.NewAttribute(types.AttributeKeyPostOwner, post.Creator.String()),
EventTypeClosePoll,
sdk.NewAttribute(AttributeKeyPostID, post.PostID.String()),
sdk.NewAttribute(AttributeKeyPostOwner, post.Creator.String()),
),
)
}
Expand Down