Skip to content

Commit

Permalink
Merge social pallets and migration sudo calls to main (#132)
Browse files Browse the repository at this point in the history
* WIP: move traits crate from solochain

* WIP: move permissions pallet from solochain

* WIP: Upgrade `pallet-permission` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* Make permissions pallet compilable

- Add User structure to parachain-utils
- Make df-traits crate compilable

* WIP: move spaces pallet from solochain

* WIP: Upgrade `pallet-spaces` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* Make spaces pallet compilable

Add throw_utils_error

* WIP: move profiles pallet from solochain

* Remove profiles struct leaving social account only

* WIP: move space-follows pallet from solochain

* WIP: Upgrade `pallet-space-follows` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* Make `pallet-space-follows` compilable

* Rearrange `pallet-space-follows` code

* WIP: move roles pallet from solochain

* WIP: upgrade `pallet-roles` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* WIP: make `pallet-roles` compilable

* Fix `pallet-roles` mocks and tests

* WIP: Move posts pallet from solochain

* WIP Upgrade `pallet-posts` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* Make `pallet-posts` compilable

* Fix code formatting

* WIP: move space ownership pallet from solochain

* WIP Upgrade `pallet-space-ownership` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* Make `pallet-space-ownership` compilable

* Fix bug with MaxSpacesPerAccount check

* Rename remove_from_bounded fn

* Fix bug with MaxSpacesPerAccount check

* Fix code formatting

* WIP: move reactions pallet from solochain

* WIP Upgrade `pallet-reactions` to the new proc macro

Co-Authored-By: Shady Khalifa <shekohex@gmail.com>

* Make `pallet-reactions` compilable

* Copy integration-tests from solochain.

* fix cargo

* pallet_utils to pallet_parachain_utils

* mock moderation

* fix construct_runtime style

* remove post/space/profile history

* remove profile follows

* skip reactions/space_ownership for now

* fixes for profile

* fix UtilsError

* import fixes

* fix spaces

* fixed space tests

* enable reactions tests

* space_ownership

* Move social pallets to runtime (#85)

* add missing imports

* fixes to spaces

* add pallets to runtime

* Update node/src/chain_spec.rs

* Update runtime/Cargo.toml

* Fix ordering

* Change pallets ordering in construct_runtime

Co-authored-by: Vlad Proshchavaiev <32250097+F3Joule@users.noreply.github.com>
Co-authored-by: Vladyslav Proshchavaiev <f3joule@gmail.com>

* uncomment update_post_should_work_after_transfer_space_ownership

* Update integration-tests/Cargo.toml

Co-authored-by: Vlad Proshchavaiev <32250097+F3Joule@users.noreply.github.com>

* Update integration-tests/Cargo.toml

Co-authored-by: Vlad Proshchavaiev <32250097+F3Joule@users.noreply.github.com>

* remove deprecated code

* naming changes to MockModeration

* add doc to _default_follow_space

* remove line

* Refactor `pallet-parachain-utils` and `df-traits` to `subsocial-support` (#78)

* Reactor utils and traits to subsocial-support crate

* Fix imports in integration tests

* Do a proper name for a crate

* Fix Error enum in subsocial-support

* Fix runtime

* Change SpacePermissionsProvider fn name

From `get_space` to `space_permissions_info`

* Split `Error` in subsocial-support to a few enums

* Refactor `Content` struct

Remove `Hyper, rename `Raw` to `Other`

* Fix strum dependency in Cargo.toml

* Fix integration tests

* Apply fix suggestions to spaces pallet (#79)

* Refactor spaces pallet code

* Fix code formatting in spaces pallet

* Remove handles and scores from spaces

* Rename some variables

* Fix spaces pallet in a runtime

* Fix formatting manually

* Fix `init_pallet` in `pallet_spaces`

* Make integration tests compile

* Upgrade `pallet-profiles` to the new proc macro (#102)

* Upgrade `pallet-profiles` to the new proc macro

* Update Cargo.lock

* Fix warnings related to profiles pallet upgrade

* Fix Cargo.toml files after merge

Update Cargo.lock

* Fix code formatting in permissions pallet

* fix pallet_profiles in mocks (#116)

* Refactor profiles to spaces as profiles (#106)

* Fix runtime and errors

* Fix integration tests error

* Replace social account with space as profile

* Fix code formatting

* Loose couple profiles with space-ownership

- Profiles and space-ownership aren't more tight coupled
- Rename `ProfileSpaceByAccount` to `ProfileSpaceIdByAccount`
- Add `unset_space_as_profile` extrinsic
- Add `ensure_space_owner` to SpacePermissionsProvider

* Rename extrinsics in profiles pallet

Now two extrinsics to manage profiles are:`set_profile` and `reset_profile`

* Remove redundant counters from Space (#112)

* Remove redundant counters from space

* Fix integration tests

* Merge solochain's profile follows pallet to parachain's profiles (#111)

* WIP: move profile follows pallet from solochain

* Update `profile-follows` to the new proc macro

* Rename profile-follows to account-follows

Add account-follows to runtime

* Refactor posts pallet and remove posts counters in `Space` and `Post` (#117)

* WIP: remove old counters

* WIP: Refactor PostExtension to add counters

- Rename PostExtension::RegularPost -> PostExtension::Post
- Rename PostExtension::SharedPost to PostExtension::SharingPost
- Add PostExtension enum parameters for every variant.
  - Each parameter has case-depending fields, and now, in addition, different counters fields.
- PostExtension::Comment now has `replies_count`
- PostExtension::Post now has `total_replies_count`
- Introduced RepliesCount struct, which as the only `replies_count` field.
- Introduced HasReplies trait, which allows to work with RepliesCount struct.
- Derive Default for PostUpdate instead of implementing it.

* Refactor post counters calculation

- Fix code formatting
- Use proper names for sharing and shared posts
- Rename SharedPostIdsByOriginalPostId -> SharingPostIdsByOriginalPostId

* Fix integration tests after posts refactoring

* Remove score from Post structure

* Rollback redundant HasReplies trait

* Rollback shared post related name changes

* Improve comments related to shared posts

* Rename replies_count to direct_replies_count in Comment

* Remove redundant functions from posts pallet

* Improve docs for counter fields of post

* Fix a few bugs with counters

Update counters for reactions counters on Post

* Remove redundant counters

* Remove let_else feature from tests

* Revert SharedPost enum variant changes

* Swap fields in Comment struct

Co-authored-by: Alex Siman <aleksandr.siman@gmail.com>

* Refactor `updated` fields to be `bool` instead of `Option<WhoAndWhen>` (#118)

* Refactor update field from WhoAndWhen to bool

It's quite redundant to store full update info in a chain storage. We can use off-chain indexer for that. What we really need is just a mark that something was updated.

* Fix integration tests

* Fix a few storages' hashers (#123)

* Add sudo calls to migrate data in spaces and space-follows pallets (#119)

* Add force_create_space to spaces pallet

* Add force_set_next_space_id to spaces pallet

* Add force_follow_space to space-follows pallet

* Add Pays::No on success for spaces sudo calls

* Fix `force_create_space` sudo call

* Fix `force_follow_space` sudo call

* Re-use `add_space_follower` in space-follows sudo

* Fix force_create_space

* Add sudo calls to perform solo- to parachain data migration (#124)

* Add force_follow_account to account-follows pallet

* Add force_set_space_as_profile to profiles pallet

* Add sudo calls for reactions pallet

- `force_crate_reactuib` and `force_set_next_reaction_id` were added

* Add sudo calls for roles pallet

- `force_crate_role`, `force_set_next_role_id` and `force_grant_role` were added

* Add sudo calls for posts pallet

- `force_create_post` and `force_set_next_post_id` were added

* Add preventive logic to force_create_post_reaction

- Clean up a pallet from redundant code

* Add preventive logic to roles pallet sudo calls

- Clean up a pallet from redundant code

* Add preventive logic to posts pallet sudo calls

- Fix roles pallet

* Fix comment

Co-authored-by: Alex Siman <aleksandr.siman@gmail.com>

* Apply suggestions from code review

* Apply suggestions for profiles, roles and reactions

* Fix comment

Co-authored-by: Alex Siman <aleksandr.siman@gmail.com>

* Apply fixes after sudo calls and refactor review (#127)

* Fix namings in profiles pallet

- Fix error name in space-ownership pallet

* Fix space-follows pallet

* Remove parent_id from Space

* Remove auto-follow space when creating it

- Refactor update_space a bit

* Remove PostShared event from posts pallet

- Also remove unused PostDeleted

* Refactor roles pallet

* Fix bug in account-follows sudo call

* Rename updated to edited field

* Fix bugs in posts pallet

- Revert part of update_space refactor

* Apply suggestions from code review

Co-authored-by: Alex Siman <aleksandr.siman@gmail.com>

* Rename who to account in roles events

Co-authored-by: Alex Siman <aleksandr.siman@gmail.com>

* Fix code formatting in social pallets

* Remove redundant parts of code

- Make space-follows Event enum named

* Add parameterized Events enums to all pallets

* Add call filter to disable social pallets (#130)

* Add .git-blame-ignore-revs (#129)

- Ignore code formatting from #125

Co-authored-by: Shady Khalifa <shekohex@gmail.com>
Co-authored-by: Tarek Mohamed Abdalla <tarekkma@gmail.com>
Co-authored-by: Alex Siman <aleksandr.siman@gmail.com>
  • Loading branch information
4 people committed Aug 9, 2022
1 parent 6502b88 commit 8a3e4f1
Show file tree
Hide file tree
Showing 99 changed files with 10,645 additions and 65 deletions.
15 changes: 15 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# You can easily exclude big automated code changes by running
#
# git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# in your local repository. It will work also in IDE integrations.
#
# On versions of Git 2.20 and later comments (#), empty lines, and any leading and
# trailing whitespace is ignored. Everything but a SHA-1 per line will error out on
# older versions.
#
# You should add new commit hashes to this file when you create or find such big
# automated refactorings while reading code history. If you only know the short hash,
# use `git rev-parse 1d5abf01` to expand it to the full SHA1 hash needed in this file.

fbe35bae2ab729405a241bbe65b5740ebb29b63b # Run cargo fmt on the social pallets (#125)
180 changes: 177 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ panic = "unwind"

[workspace]
members = [
"integration-tests",
"node",
"runtime",
"pallets/domains",
"pallets/parachain-utils",
# "pallets/*",
"pallets/*",
]
61 changes: 61 additions & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[package]
name = 'integration-tests'
version = '0.1.7'
authors = ['DappForce <dappforce@pm.me>']
edition = '2021'
license = 'GPL-3.0-only'
homepage = 'https://subsocial.network'
repository = 'https://github.com/dappforce/subsocial-parachain'
description = 'Integration tests'
keywords = ['blockchain', 'cryptocurrency', 'social-network', 'news-feed', 'marketplace']
categories = ['cryptography::cryptocurrencies']

[features]
default = ['std']
std = [
'codec/std',
'scale-info/std',
'sp-io/std',
'sp-runtime/std',
'sp-std/std',
'pallet-balances/std',
'pallet-timestamp/std',
'frame-support/std',
'frame-system/std',
'pallet-permissions/std',
'pallet-posts/std',
'pallet-profiles/std',
'pallet-reactions/std',
'pallet-roles/std',
'pallet-space-follows/std',
'pallet-space-ownership/std',
'pallet-spaces/std',
'subsocial-support/std',
]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
serde = { features = ['derive'], optional = true, version = '1.0.137' }

frame-support = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
frame-system = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
pallet-balances = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
pallet-timestamp = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
sp-io = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
sp-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
sp-std = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }

[dev-dependencies]
pallet-permissions = { path = '../pallets/permissions', default-features = false }
pallet-posts = { path = '../pallets/posts', default-features = false }
pallet-profiles = { path = '../pallets/profiles', default-features = false }
pallet-reactions = { path = '../pallets/reactions', default-features = false }
pallet-roles = { path = '../pallets/roles', default-features = false }
pallet-space-follows = { path = '../pallets/space-follows', default-features = false }
pallet-space-ownership = { path = '../pallets/space-ownership', default-features = false }
pallet-spaces = { path = '../pallets/spaces', default-features = false }
subsocial-support = { path = '../pallets/support', default-features = false }

sp-core = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
pallet-balances = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.24', default-features = false }
5 changes: 5 additions & 0 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg(test)]

mod mock;
mod tests;
mod utils;
Loading

0 comments on commit 8a3e4f1

Please sign in to comment.