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: ADR-010: Posts module #847

Merged
merged 87 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
6174fbf
added x/posts types
RiccardoM Apr 27, 2022
8f531ea
added missing validations
RiccardoM Apr 27, 2022
1ff827f
started the work on the posts keeper
RiccardoM Apr 27, 2022
6ad8e9e
added the posts keeper
RiccardoM Apr 28, 2022
37e7124
started reviewing how attachment contents are handled
RiccardoM Apr 28, 2022
4565cc1
reviewed how attachment contents are represented
RiccardoM Apr 28, 2022
2ceec10
added messages types
RiccardoM Apr 29, 2022
3fddae7
added msg server implementation
RiccardoM Apr 29, 2022
14e9b45
added msg server tests
RiccardoM May 2, 2022
c1daac2
added missing params and hooks tests
RiccardoM May 2, 2022
266340f
added genesis types
RiccardoM May 2, 2022
df16f75
adding genesis support to keeper
RiccardoM May 2, 2022
5835c0a
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM May 3, 2022
711d89d
added import genesis tests
RiccardoM May 3, 2022
b369aa5
added gRPC querier
RiccardoM May 3, 2022
25c5355
updated how poll tally results are stored
RiccardoM May 3, 2022
d515485
added end blocker tests
RiccardoM May 3, 2022
a3984fa
fixed linting
RiccardoM May 3, 2022
4b92717
added comment
RiccardoM May 3, 2022
34349b8
added the CLI commands
RiccardoM May 4, 2022
c1d04f9
added some more models checks
RiccardoM May 4, 2022
065e449
use PermissionWrite instead of PermissionWriteContent
RiccardoM May 5, 2022
2e29105
improved the posts keys
RiccardoM May 5, 2022
2bf2e7d
added simulation tests for the posts module
RiccardoM May 5, 2022
9ff776f
fixed test
RiccardoM May 5, 2022
b60583f
fixed linting
RiccardoM May 5, 2022
6f166e5
added dontcover directive where needed
RiccardoM May 5, 2022
a13c910
fixed simulation tests
RiccardoM May 5, 2022
f932f7d
fixed simulation tests
RiccardoM May 5, 2022
c1decf8
added invariants
RiccardoM May 6, 2022
c81ca22
added more checks within the genesis
RiccardoM May 9, 2022
a71702d
Update proto/desmos/posts/v1/models.proto
RiccardoM May 11, 2022
4cea674
Update proto/desmos/posts/v1/models.proto
RiccardoM May 11, 2022
07226ba
Update x/posts/keeper/alias_functions.go
RiccardoM May 11, 2022
bd327ae
Update x/posts/types/genesis.go
RiccardoM May 11, 2022
4c53cd8
Update x/posts/types/keys.go
RiccardoM May 11, 2022
7aaeb41
Update x/posts/types/models.go
RiccardoM May 11, 2022
e6f0b5c
Update x/posts/keeper/attachments_test.go
RiccardoM May 11, 2022
4a85da5
Update x/posts/keeper/attachments_test.go
RiccardoM May 11, 2022
27f7892
Update x/posts/keeper/posts_test.go
RiccardoM May 11, 2022
1152669
Update x/posts/types/events.go
RiccardoM May 11, 2022
a76a60a
Update x/posts/types/genesis.go
RiccardoM May 11, 2022
452aab6
fixed suggestions
RiccardoM May 11, 2022
f061ea5
Merge remote-tracking branch 'origin/riccardo/posts-implementation' i…
RiccardoM May 11, 2022
472f1a9
fixed suggestions
RiccardoM May 11, 2022
ead7e1e
added missing events
RiccardoM May 11, 2022
b0bd00e
fixed lint issues
RiccardoM May 11, 2022
06a3d7e
fixed tests
RiccardoM May 11, 2022
0aa1717
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM May 11, 2022
12fcbfa
changed PostID and AttachmentID related keeper methods and store keys
RiccardoM May 12, 2022
b04f498
deleted TODO
RiccardoM May 12, 2022
c93b7e8
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM May 12, 2022
cf36100
added missing invariants checks
RiccardoM May 12, 2022
f7bae29
added missing tests
RiccardoM May 13, 2022
9314a40
fixed simulation tests to run properly all the operations
RiccardoM May 13, 2022
3481361
improved invariants tests
RiccardoM May 13, 2022
e1b04f8
fixed test
RiccardoM May 13, 2022
e9d103e
removed checks from InitGenesis as they will be performed inside inva…
RiccardoM May 13, 2022
8fa59ec
updated how subspaces data is exported
RiccardoM May 13, 2022
ad5fdba
added changeset entry
RiccardoM May 13, 2022
e5026be
improved app organization
RiccardoM May 13, 2022
fbdca26
added store migration code
RiccardoM May 13, 2022
9a16926
incremented consensus version
RiccardoM May 13, 2022
3de97ae
fixed typos inside parse errors
RiccardoM May 13, 2022
56a37ed
fixed simulation tests
RiccardoM May 15, 2022
ab2067a
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM May 16, 2022
0d76c4d
fixed suggestions
RiccardoM May 17, 2022
f500bea
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM May 17, 2022
f77476d
updated Swagger config
RiccardoM May 17, 2022
4589691
Update x/posts/types/events.go
RiccardoM May 18, 2022
b4f877f
fixed segments sorting
RiccardoM May 18, 2022
e0cc415
Update x/posts/keeper/msg_server.go
RiccardoM May 18, 2022
e9a77fe
Update x/posts/types/models.go
RiccardoM May 18, 2022
14653a1
moved the author checks inside EditPost and AddPostAttachment above p…
RiccardoM May 19, 2022
a6c8642
added missing entitySegment documentation
RiccardoM May 19, 2022
5aaa609
Merge remote-tracking branch 'origin/riccardo/posts-implementation' i…
RiccardoM May 19, 2022
5eafa8a
Update x/posts/keeper/subspaces_hooks.go
RiccardoM May 26, 2022
0e3e118
fixed Validate comment
RiccardoM May 26, 2022
75d7ab2
Update x/posts/keeper/msg_server.go
RiccardoM May 26, 2022
ed94516
improved uniqueness checks
RiccardoM May 26, 2022
1ae9b63
Merge remote-tracking branch 'origin/riccardo/posts-implementation' i…
RiccardoM May 26, 2022
99ee515
removed posts events emission when deleting a subspace
RiccardoM May 26, 2022
e820a61
Merge branch 'master' of github.com:desmos-labs/desmos into riccardo/…
RiccardoM May 26, 2022
764f3d4
use string as user address instead of bytes
RiccardoM May 26, 2022
2da365d
Updated Swagger definition
RiccardoM May 26, 2022
68641f2
updated the ADR to be compatible with the changes
RiccardoM May 26, 2022
7a54d90
Merge remote-tracking branch 'origin/riccardo/posts-implementation' i…
RiccardoM May 26, 2022
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
6 changes: 4 additions & 2 deletions .changeset/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ types:
modules:
- id: x/profiles
description: Profiles
- id: x/subspaces
description: Subspaces
- id: x/relationships
description: Relationships
- id: x/subspaces
description: Subspaces
- id: x/posts
description: Posts
- id: x/fees
description: Fees
- id: x/supply
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: feat
module: x/posts
pull_request: 847
description: Added the new x/posts module
backward_compatible: false
date: 2022-05-13T11:12:11.336881249Z
44 changes: 31 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ import (
"path/filepath"
"strings"

postskeeper "github.com/desmos-labs/desmos/v3/x/posts/keeper"
poststypes "github.com/desmos-labs/desmos/v3/x/posts/types"

"github.com/desmos-labs/desmos/v3/app/upgrades"
v300 "github.com/desmos-labs/desmos/v3/app/upgrades/v300"
v310 "github.com/desmos-labs/desmos/v3/app/upgrades/v310"

profilesv4 "github.com/desmos-labs/desmos/v3/x/profiles/legacy/v4"

"github.com/cosmos/cosmos-sdk/version"

"github.com/desmos-labs/desmos/v3/x/posts"
"github.com/desmos-labs/desmos/v3/x/relationships"
relationshipstypes "github.com/desmos-labs/desmos/v3/x/relationships/types"

"github.com/cosmos/cosmos-sdk/version"

"github.com/desmos-labs/desmos/v3/x/fees"
feeskeeper "github.com/desmos-labs/desmos/v3/x/fees/keeper"
feestypes "github.com/desmos-labs/desmos/v3/x/fees/types"
Expand Down Expand Up @@ -233,6 +237,7 @@ var (
profiles.AppModuleBasic{},
relationships.AppModuleBasic{},
subspaces.AppModuleBasic{},
posts.AppModuleBasic{},
fees.AppModuleBasic{},
supply.AppModuleBasic{},
)
Expand Down Expand Up @@ -298,6 +303,7 @@ type DesmosApp struct {
SubspacesKeeper subspaceskeeper.Keeper
ProfileKeeper profileskeeper.Keeper
RelationshipsKeeper relationshipskeeper.Keeper
PostsKeeper postskeeper.Keeper
SupplyKeeper supplykeeper.Keeper

// Module Manager
Expand Down Expand Up @@ -346,6 +352,7 @@ func NewDesmosApp(

// Custom modules
profilestypes.StoreKey, relationshipstypes.StoreKey, subspacestypes.StoreKey,
poststypes.StoreKey,
feestypes.StoreKey, supplytypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -469,10 +476,22 @@ func NewDesmosApp(
app.FeesKeeper,
)

// Create posts keeper and module
app.PostsKeeper = postskeeper.NewKeeper(
app.appCodec,
keys[poststypes.StoreKey],
app.GetSubspace(poststypes.ModuleName),
&subspacesKeeper,
app.RelationshipsKeeper,
)

// Register the subspaces hooks
// NOTE: subspacesKeeper above is passed by reference, so that it will contain these hooks
app.SubspacesKeeper = *subspacesKeeper.SetHooks(
subspacestypes.NewMultiSubspacesHooks(app.RelationshipsKeeper.Hooks()),
subspacestypes.NewMultiSubspacesHooks(
app.RelationshipsKeeper.Hooks(),
app.PostsKeeper.Hooks(),
),
)

app.SupplyKeeper = supplykeeper.NewKeeper(app.appCodec, app.AccountKeeper, app.BankKeeper, app.DistrKeeper)
Expand Down Expand Up @@ -576,11 +595,8 @@ func NewDesmosApp(
fees.NewAppModule(app.appCodec, app.FeesKeeper),
subspaces.NewAppModule(appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper, app.FeesKeeper),
profilesModule,
relationships.NewAppModule(
appCodec, app.RelationshipsKeeper, app.SubspacesKeeper,
profilesv4.NewKeeper(keys[profilestypes.StoreKey], appCodec), app.AccountKeeper,
app.BankKeeper, app.FeesKeeper,
),
relationships.NewAppModule(appCodec, app.RelationshipsKeeper, app.SubspacesKeeper, profilesv4.NewKeeper(keys[profilestypes.StoreKey], appCodec), app.AccountKeeper, app.BankKeeper, app.FeesKeeper),
posts.NewAppModule(appCodec, app.PostsKeeper, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper, app.FeesKeeper),
supply.NewAppModule(appCodec, legacyAmino, app.SupplyKeeper),
)

Expand Down Expand Up @@ -614,6 +630,7 @@ func NewDesmosApp(
subspacestypes.ModuleName,
relationshipstypes.ModuleName,
profilestypes.ModuleName,
poststypes.ModuleName,
supplytypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -641,6 +658,7 @@ func NewDesmosApp(
subspacestypes.ModuleName,
relationshipstypes.ModuleName,
profilestypes.ModuleName,
poststypes.ModuleName,
supplytypes.ModuleName,
)

Expand Down Expand Up @@ -675,6 +693,7 @@ func NewDesmosApp(
subspacestypes.ModuleName,
profilestypes.ModuleName,
relationshipstypes.ModuleName,
poststypes.ModuleName,
supplytypes.ModuleName,

crisistypes.ModuleName,
Expand Down Expand Up @@ -708,6 +727,7 @@ func NewDesmosApp(
subspacestypes.ModuleName,
relationshipstypes.ModuleName,
profilestypes.ModuleName,
poststypes.ModuleName,
supplytypes.ModuleName,

crisistypes.ModuleName,
Expand Down Expand Up @@ -749,11 +769,8 @@ func NewDesmosApp(
supply.NewAppModule(appCodec, legacyAmino, app.SupplyKeeper),
subspaces.NewAppModule(appCodec, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper, app.FeesKeeper),
profilesModule,
relationships.NewAppModule(
appCodec, app.RelationshipsKeeper, app.SubspacesKeeper,
profilesv4.NewKeeper(keys[profilestypes.StoreKey], appCodec), app.AccountKeeper,
app.BankKeeper, app.FeesKeeper,
),
relationships.NewAppModule(appCodec, app.RelationshipsKeeper, app.SubspacesKeeper, profilesv4.NewKeeper(keys[profilestypes.StoreKey], appCodec), app.AccountKeeper, app.BankKeeper, app.FeesKeeper),
posts.NewAppModule(appCodec, app.PostsKeeper, app.SubspacesKeeper, app.AccountKeeper, app.BankKeeper, app.FeesKeeper),
)

app.sm.RegisterStoreDecoders()
Expand Down Expand Up @@ -1005,6 +1022,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(feestypes.ModuleName)
paramsKeeper.Subspace(subspacestypes.ModuleName)
paramsKeeper.Subspace(profilestypes.ModuleName)
paramsKeeper.Subspace(poststypes.ModuleName)

return paramsKeeper
}
7 changes: 7 additions & 0 deletions app/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ const (
DefaultWeightMsgAddUserToUserGroup int = 7
DefaultWeightMsgRemoveUserFromUserGroup int = 3
DefaultWeightMsgSetUserPermissions int = 85

DefaultWeightMsgCreatePost int = 80
DefaultWeightMsgEditPost int = 40
DefaultWeightMsgDeletePost int = 20
DefaultWeightMsgAddPostAttachment int = 50
DefaultWeightMsgRemovePostAttachment int = 50
DefaultWeightMsgAnswerPoll int = 50
)
3 changes: 3 additions & 0 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"path/filepath"
"testing"

poststypes "github.com/desmos-labs/desmos/v3/x/posts/types"

feestypes "github.com/desmos-labs/desmos/v3/x/fees/types"

relationshipstypes "github.com/desmos-labs/desmos/v3/x/relationships/types"
Expand Down Expand Up @@ -235,6 +237,7 @@ func TestAppImportExport(t *testing.T) {
{app.keys[subspacestypes.StoreKey], newApp.keys[subspacestypes.StoreKey], [][]byte{}},
{app.keys[profilestypes.StoreKey], newApp.keys[profilestypes.StoreKey], [][]byte{}},
{app.keys[relationshipstypes.StoreKey], newApp.keys[relationshipstypes.StoreKey], [][]byte{}},
{app.keys[poststypes.StoreKey], newApp.keys[poststypes.StoreKey], [][]byte{}},
}

for _, skp := range storeKeysPrefixes {
Expand Down
8 changes: 8 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
{
"url": "./tmp-swagger-gen/desmos/subspaces/v1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/desmos/posts/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "PostsParams"
}
}
},
{
"url": "./tmp-swagger-gen/desmos/fees/v1/query.swagger.json",
"operationIds": {
Expand Down
Loading